Merge "This assert is triggering when it shouldn't be. Disable it for now." into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index 9bd20ff..a5aadfa 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4915,6 +4915,7 @@
field public static final int DEFAULT_LIGHTS = 4; // 0x4
field public static final int DEFAULT_SOUND = 1; // 0x1
field public static final int DEFAULT_VIBRATE = 2; // 0x2
+ field public static final java.lang.String EXTRA_ALLOW_GENERATED_REPLIES = "android.allowGeneratedReplies";
field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri";
field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText";
field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown";
@@ -4923,12 +4924,14 @@
field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon";
field public static final java.lang.String EXTRA_LARGE_ICON_BIG = "android.largeIcon.big";
field public static final java.lang.String EXTRA_MEDIA_SESSION = "android.mediaSession";
+ field public static final java.lang.String EXTRA_MESSAGES = "android.messages";
field public static final java.lang.String EXTRA_PEOPLE = "android.people";
field public static final java.lang.String EXTRA_PICTURE = "android.picture";
field public static final java.lang.String EXTRA_PROGRESS = "android.progress";
field public static final java.lang.String EXTRA_PROGRESS_INDETERMINATE = "android.progressIndeterminate";
field public static final java.lang.String EXTRA_PROGRESS_MAX = "android.progressMax";
field public static final java.lang.String EXTRA_REMOTE_INPUT_HISTORY = "android.remoteInputHistory";
+ field public static final java.lang.String EXTRA_SELF_DISPLAY_NAME = "android.selfDisplayName";
field public static final java.lang.String EXTRA_SHOW_CHRONOMETER = "android.showChronometer";
field public static final java.lang.String EXTRA_SHOW_WHEN = "android.showWhen";
field public static final java.lang.String EXTRA_SMALL_ICON = "android.icon";
@@ -4937,6 +4940,7 @@
field public static final java.lang.String EXTRA_TEMPLATE = "android.template";
field public static final java.lang.String EXTRA_TEXT = "android.text";
field public static final java.lang.String EXTRA_TEXT_LINES = "android.textLines";
+ field public static final java.lang.String EXTRA_THREAD_TITLE = "android.threadTitle";
field public static final java.lang.String EXTRA_TITLE = "android.title";
field public static final java.lang.String EXTRA_TITLE_BIG = "android.title.big";
field public static final int FLAG_AUTO_CANCEL = 16; // 0x10
@@ -5176,6 +5180,32 @@
method public android.app.Notification.MediaStyle setShowActionsInCompactView(int...);
}
+ public static class Notification.MessagingStyle extends android.app.Notification.Style {
+ ctor public Notification.MessagingStyle(java.lang.CharSequence);
+ method public android.app.Notification.MessagingStyle addMessage(java.lang.CharSequence, long, java.lang.CharSequence);
+ method public android.app.Notification.MessagingStyle addMessage(android.app.Notification.MessagingStyle.Message);
+ method public boolean getAllowGeneratedReplies();
+ method public java.lang.CharSequence getConversationTitle();
+ method public java.util.List<android.app.Notification.MessagingStyle.Message> getMessages();
+ method public java.lang.CharSequence getUserDisplayName();
+ method public android.app.Notification.MessagingStyle setAllowGeneratedReplies(boolean);
+ method public android.app.Notification.MessagingStyle setConversationTitle(java.lang.CharSequence);
+ field public static final int MAXIMUM_RETAINED_MESSAGES = 25; // 0x19
+ }
+
+ public static final class Notification.MessagingStyle.Message implements android.os.Parcelable {
+ ctor public Notification.MessagingStyle.Message(java.lang.CharSequence, long, java.lang.CharSequence);
+ method public int describeContents();
+ method public java.lang.String getDataMimeType();
+ method public android.net.Uri getDataUri();
+ method public java.lang.CharSequence getSender();
+ method public java.lang.CharSequence getText();
+ method public long getTimestamp();
+ method public android.app.Notification.MessagingStyle.Message setData(java.lang.String, android.net.Uri);
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.app.Notification.MessagingStyle.Message> CREATOR;
+ }
+
public static abstract class Notification.Style {
ctor public Notification.Style();
method public android.app.Notification build();
@@ -7673,8 +7703,6 @@
method public void setExtras(android.os.PersistableBundle);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.content.ClipDescription> CREATOR;
- field public static final java.lang.String EXTRA_TARGET_COMPONENT_NAME = "android.content.extra.TARGET_COMPONENT_NAME";
- field public static final java.lang.String EXTRA_USER_SERIAL_NUMBER = "android.content.extra.USER_SERIAL_NUMBER";
field public static final java.lang.String MIMETYPE_TEXT_HTML = "text/html";
field public static final java.lang.String MIMETYPE_TEXT_INTENT = "text/vnd.android.intent";
field public static final java.lang.String MIMETYPE_TEXT_PLAIN = "text/plain";
@@ -8657,6 +8685,7 @@
field public static final java.lang.String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list";
field public static final java.lang.String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list";
field public static final java.lang.String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
+ field public static final java.lang.String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
@@ -8668,6 +8697,7 @@
field public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; // 0x0
field public static final java.lang.String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
field public static final java.lang.String EXTRA_EMAIL = "android.intent.extra.EMAIL";
+ field public static final java.lang.String EXTRA_EXCLUDE_COMPONENTS = "android.intent.extra.EXCLUDE_COMPONENTS";
field public static final java.lang.String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
field public static final java.lang.String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final java.lang.String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
@@ -19221,7 +19251,7 @@
field public static final int ADR_STATE_VALID = 1; // 0x1
field public static final android.os.Parcelable.Creator<android.location.GnssMeasurement> CREATOR;
field public static final int MULTIPATH_INDICATOR_DETECTED = 1; // 0x1
- field public static final int MULTIPATH_INDICATOR_NOT_USED = 2; // 0x2
+ field public static final int MULTIPATH_INDICATOR_NOT_DETECTED = 2; // 0x2
field public static final int MULTIPATH_INDICATOR_UNKNOWN = 0; // 0x0
field public static final int STATE_BDS_D2_BIT_SYNC = 256; // 0x100
field public static final int STATE_BDS_D2_SUBFRAME_SYNC = 512; // 0x200
@@ -19241,21 +19271,20 @@
}
public final class GnssMeasurementsEvent implements android.os.Parcelable {
- ctor public GnssMeasurementsEvent(android.location.GnssClock, android.location.GnssMeasurement[]);
method public int describeContents();
method public android.location.GnssClock getClock();
method public java.util.Collection<android.location.GnssMeasurement> getMeasurements();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.location.GnssMeasurementsEvent> CREATOR;
- field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
- field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
- field public static final int STATUS_READY = 1; // 0x1
}
public static abstract class GnssMeasurementsEvent.Callback {
ctor public GnssMeasurementsEvent.Callback();
method public void onGnssMeasurementsReceived(android.location.GnssMeasurementsEvent);
method public void onStatusChanged(int);
+ field public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
}
public final class GnssNavigationMessage implements android.os.Parcelable {
@@ -19283,36 +19312,24 @@
field public static final int TYPE_UNKNOWN = 0; // 0x0
}
- public final class GnssNavigationMessageEvent implements android.os.Parcelable {
- ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage);
- method public int describeContents();
- method public android.location.GnssNavigationMessage getNavigationMessage();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR;
- field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ public static abstract class GnssNavigationMessage.Callback {
+ ctor public GnssNavigationMessage.Callback();
+ method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessage);
+ method public void onStatusChanged(int);
+ field public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
field public static final int STATUS_READY = 1; // 0x1
}
- public static abstract class GnssNavigationMessageEvent.Callback {
- ctor public GnssNavigationMessageEvent.Callback();
- method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent);
- method public void onStatusChanged(int);
- }
-
- public abstract interface GnssNmeaListener {
- method public abstract void onNmeaReceived(long, java.lang.String);
- }
-
public final class GnssStatus {
method public float getAzimuthDegrees(int);
method public float getCn0DbHz(int);
method public int getConstellationType(int);
method public float getElevationDegrees(int);
- method public int getNumSatellites();
+ method public int getSatelliteCount();
method public int getSvid(int);
- method public boolean hasAlmanac(int);
- method public boolean hasEphemeris(int);
+ method public boolean hasAlmanacData(int);
+ method public boolean hasEphemerisData(int);
method public boolean usedInFix(int);
field public static final int CONSTELLATION_BEIDOU = 5; // 0x5
field public static final int CONSTELLATION_GALILEO = 6; // 0x6
@@ -19323,15 +19340,15 @@
field public static final int CONSTELLATION_UNKNOWN = 0; // 0x0
}
- public abstract class GnssStatusCallback {
- ctor public GnssStatusCallback();
+ public static abstract class GnssStatus.Callback {
+ ctor public GnssStatus.Callback();
method public void onFirstFix(int);
method public void onSatelliteStatusChanged(android.location.GnssStatus);
method public void onStarted();
method public void onStopped();
}
- public final class GpsSatellite {
+ public final deprecated class GpsSatellite {
method public float getAzimuth();
method public float getElevation();
method public int getPrn();
@@ -19341,7 +19358,7 @@
method public boolean usedInFix();
}
- public final class GpsStatus {
+ public final deprecated class GpsStatus {
method public int getMaxSatellites();
method public java.lang.Iterable<android.location.GpsSatellite> getSatellites();
method public int getTimeToFirstFix();
@@ -19351,11 +19368,11 @@
field public static final int GPS_EVENT_STOPPED = 2; // 0x2
}
- public static abstract interface GpsStatus.Listener {
+ public static abstract deprecated interface GpsStatus.Listener {
method public abstract void onGpsStatusChanged(int);
}
- public static abstract interface GpsStatus.NmeaListener {
+ public static abstract deprecated interface GpsStatus.NmeaListener {
method public abstract void onNmeaReceived(long, java.lang.String);
}
@@ -19417,8 +19434,8 @@
public class LocationManager {
method public deprecated boolean addGpsStatusListener(android.location.GpsStatus.Listener);
method public deprecated boolean addNmeaListener(android.location.GpsStatus.NmeaListener);
- method public boolean addNmeaListener(android.location.GnssNmeaListener);
- method public boolean addNmeaListener(android.location.GnssNmeaListener, android.os.Handler);
+ method public boolean addNmeaListener(android.location.OnNmeaMessageListener);
+ method public boolean addNmeaListener(android.location.OnNmeaMessageListener, android.os.Handler);
method public void addProximityAlert(double, double, float, long, android.app.PendingIntent);
method public void addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int);
method public void clearTestProviderEnabled(java.lang.String);
@@ -19434,13 +19451,13 @@
method public boolean isProviderEnabled(java.lang.String);
method public boolean registerGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback);
method public boolean registerGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback, android.os.Handler);
- method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
- method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler);
- method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback);
- method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback, android.os.Handler);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatus.Callback);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatus.Callback, android.os.Handler);
method public deprecated void removeGpsStatusListener(android.location.GpsStatus.Listener);
method public deprecated void removeNmeaListener(android.location.GpsStatus.NmeaListener);
- method public void removeNmeaListener(android.location.GnssNmeaListener);
+ method public void removeNmeaListener(android.location.OnNmeaMessageListener);
method public void removeProximityAlert(android.app.PendingIntent);
method public void removeTestProvider(java.lang.String);
method public void removeUpdates(android.location.LocationListener);
@@ -19459,8 +19476,8 @@
method public void setTestProviderLocation(java.lang.String, android.location.Location);
method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long);
method public void unregisterGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback);
- method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
- method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback);
+ method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback);
+ method public void unregisterGnssStatusCallback(android.location.GnssStatus.Callback);
field public static final java.lang.String GPS_PROVIDER = "gps";
field public static final java.lang.String KEY_LOCATION_CHANGED = "location";
field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled";
@@ -19489,6 +19506,10 @@
field public static final int TEMPORARILY_UNAVAILABLE = 1; // 0x1
}
+ public abstract interface OnNmeaMessageListener {
+ method public abstract void onNmeaMessage(java.lang.String, long);
+ }
+
public abstract class SettingInjectorService extends android.app.Service {
ctor public SettingInjectorService(java.lang.String);
method public final android.os.IBinder onBind(android.content.Intent);
@@ -34704,7 +34725,9 @@
method public static void requestRebind(android.content.ComponentName) throws android.os.RemoteException;
method public final void requestUnbind() throws android.os.RemoteException;
method public final void setNotificationsShown(java.lang.String[]);
+ field public static final int HINT_HOST_DISABLE_CALL_EFFECTS = 4; // 0x4
field public static final int HINT_HOST_DISABLE_EFFECTS = 1; // 0x1
+ field public static final int HINT_HOST_DISABLE_NOTIFICATION_EFFECTS = 2; // 0x2
field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4
field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1
field public static final int INTERRUPTION_FILTER_NONE = 3; // 0x3
@@ -34720,6 +34743,7 @@
method public int getImportance();
method public java.lang.CharSequence getImportanceExplanation();
method public java.lang.String getKey();
+ method public java.lang.String getOverrideGroupKey();
method public int getRank();
method public int getSuppressedVisualEffects();
method public boolean isAmbient();
@@ -34750,13 +34774,16 @@
method public int getId();
method public java.lang.String getKey();
method public android.app.Notification getNotification();
+ method public java.lang.String getOverrideGroupKey();
method public java.lang.String getPackageName();
method public long getPostTime();
method public java.lang.String getTag();
method public android.os.UserHandle getUser();
method public deprecated int getUserId();
method public boolean isClearable();
+ method public boolean isGroup();
method public boolean isOngoing();
+ method public void setOverrideGroupKey(java.lang.String);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.notification.StatusBarNotification> CREATOR;
}
@@ -34792,7 +34819,7 @@
method public void onClick();
method public void onStartListening();
method public void onStopListening();
- method public int onTileAdded();
+ method public void onTileAdded();
method public void onTileRemoved();
method public static final void requestListeningState(android.content.Context, android.content.ComponentName);
method public final void showDialog(android.app.Dialog);
@@ -34800,8 +34827,7 @@
method public final void unlockAndRun(java.lang.Runnable);
field public static final java.lang.String ACTION_QS_TILE = "android.service.quicksettings.action.QS_TILE";
field public static final java.lang.String ACTION_QS_TILE_PREFERENCES = "android.service.quicksettings.action.QS_TILE_PREFERENCES";
- field public static final int TILE_MODE_ACTIVE = 2; // 0x2
- field public static final int TILE_MODE_PASSIVE = 1; // 0x1
+ field public static final java.lang.String META_DATA_ACTIVE_TILE = "android.service.quicksettings.ACTIVE_TILE";
}
}
@@ -51958,7 +51984,6 @@
public final class Method extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
method public boolean equals(java.lang.Object);
method public A getAnnotation(java.lang.Class<A>);
- method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
method public java.lang.Class<?> getDeclaringClass();
method public java.lang.Object getDefaultValue();
method public java.lang.Class<?>[] getExceptionTypes();
@@ -51972,7 +51997,6 @@
method public java.lang.Class<?> getReturnType();
method public java.lang.reflect.TypeVariable<java.lang.reflect.Method>[] getTypeParameters();
method public java.lang.Object invoke(java.lang.Object, java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException;
- method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
method public boolean isBridge();
method public boolean isDefault();
method public boolean isSynthetic();
@@ -57448,6 +57472,14 @@
method public static int hashCode(float[]);
method public static int hashCode(double[]);
method public static int hashCode(java.lang.Object[]);
+ method public static void parallelPrefix(T[], java.util.function.BinaryOperator<T>);
+ method public static void parallelPrefix(T[], int, int, java.util.function.BinaryOperator<T>);
+ method public static void parallelPrefix(long[], java.util.function.LongBinaryOperator);
+ method public static void parallelPrefix(long[], int, int, java.util.function.LongBinaryOperator);
+ method public static void parallelPrefix(double[], java.util.function.DoubleBinaryOperator);
+ method public static void parallelPrefix(double[], int, int, java.util.function.DoubleBinaryOperator);
+ method public static void parallelPrefix(int[], java.util.function.IntBinaryOperator);
+ method public static void parallelPrefix(int[], int, int, java.util.function.IntBinaryOperator);
method public static void parallelSetAll(T[], java.util.function.IntFunction<? extends T>);
method public static void parallelSetAll(int[], java.util.function.IntUnaryOperator);
method public static void parallelSetAll(long[], java.util.function.IntToLongFunction);
diff --git a/api/removed.txt b/api/removed.txt
index 3f16bca..8c6abdc 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -84,6 +84,67 @@
}
+package android.location {
+
+ public final class GnssMeasurement implements android.os.Parcelable {
+ field public static final int MULTIPATH_INDICATOR_NOT_USED = 2; // 0x2
+ }
+
+ public final class GnssMeasurementsEvent implements android.os.Parcelable {
+ field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
+ }
+
+ public final class GnssNavigationMessageEvent implements android.os.Parcelable {
+ ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage);
+ method public int describeContents();
+ method public android.location.GnssNavigationMessage getNavigationMessage();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR;
+ field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
+ }
+
+ public static abstract class GnssNavigationMessageEvent.Callback {
+ ctor public GnssNavigationMessageEvent.Callback();
+ method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent);
+ method public void onStatusChanged(int);
+ }
+
+ public abstract interface GnssNmeaListener {
+ method public abstract void onNmeaReceived(long, java.lang.String);
+ }
+
+ public final class GnssStatus {
+ method public int getNumSatellites();
+ method public boolean hasAlmanac(int);
+ method public boolean hasEphemeris(int);
+ }
+
+ public abstract class GnssStatusCallback {
+ ctor public GnssStatusCallback();
+ method public void onFirstFix(int);
+ method public void onSatelliteStatusChanged(android.location.GnssStatus);
+ method public void onStarted();
+ method public void onStopped();
+ }
+
+ public class LocationManager {
+ method public boolean addNmeaListener(android.location.GnssNmeaListener);
+ method public boolean addNmeaListener(android.location.GnssNmeaListener, android.os.Handler);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler);
+ method public void removeNmeaListener(android.location.GnssNmeaListener);
+ method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
+ method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback);
+ }
+
+}
+
package android.media {
public final class AudioFormat implements android.os.Parcelable {
diff --git a/api/system-current.txt b/api/system-current.txt
index bfbe4ec..0902b53 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5048,6 +5048,7 @@
field public static final int DEFAULT_LIGHTS = 4; // 0x4
field public static final int DEFAULT_SOUND = 1; // 0x1
field public static final int DEFAULT_VIBRATE = 2; // 0x2
+ field public static final java.lang.String EXTRA_ALLOW_GENERATED_REPLIES = "android.allowGeneratedReplies";
field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri";
field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText";
field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown";
@@ -5056,12 +5057,14 @@
field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon";
field public static final java.lang.String EXTRA_LARGE_ICON_BIG = "android.largeIcon.big";
field public static final java.lang.String EXTRA_MEDIA_SESSION = "android.mediaSession";
+ field public static final java.lang.String EXTRA_MESSAGES = "android.messages";
field public static final java.lang.String EXTRA_PEOPLE = "android.people";
field public static final java.lang.String EXTRA_PICTURE = "android.picture";
field public static final java.lang.String EXTRA_PROGRESS = "android.progress";
field public static final java.lang.String EXTRA_PROGRESS_INDETERMINATE = "android.progressIndeterminate";
field public static final java.lang.String EXTRA_PROGRESS_MAX = "android.progressMax";
field public static final java.lang.String EXTRA_REMOTE_INPUT_HISTORY = "android.remoteInputHistory";
+ field public static final java.lang.String EXTRA_SELF_DISPLAY_NAME = "android.selfDisplayName";
field public static final java.lang.String EXTRA_SHOW_CHRONOMETER = "android.showChronometer";
field public static final java.lang.String EXTRA_SHOW_WHEN = "android.showWhen";
field public static final java.lang.String EXTRA_SMALL_ICON = "android.icon";
@@ -5070,8 +5073,10 @@
field public static final java.lang.String EXTRA_TEMPLATE = "android.template";
field public static final java.lang.String EXTRA_TEXT = "android.text";
field public static final java.lang.String EXTRA_TEXT_LINES = "android.textLines";
+ field public static final java.lang.String EXTRA_THREAD_TITLE = "android.threadTitle";
field public static final java.lang.String EXTRA_TITLE = "android.title";
field public static final java.lang.String EXTRA_TITLE_BIG = "android.title.big";
+ field public static final int FLAG_AUTOGROUP_SUMMARY = 1024; // 0x400
field public static final int FLAG_AUTO_CANCEL = 16; // 0x10
field public static final int FLAG_FOREGROUND_SERVICE = 64; // 0x40
field public static final int FLAG_GROUP_SUMMARY = 512; // 0x200
@@ -5309,6 +5314,32 @@
method public android.app.Notification.MediaStyle setShowActionsInCompactView(int...);
}
+ public static class Notification.MessagingStyle extends android.app.Notification.Style {
+ ctor public Notification.MessagingStyle(java.lang.CharSequence);
+ method public android.app.Notification.MessagingStyle addMessage(java.lang.CharSequence, long, java.lang.CharSequence);
+ method public android.app.Notification.MessagingStyle addMessage(android.app.Notification.MessagingStyle.Message);
+ method public boolean getAllowGeneratedReplies();
+ method public java.lang.CharSequence getConversationTitle();
+ method public java.util.List<android.app.Notification.MessagingStyle.Message> getMessages();
+ method public java.lang.CharSequence getUserDisplayName();
+ method public android.app.Notification.MessagingStyle setAllowGeneratedReplies(boolean);
+ method public android.app.Notification.MessagingStyle setConversationTitle(java.lang.CharSequence);
+ field public static final int MAXIMUM_RETAINED_MESSAGES = 25; // 0x19
+ }
+
+ public static final class Notification.MessagingStyle.Message implements android.os.Parcelable {
+ ctor public Notification.MessagingStyle.Message(java.lang.CharSequence, long, java.lang.CharSequence);
+ method public int describeContents();
+ method public java.lang.String getDataMimeType();
+ method public android.net.Uri getDataUri();
+ method public java.lang.CharSequence getSender();
+ method public java.lang.CharSequence getText();
+ method public long getTimestamp();
+ method public android.app.Notification.MessagingStyle.Message setData(java.lang.String, android.net.Uri);
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.app.Notification.MessagingStyle.Message> CREATOR;
+ }
+
public static abstract class Notification.Style {
ctor public Notification.Style();
method public android.app.Notification build();
@@ -7971,8 +8002,6 @@
method public void setExtras(android.os.PersistableBundle);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.content.ClipDescription> CREATOR;
- field public static final java.lang.String EXTRA_TARGET_COMPONENT_NAME = "android.content.extra.TARGET_COMPONENT_NAME";
- field public static final java.lang.String EXTRA_USER_SERIAL_NUMBER = "android.content.extra.USER_SERIAL_NUMBER";
field public static final java.lang.String MIMETYPE_TEXT_HTML = "text/html";
field public static final java.lang.String MIMETYPE_TEXT_INTENT = "text/vnd.android.intent";
field public static final java.lang.String MIMETYPE_TEXT_PLAIN = "text/plain";
@@ -8976,6 +9005,7 @@
field public static final java.lang.String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list";
field public static final java.lang.String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list";
field public static final java.lang.String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
+ field public static final java.lang.String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
@@ -8989,6 +9019,7 @@
field public static final java.lang.String EXTRA_EMAIL = "android.intent.extra.EMAIL";
field public static final java.lang.String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
field public static final java.lang.String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
+ field public static final java.lang.String EXTRA_EXCLUDE_COMPONENTS = "android.intent.extra.EXCLUDE_COMPONENTS";
field public static final java.lang.String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
field public static final java.lang.String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final java.lang.String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
@@ -20381,7 +20412,7 @@
field public static final int ADR_STATE_VALID = 1; // 0x1
field public static final android.os.Parcelable.Creator<android.location.GnssMeasurement> CREATOR;
field public static final int MULTIPATH_INDICATOR_DETECTED = 1; // 0x1
- field public static final int MULTIPATH_INDICATOR_NOT_USED = 2; // 0x2
+ field public static final int MULTIPATH_INDICATOR_NOT_DETECTED = 2; // 0x2
field public static final int MULTIPATH_INDICATOR_UNKNOWN = 0; // 0x0
field public static final int STATE_BDS_D2_BIT_SYNC = 256; // 0x100
field public static final int STATE_BDS_D2_SUBFRAME_SYNC = 512; // 0x200
@@ -20401,21 +20432,20 @@
}
public final class GnssMeasurementsEvent implements android.os.Parcelable {
- ctor public GnssMeasurementsEvent(android.location.GnssClock, android.location.GnssMeasurement[]);
method public int describeContents();
method public android.location.GnssClock getClock();
method public java.util.Collection<android.location.GnssMeasurement> getMeasurements();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.location.GnssMeasurementsEvent> CREATOR;
- field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
- field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
- field public static final int STATUS_READY = 1; // 0x1
}
public static abstract class GnssMeasurementsEvent.Callback {
ctor public GnssMeasurementsEvent.Callback();
method public void onGnssMeasurementsReceived(android.location.GnssMeasurementsEvent);
method public void onStatusChanged(int);
+ field public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
}
public final class GnssNavigationMessage implements android.os.Parcelable {
@@ -20443,36 +20473,24 @@
field public static final int TYPE_UNKNOWN = 0; // 0x0
}
- public final class GnssNavigationMessageEvent implements android.os.Parcelable {
- ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage);
- method public int describeContents();
- method public android.location.GnssNavigationMessage getNavigationMessage();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR;
- field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ public static abstract class GnssNavigationMessage.Callback {
+ ctor public GnssNavigationMessage.Callback();
+ method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessage);
+ method public void onStatusChanged(int);
+ field public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
field public static final int STATUS_READY = 1; // 0x1
}
- public static abstract class GnssNavigationMessageEvent.Callback {
- ctor public GnssNavigationMessageEvent.Callback();
- method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent);
- method public void onStatusChanged(int);
- }
-
- public abstract interface GnssNmeaListener {
- method public abstract void onNmeaReceived(long, java.lang.String);
- }
-
public final class GnssStatus {
method public float getAzimuthDegrees(int);
method public float getCn0DbHz(int);
method public int getConstellationType(int);
method public float getElevationDegrees(int);
- method public int getNumSatellites();
+ method public int getSatelliteCount();
method public int getSvid(int);
- method public boolean hasAlmanac(int);
- method public boolean hasEphemeris(int);
+ method public boolean hasAlmanacData(int);
+ method public boolean hasEphemerisData(int);
method public boolean usedInFix(int);
field public static final int CONSTELLATION_BEIDOU = 5; // 0x5
field public static final int CONSTELLATION_GALILEO = 6; // 0x6
@@ -20483,8 +20501,8 @@
field public static final int CONSTELLATION_UNKNOWN = 0; // 0x0
}
- public abstract class GnssStatusCallback {
- ctor public GnssStatusCallback();
+ public static abstract class GnssStatus.Callback {
+ ctor public GnssStatus.Callback();
method public void onFirstFix(int);
method public void onSatelliteStatusChanged(android.location.GnssStatus);
method public void onStarted();
@@ -20716,7 +20734,7 @@
method public abstract void onStatusChanged(int);
}
- public final class GpsSatellite {
+ public final deprecated class GpsSatellite {
method public float getAzimuth();
method public float getElevation();
method public int getPrn();
@@ -20726,7 +20744,7 @@
method public boolean usedInFix();
}
- public final class GpsStatus {
+ public final deprecated class GpsStatus {
method public int getMaxSatellites();
method public java.lang.Iterable<android.location.GpsSatellite> getSatellites();
method public int getTimeToFirstFix();
@@ -20736,11 +20754,11 @@
field public static final int GPS_EVENT_STOPPED = 2; // 0x2
}
- public static abstract interface GpsStatus.Listener {
+ public static abstract deprecated interface GpsStatus.Listener {
method public abstract void onGpsStatusChanged(int);
}
- public static abstract interface GpsStatus.NmeaListener {
+ public static abstract deprecated interface GpsStatus.NmeaListener {
method public abstract void onNmeaReceived(long, java.lang.String);
}
@@ -20824,8 +20842,8 @@
method public deprecated boolean addGpsNavigationMessageListener(android.location.GpsNavigationMessageEvent.Listener);
method public deprecated boolean addGpsStatusListener(android.location.GpsStatus.Listener);
method public deprecated boolean addNmeaListener(android.location.GpsStatus.NmeaListener);
- method public boolean addNmeaListener(android.location.GnssNmeaListener);
- method public boolean addNmeaListener(android.location.GnssNmeaListener, android.os.Handler);
+ method public boolean addNmeaListener(android.location.OnNmeaMessageListener);
+ method public boolean addNmeaListener(android.location.OnNmeaMessageListener, android.os.Handler);
method public void addProximityAlert(double, double, float, long, android.app.PendingIntent);
method public void addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int);
method public void clearTestProviderEnabled(java.lang.String);
@@ -20841,15 +20859,15 @@
method public boolean isProviderEnabled(java.lang.String);
method public boolean registerGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback);
method public boolean registerGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback, android.os.Handler);
- method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
- method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler);
- method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback);
- method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback, android.os.Handler);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatus.Callback);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatus.Callback, android.os.Handler);
method public deprecated void removeGpsMeasurementListener(android.location.GpsMeasurementsEvent.Listener);
method public deprecated void removeGpsNavigationMessageListener(android.location.GpsNavigationMessageEvent.Listener);
method public deprecated void removeGpsStatusListener(android.location.GpsStatus.Listener);
method public deprecated void removeNmeaListener(android.location.GpsStatus.NmeaListener);
- method public void removeNmeaListener(android.location.GnssNmeaListener);
+ method public void removeNmeaListener(android.location.OnNmeaMessageListener);
method public void removeProximityAlert(android.app.PendingIntent);
method public void removeTestProvider(java.lang.String);
method public void removeUpdates(android.location.LocationListener);
@@ -20870,8 +20888,8 @@
method public void setTestProviderLocation(java.lang.String, android.location.Location);
method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long);
method public void unregisterGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback);
- method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
- method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback);
+ method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback);
+ method public void unregisterGnssStatusCallback(android.location.GnssStatus.Callback);
field public static final java.lang.String GPS_PROVIDER = "gps";
field public static final java.lang.String KEY_LOCATION_CHANGED = "location";
field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled";
@@ -20934,6 +20952,10 @@
field public static final int POWER_NONE = 200; // 0xc8
}
+ public abstract interface OnNmeaMessageListener {
+ method public abstract void onNmeaMessage(java.lang.String, long);
+ }
+
public abstract class SettingInjectorService extends android.app.Service {
ctor public SettingInjectorService(java.lang.String);
method public final android.os.IBinder onBind(android.content.Intent);
@@ -37098,6 +37120,22 @@
package android.service.notification {
+ public final class Adjustment implements android.os.Parcelable {
+ ctor public Adjustment(java.lang.String, java.lang.String, int, android.os.Bundle, java.lang.CharSequence, android.net.Uri);
+ ctor protected Adjustment(android.os.Parcel);
+ method public int describeContents();
+ method public java.lang.CharSequence getExplanation();
+ method public int getImportance();
+ method public java.lang.String getKey();
+ method public java.lang.String getPackage();
+ method public android.net.Uri getReference();
+ method public android.os.Bundle getSignals();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.service.notification.Adjustment> CREATOR;
+ field public static final java.lang.String GROUP_KEY_OVERRIDE_KEY = "group_key_override";
+ field public static final java.lang.String NEEDS_AUTOGROUPING_KEY = "autogroup_needed";
+ }
+
public class Condition implements android.os.Parcelable {
ctor public Condition(android.net.Uri, java.lang.String, int);
ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int, int, int);
@@ -37173,7 +37211,9 @@
method public final void setNotificationsShown(java.lang.String[]);
method public final void setOnNotificationPostedTrim(int);
method public void unregisterAsSystemService() throws android.os.RemoteException;
+ field public static final int HINT_HOST_DISABLE_CALL_EFFECTS = 4; // 0x4
field public static final int HINT_HOST_DISABLE_EFFECTS = 1; // 0x1
+ field public static final int HINT_HOST_DISABLE_NOTIFICATION_EFFECTS = 2; // 0x2
field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4
field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1
field public static final int INTERRUPTION_FILTER_NONE = 3; // 0x3
@@ -37191,6 +37231,7 @@
method public int getImportance();
method public java.lang.CharSequence getImportanceExplanation();
method public java.lang.String getKey();
+ method public java.lang.String getOverrideGroupKey();
method public int getRank();
method public int getSuppressedVisualEffects();
method public boolean isAmbient();
@@ -37214,11 +37255,12 @@
public abstract class NotificationRankerService extends android.service.notification.NotificationListenerService {
ctor public NotificationRankerService();
- method public final void adjustImportance(java.lang.String, android.service.notification.NotificationRankerService.Adjustment);
+ method public final void adjustNotification(android.service.notification.Adjustment);
+ method public final void adjustNotifications(java.util.List<android.service.notification.Adjustment>);
method public final android.os.IBinder onBind(android.content.Intent);
method public void onNotificationActionClick(java.lang.String, long, int);
method public void onNotificationClick(java.lang.String, long);
- method public abstract android.service.notification.NotificationRankerService.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification, int, boolean);
+ method public abstract android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification, int, boolean);
method public void onNotificationRemoved(java.lang.String, long, int);
method public void onNotificationVisibilityChanged(java.lang.String, long, boolean);
field public static final int REASON_APP_CANCEL = 8; // 0x8
@@ -37235,14 +37277,11 @@
field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5
field public static final int REASON_PACKAGE_SUSPENDED = 14; // 0xe
field public static final int REASON_PROFILE_TURNED_OFF = 15; // 0xf
+ field public static final int REASON_UNAUTOBUNDLED = 16; // 0x10
field public static final int REASON_USER_STOPPED = 6; // 0x6
field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationRankerService";
}
- public class NotificationRankerService.Adjustment {
- ctor public NotificationRankerService.Adjustment(int, java.lang.CharSequence, android.net.Uri);
- }
-
public class StatusBarNotification implements android.os.Parcelable {
ctor public StatusBarNotification(java.lang.String, java.lang.String, int, java.lang.String, int, int, int, android.app.Notification, android.os.UserHandle, long);
ctor public StatusBarNotification(android.os.Parcel);
@@ -37252,13 +37291,16 @@
method public int getId();
method public java.lang.String getKey();
method public android.app.Notification getNotification();
+ method public java.lang.String getOverrideGroupKey();
method public java.lang.String getPackageName();
method public long getPostTime();
method public java.lang.String getTag();
method public android.os.UserHandle getUser();
method public deprecated int getUserId();
method public boolean isClearable();
+ method public boolean isGroup();
method public boolean isOngoing();
+ method public void setOverrideGroupKey(java.lang.String);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.notification.StatusBarNotification> CREATOR;
}
@@ -37327,7 +37369,7 @@
method public void onClick();
method public void onStartListening();
method public void onStopListening();
- method public int onTileAdded();
+ method public void onTileAdded();
method public void onTileRemoved();
method public static final void requestListeningState(android.content.Context, android.content.ComponentName);
method public final void setStatusIcon(android.graphics.drawable.Icon, java.lang.String);
@@ -37336,8 +37378,7 @@
method public final void unlockAndRun(java.lang.Runnable);
field public static final java.lang.String ACTION_QS_TILE = "android.service.quicksettings.action.QS_TILE";
field public static final java.lang.String ACTION_QS_TILE_PREFERENCES = "android.service.quicksettings.action.QS_TILE_PREFERENCES";
- field public static final int TILE_MODE_ACTIVE = 2; // 0x2
- field public static final int TILE_MODE_PASSIVE = 1; // 0x1
+ field public static final java.lang.String META_DATA_ACTIVE_TILE = "android.service.quicksettings.ACTIVE_TILE";
}
}
@@ -55055,7 +55096,6 @@
public final class Method extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
method public boolean equals(java.lang.Object);
method public A getAnnotation(java.lang.Class<A>);
- method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
method public java.lang.Class<?> getDeclaringClass();
method public java.lang.Object getDefaultValue();
method public java.lang.Class<?>[] getExceptionTypes();
@@ -55069,7 +55109,6 @@
method public java.lang.Class<?> getReturnType();
method public java.lang.reflect.TypeVariable<java.lang.reflect.Method>[] getTypeParameters();
method public java.lang.Object invoke(java.lang.Object, java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException;
- method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
method public boolean isBridge();
method public boolean isDefault();
method public boolean isSynthetic();
@@ -60545,6 +60584,14 @@
method public static int hashCode(float[]);
method public static int hashCode(double[]);
method public static int hashCode(java.lang.Object[]);
+ method public static void parallelPrefix(T[], java.util.function.BinaryOperator<T>);
+ method public static void parallelPrefix(T[], int, int, java.util.function.BinaryOperator<T>);
+ method public static void parallelPrefix(long[], java.util.function.LongBinaryOperator);
+ method public static void parallelPrefix(long[], int, int, java.util.function.LongBinaryOperator);
+ method public static void parallelPrefix(double[], java.util.function.DoubleBinaryOperator);
+ method public static void parallelPrefix(double[], int, int, java.util.function.DoubleBinaryOperator);
+ method public static void parallelPrefix(int[], java.util.function.IntBinaryOperator);
+ method public static void parallelPrefix(int[], int, int, java.util.function.IntBinaryOperator);
method public static void parallelSetAll(T[], java.util.function.IntFunction<? extends T>);
method public static void parallelSetAll(int[], java.util.function.IntUnaryOperator);
method public static void parallelSetAll(long[], java.util.function.IntToLongFunction);
diff --git a/api/system-removed.txt b/api/system-removed.txt
index 03cf8b0..95734c1 100644
--- a/api/system-removed.txt
+++ b/api/system-removed.txt
@@ -82,6 +82,67 @@
}
+package android.location {
+
+ public final class GnssMeasurement implements android.os.Parcelable {
+ field public static final int MULTIPATH_INDICATOR_NOT_USED = 2; // 0x2
+ }
+
+ public final class GnssMeasurementsEvent implements android.os.Parcelable {
+ field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
+ }
+
+ public final class GnssNavigationMessageEvent implements android.os.Parcelable {
+ ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage);
+ method public int describeContents();
+ method public android.location.GnssNavigationMessage getNavigationMessage();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR;
+ field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
+ }
+
+ public static abstract class GnssNavigationMessageEvent.Callback {
+ ctor public GnssNavigationMessageEvent.Callback();
+ method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent);
+ method public void onStatusChanged(int);
+ }
+
+ public abstract interface GnssNmeaListener {
+ method public abstract void onNmeaReceived(long, java.lang.String);
+ }
+
+ public final class GnssStatus {
+ method public int getNumSatellites();
+ method public boolean hasAlmanac(int);
+ method public boolean hasEphemeris(int);
+ }
+
+ public abstract class GnssStatusCallback {
+ ctor public GnssStatusCallback();
+ method public void onFirstFix(int);
+ method public void onSatelliteStatusChanged(android.location.GnssStatus);
+ method public void onStarted();
+ method public void onStopped();
+ }
+
+ public class LocationManager {
+ method public boolean addNmeaListener(android.location.GnssNmeaListener);
+ method public boolean addNmeaListener(android.location.GnssNmeaListener, android.os.Handler);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler);
+ method public void removeNmeaListener(android.location.GnssNmeaListener);
+ method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
+ method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback);
+ }
+
+}
+
package android.media {
public final class AudioFormat implements android.os.Parcelable {
diff --git a/api/test-current.txt b/api/test-current.txt
index 85badae..5ec3a5f 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -4915,6 +4915,7 @@
field public static final int DEFAULT_LIGHTS = 4; // 0x4
field public static final int DEFAULT_SOUND = 1; // 0x1
field public static final int DEFAULT_VIBRATE = 2; // 0x2
+ field public static final java.lang.String EXTRA_ALLOW_GENERATED_REPLIES = "android.allowGeneratedReplies";
field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri";
field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText";
field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown";
@@ -4923,12 +4924,14 @@
field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon";
field public static final java.lang.String EXTRA_LARGE_ICON_BIG = "android.largeIcon.big";
field public static final java.lang.String EXTRA_MEDIA_SESSION = "android.mediaSession";
+ field public static final java.lang.String EXTRA_MESSAGES = "android.messages";
field public static final java.lang.String EXTRA_PEOPLE = "android.people";
field public static final java.lang.String EXTRA_PICTURE = "android.picture";
field public static final java.lang.String EXTRA_PROGRESS = "android.progress";
field public static final java.lang.String EXTRA_PROGRESS_INDETERMINATE = "android.progressIndeterminate";
field public static final java.lang.String EXTRA_PROGRESS_MAX = "android.progressMax";
field public static final java.lang.String EXTRA_REMOTE_INPUT_HISTORY = "android.remoteInputHistory";
+ field public static final java.lang.String EXTRA_SELF_DISPLAY_NAME = "android.selfDisplayName";
field public static final java.lang.String EXTRA_SHOW_CHRONOMETER = "android.showChronometer";
field public static final java.lang.String EXTRA_SHOW_WHEN = "android.showWhen";
field public static final java.lang.String EXTRA_SMALL_ICON = "android.icon";
@@ -4937,6 +4940,7 @@
field public static final java.lang.String EXTRA_TEMPLATE = "android.template";
field public static final java.lang.String EXTRA_TEXT = "android.text";
field public static final java.lang.String EXTRA_TEXT_LINES = "android.textLines";
+ field public static final java.lang.String EXTRA_THREAD_TITLE = "android.threadTitle";
field public static final java.lang.String EXTRA_TITLE = "android.title";
field public static final java.lang.String EXTRA_TITLE_BIG = "android.title.big";
field public static final int FLAG_AUTO_CANCEL = 16; // 0x10
@@ -5176,6 +5180,32 @@
method public android.app.Notification.MediaStyle setShowActionsInCompactView(int...);
}
+ public static class Notification.MessagingStyle extends android.app.Notification.Style {
+ ctor public Notification.MessagingStyle(java.lang.CharSequence);
+ method public android.app.Notification.MessagingStyle addMessage(java.lang.CharSequence, long, java.lang.CharSequence);
+ method public android.app.Notification.MessagingStyle addMessage(android.app.Notification.MessagingStyle.Message);
+ method public boolean getAllowGeneratedReplies();
+ method public java.lang.CharSequence getConversationTitle();
+ method public java.util.List<android.app.Notification.MessagingStyle.Message> getMessages();
+ method public java.lang.CharSequence getUserDisplayName();
+ method public android.app.Notification.MessagingStyle setAllowGeneratedReplies(boolean);
+ method public android.app.Notification.MessagingStyle setConversationTitle(java.lang.CharSequence);
+ field public static final int MAXIMUM_RETAINED_MESSAGES = 25; // 0x19
+ }
+
+ public static final class Notification.MessagingStyle.Message implements android.os.Parcelable {
+ ctor public Notification.MessagingStyle.Message(java.lang.CharSequence, long, java.lang.CharSequence);
+ method public int describeContents();
+ method public java.lang.String getDataMimeType();
+ method public android.net.Uri getDataUri();
+ method public java.lang.CharSequence getSender();
+ method public java.lang.CharSequence getText();
+ method public long getTimestamp();
+ method public android.app.Notification.MessagingStyle.Message setData(java.lang.String, android.net.Uri);
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.app.Notification.MessagingStyle.Message> CREATOR;
+ }
+
public static abstract class Notification.Style {
ctor public Notification.Style();
method public android.app.Notification build();
@@ -7677,8 +7707,6 @@
method public void setExtras(android.os.PersistableBundle);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.content.ClipDescription> CREATOR;
- field public static final java.lang.String EXTRA_TARGET_COMPONENT_NAME = "android.content.extra.TARGET_COMPONENT_NAME";
- field public static final java.lang.String EXTRA_USER_SERIAL_NUMBER = "android.content.extra.USER_SERIAL_NUMBER";
field public static final java.lang.String MIMETYPE_TEXT_HTML = "text/html";
field public static final java.lang.String MIMETYPE_TEXT_INTENT = "text/vnd.android.intent";
field public static final java.lang.String MIMETYPE_TEXT_PLAIN = "text/plain";
@@ -8664,6 +8692,7 @@
field public static final java.lang.String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list";
field public static final java.lang.String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list";
field public static final java.lang.String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
+ field public static final java.lang.String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
@@ -8675,6 +8704,7 @@
field public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; // 0x0
field public static final java.lang.String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
field public static final java.lang.String EXTRA_EMAIL = "android.intent.extra.EMAIL";
+ field public static final java.lang.String EXTRA_EXCLUDE_COMPONENTS = "android.intent.extra.EXCLUDE_COMPONENTS";
field public static final java.lang.String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
field public static final java.lang.String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final java.lang.String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
@@ -19276,7 +19306,7 @@
field public static final int ADR_STATE_VALID = 1; // 0x1
field public static final android.os.Parcelable.Creator<android.location.GnssMeasurement> CREATOR;
field public static final int MULTIPATH_INDICATOR_DETECTED = 1; // 0x1
- field public static final int MULTIPATH_INDICATOR_NOT_USED = 2; // 0x2
+ field public static final int MULTIPATH_INDICATOR_NOT_DETECTED = 2; // 0x2
field public static final int MULTIPATH_INDICATOR_UNKNOWN = 0; // 0x0
field public static final int STATE_BDS_D2_BIT_SYNC = 256; // 0x100
field public static final int STATE_BDS_D2_SUBFRAME_SYNC = 512; // 0x200
@@ -19302,15 +19332,15 @@
method public java.util.Collection<android.location.GnssMeasurement> getMeasurements();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.location.GnssMeasurementsEvent> CREATOR;
- field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
- field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
- field public static final int STATUS_READY = 1; // 0x1
}
public static abstract class GnssMeasurementsEvent.Callback {
ctor public GnssMeasurementsEvent.Callback();
method public void onGnssMeasurementsReceived(android.location.GnssMeasurementsEvent);
method public void onStatusChanged(int);
+ field public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
}
public final class GnssNavigationMessage implements android.os.Parcelable {
@@ -19347,36 +19377,24 @@
field public static final int TYPE_UNKNOWN = 0; // 0x0
}
- public final class GnssNavigationMessageEvent implements android.os.Parcelable {
- ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage);
- method public int describeContents();
- method public android.location.GnssNavigationMessage getNavigationMessage();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR;
- field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ public static abstract class GnssNavigationMessage.Callback {
+ ctor public GnssNavigationMessage.Callback();
+ method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessage);
+ method public void onStatusChanged(int);
+ field public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
field public static final int STATUS_READY = 1; // 0x1
}
- public static abstract class GnssNavigationMessageEvent.Callback {
- ctor public GnssNavigationMessageEvent.Callback();
- method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent);
- method public void onStatusChanged(int);
- }
-
- public abstract interface GnssNmeaListener {
- method public abstract void onNmeaReceived(long, java.lang.String);
- }
-
public final class GnssStatus {
method public float getAzimuthDegrees(int);
method public float getCn0DbHz(int);
method public int getConstellationType(int);
method public float getElevationDegrees(int);
- method public int getNumSatellites();
+ method public int getSatelliteCount();
method public int getSvid(int);
- method public boolean hasAlmanac(int);
- method public boolean hasEphemeris(int);
+ method public boolean hasAlmanacData(int);
+ method public boolean hasEphemerisData(int);
method public boolean usedInFix(int);
field public static final int CONSTELLATION_BEIDOU = 5; // 0x5
field public static final int CONSTELLATION_GALILEO = 6; // 0x6
@@ -19387,15 +19405,15 @@
field public static final int CONSTELLATION_UNKNOWN = 0; // 0x0
}
- public abstract class GnssStatusCallback {
- ctor public GnssStatusCallback();
+ public static abstract class GnssStatus.Callback {
+ ctor public GnssStatus.Callback();
method public void onFirstFix(int);
method public void onSatelliteStatusChanged(android.location.GnssStatus);
method public void onStarted();
method public void onStopped();
}
- public final class GpsSatellite {
+ public final deprecated class GpsSatellite {
method public float getAzimuth();
method public float getElevation();
method public int getPrn();
@@ -19405,7 +19423,7 @@
method public boolean usedInFix();
}
- public final class GpsStatus {
+ public final deprecated class GpsStatus {
method public int getMaxSatellites();
method public java.lang.Iterable<android.location.GpsSatellite> getSatellites();
method public int getTimeToFirstFix();
@@ -19415,11 +19433,11 @@
field public static final int GPS_EVENT_STOPPED = 2; // 0x2
}
- public static abstract interface GpsStatus.Listener {
+ public static abstract deprecated interface GpsStatus.Listener {
method public abstract void onGpsStatusChanged(int);
}
- public static abstract interface GpsStatus.NmeaListener {
+ public static abstract deprecated interface GpsStatus.NmeaListener {
method public abstract void onNmeaReceived(long, java.lang.String);
}
@@ -19481,8 +19499,8 @@
public class LocationManager {
method public deprecated boolean addGpsStatusListener(android.location.GpsStatus.Listener);
method public deprecated boolean addNmeaListener(android.location.GpsStatus.NmeaListener);
- method public boolean addNmeaListener(android.location.GnssNmeaListener);
- method public boolean addNmeaListener(android.location.GnssNmeaListener, android.os.Handler);
+ method public boolean addNmeaListener(android.location.OnNmeaMessageListener);
+ method public boolean addNmeaListener(android.location.OnNmeaMessageListener, android.os.Handler);
method public void addProximityAlert(double, double, float, long, android.app.PendingIntent);
method public void addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int);
method public void clearTestProviderEnabled(java.lang.String);
@@ -19499,13 +19517,13 @@
method public boolean isProviderEnabled(java.lang.String);
method public boolean registerGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback);
method public boolean registerGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback, android.os.Handler);
- method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
- method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler);
- method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback);
- method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback, android.os.Handler);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatus.Callback);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatus.Callback, android.os.Handler);
method public deprecated void removeGpsStatusListener(android.location.GpsStatus.Listener);
method public deprecated void removeNmeaListener(android.location.GpsStatus.NmeaListener);
- method public void removeNmeaListener(android.location.GnssNmeaListener);
+ method public void removeNmeaListener(android.location.OnNmeaMessageListener);
method public void removeProximityAlert(android.app.PendingIntent);
method public void removeTestProvider(java.lang.String);
method public void removeUpdates(android.location.LocationListener);
@@ -19524,8 +19542,8 @@
method public void setTestProviderLocation(java.lang.String, android.location.Location);
method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long);
method public void unregisterGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback);
- method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
- method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback);
+ method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback);
+ method public void unregisterGnssStatusCallback(android.location.GnssStatus.Callback);
field public static final java.lang.String GPS_PROVIDER = "gps";
field public static final java.lang.String KEY_LOCATION_CHANGED = "location";
field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled";
@@ -19554,6 +19572,10 @@
field public static final int TEMPORARILY_UNAVAILABLE = 1; // 0x1
}
+ public abstract interface OnNmeaMessageListener {
+ method public abstract void onNmeaMessage(java.lang.String, long);
+ }
+
public abstract class SettingInjectorService extends android.app.Service {
ctor public SettingInjectorService(java.lang.String);
method public final android.os.IBinder onBind(android.content.Intent);
@@ -34776,7 +34798,9 @@
method public static void requestRebind(android.content.ComponentName) throws android.os.RemoteException;
method public final void requestUnbind() throws android.os.RemoteException;
method public final void setNotificationsShown(java.lang.String[]);
+ field public static final int HINT_HOST_DISABLE_CALL_EFFECTS = 4; // 0x4
field public static final int HINT_HOST_DISABLE_EFFECTS = 1; // 0x1
+ field public static final int HINT_HOST_DISABLE_NOTIFICATION_EFFECTS = 2; // 0x2
field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4
field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1
field public static final int INTERRUPTION_FILTER_NONE = 3; // 0x3
@@ -34792,6 +34816,7 @@
method public int getImportance();
method public java.lang.CharSequence getImportanceExplanation();
method public java.lang.String getKey();
+ method public java.lang.String getOverrideGroupKey();
method public int getRank();
method public int getSuppressedVisualEffects();
method public boolean isAmbient();
@@ -34822,13 +34847,16 @@
method public int getId();
method public java.lang.String getKey();
method public android.app.Notification getNotification();
+ method public java.lang.String getOverrideGroupKey();
method public java.lang.String getPackageName();
method public long getPostTime();
method public java.lang.String getTag();
method public android.os.UserHandle getUser();
method public deprecated int getUserId();
method public boolean isClearable();
+ method public boolean isGroup();
method public boolean isOngoing();
+ method public void setOverrideGroupKey(java.lang.String);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.notification.StatusBarNotification> CREATOR;
}
@@ -34864,7 +34892,7 @@
method public void onClick();
method public void onStartListening();
method public void onStopListening();
- method public int onTileAdded();
+ method public void onTileAdded();
method public void onTileRemoved();
method public static final void requestListeningState(android.content.Context, android.content.ComponentName);
method public final void showDialog(android.app.Dialog);
@@ -34872,8 +34900,7 @@
method public final void unlockAndRun(java.lang.Runnable);
field public static final java.lang.String ACTION_QS_TILE = "android.service.quicksettings.action.QS_TILE";
field public static final java.lang.String ACTION_QS_TILE_PREFERENCES = "android.service.quicksettings.action.QS_TILE_PREFERENCES";
- field public static final int TILE_MODE_ACTIVE = 2; // 0x2
- field public static final int TILE_MODE_PASSIVE = 1; // 0x1
+ field public static final java.lang.String META_DATA_ACTIVE_TILE = "android.service.quicksettings.ACTIVE_TILE";
}
}
@@ -52033,7 +52060,6 @@
public final class Method extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
method public boolean equals(java.lang.Object);
method public A getAnnotation(java.lang.Class<A>);
- method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
method public java.lang.Class<?> getDeclaringClass();
method public java.lang.Object getDefaultValue();
method public java.lang.Class<?>[] getExceptionTypes();
@@ -52047,7 +52073,6 @@
method public java.lang.Class<?> getReturnType();
method public java.lang.reflect.TypeVariable<java.lang.reflect.Method>[] getTypeParameters();
method public java.lang.Object invoke(java.lang.Object, java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException;
- method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
method public boolean isBridge();
method public boolean isDefault();
method public boolean isSynthetic();
@@ -57523,6 +57548,14 @@
method public static int hashCode(float[]);
method public static int hashCode(double[]);
method public static int hashCode(java.lang.Object[]);
+ method public static void parallelPrefix(T[], java.util.function.BinaryOperator<T>);
+ method public static void parallelPrefix(T[], int, int, java.util.function.BinaryOperator<T>);
+ method public static void parallelPrefix(long[], java.util.function.LongBinaryOperator);
+ method public static void parallelPrefix(long[], int, int, java.util.function.LongBinaryOperator);
+ method public static void parallelPrefix(double[], java.util.function.DoubleBinaryOperator);
+ method public static void parallelPrefix(double[], int, int, java.util.function.DoubleBinaryOperator);
+ method public static void parallelPrefix(int[], java.util.function.IntBinaryOperator);
+ method public static void parallelPrefix(int[], int, int, java.util.function.IntBinaryOperator);
method public static void parallelSetAll(T[], java.util.function.IntFunction<? extends T>);
method public static void parallelSetAll(int[], java.util.function.IntUnaryOperator);
method public static void parallelSetAll(long[], java.util.function.IntToLongFunction);
diff --git a/api/test-removed.txt b/api/test-removed.txt
index 3f16bca..8c6abdc 100644
--- a/api/test-removed.txt
+++ b/api/test-removed.txt
@@ -84,6 +84,67 @@
}
+package android.location {
+
+ public final class GnssMeasurement implements android.os.Parcelable {
+ field public static final int MULTIPATH_INDICATOR_NOT_USED = 2; // 0x2
+ }
+
+ public final class GnssMeasurementsEvent implements android.os.Parcelable {
+ field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
+ }
+
+ public final class GnssNavigationMessageEvent implements android.os.Parcelable {
+ ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage);
+ method public int describeContents();
+ method public android.location.GnssNavigationMessage getNavigationMessage();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR;
+ field public static final int STATUS_GNSS_LOCATION_DISABLED = 2; // 0x2
+ field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
+ field public static final int STATUS_READY = 1; // 0x1
+ }
+
+ public static abstract class GnssNavigationMessageEvent.Callback {
+ ctor public GnssNavigationMessageEvent.Callback();
+ method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent);
+ method public void onStatusChanged(int);
+ }
+
+ public abstract interface GnssNmeaListener {
+ method public abstract void onNmeaReceived(long, java.lang.String);
+ }
+
+ public final class GnssStatus {
+ method public int getNumSatellites();
+ method public boolean hasAlmanac(int);
+ method public boolean hasEphemeris(int);
+ }
+
+ public abstract class GnssStatusCallback {
+ ctor public GnssStatusCallback();
+ method public void onFirstFix(int);
+ method public void onSatelliteStatusChanged(android.location.GnssStatus);
+ method public void onStarted();
+ method public void onStopped();
+ }
+
+ public class LocationManager {
+ method public boolean addNmeaListener(android.location.GnssNmeaListener);
+ method public boolean addNmeaListener(android.location.GnssNmeaListener, android.os.Handler);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
+ method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback);
+ method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler);
+ method public void removeNmeaListener(android.location.GnssNmeaListener);
+ method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback);
+ method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback);
+ }
+
+}
+
package android.media {
public final class AudioFormat implements android.os.Parcelable {
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java
index bf823f8..56728ad 100644
--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -600,11 +600,16 @@
* Dispatch a gesture to the touch screen. Any gestures currently in progress, whether from
* the user, this service, or another service, will be cancelled.
* <p>
+ * The gesture will be dispatched as if it were performed directly on the screen by a user, so
+ * the events may be affected by features such as magnification and explore by touch.
+ * </p>
+ * <p>
* <strong>Note:</strong> In order to dispatch gestures, your service
* must declare the capability by setting the
* {@link android.R.styleable#AccessibilityService_canPerformGestures}
* property in its meta-data. For more information, see
* {@link #SERVICE_META_DATA}.
+ * </p>
*
* @param gesture The gesture to dispatch
* @param callback The object to call back when the status of the gesture is known. If
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 14c4fc6..36e962e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -1526,7 +1526,7 @@
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
case CREATE_SERVICE:
- Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "serviceCreate");
+ Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, ("serviceCreate: " + String.valueOf(msg.obj)));
handleCreateService((CreateServiceData)msg.obj);
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
@@ -1541,7 +1541,7 @@
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
case SERVICE_ARGS:
- Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "serviceStart");
+ Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, ("serviceStart: " + String.valueOf(msg.obj)));
handleServiceArgs((ServiceArgsData)msg.obj);
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
@@ -4727,8 +4727,16 @@
if (callbacks != null) {
final int N = callbacks.size();
for (int i=0; i<N; i++) {
- performConfigurationChanged(callbacks.get(i), null, config, null,
- REPORT_TO_ACTIVITY);
+ ComponentCallbacks2 cb = callbacks.get(i);
+ if (cb instanceof Activity) {
+ // If callback is an Activity - call corresponding method to consider override
+ // config and avoid onConfigurationChanged if it hasn't changed.
+ Activity a = (Activity) cb;
+ performConfigurationChangedForActivity(mActivities.get(a.getActivityToken()),
+ config, REPORT_TO_ACTIVITY);
+ } else {
+ performConfigurationChanged(cb, null, config, null, REPORT_TO_ACTIVITY);
+ }
}
}
}
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 7a69c62..ee80ec3 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -25,6 +25,7 @@
import android.content.pm.ParceledListSlice;
import android.net.Uri;
import android.os.Bundle;
+import android.service.notification.Adjustment;
import android.service.notification.Condition;
import android.service.notification.IConditionListener;
import android.service.notification.IConditionProvider;
@@ -80,7 +81,8 @@
void setOnNotificationPostedTrimFromListener(in INotificationListener token, int trim);
void setInterruptionFilter(String pkg, int interruptionFilter);
- void setImportanceFromRankerService(in INotificationListener token, String key, int importance, CharSequence explanation);
+ void applyAdjustmentFromRankerService(in INotificationListener token, in Adjustment adjustment);
+ void applyAdjustmentsFromRankerService(in INotificationListener token, in List<Adjustment> adjustments);
ComponentName getEffectsSuppressor();
boolean matchesCallFilter(in Bundle extras);
diff --git a/core/java/android/app/ITaskStackListener.aidl b/core/java/android/app/ITaskStackListener.aidl
index fa67529..496ca6f 100644
--- a/core/java/android/app/ITaskStackListener.aidl
+++ b/core/java/android/app/ITaskStackListener.aidl
@@ -40,4 +40,9 @@
* Called when we launched an activity that we forced to be resizable.
*/
void onActivityForcedResizable(String packageName, int taskId);
+
+ /**
+ * Callen when we launched an activity that is dismissed the docked stack.
+ */
+ void onActivityDismissingDockedStack();
}
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 2e4a8c6..4bf1aa3 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -21,6 +21,7 @@
import android.annotation.IntDef;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
+import android.annotation.SystemApi;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -496,6 +497,15 @@
*/
public static final int FLAG_GROUP_SUMMARY = 0x00000200;
+ /**
+ * Bit to be bitswise-ored into the {@link #flags} field that should be
+ * set if this notification is the group summary for an auto-group of notifications.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final int FLAG_AUTOGROUP_SUMMARY = 0x00000400;
+
public int flags;
/** @hide */
@@ -904,6 +914,34 @@
public static final String EXTRA_COMPACT_ACTIONS = "android.compactActions";
/**
+ * {@link #extras} key: the username to be displayed for all messages sent by the user including
+ * direct replies
+ * {@link android.app.Notification.MessagingStyle} notification.
+ */
+ public static final String EXTRA_SELF_DISPLAY_NAME = "android.selfDisplayName";
+
+ /**
+ * {@link #extras} key: a boolean describing whether the platform should automatically
+ * generate possible replies to
+ * {@link android.app.Notification.MessagingStyle.Message} objects provided by a
+ * {@link android.app.Notification.MessagingStyle} notification.
+ */
+ public static final String EXTRA_ALLOW_GENERATED_REPLIES = "android.allowGeneratedReplies";
+
+ /**
+ * {@link #extras} key: a {@link String} to be displayed as the title to a thread represented by
+ * a {@link android.app.Notification.MessagingStyle}
+ */
+ public static final String EXTRA_THREAD_TITLE = "android.threadTitle";
+
+ /**
+ * {@link #extras} key: an array of {@link android.app.Notification.MessagingStyle.Message}
+ * bundles provided by a
+ * {@link android.app.Notification.MessagingStyle} notification.
+ */
+ public static final String EXTRA_MESSAGES = "android.messages";
+
+ /**
* {@link #extras} key: the user that built the notification.
*
* @hide
@@ -1917,13 +1955,9 @@
* @hide
*/
public static void addFieldsFromContext(Context context, Notification notification) {
- if (notification.extras.getParcelable(EXTRA_BUILDER_APPLICATION_INFO) == null) {
- notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO,
- context.getApplicationInfo());
- }
- if (!notification.extras.containsKey(EXTRA_ORIGINATING_USERID)) {
- notification.extras.putInt(EXTRA_ORIGINATING_USERID, context.getUserId());
- }
+ notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO,
+ context.getApplicationInfo());
+ notification.extras.putInt(EXTRA_ORIGINATING_USERID, context.getUserId());
}
@Override
@@ -2992,12 +3026,13 @@
/**
* @hide
*/
- public void setFlag(int mask, boolean value) {
+ public Builder setFlag(int mask, boolean value) {
if (value) {
mN.flags |= mask;
} else {
mN.flags &= ~mask;
}
+ return this;
}
/**
@@ -3560,7 +3595,8 @@
private static Class<? extends Style> getNotificationStyleClass(String templateClass) {
Class<? extends Style>[] classes = new Class[] {
BigTextStyle.class, BigPictureStyle.class, InboxStyle.class, MediaStyle.class,
- DecoratedCustomViewStyle.class, DecoratedMediaCustomViewStyle.class };
+ DecoratedCustomViewStyle.class, DecoratedMediaCustomViewStyle.class,
+ MessagingStyle.class };
for (Class<? extends Style> innerClass : classes) {
if (templateClass.equals(innerClass.getName())) {
return innerClass;
@@ -4157,6 +4193,350 @@
}
/**
+ * Helper class for generating large-format notifications that include multiple back-and-forth
+ * messages of varying types between any number of people.
+ *
+ * <br>
+ * If the platform does not provide large-format notifications, this method has no effect. The
+ * user will always see the normal notification view.
+ * <br>
+ * This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like
+ * so:
+ * <pre class="prettyprint">
+ *
+ * Notification noti = new Notification.Builder()
+ * .setContentTitle("2 new messages wtih " + sender.toString())
+ * .setContentText(subject)
+ * .setSmallIcon(R.drawable.new_message)
+ * .setLargeIcon(aBitmap)
+ * .setStyle(new Notification.MessagingStyle(resources.getString(R.string.reply_name))
+ * .addMessage(messages[0].getText(), messages[0].getTime(), messages[0].getSender())
+ * .addMessage(messages[1].getText(), messages[1].getTime(), messages[1].getSender()))
+ * .build();
+ * </pre>
+ */
+ public static class MessagingStyle extends Style {
+
+ /**
+ * The maximum number of messages that will be retained in the Notification itself (the
+ * number displayed is up to the platform).
+ */
+ public static final int MAXIMUM_RETAINED_MESSAGES = 25;
+
+ CharSequence mUserDisplayName;
+ CharSequence mConversationTitle;
+ boolean mAllowGeneratedReplies = true;
+ ArrayList<Message> mMessages = new ArrayList<>();
+
+ MessagingStyle() {
+ }
+
+ /**
+ * @param userDisplayName the name to be displayed for any replies sent by the user before the
+ * posting app reposts the notification with those messages after they've been actually
+ * sent and in previous messages sent by the user added in
+ * {@link #addMessage(Notification.MessagingStyle.Message)}
+ */
+ public MessagingStyle(CharSequence userDisplayName) {
+ mUserDisplayName = userDisplayName;
+ }
+
+ /**
+ * Returns the name to be displayed for any replies sent by the user
+ */
+ public CharSequence getUserDisplayName() {
+ return mUserDisplayName;
+ }
+
+ /**
+ * Set whether the platform should automatically generate possible replies from messages.
+ * @param allowGeneratedReplies {@code true} to allow generated replies, {@code false}
+ * otherwise
+ * @return this object for method chaining
+ * The default value is {@code true}
+ */
+ public MessagingStyle setAllowGeneratedReplies(boolean allowGeneratedReplies) {
+ mAllowGeneratedReplies = allowGeneratedReplies;
+ return this;
+ }
+
+ /**
+ * Return whether the platform should automatically generate possible replies from messages.
+ */
+ public boolean getAllowGeneratedReplies() {
+ return mAllowGeneratedReplies;
+ }
+
+ /**
+ * Sets the title to be displayed on this conversation. This should only be used for
+ * group messaging and left unset for one-on-one conversations.
+ * @param conversationTitle
+ * @return this object for method chaining.
+ */
+ public MessagingStyle setConversationTitle(CharSequence conversationTitle) {
+ mConversationTitle = conversationTitle;
+ return this;
+ }
+
+ /**
+ * Return the title to be displayed on this conversation. Can be <code>null</code> and
+ * should be for one-on-one conversations
+ */
+ public CharSequence getConversationTitle() {
+ return mConversationTitle;
+ }
+
+ /**
+ * Adds a message for display by this notification. Convenience call for a simple
+ * {@link Message} in {@link #addMessage(Notification.MessagingStyle.Message)}.
+ * @param text A {@link CharSequence} to be displayed as the message content
+ * @param timestamp Time at which the message arrived
+ * @param sender A {@link CharSequence} to be used for displaying the name of the
+ * sender. Should be <code>null</code> for messages by the current user, in which case
+ * the platform will insert {@link #getUserDisplayName()}.
+ * Should be unique amongst all individuals in the conversation, and should be
+ * consistent during re-posts of the notification.
+ *
+ * @see Message#Message(CharSequence, long, CharSequence)
+ *
+ * @return this object for method chaining
+ */
+ public MessagingStyle addMessage(CharSequence text, long timestamp, CharSequence sender) {
+ mMessages.add(new Message(text, timestamp, sender));
+ if (mMessages.size() > MAXIMUM_RETAINED_MESSAGES) {
+ mMessages.remove(0);
+ }
+ return this;
+ }
+
+ /**
+ * Adds a {@link Message} for display in this notification.
+ * @param message The {@link Message} to be displayed
+ * @return this object for method chaining
+ */
+ public MessagingStyle addMessage(Message message) {
+ mMessages.add(message);
+ if (mMessages.size() > MAXIMUM_RETAINED_MESSAGES) {
+ mMessages.remove(0);
+ }
+ return this;
+ }
+
+ /**
+ * Gets the list of {@code Message} objects that represent the notification
+ */
+ public List<Message> getMessages() {
+ return mMessages;
+ }
+
+ /**
+ * @hide
+ */
+ @Override
+ public void addExtras(Bundle extras) {
+ super.addExtras(extras);
+ if (mUserDisplayName != null) {
+ extras.putCharSequence(EXTRA_SELF_DISPLAY_NAME, mUserDisplayName);
+ }
+ if (mConversationTitle != null) {
+ extras.putCharSequence(EXTRA_THREAD_TITLE, mConversationTitle);
+ }
+ extras.putBoolean(EXTRA_ALLOW_GENERATED_REPLIES, mAllowGeneratedReplies);
+ if (!mMessages.isEmpty()) {
+ extras.putParcelableArrayList(EXTRA_MESSAGES, mMessages);
+ }
+ }
+
+ /**
+ * @hide
+ */
+ @Override
+ protected void restoreFromExtras(Bundle extras) {
+ super.restoreFromExtras(extras);
+
+ mMessages.clear();
+ mUserDisplayName = extras.getString(EXTRA_SELF_DISPLAY_NAME);
+ mConversationTitle = extras.getString(EXTRA_THREAD_TITLE);
+ mAllowGeneratedReplies = extras.getBoolean(EXTRA_ALLOW_GENERATED_REPLIES,
+ mAllowGeneratedReplies);
+ List<Message> messages = extras.getParcelableArrayList(EXTRA_MESSAGES);
+ if (messages != null) {
+ mMessages.addAll(messages);
+ }
+ }
+
+ /**
+ * @hide
+ */
+ public RemoteViews makeBigContentView() {
+ // TODO handset to write implementation
+ RemoteViews contentView = getStandardView(mBuilder.getBigTextLayoutResource());
+
+ return contentView;
+ }
+
+ public static final class Message implements Parcelable {
+
+ private final CharSequence mText;
+ private final long mTimestamp;
+ private final CharSequence mSender;
+
+ private String mDataMimeType;
+ private Uri mDataUri;
+
+ /**
+ * Constructor
+ * @param text A {@link CharSequence} to be displayed as the message content
+ * @param timestamp Time at which the message arrived
+ * @param sender A {@link CharSequence} to be used for displaying the name of the
+ * sender. Should be <code>null</code> for messages by the current user, in which case
+ * the platform will insert {@link MessagingStyle#getUserDisplayName()}.
+ * Should be unique amongst all individuals in the conversation, and should be
+ * consistent during re-posts of the notification.
+ */
+ public Message(CharSequence text, long timestamp, CharSequence sender){
+ mText = text;
+ mTimestamp = timestamp;
+ mSender = sender;
+ }
+
+ /**
+ * Sets a binary blob of data and an associated MIME type for a message. In the case
+ * where the platform doesn't support the MIME type, the original text provided in the
+ * constructor will be used.
+ * @param dataMimeType The MIME type of the content. See
+ * <a href="{@docRoot}notifications/messaging.html"> for the list of supported MIME
+ * types on Android and Android Wear.
+ * @param dataUri The uri containing the content whose type is given by the MIME type.
+ * <p class="note">
+ * <ol>
+ * <li>Notification Listeners including the System UI need permission to access the
+ * data the Uri points to. The recommended ways to do this are:</li>
+ * <li>Store the data in your own ContentProvider, making sure that other apps have
+ * the correct permission to access your provider. The preferred mechanism for
+ * providing access is to use per-URI permissions which are temporary and only
+ * grant access to the receiving application. An easy way to create a
+ * ContentProvider like this is to use the FileProvider helper class.</li>
+ * <li>Use the system MediaStore. The MediaStore is primarily aimed at video, audio
+ * and image MIME types, however beginning with Android 3.0 (API level 11) it can
+ * also store non-media types (see MediaStore.Files for more info). Files can be
+ * inserted into the MediaStore using scanFile() after which a content:// style
+ * Uri suitable for sharing is passed to the provided onScanCompleted() callback.
+ * Note that once added to the system MediaStore the content is accessible to any
+ * app on the device.</li>
+ * </ol>
+ * @return this object for method chaining
+ */
+ public Message setData(String dataMimeType, Uri dataUri) {
+ mDataMimeType = dataMimeType;
+ mDataUri = dataUri;
+ return this;
+ }
+
+ private Message(Parcel in) {
+ if (in.readInt() != 0) {
+ mText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ } else {
+ mText = null;
+ }
+ mTimestamp = in.readLong();
+ if (in.readInt() != 0) {
+ mSender = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ } else {
+ mSender = null;
+ }
+ if (in.readInt() != 0) {
+ mDataMimeType = in.readString();
+ }
+ if (in.readInt() != 0) {
+ mDataUri = in.readParcelable(Uri.class.getClassLoader());
+ }
+ }
+
+ /**
+ * Get the text to be used for this message, or the fallback text if a type and content
+ * Uri have been set
+ */
+ public CharSequence getText() {
+ return mText;
+ }
+
+ /**
+ * Get the time at which this message arrived
+ */
+ public long getTimestamp() {
+ return mTimestamp;
+ }
+
+ /**
+ * Get the text used to display the contact's name in the messaging experience
+ */
+ public CharSequence getSender() {
+ return mSender;
+ }
+
+ /**
+ * Get the MIME type of the data pointed to by the Uri
+ */
+ public String getDataMimeType() {
+ return mDataMimeType;
+ }
+
+ /**
+ * Get the the Uri pointing to the content of the message. Can be null, in which case
+ * {@see #getText()} is used.
+ */
+ public Uri getDataUri() {
+ return mDataUri;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ if (mText != null) {
+ out.writeInt(1);
+ TextUtils.writeToParcel(mText, out, flags);
+ } else {
+ out.writeInt(0);
+ }
+ out.writeLong(mTimestamp);
+ if (mSender != null) {
+ out.writeInt(1);
+ TextUtils.writeToParcel(mSender, out, flags);
+ } else {
+ out.writeInt(0);
+ }
+ if (mDataMimeType != null) {
+ out.writeInt(1);
+ out.writeString(mDataMimeType);
+ } else {
+ out.writeInt(0);
+ }
+ if (mDataUri != null) {
+ out.writeInt(1);
+ out.writeParcelable(mDataUri, flags);
+ } else {
+ out.writeInt(0);
+ }
+ }
+
+ public static final Parcelable.Creator<Message> CREATOR =
+ new Parcelable.Creator<Message>() {
+ public Message createFromParcel(Parcel in) {
+ return new Message(in);
+ }
+ public Message[] newArray(int size) {
+ return new Message[size];
+ }
+ };
+ }
+ }
+
+ /**
* Helper class for generating large-format notifications that include a list of (up to 5) strings.
*
* Here's how you'd set the <code>InboxStyle</code> on a notification:
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 96757bb..3f9629c 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2216,9 +2216,7 @@
* that uses {@link DeviceAdminInfo#USES_POLICY_RESET_PASSWORD}
*/
public boolean resetPassword(String password, int flags) {
- if (mParentInstance) {
- throw new SecurityException("Reset password does not work across profiles.");
- }
+ throwIfParentInstance("resetPassword");
if (mService != null) {
try {
return mService.resetPassword(password, flags);
@@ -2355,6 +2353,7 @@
* that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}
*/
public void wipeData(int flags) {
+ throwIfParentInstance("wipeData");
if (mService != null) {
try {
mService.wipeData(flags);
@@ -2388,6 +2387,7 @@
*/
public ComponentName setGlobalProxy(@NonNull ComponentName admin, Proxy proxySpec,
List<String> exclusionList ) {
+ throwIfParentInstance("setGlobalProxy");
if (proxySpec == null) {
throw new NullPointerException();
}
@@ -2453,6 +2453,7 @@
*/
public void setRecommendedGlobalProxy(@NonNull ComponentName admin, @Nullable ProxyInfo
proxyInfo) {
+ throwIfParentInstance("setRecommendedGlobalProxy");
if (mService != null) {
try {
mService.setRecommendedGlobalProxy(admin, proxyInfo);
@@ -2603,6 +2604,7 @@
* {@link DeviceAdminInfo#USES_ENCRYPTED_STORAGE}
*/
public int setStorageEncryption(@NonNull ComponentName admin, boolean encrypt) {
+ throwIfParentInstance("setStorageEncryption");
if (mService != null) {
try {
return mService.setStorageEncryption(admin, encrypt);
@@ -2623,6 +2625,7 @@
* @return true if the admin(s) are requesting encryption, false if not.
*/
public boolean getStorageEncryption(@Nullable ComponentName admin) {
+ throwIfParentInstance("getStorageEncryption");
if (mService != null) {
try {
return mService.getStorageEncryption(admin, myUserId());
@@ -2718,6 +2721,7 @@
* owner.
*/
public boolean installCaCert(@Nullable ComponentName admin, byte[] certBuffer) {
+ throwIfParentInstance("installCaCert");
if (mService != null) {
try {
return mService.installCaCert(admin, certBuffer);
@@ -2738,6 +2742,7 @@
* owner.
*/
public void uninstallCaCert(@Nullable ComponentName admin, byte[] certBuffer) {
+ throwIfParentInstance("uninstallCaCert");
if (mService != null) {
try {
final String alias = getCaCertAlias(certBuffer);
@@ -2763,6 +2768,7 @@
*/
public List<byte[]> getInstalledCaCerts(@Nullable ComponentName admin) {
List<byte[]> certs = new ArrayList<byte[]>();
+ throwIfParentInstance("getInstalledCaCerts");
if (mService != null) {
try {
mService.enforceCanManageCaCerts(admin);
@@ -2791,6 +2797,7 @@
* owner.
*/
public void uninstallAllUserCaCerts(@Nullable ComponentName admin) {
+ throwIfParentInstance("uninstallAllUserCaCerts");
if (mService != null) {
try {
mService.uninstallCaCerts(admin, new TrustedCertificateStore().userAliases()
@@ -2811,6 +2818,7 @@
* owner.
*/
public boolean hasCaCertInstalled(@Nullable ComponentName admin, byte[] certBuffer) {
+ throwIfParentInstance("hasCaCertInstalled");
if (mService != null) {
try {
mService.enforceCanManageCaCerts(admin);
@@ -2879,6 +2887,7 @@
*/
public boolean installKeyPair(@Nullable ComponentName admin, @NonNull PrivateKey privKey,
@NonNull Certificate[] certs, @NonNull String alias, boolean requestAccess) {
+ throwIfParentInstance("installKeyPair");
try {
final byte[] pemCert = Credentials.convertToPem(certs[0]);
byte[] pemChain = null;
@@ -2911,6 +2920,7 @@
* owner.
*/
public boolean removeKeyPair(@Nullable ComponentName admin, @NonNull String alias) {
+ throwIfParentInstance("removeKeyPair");
try {
return mService.removeKeyPair(admin, alias);
} catch (RemoteException e) {
@@ -2951,6 +2961,7 @@
*/
public void setCertInstallerPackage(@NonNull ComponentName admin, @Nullable String
installerPackage) throws SecurityException {
+ throwIfParentInstance("setCertInstallerPackage");
if (mService != null) {
try {
mService.setCertInstallerPackage(admin, installerPackage);
@@ -2970,6 +2981,7 @@
* @throws SecurityException if {@code admin} is not a device or a profile owner.
*/
public String getCertInstallerPackage(@NonNull ComponentName admin) throws SecurityException {
+ throwIfParentInstance("getCertInstallerPackage");
if (mService != null) {
try {
return mService.getCertInstallerPackage(admin);
@@ -3000,6 +3012,7 @@
*/
public void setAlwaysOnVpnPackage(@NonNull ComponentName admin, @Nullable String vpnPackage)
throws NameNotFoundException, UnsupportedOperationException {
+ throwIfParentInstance("setAlwaysOnVpnPackage");
if (mService != null) {
try {
if (!mService.setAlwaysOnVpnPackage(admin, vpnPackage)) {
@@ -3021,6 +3034,7 @@
* @throws SecurityException if {@code admin} is not a device or a profile owner.
*/
public String getAlwaysOnVpnPackage(@NonNull ComponentName admin) {
+ throwIfParentInstance("getAlwaysOnVpnPackage");
if (mService != null) {
try {
return mService.getAlwaysOnVpnPackage(admin);
@@ -3048,6 +3062,7 @@
* {@link DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA}.
*/
public void setCameraDisabled(@NonNull ComponentName admin, boolean disabled) {
+ throwIfParentInstance("setCameraDisabled");
if (mService != null) {
try {
mService.setCameraDisabled(admin, disabled);
@@ -3064,6 +3079,7 @@
* have disabled the camera
*/
public boolean getCameraDisabled(@Nullable ComponentName admin) {
+ throwIfParentInstance("getCameraDisabled");
return getCameraDisabled(admin, myUserId());
}
@@ -3093,6 +3109,7 @@
* than the one managed by the device owner.
*/
public boolean requestBugreport(@NonNull ComponentName admin) {
+ throwIfParentInstance("requestBugreport");
if (mService != null) {
try {
return mService.requestBugreport(admin);
@@ -3131,6 +3148,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void setScreenCaptureDisabled(@NonNull ComponentName admin, boolean disabled) {
+ throwIfParentInstance("setScreenCaptureDisabled");
if (mService != null) {
try {
mService.setScreenCaptureDisabled(admin, disabled);
@@ -3147,6 +3165,7 @@
* have disabled screen capture.
*/
public boolean getScreenCaptureDisabled(@Nullable ComponentName admin) {
+ throwIfParentInstance("getScreenCaptureDisabled");
return getScreenCaptureDisabled(admin, myUserId());
}
@@ -3176,6 +3195,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public void setAutoTimeRequired(@NonNull ComponentName admin, boolean required) {
+ throwIfParentInstance("setAutoTimeRequired");
if (mService != null) {
try {
mService.setAutoTimeRequired(admin, required);
@@ -3189,6 +3209,7 @@
* @return true if auto time is required.
*/
public boolean getAutoTimeRequired() {
+ throwIfParentInstance("getAutoTimeRequired");
if (mService != null) {
try {
return mService.getAutoTimeRequired();
@@ -3215,6 +3236,7 @@
*/
public void setForceEphemeralUsers(
@NonNull ComponentName admin, boolean forceEphemeralUsers) {
+ throwIfParentInstance("setForceEphemeralUsers");
if (mService != null) {
try {
mService.setForceEphemeralUsers(admin, forceEphemeralUsers);
@@ -3230,6 +3252,7 @@
* @hide
*/
public boolean getForceEphemeralUsers(@NonNull ComponentName admin) {
+ throwIfParentInstance("getForceEphemeralUsers");
if (mService != null) {
try {
return mService.getForceEphemeralUsers(admin);
@@ -3517,6 +3540,7 @@
* @return whether or not the package is registered as the device owner app.
*/
public boolean isDeviceOwnerApp(String packageName) {
+ throwIfParentInstance("isDeviceOwnerApp");
return isDeviceOwnerAppOnCallingUser(packageName);
}
@@ -3614,6 +3638,7 @@
* does not own the current device owner component.
*/
public void clearDeviceOwnerApp(String packageName) {
+ throwIfParentInstance("clearDeviceOwnerApp");
if (mService != null) {
try {
mService.clearDeviceOwner(packageName);
@@ -3731,6 +3756,7 @@
* @throws SecurityException if {@code admin} is not an active profile owner.
*/
public void clearProfileOwner(@NonNull ComponentName admin) {
+ throwIfParentInstance("clearProfileOwner");
if (mService != null) {
try {
mService.clearProfileOwner(admin);
@@ -3804,6 +3830,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public void setDeviceOwnerLockScreenInfo(@NonNull ComponentName admin, CharSequence info) {
+ throwIfParentInstance("setDeviceOwnerLockScreenInfo");
if (mService != null) {
try {
mService.setDeviceOwnerLockScreenInfo(admin, info);
@@ -3817,6 +3844,7 @@
* @return The device owner information. If it is not set returns {@code null}.
*/
public CharSequence getDeviceOwnerLockScreenInfo() {
+ throwIfParentInstance("getDeviceOwnerLockScreenInfo");
if (mService != null) {
try {
return mService.getDeviceOwnerLockScreenInfo();
@@ -3848,6 +3876,7 @@
*/
public String[] setPackagesSuspended(@NonNull ComponentName admin, String[] packageNames,
boolean suspended) {
+ throwIfParentInstance("setPackagesSuspended");
if (mService != null) {
try {
return mService.setPackagesSuspended(admin, packageNames, suspended);
@@ -3870,6 +3899,7 @@
*/
public boolean isPackageSuspended(@NonNull ComponentName admin, String packageName)
throws NameNotFoundException {
+ throwIfParentInstance("isPackageSuspended");
if (mService != null) {
try {
return mService.isPackageSuspended(admin, packageName);
@@ -3891,6 +3921,7 @@
* @throws SecurityException if {@code admin} is not a profile owner.
*/
public void setProfileEnabled(@NonNull ComponentName admin) {
+ throwIfParentInstance("setProfileEnabled");
if (mService != null) {
try {
mService.setProfileEnabled(admin);
@@ -3912,6 +3943,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void setProfileName(@NonNull ComponentName admin, String profileName) {
+ throwIfParentInstance("setProfileName");
if (mService != null) {
try {
mService.setProfileName(admin, profileName);
@@ -3930,6 +3962,7 @@
* @return Whether or not the package is registered as the profile owner.
*/
public boolean isProfileOwnerApp(String packageName) {
+ throwIfParentInstance("isProfileOwnerApp");
if (mService != null) {
try {
ComponentName profileOwner = mService.getProfileOwner(myUserId());
@@ -4024,6 +4057,7 @@
*/
public void addPersistentPreferredActivity(@NonNull ComponentName admin, IntentFilter filter,
@NonNull ComponentName activity) {
+ throwIfParentInstance("addPersistentPreferredActivity");
if (mService != null) {
try {
mService.addPersistentPreferredActivity(admin, filter, activity);
@@ -4046,6 +4080,7 @@
*/
public void clearPackagePersistentPreferredActivities(@NonNull ComponentName admin,
String packageName) {
+ throwIfParentInstance("clearPackagePersistentPreferredActivities");
if (mService != null) {
try {
mService.clearPackagePersistentPreferredActivities(admin, packageName);
@@ -4074,6 +4109,7 @@
*/
public void setApplicationRestrictionsManagingPackage(@NonNull ComponentName admin,
@Nullable String packageName) throws NameNotFoundException {
+ throwIfParentInstance("setApplicationRestrictionsManagingPackage");
if (mService != null) {
try {
if (!mService.setApplicationRestrictionsManagingPackage(admin, packageName)) {
@@ -4095,6 +4131,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public String getApplicationRestrictionsManagingPackage(@NonNull ComponentName admin) {
+ throwIfParentInstance("getApplicationRestrictionsManagingPackage");
if (mService != null) {
try {
return mService.getApplicationRestrictionsManagingPackage(admin);
@@ -4114,6 +4151,7 @@
* that method.
*/
public boolean isCallerApplicationRestrictionsManagingPackage() {
+ throwIfParentInstance("isCallerApplicationRestrictionsManagingPackage");
if (mService != null) {
try {
return mService.isCallerApplicationRestrictionsManagingPackage();
@@ -4159,6 +4197,7 @@
*/
public void setApplicationRestrictions(@Nullable ComponentName admin, String packageName,
Bundle settings) {
+ throwIfParentInstance("setApplicationRestrictions");
if (mService != null) {
try {
mService.setApplicationRestrictions(admin, packageName, settings);
@@ -4257,6 +4296,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void setCrossProfileCallerIdDisabled(@NonNull ComponentName admin, boolean disabled) {
+ throwIfParentInstance("setCrossProfileCallerIdDisabled");
if (mService != null) {
try {
mService.setCrossProfileCallerIdDisabled(admin, disabled);
@@ -4277,6 +4317,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public boolean getCrossProfileCallerIdDisabled(@NonNull ComponentName admin) {
+ throwIfParentInstance("getCrossProfileCallerIdDisabled");
if (mService != null) {
try {
return mService.getCrossProfileCallerIdDisabled(admin);
@@ -4317,6 +4358,7 @@
*/
public void setCrossProfileContactsSearchDisabled(@NonNull ComponentName admin,
boolean disabled) {
+ throwIfParentInstance("setCrossProfileContactsSearchDisabled");
if (mService != null) {
try {
mService.setCrossProfileContactsSearchDisabled(admin, disabled);
@@ -4337,6 +4379,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public boolean getCrossProfileContactsSearchDisabled(@NonNull ComponentName admin) {
+ throwIfParentInstance("getCrossProfileContactsSearchDisabled");
if (mService != null) {
try {
return mService.getCrossProfileContactsSearchDisabled(admin);
@@ -4407,6 +4450,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void setBluetoothContactSharingDisabled(@NonNull ComponentName admin, boolean disabled) {
+ throwIfParentInstance("setBluetoothContactSharingDisabled");
if (mService != null) {
try {
mService.setBluetoothContactSharingDisabled(admin, disabled);
@@ -4429,6 +4473,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public boolean getBluetoothContactSharingDisabled(@NonNull ComponentName admin) {
+ throwIfParentInstance("getBluetoothContactSharingDisabled");
if (mService != null) {
try {
return mService.getBluetoothContactSharingDisabled(admin);
@@ -4472,6 +4517,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void addCrossProfileIntentFilter(@NonNull ComponentName admin, IntentFilter filter, int flags) {
+ throwIfParentInstance("addCrossProfileIntentFilter");
if (mService != null) {
try {
mService.addCrossProfileIntentFilter(admin, filter, flags);
@@ -4490,6 +4536,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void clearCrossProfileIntentFilters(@NonNull ComponentName admin) {
+ throwIfParentInstance("clearCrossProfileIntentFilters");
if (mService != null) {
try {
mService.clearCrossProfileIntentFilters(admin);
@@ -4519,6 +4566,7 @@
*/
public boolean setPermittedAccessibilityServices(@NonNull ComponentName admin,
List<String> packageNames) {
+ throwIfParentInstance("setPermittedAccessibilityServices");
if (mService != null) {
try {
return mService.setPermittedAccessibilityServices(admin, packageNames);
@@ -4540,6 +4588,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public List<String> getPermittedAccessibilityServices(@NonNull ComponentName admin) {
+ throwIfParentInstance("getPermittedAccessibilityServices");
if (mService != null) {
try {
return mService.getPermittedAccessibilityServices(admin);
@@ -4617,6 +4666,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public boolean setPermittedInputMethods(@NonNull ComponentName admin, List<String> packageNames) {
+ throwIfParentInstance("setPermittedInputMethods");
if (mService != null) {
try {
return mService.setPermittedInputMethods(admin, packageNames);
@@ -4639,6 +4689,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public List<String> getPermittedInputMethods(@NonNull ComponentName admin) {
+ throwIfParentInstance("getPermittedInputMethods");
if (mService != null) {
try {
return mService.getPermittedInputMethods(admin);
@@ -4834,6 +4885,7 @@
public UserHandle createAndManageUser(@NonNull ComponentName admin, @NonNull String name,
@NonNull ComponentName profileOwner, @Nullable PersistableBundle adminExtras,
int flags) {
+ throwIfParentInstance("createAndManageUser");
try {
return mService.createAndManageUser(admin, name, profileOwner, adminExtras, flags);
} catch (RemoteException re) {
@@ -4851,6 +4903,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public boolean removeUser(@NonNull ComponentName admin, UserHandle userHandle) {
+ throwIfParentInstance("removeUser");
try {
return mService.removeUser(admin, userHandle);
} catch (RemoteException re) {
@@ -4868,6 +4921,7 @@
* @see Intent#ACTION_USER_FOREGROUND
*/
public boolean switchUser(@NonNull ComponentName admin, @Nullable UserHandle userHandle) {
+ throwIfParentInstance("switchUser");
try {
return mService.switchUser(admin, userHandle);
} catch (RemoteException re) {
@@ -4893,6 +4947,7 @@
* @see {@link #setApplicationRestrictionsManagingPackage}
*/
public Bundle getApplicationRestrictions(@Nullable ComponentName admin, String packageName) {
+ throwIfParentInstance("getApplicationRestrictions");
if (mService != null) {
try {
return mService.getApplicationRestrictions(admin, packageName);
@@ -4915,6 +4970,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void addUserRestriction(@NonNull ComponentName admin, String key) {
+ throwIfParentInstance("addUserRestriction");
if (mService != null) {
try {
mService.setUserRestriction(admin, key, true);
@@ -4936,6 +4992,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void clearUserRestriction(@NonNull ComponentName admin, String key) {
+ throwIfParentInstance("clearUserRestriction");
if (mService != null) {
try {
mService.setUserRestriction(admin, key, false);
@@ -4957,6 +5014,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public Bundle getUserRestrictions(@NonNull ComponentName admin) {
+ throwIfParentInstance("getUserRestrictions");
Bundle ret = null;
if (mService != null) {
try {
@@ -5001,6 +5059,7 @@
*/
public boolean setApplicationHidden(@NonNull ComponentName admin, String packageName,
boolean hidden) {
+ throwIfParentInstance("setApplicationHidden");
if (mService != null) {
try {
return mService.setApplicationHidden(admin, packageName, hidden);
@@ -5020,6 +5079,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public boolean isApplicationHidden(@NonNull ComponentName admin, String packageName) {
+ throwIfParentInstance("isApplicationHidden");
if (mService != null) {
try {
return mService.isApplicationHidden(admin, packageName);
@@ -5039,6 +5099,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void enableSystemApp(@NonNull ComponentName admin, String packageName) {
+ throwIfParentInstance("enableSystemApp");
if (mService != null) {
try {
mService.enableSystemApp(admin, packageName);
@@ -5059,6 +5120,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public int enableSystemApp(@NonNull ComponentName admin, Intent intent) {
+ throwIfParentInstance("enableSystemApp");
if (mService != null) {
try {
return mService.enableSystemAppWithIntent(admin, intent);
@@ -5091,6 +5153,7 @@
*/
public void setAccountManagementDisabled(@NonNull ComponentName admin, String accountType,
boolean disabled) {
+ throwIfParentInstance("setAccountManagementDisabled");
if (mService != null) {
try {
mService.setAccountManagementDisabled(admin, accountType, disabled);
@@ -5111,6 +5174,7 @@
* @see #setAccountManagementDisabled
*/
public String[] getAccountTypesWithManagementDisabled() {
+ throwIfParentInstance("getAccountTypesWithManagementDisabled");
return getAccountTypesWithManagementDisabledAsUser(myUserId());
}
@@ -5148,6 +5212,7 @@
*/
public void setLockTaskPackages(@NonNull ComponentName admin, String[] packages)
throws SecurityException {
+ throwIfParentInstance("setLockTaskPackages");
if (mService != null) {
try {
mService.setLockTaskPackages(admin, packages);
@@ -5164,6 +5229,7 @@
* @hide
*/
public String[] getLockTaskPackages(@NonNull ComponentName admin) {
+ throwIfParentInstance("getLockTaskPackages");
if (mService != null) {
try {
return mService.getLockTaskPackages(admin);
@@ -5180,6 +5246,7 @@
* @param pkg The package to check
*/
public boolean isLockTaskPermitted(String pkg) {
+ throwIfParentInstance("isLockTaskPermitted");
if (mService != null) {
try {
return mService.isLockTaskPermitted(pkg);
@@ -5228,6 +5295,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public void setGlobalSetting(@NonNull ComponentName admin, String setting, String value) {
+ throwIfParentInstance("setGlobalSetting");
if (mService != null) {
try {
mService.setGlobalSetting(admin, setting, value);
@@ -5260,6 +5328,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void setSecureSetting(@NonNull ComponentName admin, String setting, String value) {
+ throwIfParentInstance("setSecureSetting");
if (mService != null) {
try {
mService.setSecureSetting(admin, setting, value);
@@ -5283,6 +5352,7 @@
*/
public void setRestrictionsProvider(@NonNull ComponentName admin,
@Nullable ComponentName provider) {
+ throwIfParentInstance("setRestrictionsProvider");
if (mService != null) {
try {
mService.setRestrictionsProvider(admin, provider);
@@ -5300,6 +5370,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void setMasterVolumeMuted(@NonNull ComponentName admin, boolean on) {
+ throwIfParentInstance("setMasterVolumeMuted");
if (mService != null) {
try {
mService.setMasterVolumeMuted(admin, on);
@@ -5317,6 +5388,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public boolean isMasterVolumeMuted(@NonNull ComponentName admin) {
+ throwIfParentInstance("isMasterVolumeMuted");
if (mService != null) {
try {
return mService.isMasterVolumeMuted(admin);
@@ -5337,6 +5409,7 @@
*/
public void setUninstallBlocked(@NonNull ComponentName admin, String packageName,
boolean uninstallBlocked) {
+ throwIfParentInstance("setUninstallBlocked");
if (mService != null) {
try {
mService.setUninstallBlocked(admin, packageName, uninstallBlocked);
@@ -5362,6 +5435,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public boolean isUninstallBlocked(@Nullable ComponentName admin, String packageName) {
+ throwIfParentInstance("isUninstallBlocked");
if (mService != null) {
try {
return mService.isUninstallBlocked(admin, packageName);
@@ -5389,6 +5463,7 @@
* @see #getCrossProfileWidgetProviders(android.content.ComponentName)
*/
public boolean addCrossProfileWidgetProvider(@NonNull ComponentName admin, String packageName) {
+ throwIfParentInstance("addCrossProfileWidgetProvider");
if (mService != null) {
try {
return mService.addCrossProfileWidgetProvider(admin, packageName);
@@ -5416,6 +5491,7 @@
*/
public boolean removeCrossProfileWidgetProvider(
@NonNull ComponentName admin, String packageName) {
+ throwIfParentInstance("removeCrossProfileWidgetProvider");
if (mService != null) {
try {
return mService.removeCrossProfileWidgetProvider(admin, packageName);
@@ -5437,6 +5513,7 @@
* @throws SecurityException if {@code admin} is not a profile owner.
*/
public List<String> getCrossProfileWidgetProviders(@NonNull ComponentName admin) {
+ throwIfParentInstance("getCrossProfileWidgetProviders");
if (mService != null) {
try {
List<String> providers = mService.getCrossProfileWidgetProviders(admin);
@@ -5458,6 +5535,7 @@
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void setUserIcon(@NonNull ComponentName admin, Bitmap icon) {
+ throwIfParentInstance("setUserIcon");
try {
mService.setUserIcon(admin, icon);
} catch (RemoteException re) {
@@ -5477,6 +5555,7 @@
* @see SystemUpdatePolicy
*/
public void setSystemUpdatePolicy(@NonNull ComponentName admin, SystemUpdatePolicy policy) {
+ throwIfParentInstance("setSystemUpdatePolicy");
if (mService != null) {
try {
mService.setSystemUpdatePolicy(admin, policy);
@@ -5492,6 +5571,7 @@
* @return The current policy object, or {@code null} if no policy is set.
*/
public SystemUpdatePolicy getSystemUpdatePolicy() {
+ throwIfParentInstance("getSystemUpdatePolicy");
if (mService != null) {
try {
return mService.getSystemUpdatePolicy();
@@ -5517,6 +5597,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public boolean setKeyguardDisabled(@NonNull ComponentName admin, boolean disabled) {
+ throwIfParentInstance("setKeyguardDisabled");
try {
return mService.setKeyguardDisabled(admin, disabled);
} catch (RemoteException re) {
@@ -5535,6 +5616,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public boolean setStatusBarDisabled(@NonNull ComponentName admin, boolean disabled) {
+ throwIfParentInstance("setStatusBarDisabled");
try {
return mService.setStatusBarDisabled(admin, disabled);
} catch (RemoteException re) {
@@ -5580,6 +5662,7 @@
* @see #setPermissionGrantState
*/
public void setPermissionPolicy(@NonNull ComponentName admin, int policy) {
+ throwIfParentInstance("setPermissionPolicy");
try {
mService.setPermissionPolicy(admin, policy);
} catch (RemoteException re) {
@@ -5594,6 +5677,7 @@
* @return the current policy for future permission requests.
*/
public int getPermissionPolicy(ComponentName admin) {
+ throwIfParentInstance("getPermissionPolicy");
try {
return mService.getPermissionPolicy(admin);
} catch (RemoteException re) {
@@ -5630,6 +5714,7 @@
*/
public boolean setPermissionGrantState(@NonNull ComponentName admin, String packageName,
String permission, int grantState) {
+ throwIfParentInstance("setPermissionGrantState");
try {
return mService.setPermissionGrantState(admin, packageName, permission, grantState);
} catch (RemoteException re) {
@@ -5658,6 +5743,7 @@
*/
public int getPermissionGrantState(@NonNull ComponentName admin, String packageName,
String permission) {
+ throwIfParentInstance("getPermissionGrantState");
try {
return mService.getPermissionGrantState(admin, packageName, permission);
} catch (RemoteException re) {
@@ -5673,6 +5759,7 @@
* @throws IllegalArgumentException if the supplied action is not valid.
*/
public boolean isProvisioningAllowed(String action) {
+ throwIfParentInstance("isProvisioningAllowed");
try {
return mService.isProvisioningAllowed(action);
} catch (RemoteException re) {
@@ -5688,6 +5775,7 @@
* @return if this user is a managed profile of another user.
*/
public boolean isManagedProfile(@NonNull ComponentName admin) {
+ throwIfParentInstance("isManagedProfile");
try {
return mService.isManagedProfile(admin);
} catch (RemoteException re) {
@@ -5721,6 +5809,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public String getWifiMacAddress(@NonNull ComponentName admin) {
+ throwIfParentInstance("getWifiMacAddress");
try {
return mService.getWifiMacAddress(admin);
} catch (RemoteException re) {
@@ -5737,6 +5826,7 @@
* @see TelephonyManager#CALL_STATE_IDLE
*/
public void reboot(@NonNull ComponentName admin) {
+ throwIfParentInstance("reboot");
try {
mService.reboot(admin);
} catch (RemoteException re) {
@@ -5763,6 +5853,7 @@
*/
public void setShortSupportMessage(@NonNull ComponentName admin,
@Nullable String message) {
+ throwIfParentInstance("setShortSupportMessage");
if (mService != null) {
try {
mService.setShortSupportMessage(admin, message);
@@ -5781,6 +5872,7 @@
* @throws SecurityException if {@code admin} is not an active administrator.
*/
public String getShortSupportMessage(@NonNull ComponentName admin) {
+ throwIfParentInstance("getShortSupportMessage");
if (mService != null) {
try {
return mService.getShortSupportMessage(admin);
@@ -5807,6 +5899,7 @@
*/
public void setLongSupportMessage(@NonNull ComponentName admin,
@Nullable String message) {
+ throwIfParentInstance("setLongSupportMessage");
if (mService != null) {
try {
mService.setLongSupportMessage(admin, message);
@@ -5825,6 +5918,7 @@
* @throws SecurityException if {@code admin} is not an active administrator.
*/
public String getLongSupportMessage(@NonNull ComponentName admin) {
+ throwIfParentInstance("getLongSupportMessage");
if (mService != null) {
try {
return mService.getLongSupportMessage(admin);
@@ -5921,6 +6015,7 @@
* @throws SecurityException if {@code admin} is not a profile owner.
*/
public DevicePolicyManager getParentProfileInstance(@NonNull ComponentName admin) {
+ throwIfParentInstance("getParentProfileInstance");
try {
if (!mService.isManagedProfile(admin)) {
throw new SecurityException("The current user does not have a parent profile.");
@@ -5947,6 +6042,7 @@
* @see #retrieveSecurityLogs
*/
public void setSecurityLoggingEnabled(@NonNull ComponentName admin, boolean enabled) {
+ throwIfParentInstance("setSecurityLoggingEnabled");
try {
mService.setSecurityLoggingEnabled(admin, enabled);
} catch (RemoteException re) {
@@ -5965,6 +6061,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public boolean isSecurityLoggingEnabled(@NonNull ComponentName admin) {
+ throwIfParentInstance("isSecurityLoggingEnabled");
try {
return mService.isSecurityLoggingEnabled(admin);
} catch (RemoteException re) {
@@ -5988,6 +6085,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public List<SecurityEvent> retrieveSecurityLogs(@NonNull ComponentName admin) {
+ throwIfParentInstance("retrieveSecurityLogs");
try {
ParceledListSlice<SecurityEvent> list = mService.retrieveSecurityLogs(admin);
if (list != null) {
@@ -6033,6 +6131,7 @@
* @throws SecurityException if {@code admin} is not a device owner.
*/
public List<SecurityEvent> retrievePreRebootSecurityLogs(@NonNull ComponentName admin) {
+ throwIfParentInstance("retrievePreRebootSecurityLogs");
try {
ParceledListSlice<SecurityEvent> list = mService.retrievePreRebootSecurityLogs(admin);
return list.getList();
@@ -6054,6 +6153,7 @@
* @throws SecurityException if {@code admin} is not a profile owner.
*/
public void setOrganizationColor(@NonNull ComponentName admin, int color) {
+ throwIfParentInstance("setOrganizationColor");
try {
mService.setOrganizationColor(admin, color);
} catch (RemoteException re) {
@@ -6089,6 +6189,7 @@
* @throws SecurityException if {@code admin} is not a profile owner.
*/
public int getOrganizationColor(@NonNull ComponentName admin) {
+ throwIfParentInstance("getOrganizationColor");
try {
return mService.getOrganizationColor(admin);
} catch (RemoteException re) {
@@ -6124,6 +6225,7 @@
* @throws SecurityException if {@code admin} is not a profile owner.
*/
public void setOrganizationName(@NonNull ComponentName admin, @Nullable String title) {
+ throwIfParentInstance("setOrganizationName");
try {
mService.setOrganizationName(admin, title);
} catch (RemoteException re) {
@@ -6140,6 +6242,7 @@
* @throws SecurityException if {@code admin} is not a profile owner.
*/
public String getOrganizationName(@NonNull ComponentName admin) {
+ throwIfParentInstance("getOrganizationName");
try {
return mService.getOrganizationName(admin);
} catch (RemoteException re) {
@@ -6265,4 +6368,10 @@
throw re.rethrowFromSystemServer();
}
}
+
+ private void throwIfParentInstance(String functionName) {
+ if (mParentInstance) {
+ throw new SecurityException(functionName + " cannot be called on the parent instance");
+ }
+ }
}
diff --git a/core/java/android/app/job/JobService.java b/core/java/android/app/job/JobService.java
index 95a8ccf..77307b7 100644
--- a/core/java/android/app/job/JobService.java
+++ b/core/java/android/app/job/JobService.java
@@ -27,6 +27,8 @@
import com.android.internal.annotations.GuardedBy;
+import java.lang.ref.WeakReference;
+
/**
* <p>Entry point for the callback from the {@link android.app.job.JobScheduler}.</p>
* <p>This is the base class that handles asynchronous requests that were previously scheduled. You
@@ -62,15 +64,15 @@
* Identifier for a message that will result in a call to
* {@link #onStartJob(android.app.job.JobParameters)}.
*/
- private final int MSG_EXECUTE_JOB = 0;
+ private static final int MSG_EXECUTE_JOB = 0;
/**
* Message that will result in a call to {@link #onStopJob(android.app.job.JobParameters)}.
*/
- private final int MSG_STOP_JOB = 1;
+ private static final int MSG_STOP_JOB = 1;
/**
* Message that the client has completed execution of this job.
*/
- private final int MSG_JOB_FINISHED = 2;
+ private static final int MSG_JOB_FINISHED = 2;
/** Lock object for {@link #mHandler}. */
private final Object mHandlerLock = new Object();
@@ -82,21 +84,36 @@
@GuardedBy("mHandlerLock")
JobHandler mHandler;
- /** Binder for this service. */
- IJobService mBinder = new IJobService.Stub() {
- @Override
- public void startJob(JobParameters jobParams) {
- ensureHandler();
- Message m = Message.obtain(mHandler, MSG_EXECUTE_JOB, jobParams);
- m.sendToTarget();
+ static final class JobInterface extends IJobService.Stub {
+ final WeakReference<JobService> mService;
+
+ JobInterface(JobService service) {
+ mService = new WeakReference<>(service);
}
+
@Override
- public void stopJob(JobParameters jobParams) {
- ensureHandler();
- Message m = Message.obtain(mHandler, MSG_STOP_JOB, jobParams);
- m.sendToTarget();
+ public void startJob(JobParameters jobParams) throws RemoteException {
+ JobService service = mService.get();
+ if (service != null) {
+ service.ensureHandler();
+ Message m = Message.obtain(service.mHandler, MSG_EXECUTE_JOB, jobParams);
+ m.sendToTarget();
+ }
}
- };
+
+ @Override
+ public void stopJob(JobParameters jobParams) throws RemoteException {
+ JobService service = mService.get();
+ if (service != null) {
+ service.ensureHandler();
+ Message m = Message.obtain(service.mHandler, MSG_STOP_JOB, jobParams);
+ m.sendToTarget();
+ }
+
+ }
+ }
+
+ IJobService mBinder;
/** @hide */
void ensureHandler() {
@@ -194,6 +211,9 @@
/** @hide */
public final IBinder onBind(Intent intent) {
+ if (mBinder == null) {
+ mBinder = new JobInterface(this);
+ }
return mBinder.asBinder();
}
diff --git a/core/java/android/content/ClipDescription.java b/core/java/android/content/ClipDescription.java
index 1b024e2..461d1e0 100644
--- a/core/java/android/content/ClipDescription.java
+++ b/core/java/android/content/ClipDescription.java
@@ -71,6 +71,7 @@
* and {@link ComponentName#flattenToString()} to convert the extra value
* to/from {@link ComponentName}.
* </p>
+ * @hide
*/
public static final String EXTRA_TARGET_COMPONENT_NAME =
"android.content.extra.TARGET_COMPONENT_NAME";
@@ -81,6 +82,7 @@
* <p>
* Type: long
* </p>
+ * @hide
*/
public static final String EXTRA_USER_SERIAL_NUMBER =
"android.content.extra.USER_SERIAL_NUMBER";
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 30f2c94..207b70a 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -3730,6 +3730,31 @@
public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
/**
+ * A {@link ComponentName ComponentName[]} describing components that should be filtered out
+ * and omitted from a list of components presented to the user.
+ *
+ * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
+ * in this array if it otherwise would have shown them. Useful for omitting specific targets
+ * from your own package or other apps from your organization if the idea of sending to those
+ * targets would be redundant with other app functionality. Filtered components will not
+ * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
+ */
+ public static final String EXTRA_EXCLUDE_COMPONENTS
+ = "android.intent.extra.EXCLUDE_COMPONENTS";
+
+ /**
+ * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
+ * describing additional high-priority deep-link targets for the chooser to present to the user.
+ *
+ * <p>Targets provided in this way will be presented inline with all other targets provided
+ * by services from other apps. They will be prioritized before other service targets, but
+ * after those targets provided by sources that the user has manually pinned to the front.</p>
+ *
+ * @see #ACTION_CHOOSER
+ */
+ public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
+
+ /**
* An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
* from the chooser activity presented by {@link #ACTION_CHOOSER}.
*
diff --git a/core/java/android/content/pm/FeatureInfo.java b/core/java/android/content/pm/FeatureInfo.java
index 7671f72..9ee6fa2 100644
--- a/core/java/android/content/pm/FeatureInfo.java
+++ b/core/java/android/content/pm/FeatureInfo.java
@@ -48,6 +48,9 @@
* <p>
* If this object represents a feature requested by an app, this is the
* minimum version of the feature required by the app.
+ * <p>
+ * When a feature version is undefined by a device, it's assumed to be
+ * version 0.
*/
public int version;
diff --git a/core/java/android/inputmethodservice/CompactExtractEditLayout.java b/core/java/android/inputmethodservice/CompactExtractEditLayout.java
new file mode 100644
index 0000000..f994c65
--- /dev/null
+++ b/core/java/android/inputmethodservice/CompactExtractEditLayout.java
@@ -0,0 +1,103 @@
+package android.inputmethodservice;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.annotation.FractionRes;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+/**
+ * A special purpose layout for the editor extract view for tiny (sub 250dp) screens.
+ * The layout is based on sizes proportional to screen pixel size to provide for the
+ * best layout fidelity on varying pixel sizes and densities.
+ *
+ * @hide
+ */
+public class CompactExtractEditLayout extends LinearLayout {
+ private View mInputExtractEditText;
+ private View mInputExtractAccessories;
+ private View mInputExtractAction;
+ private boolean mPerformLayoutChanges;
+
+ public CompactExtractEditLayout(Context context) {
+ super(context);
+ }
+
+ public CompactExtractEditLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public CompactExtractEditLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mInputExtractEditText = findViewById(com.android.internal.R.id.inputExtractEditText);
+ mInputExtractAccessories = findViewById(com.android.internal.R.id.inputExtractAccessories);
+ mInputExtractAction = findViewById(com.android.internal.R.id.inputExtractAction);
+
+ if (mInputExtractEditText != null && mInputExtractAccessories != null
+ && mInputExtractAction != null) {
+ mPerformLayoutChanges = true;
+ }
+ }
+
+ private int applyFractionInt(@FractionRes int fraction, int whole) {
+ return Math.round(getResources().getFraction(fraction, whole, whole));
+ }
+
+ private static void setLayoutHeight(View v, int px) {
+ ViewGroup.LayoutParams lp = v.getLayoutParams();
+ lp.height = px;
+ v.setLayoutParams(lp);
+ }
+
+ private static void setLayoutMarginBottom(View v, int px) {
+ ViewGroup.MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
+ lp.bottomMargin = px;
+ v.setLayoutParams(lp);
+ }
+
+ private void applyProportionalLayout(int screenWidthPx, int screenHeightPx) {
+ if (getResources().getConfiguration().isScreenRound()) {
+ setGravity(Gravity.BOTTOM);
+ }
+ setLayoutHeight(this, applyFractionInt(
+ com.android.internal.R.fraction.input_extract_layout_height, screenHeightPx));
+
+ setPadding(
+ applyFractionInt(com.android.internal.R.fraction.input_extract_layout_padding_left,
+ screenWidthPx),
+ 0,
+ applyFractionInt(com.android.internal.R.fraction.input_extract_layout_padding_right,
+ screenWidthPx),
+ 0);
+
+ setLayoutMarginBottom(mInputExtractEditText,
+ applyFractionInt(com.android.internal.R.fraction.input_extract_text_margin_bottom,
+ screenHeightPx));
+
+ setLayoutMarginBottom(mInputExtractAccessories,
+ applyFractionInt(com.android.internal.R.fraction.input_extract_action_margin_bottom,
+ screenHeightPx));
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ if (mPerformLayoutChanges) {
+ Resources res = getResources();
+ DisplayMetrics dm = res.getDisplayMetrics();
+ int heightPixels = dm.heightPixels;
+ int widthPixels = dm.widthPixels;
+ applyProportionalLayout(widthPixels, heightPixels);
+ }
+ }
+}
+
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index cc201bc..085b97c 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -68,9 +68,10 @@
import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
-import android.widget.Button;
import android.widget.FrameLayout;
+import android.widget.ImageButton;
import android.widget.LinearLayout;
+import android.widget.TextView;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -302,7 +303,7 @@
boolean mExtractViewHidden;
ExtractEditText mExtractEditText;
ViewGroup mExtractAccessories;
- Button mExtractAction;
+ View mExtractAction;
ExtractedText mExtractedText;
int mExtractedToken;
@@ -1344,7 +1345,7 @@
mExtractEditText = (ExtractEditText)view.findViewById(
com.android.internal.R.id.inputExtractEditText);
mExtractEditText.setIME(this);
- mExtractAction = (Button)view.findViewById(
+ mExtractAction = view.findViewById(
com.android.internal.R.id.inputExtractAction);
if (mExtractAction != null) {
mExtractAccessories = (ViewGroup)view.findViewById(
@@ -2408,7 +2409,35 @@
return getText(com.android.internal.R.string.ime_action_default);
}
}
-
+
+ /**
+ * Return a drawable resource id that can be used as a button icon for the given
+ * {@link EditorInfo#imeOptions EditorInfo.imeOptions}.
+ *
+ * @param imeOptions The value from @link EditorInfo#imeOptions EditorInfo.imeOptions}.
+ *
+ * @return Returns a drawable resource id to use.
+ */
+ @DrawableRes
+ private int getIconForImeAction(int imeOptions) {
+ switch (imeOptions&EditorInfo.IME_MASK_ACTION) {
+ case EditorInfo.IME_ACTION_GO:
+ return com.android.internal.R.drawable.ic_input_extract_action_go;
+ case EditorInfo.IME_ACTION_SEARCH:
+ return com.android.internal.R.drawable.ic_input_extract_action_search;
+ case EditorInfo.IME_ACTION_SEND:
+ return com.android.internal.R.drawable.ic_input_extract_action_send;
+ case EditorInfo.IME_ACTION_NEXT:
+ return com.android.internal.R.drawable.ic_input_extract_action_next;
+ case EditorInfo.IME_ACTION_DONE:
+ return com.android.internal.R.drawable.ic_input_extract_action_done;
+ case EditorInfo.IME_ACTION_PREVIOUS:
+ return com.android.internal.R.drawable.ic_input_extract_action_previous;
+ default:
+ return com.android.internal.R.drawable.ic_input_extract_action_return;
+ }
+ }
+
/**
* Called when the fullscreen-mode extracting editor info has changed,
* to determine whether the extracting (extract text and candidates) portion
@@ -2459,10 +2488,20 @@
if (hasAction) {
mExtractAccessories.setVisibility(View.VISIBLE);
if (mExtractAction != null) {
- if (ei.actionLabel != null) {
- mExtractAction.setText(ei.actionLabel);
+ if (mExtractAction instanceof ImageButton) {
+ ((ImageButton) mExtractAction)
+ .setImageResource(getIconForImeAction(ei.imeOptions));
+ if (ei.actionLabel != null) {
+ mExtractAction.setContentDescription(ei.actionLabel);
+ } else {
+ mExtractAction.setContentDescription(getTextForImeAction(ei.imeOptions));
+ }
} else {
- mExtractAction.setText(getTextForImeAction(ei.imeOptions));
+ if (ei.actionLabel != null) {
+ ((TextView) mExtractAction).setText(ei.actionLabel);
+ } else {
+ ((TextView) mExtractAction).setText(getTextForImeAction(ei.imeOptions));
+ }
}
mExtractAction.setOnClickListener(mActionClickListener);
}
diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java
index e40ebf7..d39968a 100644
--- a/core/java/android/os/BatteryManager.java
+++ b/core/java/android/os/BatteryManager.java
@@ -115,6 +115,13 @@
*/
public static final String EXTRA_MAX_CHARGING_VOLTAGE = "max_charging_voltage";
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer containing the charge counter present in the battery.
+ * {@hide}
+ */
+ public static final String EXTRA_CHARGE_COUNTER = "charge_counter";
+
// values for "status" field in the ACTION_BATTERY_CHANGED Intent
public static final int BATTERY_STATUS_UNKNOWN = 1;
public static final int BATTERY_STATUS_CHARGING = 2;
diff --git a/core/java/android/os/BatteryProperties.java b/core/java/android/os/BatteryProperties.java
index c3e0f24..b509d76 100644
--- a/core/java/android/os/BatteryProperties.java
+++ b/core/java/android/os/BatteryProperties.java
@@ -30,6 +30,7 @@
public int batteryLevel;
public int batteryVoltage;
public int batteryTemperature;
+ public int batteryChargeCounter;
public String batteryTechnology;
public BatteryProperties() {
@@ -47,6 +48,7 @@
batteryLevel = other.batteryLevel;
batteryVoltage = other.batteryVoltage;
batteryTemperature = other.batteryTemperature;
+ batteryChargeCounter = other.batteryChargeCounter;
batteryTechnology = other.batteryTechnology;
}
@@ -67,6 +69,7 @@
batteryLevel = p.readInt();
batteryVoltage = p.readInt();
batteryTemperature = p.readInt();
+ batteryChargeCounter = p.readInt();
batteryTechnology = p.readString();
}
@@ -82,6 +85,7 @@
p.writeInt(batteryLevel);
p.writeInt(batteryVoltage);
p.writeInt(batteryTemperature);
+ p.writeInt(batteryChargeCounter);
p.writeString(batteryTechnology);
}
diff --git a/core/java/android/service/notification/Adjustment.aidl b/core/java/android/service/notification/Adjustment.aidl
new file mode 100644
index 0000000..8bd814a
--- /dev/null
+++ b/core/java/android/service/notification/Adjustment.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.notification;
+
+parcelable Adjustment;
\ No newline at end of file
diff --git a/core/java/android/service/notification/Adjustment.java b/core/java/android/service/notification/Adjustment.java
new file mode 100644
index 0000000..2e4f48d
--- /dev/null
+++ b/core/java/android/service/notification/Adjustment.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.notification;
+
+import android.annotation.SystemApi;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Ranking updates from the Ranker.
+ *
+ * @hide
+ */
+@SystemApi
+public final class Adjustment implements Parcelable {
+ private final String mPackage;
+ private final String mKey;
+ private final int mImportance;
+ private final CharSequence mExplanation;
+ private final Uri mReference;
+ private final Bundle mSignals;
+
+ public static final String GROUP_KEY_OVERRIDE_KEY = "group_key_override";
+ public static final String NEEDS_AUTOGROUPING_KEY = "autogroup_needed";
+
+ /**
+ * Create a notification adjustment.
+ *
+ * @param pkg The package of the notification.
+ * @param key The notification key.
+ * @param importance The recommended importance of the notification.
+ * @param signals A bundle of signals that should inform notification grouping and ordering.
+ * @param explanation A human-readable justification for the adjustment.
+ * @param reference A reference to an external object that augments the
+ * explanation, such as a
+ * {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI},
+ * or null.
+ */
+ public Adjustment(String pkg, String key, int importance, Bundle signals,
+ CharSequence explanation, Uri reference) {
+ mPackage = pkg;
+ mKey = key;
+ mImportance = importance;
+ mSignals = signals;
+ mExplanation = explanation;
+ mReference = reference;
+ }
+
+ protected Adjustment(Parcel in) {
+ if (in.readInt() == 1) {
+ mPackage = in.readString();
+ } else {
+ mPackage = null;
+ }
+ if (in.readInt() == 1) {
+ mKey = in.readString();
+ } else {
+ mKey = null;
+ }
+ mImportance = in.readInt();
+ if (in.readInt() == 1) {
+ mExplanation = in.readCharSequence();
+ } else {
+ mExplanation = null;
+ }
+ mReference = in.readParcelable(Uri.class.getClassLoader());
+ mSignals = in.readBundle();
+ }
+
+ public static final Creator<Adjustment> CREATOR = new Creator<Adjustment>() {
+ @Override
+ public Adjustment createFromParcel(Parcel in) {
+ return new Adjustment(in);
+ }
+
+ @Override
+ public Adjustment[] newArray(int size) {
+ return new Adjustment[size];
+ }
+ };
+
+ public String getPackage() {
+ return mPackage;
+ }
+
+ public String getKey() {
+ return mKey;
+ }
+
+ public int getImportance() {
+ return mImportance;
+ }
+
+ public CharSequence getExplanation() {
+ return mExplanation;
+ }
+
+ public Uri getReference() {
+ return mReference;
+ }
+
+ public Bundle getSignals() {
+ return mSignals;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (mPackage != null) {
+ dest.writeInt(1);
+ dest.writeString(mPackage);
+ } else {
+ dest.writeInt(0);
+ }
+ if (mKey != null) {
+ dest.writeInt(1);
+ dest.writeString(mKey);
+ } else {
+ dest.writeInt(0);
+ }
+ dest.writeInt(mImportance);
+ if (mExplanation != null) {
+ dest.writeInt(1);
+ dest.writeCharSequence(mExplanation);
+ } else {
+ dest.writeInt(0);
+ }
+ dest.writeParcelable(mReference, flags);
+ dest.writeBundle(mSignals);
+ }
+}
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 7325aef..e708b0a 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -123,6 +123,16 @@
* This does not change the interruption filter, only the effects. **/
public static final int HINT_HOST_DISABLE_EFFECTS = 1;
+ /** {@link #getCurrentListenerHints() Listener hints} constant - the primary device UI
+ * should disable notification sound, but not phone calls.
+ * This does not change the interruption filter, only the effects. **/
+ public static final int HINT_HOST_DISABLE_NOTIFICATION_EFFECTS = 1 << 1;
+
+ /** {@link #getCurrentListenerHints() Listener hints} constant - the primary device UI
+ * should disable phone call sounds, buyt not notification sound.
+ * This does not change the interruption filter, only the effects. **/
+ public static final int HINT_HOST_DISABLE_CALL_EFFECTS = 1 << 2;
+
/**
* Whether notification suppressed by DND should not interruption visually when the screen is
* off.
@@ -1052,6 +1062,8 @@
private int mSuppressedVisualEffects;
private @Importance int mImportance;
private CharSequence mImportanceExplanation;
+ // System specified group key.
+ private String mOverrideGroupKey;
public Ranking() {}
@@ -1130,9 +1142,17 @@
return mImportanceExplanation;
}
+ /**
+ * If the system has overriden the group key, then this will be non-null, and this
+ * key should be used to bundle notifications.
+ */
+ public String getOverrideGroupKey() {
+ return mOverrideGroupKey;
+ }
+
private void populate(String key, int rank, boolean matchesInterruptionFilter,
int visibilityOverride, int suppressedVisualEffects, int importance,
- CharSequence explanation) {
+ CharSequence explanation, String overrideGroupKey) {
mKey = key;
mRank = rank;
mIsAmbient = importance < IMPORTANCE_LOW;
@@ -1141,6 +1161,7 @@
mSuppressedVisualEffects = suppressedVisualEffects;
mImportance = importance;
mImportanceExplanation = explanation;
+ mOverrideGroupKey = overrideGroupKey;
}
/**
@@ -1184,6 +1205,7 @@
private ArrayMap<String, Integer> mSuppressedVisualEffects;
private ArrayMap<String, Integer> mImportance;
private ArrayMap<String, String> mImportanceExplanation;
+ private ArrayMap<String, String> mOverrideGroupKeys;
private RankingMap(NotificationRankingUpdate rankingUpdate) {
mRankingUpdate = rankingUpdate;
@@ -1210,7 +1232,7 @@
int rank = getRank(key);
outRanking.populate(key, rank, !isIntercepted(key),
getVisibilityOverride(key), getSuppressedVisualEffects(key),
- getImportance(key), getImportanceExplanation(key));
+ getImportance(key), getImportanceExplanation(key), getOverrideGroupKey(key));
return rank >= 0;
}
@@ -1281,6 +1303,15 @@
return mImportanceExplanation.get(key);
}
+ private String getOverrideGroupKey(String key) {
+ synchronized (this) {
+ if (mOverrideGroupKeys == null) {
+ buildOverrideGroupKeys();
+ }
+ }
+ return mOverrideGroupKeys.get(key);
+ }
+
// Locked by 'this'
private void buildRanksLocked() {
String[] orderedKeys = mRankingUpdate.getOrderedKeys();
@@ -1335,6 +1366,15 @@
}
}
+ // Locked by 'this'
+ private void buildOverrideGroupKeys() {
+ Bundle overrideGroupKeys = mRankingUpdate.getOverrideGroupKeys();
+ mOverrideGroupKeys = new ArrayMap<>(overrideGroupKeys.size());
+ for (String key: overrideGroupKeys.keySet()) {
+ mOverrideGroupKeys.put(key, overrideGroupKeys.getString(key));
+ }
+ }
+
// ----------- Parcelable
@Override
diff --git a/core/java/android/service/notification/NotificationRankerService.java b/core/java/android/service/notification/NotificationRankerService.java
index 47fdac6..ee5361a 100644
--- a/core/java/android/service/notification/NotificationRankerService.java
+++ b/core/java/android/service/notification/NotificationRankerService.java
@@ -22,14 +22,19 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.os.RemoteException;
import android.util.Log;
import com.android.internal.os.SomeArgs;
+import java.util.List;
+
/**
* A service that helps the user manage notifications. This class is only used to
* extend the framework service and may not be implemented by non-framework components.
@@ -91,27 +96,8 @@
/** Notification was canceled by the owning managed profile being turned off. */
public static final int REASON_PROFILE_TURNED_OFF = 15;
- public class Adjustment {
- int mImportance;
- CharSequence mExplanation;
- Uri mReference;
-
- /**
- * Create a notification importance adjustment.
- *
- * @param importance The final importance of the notification.
- * @param explanation A human-readable justification for the adjustment.
- * @param reference A reference to an external object that augments the
- * explanation, such as a
- * {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI},
- * or null.
- */
- public Adjustment(int importance, CharSequence explanation, Uri reference) {
- mImportance = importance;
- mExplanation = explanation;
- mReference = reference;
- }
- }
+ /** Autobundled summary notification was canceled because its group was unbundled */
+ public static final int REASON_UNAUTOBUNDLED = 16;
private Handler mHandler;
@@ -200,18 +186,32 @@
}
/**
- * Change the importance of an existing notification. N.B. this won’t cause
+ * Updates a notification. N.B. this won’t cause
* an existing notification to alert, but might allow a future update to
* this notification to alert.
*
- * @param key the notification key
- * @param adjustment the new importance with an explanation
+ * @param adjustment the adjustment with an explanation
*/
- public final void adjustImportance(String key, Adjustment adjustment) {
+ public final void adjustNotification(Adjustment adjustment) {
if (!isBound()) return;
try {
- getNotificationInterface().setImportanceFromRankerService(mWrapper, key,
- adjustment.mImportance, adjustment.mExplanation);
+ getNotificationInterface().applyAdjustmentFromRankerService(mWrapper, adjustment);
+ } catch (android.os.RemoteException ex) {
+ Log.v(TAG, "Unable to contact notification manager", ex);
+ }
+ }
+
+ /**
+ * Updates existing notifications. Re-ranking won't occur until all adjustments are applied.
+ * N.B. this won’t cause an existing notification to alert, but might allow a future update to
+ * these notifications to alert.
+ *
+ * @param adjustments a list of adjustments with explanations
+ */
+ public final void adjustNotifications(List<Adjustment> adjustments) {
+ if (!isBound()) return;
+ try {
+ getNotificationInterface().applyAdjustmentsFromRankerService(mWrapper, adjustments);
} catch (android.os.RemoteException ex) {
Log.v(TAG, "Unable to contact notification manager", ex);
}
@@ -299,7 +299,7 @@
args.recycle();
Adjustment adjustment = onNotificationEnqueued(sbn, importance, user);
if (adjustment != null) {
- adjustImportance(sbn.getKey(), adjustment);
+ adjustNotification(adjustment);
}
} break;
diff --git a/core/java/android/service/notification/NotificationRankingUpdate.java b/core/java/android/service/notification/NotificationRankingUpdate.java
index 79f6fc4..788b5c0 100644
--- a/core/java/android/service/notification/NotificationRankingUpdate.java
+++ b/core/java/android/service/notification/NotificationRankingUpdate.java
@@ -30,16 +30,18 @@
private final Bundle mSuppressedVisualEffects;
private final int[] mImportance;
private final Bundle mImportanceExplanation;
+ private final Bundle mOverrideGroupKeys;
public NotificationRankingUpdate(String[] keys, String[] interceptedKeys,
Bundle visibilityOverrides, Bundle suppressedVisualEffects,
- int[] importance, Bundle explanation) {
+ int[] importance, Bundle explanation, Bundle overrideGroupKeys) {
mKeys = keys;
mInterceptedKeys = interceptedKeys;
mVisibilityOverrides = visibilityOverrides;
mSuppressedVisualEffects = suppressedVisualEffects;
mImportance = importance;
mImportanceExplanation = explanation;
+ mOverrideGroupKeys = overrideGroupKeys;
}
public NotificationRankingUpdate(Parcel in) {
@@ -50,6 +52,7 @@
mImportance = new int[mKeys.length];
in.readIntArray(mImportance);
mImportanceExplanation = in.readBundle();
+ mOverrideGroupKeys = in.readBundle();
}
@Override
@@ -65,6 +68,7 @@
out.writeBundle(mSuppressedVisualEffects);
out.writeIntArray(mImportance);
out.writeBundle(mImportanceExplanation);
+ out.writeBundle(mOverrideGroupKeys);
}
public static final Parcelable.Creator<NotificationRankingUpdate> CREATOR
@@ -101,4 +105,8 @@
public Bundle getImportanceExplanation() {
return mImportanceExplanation;
}
+
+ public Bundle getOverrideGroupKeys() {
+ return mOverrideGroupKeys;
+ }
}
diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java
index 198e43d..0221b66 100644
--- a/core/java/android/service/notification/StatusBarNotification.java
+++ b/core/java/android/service/notification/StatusBarNotification.java
@@ -33,7 +33,8 @@
private final int id;
private final String tag;
private final String key;
- private final String groupKey;
+ private String groupKey;
+ private String overrideGroupKey;
private final int uid;
private final String opPkg;
@@ -51,6 +52,27 @@
System.currentTimeMillis());
}
+ /** @hide */
+ public StatusBarNotification(String pkg, String opPkg, int id, String tag, int uid,
+ int initialPid, Notification notification, UserHandle user, String overrideGroupKey,
+ long postTime) {
+ if (pkg == null) throw new NullPointerException();
+ if (notification == null) throw new NullPointerException();
+
+ this.pkg = pkg;
+ this.opPkg = opPkg;
+ this.id = id;
+ this.tag = tag;
+ this.uid = uid;
+ this.initialPid = initialPid;
+ this.notification = notification;
+ this.user = user;
+ this.postTime = postTime;
+ this.overrideGroupKey = overrideGroupKey;
+ this.key = key();
+ this.groupKey = groupKey();
+ }
+
public StatusBarNotification(String pkg, String opPkg, int id, String tag, int uid,
int initialPid, int score, Notification notification, UserHandle user,
long postTime) {
@@ -84,15 +106,27 @@
this.notification = new Notification(in);
this.user = UserHandle.readFromParcel(in);
this.postTime = in.readLong();
+ if (in.readInt() != 0) {
+ this.overrideGroupKey = in.readString();
+ } else {
+ this.overrideGroupKey = null;
+ }
this.key = key();
this.groupKey = groupKey();
}
private String key() {
- return user.getIdentifier() + "|" + pkg + "|" + id + "|" + tag + "|" + uid;
+ String sbnKey = user.getIdentifier() + "|" + pkg + "|" + id + "|" + tag + "|" + uid;
+ if (overrideGroupKey != null && getNotification().isGroupSummary()) {
+ sbnKey = sbnKey + "|" + overrideGroupKey;
+ }
+ return sbnKey;
}
private String groupKey() {
+ if (overrideGroupKey != null) {
+ return user.getIdentifier() + "|" + pkg + "|" + "g:" + overrideGroupKey;
+ }
final String group = getNotification().getGroup();
final String sortKey = getNotification().getSortKey();
if (group == null && sortKey == null) {
@@ -105,6 +139,17 @@
: "g:" + group);
}
+ /**
+ * Returns true if this notification is part of a group.
+ */
+ public boolean isGroup() {
+ if (overrideGroupKey != null || getNotification().getGroup() != null
+ || getNotification().getSortKey() != null) {
+ return true;
+ }
+ return false;
+ }
+
public void writeToParcel(Parcel out, int flags) {
out.writeString(this.pkg);
out.writeString(this.opPkg);
@@ -121,6 +166,12 @@
user.writeToParcel(out, flags);
out.writeLong(this.postTime);
+ if (this.overrideGroupKey != null) {
+ out.writeInt(1);
+ out.writeString(this.overrideGroupKey);
+ } else {
+ out.writeInt(0);
+ }
}
public int describeContents() {
@@ -149,22 +200,22 @@
this.notification.cloneInto(no, false); // light copy
return new StatusBarNotification(this.pkg, this.opPkg,
this.id, this.tag, this.uid, this.initialPid,
- 0, no, this.user, this.postTime);
+ no, this.user, this.overrideGroupKey, this.postTime);
}
@Override
public StatusBarNotification clone() {
return new StatusBarNotification(this.pkg, this.opPkg,
this.id, this.tag, this.uid, this.initialPid,
- 0, this.notification.clone(), this.user, this.postTime);
+ this.notification.clone(), this.user, this.overrideGroupKey, this.postTime);
}
@Override
public String toString() {
return String.format(
- "StatusBarNotification(pkg=%s user=%s id=%d tag=%s score=%d key=%s: %s)",
+ "StatusBarNotification(pkg=%s user=%s id=%d tag=%s key=%s: %s)",
this.pkg, this.user, this.id, this.tag,
- 0, this.key, this.notification);
+ this.key, this.notification);
}
/** Convenience method to check the notification's flags for
@@ -258,6 +309,21 @@
}
/**
+ * Sets the override group key.
+ */
+ public void setOverrideGroupKey(String overrideGroupKey) {
+ this.overrideGroupKey = overrideGroupKey;
+ groupKey = groupKey();
+ }
+
+ /**
+ * Returns the override group key.
+ */
+ public String getOverrideGroupKey() {
+ return overrideGroupKey;
+ }
+
+ /**
* @hide
*/
public Context getPackageContext(Context context) {
diff --git a/core/java/android/service/quicksettings/IQSService.aidl b/core/java/android/service/quicksettings/IQSService.aidl
index 5434e2e..747f185 100644
--- a/core/java/android/service/quicksettings/IQSService.aidl
+++ b/core/java/android/service/quicksettings/IQSService.aidl
@@ -28,7 +28,6 @@
String contentDescription);
void onShowDialog(in Tile tile);
void onStartActivity(in Tile tile);
- void setTileMode(in ComponentName component, int mode);
boolean isLocked();
boolean isSecure();
void startUnlockAndRun(in Tile tile);
diff --git a/core/java/android/service/quicksettings/TileService.java b/core/java/android/service/quicksettings/TileService.java
index 553d539..4e9a075 100644
--- a/core/java/android/service/quicksettings/TileService.java
+++ b/core/java/android/service/quicksettings/TileService.java
@@ -89,28 +89,24 @@
public static final String ACTION_QS_TILE = "android.service.quicksettings.action.QS_TILE";
/**
- * The tile mode hasn't been set yet.
- * @hide
- */
- public static final int TILE_MODE_UNSET = 0;
-
- /**
- * Constant to be returned by {@link #onTileAdded}.
- * <p>
- * Passive mode is the default mode for tiles. The System will tell the tile
- * when it is most important to update by putting it in the listening state.
- */
- public static final int TILE_MODE_PASSIVE = 1;
-
- /**
- * Constant to be returned by {@link #onTileAdded}.
+ * Meta-data for tile definition to set a tile into active mode.
* <p>
* Active mode is for tiles which already listen and keep track of their state in their
* own process. These tiles may request to send an update to the System while their process
* is alive using {@link #requestListeningState}. The System will only bind these tiles
* on its own when a click needs to occur.
+ *
+ * To make a TileService an active tile, set this meta-data to true on the TileService's
+ * manifest declaration.
+ * <pre class="prettyprint">
+ * {@literal
+ * <meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
+ * android:value="true" />
+ * }
+ * </pre>
*/
- public static final int TILE_MODE_ACTIVE = 2;
+ public static final String META_DATA_ACTIVE_TILE
+ = "android.service.quicksettings.ACTIVE_TILE";
/**
* Used to notify SysUI that Listening has be requested.
@@ -147,12 +143,8 @@
* Note that this is not guaranteed to be called between {@link #onCreate()}
* and {@link #onStartListening()}, it will only be called when the tile is added
* and not on subsequent binds.
- *
- * @see #TILE_MODE_PASSIVE
- * @see #TILE_MODE_ACTIVE
*/
- public int onTileAdded() {
- return TILE_MODE_PASSIVE;
+ public void onTileAdded() {
}
/**
@@ -386,15 +378,7 @@
}
break;
case MSG_TILE_ADDED:
- int mode = TileService.this.onTileAdded();
- if (mService == null) {
- return;
- }
- try {
- mService.setTileMode(new ComponentName(TileService.this,
- TileService.this.getClass()), mode);
- } catch (RemoteException e) {
- }
+ TileService.this.onTileAdded();
break;
case MSG_TILE_REMOVED:
if (mListening) {
@@ -431,8 +415,8 @@
/**
* Requests that a tile be put in the listening state so it can send an update.
*
- * This method is only applicable to tiles that return {@link #TILE_MODE_ACTIVE} from
- * {@link #onTileAdded()}, and will do nothing otherwise.
+ * This method is only applicable to tiles that have {@link #META_DATA_ACTIVE_TILE} defined
+ * as true on their TileService Manifest declaration, and will do nothing otherwise.
*/
public static final void requestListeningState(Context context, ComponentName component) {
Intent intent = new Intent(ACTION_REQUEST_LISTENING);
diff --git a/core/java/android/util/PathParser.java b/core/java/android/util/PathParser.java
index 29a72fd..f1c8c7d 100644
--- a/core/java/android/util/PathParser.java
+++ b/core/java/android/util/PathParser.java
@@ -31,12 +31,7 @@
throw new IllegalArgumentException("Path string can not be null.");
}
Path path = new Path();
- boolean hasValidPathData = nParseStringForPath(path.mNativePath, pathString,
- pathString.length());
- if (!hasValidPathData) {
- throw new IllegalArgumentException("Path string: " + pathString +
- " does not contain valid path data");
- }
+ nParseStringForPath(path.mNativePath, pathString, pathString.length());
return path;
}
@@ -104,7 +99,6 @@
}
super.finalize();
}
-
}
/**
@@ -123,7 +117,7 @@
}
// Native functions are defined below.
- private static native boolean nParseStringForPath(long pathPtr, String pathString,
+ private static native void nParseStringForPath(long pathPtr, String pathString,
int stringLength);
private static native void nCreatePathFromPathData(long outPathPtr, long pathData);
private static native long nCreateEmptyPathData();
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index df774b4..f44d4c1a 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -485,15 +485,25 @@
}
/**
- * Stops any rendering into the surface. Use this if it is unclear whether
+ * Halts any current rendering into the surface. Use this if it is unclear whether
* or not the surface used by the HardwareRenderer will be changing. It
- * Suspends any rendering into the surface, but will not do any destruction
+ * Suspends any rendering into the surface, but will not do any destruction.
+ *
+ * Any subsequent draws will override the pause, resuming normal operation.
*/
boolean pauseSurface(Surface surface) {
return nPauseSurface(mNativeProxy, surface);
}
/**
+ * Hard stops or resumes rendering into the surface. This flag is used to
+ * determine whether or not it is safe to use the given surface *at all*
+ */
+ void setStopped(boolean stopped) {
+ nSetStopped(mNativeProxy, stopped);
+ }
+
+ /**
* Destroys all hardware rendering resources associated with the specified
* view hierarchy.
*
@@ -794,8 +804,7 @@
}
final long[] frameInfo = choreographer.mFrameInfo.mFrameInfo;
- int syncResult = nSyncAndDrawFrame(mNativeProxy, frameInfo, frameInfo.length,
- mRootNode.mNativeRenderNode);
+ int syncResult = nSyncAndDrawFrame(mNativeProxy, frameInfo, frameInfo.length);
if ((syncResult & SYNC_LOST_SURFACE_REWARD_IF_FOUND) != 0) {
setEnabled(false);
attachInfo.mViewRootImpl.mSurface.release();
@@ -989,13 +998,13 @@
private static native void nInitialize(long nativeProxy, Surface window);
private static native void nUpdateSurface(long nativeProxy, Surface window);
private static native boolean nPauseSurface(long nativeProxy, Surface window);
+ private static native void nSetStopped(long nativeProxy, boolean stopped);
private static native void nSetup(long nativeProxy, int width, int height,
float lightRadius, int ambientShadowAlpha, int spotShadowAlpha);
private static native void nSetLightCenter(long nativeProxy,
float lightX, float lightY, float lightZ);
private static native void nSetOpaque(long nativeProxy, boolean opaque);
- private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size,
- long rootRenderNode);
+ private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size);
private static native void nDestroy(long nativeProxy, long rootRenderNode);
private static native void nRegisterAnimatingRenderNode(long rootRenderNode, long animatingNode);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index b95d830..b0aa5c3 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -20424,21 +20424,21 @@
* the touch point.
* </p>
*
- * @param shadowSize A {@link android.graphics.Point} containing the width and height
+ * @param outShadowSize A {@link android.graphics.Point} containing the width and height
* of the shadow image. Your application must set {@link android.graphics.Point#x} to the
* desired width and must set {@link android.graphics.Point#y} to the desired height of the
* image.
*
- * @param shadowTouchPoint A {@link android.graphics.Point} for the position within the
+ * @param outShadowTouchPoint A {@link android.graphics.Point} for the position within the
* shadow image that should be underneath the touch point during the drag and drop
* operation. Your application must set {@link android.graphics.Point#x} to the
* X coordinate and {@link android.graphics.Point#y} to the Y coordinate of this position.
*/
- public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) {
+ public void onProvideShadowMetrics(Point outShadowSize, Point outShadowTouchPoint) {
final View view = mView.get();
if (view != null) {
- shadowSize.set(view.getWidth(), view.getHeight());
- shadowTouchPoint.set(shadowSize.x / 2, shadowSize.y / 2);
+ outShadowSize.set(view.getWidth(), view.getHeight());
+ outShadowTouchPoint.set(outShadowSize.x / 2, outShadowSize.y / 2);
} else {
Log.e(View.VIEW_LOG_TAG, "Asked for drag thumb metrics but no view");
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 5b2877f..5626f01 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1079,13 +1079,16 @@
void setWindowStopped(boolean stopped) {
if (mStopped != stopped) {
mStopped = stopped;
+ final ThreadedRenderer renderer = mAttachInfo.mHardwareRenderer;
+ if (renderer != null) {
+ if (DEBUG_DRAW) Log.d(mTag, "WindowStopped on " + getTitle() + " set to " + mStopped);
+ renderer.setStopped(mStopped);
+ }
if (!mStopped) {
scheduleTraversals();
} else {
- if (mAttachInfo.mHardwareRenderer != null) {
- if (DEBUG_DRAW) Log.d(mTag, "WindowStopped on " + getTitle());
- mAttachInfo.mHardwareRenderer.updateSurface(null);
- mAttachInfo.mHardwareRenderer.destroyHardwareResources(mView);
+ if (renderer != null) {
+ renderer.destroyHardwareResources(mView);
}
}
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index c372c30..ddad23a 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -1701,6 +1701,14 @@
*/
public int accessibilityIdOfAnchor = -1;
+ /**
+ * The window title isn't kept in sync with what is displayed in the title bar, so we
+ * separately track the currently shown title to provide to accessibility.
+ *
+ * @hide
+ */
+ public CharSequence accessibilityTitle;
+
public LayoutParams() {
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
type = TYPE_APPLICATION;
@@ -1749,6 +1757,7 @@
title = "";
mTitle = TextUtils.stringOrSpannedString(title);
+ accessibilityTitle = mTitle;
}
public final CharSequence getTitle() {
@@ -1808,6 +1817,7 @@
out.writeInt(hasManualSurfaceInsets ? 1 : 0);
out.writeInt(needsMenuKey);
out.writeInt(accessibilityIdOfAnchor);
+ TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
}
public static final Parcelable.Creator<LayoutParams> CREATOR
@@ -1859,6 +1869,7 @@
hasManualSurfaceInsets = in.readInt() != 0;
needsMenuKey = in.readInt();
accessibilityIdOfAnchor = in.readInt();
+ accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
}
@SuppressWarnings({"PointlessBitwiseExpression"})
@@ -1900,6 +1911,8 @@
/** {@hide} */
public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24;
/** {@hide} */
+ public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25;
+ /** {@hide} */
public static final int EVERYTHING_CHANGED = 0xffffffff;
// internal buffer to backup/restore parameters under compatibility mode.
@@ -2065,6 +2078,13 @@
changes |= ACCESSIBILITY_ANCHOR_CHANGED;
}
+ if (!Objects.equals(accessibilityTitle, o.accessibilityTitle)
+ && o.accessibilityTitle != null) {
+ // NOTE: accessibilityTitle only copied if the originator set one.
+ accessibilityTitle = o.accessibilityTitle;
+ changes |= ACCESSIBILITY_TITLE_CHANGED;
+ }
+
return changes;
}
diff --git a/core/java/android/webkit/WebViewProviderResponse.java b/core/java/android/webkit/WebViewProviderResponse.java
index f5e09e2..c0aeb59 100644
--- a/core/java/android/webkit/WebViewProviderResponse.java
+++ b/core/java/android/webkit/WebViewProviderResponse.java
@@ -21,7 +21,7 @@
import android.os.Parcelable;
/** @hide */
-public class WebViewProviderResponse implements Parcelable {
+public final class WebViewProviderResponse implements Parcelable {
public WebViewProviderResponse(PackageInfo packageInfo, int status) {
this.packageInfo = packageInfo;
@@ -56,6 +56,6 @@
out.writeInt(status);
}
- PackageInfo packageInfo;
- int status;
+ public final PackageInfo packageInfo;
+ public final int status;
}
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index a4e489c..ed6ab56 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -41,12 +41,12 @@
import android.os.IBinder;
import android.os.Message;
import android.os.Parcelable;
+import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
-import android.provider.DocumentsContract;
import android.service.chooser.ChooserTarget;
import android.service.chooser.ChooserTargetService;
import android.service.chooser.IChooserTargetResult;
@@ -70,6 +70,7 @@
import com.android.internal.R;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
+import com.google.android.collect.Lists;
import java.io.File;
import java.util.ArrayList;
@@ -89,6 +90,7 @@
private IntentSender mChosenComponentSender;
private IntentSender mRefinementIntentSender;
private RefinementResultReceiver mRefinementResultReceiver;
+ private ChooserTarget[] mCallerChooserTargets;
private Intent mReferrerFillInIntent;
@@ -97,6 +99,7 @@
private SharedPreferences mPinnedSharedPrefs;
private static final float PINNED_TARGET_SCORE_BOOST = 1000.f;
+ private static final float CALLER_TARGET_SCORE_BOOST = 900.f;
private static final String PINNED_SHARED_PREFS_NAME = "chooser_pin_settings";
private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment";
@@ -219,6 +222,34 @@
Intent.EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER);
setSafeForwardingMode(true);
+ pa = intent.getParcelableArrayExtra(Intent.EXTRA_EXCLUDE_COMPONENTS);
+ if (pa != null) {
+ ComponentName[] names = new ComponentName[pa.length];
+ for (int i = 0; i < pa.length; i++) {
+ if (!(pa[i] instanceof ComponentName)) {
+ Log.w(TAG, "Filtered component #" + i + " not a ComponentName: " + pa[i]);
+ names = null;
+ break;
+ }
+ names[i] = (ComponentName) pa[i];
+ }
+ setFilteredComponents(names);
+ }
+
+ pa = intent.getParcelableArrayExtra(Intent.EXTRA_CHOOSER_TARGETS);
+ if (pa != null) {
+ ChooserTarget[] targets = new ChooserTarget[pa.length];
+ for (int i = 0; i < pa.length; i++) {
+ if (!(pa[i] instanceof ChooserTarget)) {
+ Log.w(TAG, "Chooser target #" + i + " not a ChooserTarget: " + pa[i]);
+ targets = null;
+ break;
+ }
+ targets[i] = (ChooserTarget) pa[i];
+ }
+ mCallerChooserTargets = targets;
+ }
+
mPinnedSharedPrefs = getPinnedSharedPrefs(this);
super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents,
null, false);
@@ -292,6 +323,9 @@
boolean alwaysUseOption) {
final ListView listView = adapterView instanceof ListView ? (ListView) adapterView : null;
mChooserListAdapter = (ChooserListAdapter) adapter;
+ if (mCallerChooserTargets != null && mCallerChooserTargets.length > 0) {
+ mChooserListAdapter.addServiceResults(null, Lists.newArrayList(mCallerChooserTargets));
+ }
mChooserRowAdapter = new ChooserRowAdapter(mChooserListAdapter);
mChooserRowAdapter.registerDataSetObserver(new OffsetDataSetObserver(adapterView));
adapterView.setAdapter(mChooserRowAdapter);
@@ -427,13 +461,19 @@
continue;
}
} catch (NameNotFoundException e) {
- Log.e(TAG, "Could not look up service " + serviceComponent, e);
+ Log.e(TAG, "Could not look up service " + serviceComponent
+ + "; component name not found");
continue;
}
final ChooserTargetServiceConnection conn =
new ChooserTargetServiceConnection(this, dri);
- if (bindService(serviceIntent, conn, BIND_AUTO_CREATE | BIND_NOT_FOREGROUND)) {
+
+ // Explicitly specify Process.myUserHandle instead of calling bindService
+ // to avoid the warning from calling from the system process without an explicit
+ // user handle
+ if (bindServiceAsUser(serviceIntent, conn, BIND_AUTO_CREATE | BIND_NOT_FOREGROUND,
+ Process.myUserHandle())) {
if (DEBUG) {
Log.d(TAG, "Binding service connection for target " + dri
+ " intent " + serviceIntent);
@@ -635,7 +675,11 @@
if (mSourceInfo != null) {
return mSourceInfo.getResolvedIntent();
}
- return getTargetIntent();
+
+ final Intent targetIntent = new Intent(getTargetIntent());
+ targetIntent.setComponent(mChooserTarget.getComponentName());
+ targetIntent.putExtras(mChooserTarget.getIntentExtras());
+ return targetIntent;
}
@Override
@@ -650,8 +694,7 @@
}
private Intent getBaseIntentToSend() {
- Intent result = mSourceInfo != null
- ? mSourceInfo.getResolvedIntent() : getTargetIntent();
+ Intent result = getResolvedIntent();
if (result == null) {
Log.e(TAG, "ChooserTargetInfo: no base intent available to send");
} else {
@@ -677,7 +720,19 @@
}
intent.setComponent(mChooserTarget.getComponentName());
intent.putExtras(mChooserTarget.getIntentExtras());
- activity.startActivityAsCaller(intent, options, true, userId);
+
+ // Important: we will ignore the target security checks in ActivityManager
+ // if and only if the ChooserTarget's target package is the same package
+ // where we got the ChooserTargetService that provided it. This lets a
+ // ChooserTargetService provide a non-exported or permission-guarded target
+ // to the chooser for the user to pick.
+ //
+ // If mSourceInfo is null, we got this ChooserTarget from the caller or elsewhere
+ // so we'll obey the caller's normal security checks.
+ final boolean ignoreTargetSecurity = mSourceInfo != null
+ && mSourceInfo.getResolvedComponentName().getPackageName()
+ .equals(mChooserTarget.getComponentName().getPackageName());
+ activity.startActivityAsCaller(intent, options, ignoreTargetSecurity, userId);
return true;
}
@@ -810,6 +865,9 @@
@Override
public float getScore(DisplayResolveInfo target) {
+ if (target == null) {
+ return CALLER_TARGET_SCORE_BOOST;
+ }
float score = super.getScore(target);
if (target.isPinned()) {
score += PINNED_TARGET_SCORE_BOOST;
@@ -1281,7 +1339,7 @@
}
static class ChooserTargetServiceConnection implements ServiceConnection {
- private final DisplayResolveInfo mOriginalTarget;
+ private DisplayResolveInfo mOriginalTarget;
private ComponentName mConnectedComponent;
private ChooserActivity mChooserActivity;
private final Object mLock = new Object();
@@ -1359,6 +1417,7 @@
public void destroy() {
synchronized (mLock) {
mChooserActivity = null;
+ mOriginalTarget = null;
}
}
@@ -1366,7 +1425,9 @@
public String toString() {
return "ChooserTargetServiceConnection{service="
+ mConnectedComponent + ", activity="
- + mOriginalTarget.getResolveInfo().activityInfo.toString() + "}";
+ + (mOriginalTarget != null
+ ? mOriginalTarget.getResolveInfo().activityInfo.toString()
+ : "<connection destroyed>") + "}";
}
}
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index ff680e2..f2bf9e1 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -105,6 +105,7 @@
private final ArrayList<Intent> mIntents = new ArrayList<>();
private ResolverComparator mResolverComparator;
private PickTargetOptionRequest mPickOptionRequest;
+ private ComponentName[] mFilteredComponents;
protected ResolverDrawerLayout mResolverDrawerLayout;
@@ -332,6 +333,24 @@
}
}
+ public final void setFilteredComponents(ComponentName[] components) {
+ mFilteredComponents = components;
+ }
+
+ public final boolean isComponentFiltered(ComponentInfo component) {
+ if (mFilteredComponents == null) {
+ return false;
+ }
+
+ final ComponentName checkName = component.getComponentName();
+ for (ComponentName name : mFilteredComponents) {
+ if (name.equals(checkName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Perform any initialization needed for voice interaction.
*/
@@ -1269,7 +1288,8 @@
ai.applicationInfo.uid, ai.exported);
boolean suspended = (ai.applicationInfo.flags
& ApplicationInfo.FLAG_SUSPENDED) != 0;
- if (granted != PackageManager.PERMISSION_GRANTED || suspended) {
+ if (granted != PackageManager.PERMISSION_GRANTED || suspended
+ || isComponentFiltered(ai)) {
// Access not allowed!
if (mOrigResolveList == currentResolveList) {
mOrigResolveList = new ArrayList<>(mOrigResolveList);
diff --git a/core/java/com/android/internal/app/UnlaunchableAppActivity.java b/core/java/com/android/internal/app/UnlaunchableAppActivity.java
index f6fbaab..27588e9 100644
--- a/core/java/com/android/internal/app/UnlaunchableAppActivity.java
+++ b/core/java/com/android/internal/app/UnlaunchableAppActivity.java
@@ -26,6 +26,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentSender;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -53,6 +54,7 @@
private int mUserId;
private int mReason;
+ private IntentSender mTarget;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -60,6 +62,7 @@
Intent intent = getIntent();
mReason = intent.getIntExtra(EXTRA_UNLAUNCHABLE_REASON, -1);
mUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
+ mTarget = intent.getParcelableExtra(Intent.EXTRA_INTENT);
if (mUserId == UserHandle.USER_NULL) {
Log.wtf(TAG, "Invalid user id: " + mUserId + ". Stopping.");
@@ -105,6 +108,14 @@
public void onClick(DialogInterface dialog, int which) {
if (mReason == UNLAUNCHABLE_REASON_QUIET_MODE && which == DialogInterface.BUTTON_POSITIVE) {
UserManager.get(this).setQuietModeEnabled(mUserId, false);
+
+ if (mTarget != null) {
+ try {
+ startIntentSenderForResult(mTarget, -1, null, 0, 0, 0);
+ } catch (IntentSender.SendIntentException e) {
+ /* ignore */
+ }
+ }
}
}
@@ -121,4 +132,10 @@
intent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
return intent;
}
+
+ public static Intent createInQuietModeDialogIntent(int userId, IntentSender target) {
+ Intent intent = createInQuietModeDialogIntent(userId);
+ intent.putExtra(Intent.EXTRA_INTENT, target);
+ return intent;
+ }
}
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 0f257d7..c64328b 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -516,8 +516,8 @@
}
mTitle = title;
WindowManager.LayoutParams params = getAttributes();
- if (!TextUtils.equals(title, params.getTitle())) {
- params.setTitle(title);
+ if (!TextUtils.equals(title, params.accessibilityTitle)) {
+ params.accessibilityTitle = TextUtils.stringOrSpannedString(title);
dispatchWindowAttributesChanged(getAttributes());
}
}
diff --git a/core/java/com/android/internal/view/menu/StandardMenuPopup.java b/core/java/com/android/internal/view/menu/StandardMenuPopup.java
index d8ed92d..339c2bf 100644
--- a/core/java/com/android/internal/view/menu/StandardMenuPopup.java
+++ b/core/java/com/android/internal/view/menu/StandardMenuPopup.java
@@ -208,7 +208,7 @@
@Override
public void show() {
if (!tryShow()) {
- throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor");
+ throw new IllegalStateException("StandardMenuPopup cannot be used without an anchor");
}
}
@@ -273,7 +273,7 @@
mOnDismissListener = null;
// Close this menu popup to make room for the submenu popup.
- dismiss();
+ mMenu.close(false /* closeAllMenus */);
// Show the new sub-menu popup at the same location as this popup.
if (subPopup.tryShow(mXOffset, mYOffset)) {
diff --git a/core/jni/android/graphics/FontFamily.cpp b/core/jni/android/graphics/FontFamily.cpp
index 6dc251c..1c2d13d 100644
--- a/core/jni/android/graphics/FontFamily.cpp
+++ b/core/jni/android/graphics/FontFamily.cpp
@@ -53,36 +53,14 @@
fontFamily->Unref();
}
-static jboolean addSkTypeface(FontFamily* family, SkTypeface* face) {
- MinikinFont* minikinFont = new MinikinFontSkia(face);
+static jboolean addSkTypeface(FontFamily* family, SkTypeface* face, const void* fontData,
+ size_t fontSize, int ttcIndex) {
+ MinikinFont* minikinFont = new MinikinFontSkia(face, fontData, fontSize, ttcIndex);
bool result = family->addFont(minikinFont);
minikinFont->Unref();
return result;
}
-static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr, jstring path,
- jint ttcIndex) {
- NPE_CHECK_RETURN_ZERO(env, path);
- ScopedUtfChars str(env, path);
- SkTypeface* face = SkTypeface::CreateFromFile(str.c_str(), ttcIndex);
- if (face == NULL) {
- ALOGE("addFont failed to create font %s", str.c_str());
- return false;
- }
- FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr);
- return addSkTypeface(fontFamily, face);
-}
-
-static struct {
- jmethodID mGet;
- jmethodID mSize;
-} gListClassInfo;
-
-static struct {
- jfieldID mTag;
- jfieldID mStyleValue;
-} gAxisClassInfo;
-
static void release_global_ref(const void* /*data*/, void* context) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
bool needToAttach = (env == NULL);
@@ -106,6 +84,47 @@
}
}
+static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr, jobject bytebuf,
+ jint ttcIndex) {
+ NPE_CHECK_RETURN_ZERO(env, bytebuf);
+ const void* fontPtr = env->GetDirectBufferAddress(bytebuf);
+ if (fontPtr == NULL) {
+ ALOGE("addFont failed to create font, buffer invalid");
+ return false;
+ }
+ jlong fontSize = env->GetDirectBufferCapacity(bytebuf);
+ if (fontSize < 0) {
+ ALOGE("addFont failed to create font, buffer size invalid");
+ return false;
+ }
+ jobject fontRef = MakeGlobalRefOrDie(env, bytebuf);
+ SkAutoTUnref<SkData> data(SkData::NewWithProc(fontPtr, fontSize,
+ release_global_ref, reinterpret_cast<void*>(fontRef)));
+ std::unique_ptr<SkStreamAsset> fontData(new SkMemoryStream(data));
+
+ SkFontMgr::FontParameters params;
+ params.setCollectionIndex(ttcIndex);
+
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ SkTypeface* face = fm->createFromStream(fontData.release(), params);
+ if (face == NULL) {
+ ALOGE("addFont failed to create font");
+ return false;
+ }
+ FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr);
+ return addSkTypeface(fontFamily, face, fontPtr, (size_t)fontSize, ttcIndex);
+}
+
+static struct {
+ jmethodID mGet;
+ jmethodID mSize;
+} gListClassInfo;
+
+static struct {
+ jfieldID mTag;
+ jfieldID mStyleValue;
+} gAxisClassInfo;
+
static jboolean FontFamily_addFontWeightStyle(JNIEnv* env, jobject clazz, jlong familyPtr,
jobject font, jint ttcIndex, jobject listOfAxis, jint weight, jboolean isItalic) {
NPE_CHECK_RETURN_ZERO(env, font);
@@ -133,7 +152,7 @@
}
}
- void* fontPtr = env->GetDirectBufferAddress(font);
+ const void* fontPtr = env->GetDirectBufferAddress(font);
if (fontPtr == NULL) {
ALOGE("addFont failed to create font, buffer invalid");
return false;
@@ -159,7 +178,7 @@
return false;
}
FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr);
- MinikinFont* minikinFont = new MinikinFontSkia(face);
+ MinikinFont* minikinFont = new MinikinFontSkia(face, fontPtr, (size_t)fontSize, ttcIndex);
fontFamily->addFont(minikinFont, FontStyle(weight / 100, isItalic));
minikinFont->Unref();
return true;
@@ -191,6 +210,7 @@
return false;
}
+ size_t bufSize = asset->getLength();
SkAutoTUnref<SkData> data(SkData::NewWithProc(buf, asset->getLength(), releaseAsset, asset));
SkMemoryStream* stream = new SkMemoryStream(data);
// CreateFromStream takes ownership of stream.
@@ -200,7 +220,7 @@
return false;
}
FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr);
- return addSkTypeface(fontFamily, face);
+ return addSkTypeface(fontFamily, face, buf, bufSize, /* ttcIndex */ 0);
}
///////////////////////////////////////////////////////////////////////////////
@@ -208,7 +228,7 @@
static const JNINativeMethod gFontFamilyMethods[] = {
{ "nCreateFamily", "(Ljava/lang/String;I)J", (void*)FontFamily_create },
{ "nUnrefFamily", "(J)V", (void*)FontFamily_unref },
- { "nAddFont", "(JLjava/lang/String;I)Z", (void*)FontFamily_addFont },
+ { "nAddFont", "(JLjava/nio/ByteBuffer;I)Z", (void*)FontFamily_addFont },
{ "nAddFontWeightStyle", "(JLjava/nio/ByteBuffer;ILjava/util/List;IZ)Z",
(void*)FontFamily_addFontWeightStyle },
{ "nAddFontFromAsset", "(JLandroid/content/res/AssetManager;Ljava/lang/String;)Z",
diff --git a/core/jni/android_graphics_drawable_VectorDrawable.cpp b/core/jni/android_graphics_drawable_VectorDrawable.cpp
index b04293e..e5c4a2d 100644
--- a/core/jni/android_graphics_drawable_VectorDrawable.cpp
+++ b/core/jni/android_graphics_drawable_VectorDrawable.cpp
@@ -176,6 +176,9 @@
PathParser::ParseResult result;
PathData data;
PathParser::getPathDataFromString(&data, &result, pathString, stringLength);
+ if (result.failureOccurred) {
+ doThrowIAE(env, result.failureMessage.c_str());
+ }
path->mutateStagingProperties()->setData(data);
env->ReleaseStringUTFChars(inputStr, pathString);
}
diff --git a/core/jni/android_util_PathParser.cpp b/core/jni/android_util_PathParser.cpp
index 0927120..0c867f1 100644
--- a/core/jni/android_util_PathParser.cpp
+++ b/core/jni/android_util_PathParser.cpp
@@ -15,6 +15,7 @@
*/
#include "jni.h"
+#include "GraphicsJNI.h"
#include <PathParser.h>
#include <SkPath.h>
@@ -27,7 +28,7 @@
using namespace uirenderer;
-static bool parseStringForPath(JNIEnv* env, jobject, jlong skPathHandle, jstring inputPathStr,
+static void parseStringForPath(JNIEnv* env, jobject, jlong skPathHandle, jstring inputPathStr,
jint strLength) {
const char* pathString = env->GetStringUTFChars(inputPathStr, NULL);
SkPath* skPath = reinterpret_cast<SkPath*>(skPathHandle);
@@ -36,9 +37,8 @@
PathParser::parseStringForSkPath(skPath, &result, pathString, strLength);
env->ReleaseStringUTFChars(inputPathStr, pathString);
if (result.failureOccurred) {
- ALOGE(result.failureMessage.c_str());
+ doThrowIAE(env, result.failureMessage.c_str());
}
- return !result.failureOccurred;
}
static long createEmptyPathData(JNIEnv*, jobject) {
@@ -62,7 +62,7 @@
return reinterpret_cast<jlong>(pathData);
} else {
delete pathData;
- ALOGE(result.failureMessage.c_str());
+ doThrowIAE(env, result.failureMessage.c_str());
return NULL;
}
}
@@ -100,7 +100,7 @@
}
static const JNINativeMethod gMethods[] = {
- {"nParseStringForPath", "(JLjava/lang/String;I)Z", (void*)parseStringForPath},
+ {"nParseStringForPath", "(JLjava/lang/String;I)V", (void*)parseStringForPath},
{"nCreateEmptyPathData", "!()J", (void*)createEmptyPathData},
{"nCreatePathData", "!(J)J", (void*)createPathData},
{"nCreatePathDataFromString", "(Ljava/lang/String;I)J", (void*)createPathDataFromStringPath},
diff --git a/core/jni/android_view_RenderNode.cpp b/core/jni/android_view_RenderNode.cpp
index 27e2ee8..4459f32 100644
--- a/core/jni/android_view_RenderNode.cpp
+++ b/core/jni/android_view_RenderNode.cpp
@@ -128,9 +128,22 @@
static void android_view_RenderNode_setDisplayList(JNIEnv* env,
jobject clazz, jlong renderNodePtr, jlong displayListPtr) {
+ class RemovedObserver : public TreeObserver {
+ public:
+ virtual void onMaybeRemovedFromTree(RenderNode* node) override {
+ maybeRemovedNodes.insert(sp<RenderNode>(node));
+ }
+ std::set< sp<RenderNode> > maybeRemovedNodes;
+ };
+
RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
DisplayList* newData = reinterpret_cast<DisplayList*>(displayListPtr);
- renderNode->setStagingDisplayList(newData);
+ RemovedObserver observer;
+ renderNode->setStagingDisplayList(newData, &observer);
+ for (auto& node : observer.maybeRemovedNodes) {
+ if (node->hasParents()) continue;
+ onRenderNodeRemoved(env, node.get());
+ }
}
// ----------------------------------------------------------------------------
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 14252dc..21e4d2f 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -525,7 +525,7 @@
UiFrameInfoBuilder(proxy->frameInfo())
.setVsync(vsync, vsync)
.addFlag(FrameInfoFlags::SurfaceCanvas);
- proxy->syncAndDrawFrame();
+ proxy->syncAndDrawFrame(nullptr);
}
static void destroy(JNIEnv* env, jclass clazz, jlong rendererPtr) {
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index 8019326..ef45c87 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -72,6 +72,31 @@
return env;
}
+// TODO: Clean this up, it's a bit odd to need to call over to
+// rendernode's jni layer. Probably means RootRenderNode should be pulled
+// into HWUI with appropriate callbacks for the various JNI hooks so
+// that RenderNode's JNI layer can handle its own thing
+void onRenderNodeRemoved(JNIEnv* env, RenderNode* node);
+
+class ScopedRemovedRenderNodeObserver : public TreeObserver {
+public:
+ ScopedRemovedRenderNodeObserver(JNIEnv* env) : mEnv(env) {}
+ ~ScopedRemovedRenderNodeObserver() {
+ for (auto& node : mMaybeRemovedNodes) {
+ if (node->hasParents()) continue;
+ onRenderNodeRemoved(mEnv, node.get());
+ }
+ }
+
+ virtual void onMaybeRemovedFromTree(RenderNode* node) override {
+ mMaybeRemovedNodes.insert(sp<RenderNode>(node));
+ }
+
+private:
+ JNIEnv* mEnv;
+ std::set< sp<RenderNode> > mMaybeRemovedNodes;
+};
+
class OnFinishedEvent {
public:
OnFinishedEvent(BaseRenderNodeAnimator* animator, AnimationListener* listener)
@@ -120,13 +145,7 @@
std::string mMessage;
};
-// TODO: Clean this up, it's a bit odd to need to call over to
-// rendernode's jni layer. Probably means RootRenderNode should be pulled
-// into HWUI with appropriate callbacks for the various JNI hooks so
-// that RenderNode's JNI layer can handle its own thing
-void onRenderNodeRemoved(JNIEnv* env, RenderNode* node);
-
-class RootRenderNode : public RenderNode, ErrorHandler, TreeObserver {
+class RootRenderNode : public RenderNode, ErrorHandler {
public:
RootRenderNode(JNIEnv* env) : RenderNode() {
mLooper = Looper::getForThread();
@@ -143,9 +162,6 @@
virtual void prepareTree(TreeInfo& info) override {
info.errorHandler = this;
- if (info.mode == TreeInfo::MODE_FULL) {
- info.observer = this;
- }
// TODO: This is hacky
info.windowInsetLeft = -stagingProperties().getLeft();
info.windowInsetTop = -stagingProperties().getTop();
@@ -155,7 +171,6 @@
info.windowInsetLeft = 0;
info.windowInsetTop = 0;
info.errorHandler = nullptr;
- info.observer = nullptr;
}
void sendMessage(const sp<MessageHandler>& handler) {
@@ -181,27 +196,10 @@
mPendingAnimatingRenderNodes.clear();
}
- virtual void onMaybeRemovedFromTree(RenderNode* node) override {
- mMaybeRemovedNodes.insert(sp<RenderNode>(node));
- }
-
- void processMaybeRemovedNodes(JNIEnv* env) {
- // We can safely access mMaybeRemovedNodes here because
- // we will only modify it in prepareTree calls that are
- // MODE_FULL
-
- for (auto& node : mMaybeRemovedNodes) {
- if (node->hasParents()) continue;
- onRenderNodeRemoved(env, node.get());
- }
- mMaybeRemovedNodes.clear();
- }
-
private:
sp<Looper> mLooper;
JavaVM* mVm;
std::vector< sp<RenderNode> > mPendingAnimatingRenderNodes;
- std::set< sp<RenderNode> > mMaybeRemovedNodes;
};
class AnimationContextBridge : public AnimationContext {
@@ -481,6 +479,12 @@
return proxy->pauseSurface(surface);
}
+static void android_view_ThreadedRenderer_setStopped(JNIEnv* env, jobject clazz,
+ jlong proxyPtr, jboolean stopped) {
+ RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
+ proxy->setStopped(stopped);
+}
+
static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr,
jint width, jint height, jfloat lightRadius, jint ambientShadowAlpha, jint spotShadowAlpha) {
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
@@ -500,24 +504,23 @@
}
static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject clazz,
- jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize, jlong rootNodePtr) {
+ jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize) {
LOG_ALWAYS_FATAL_IF(frameInfoSize != UI_THREAD_FRAME_INFO_SIZE,
"Mismatched size expectations, given %d expected %d",
frameInfoSize, UI_THREAD_FRAME_INFO_SIZE);
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
- RootRenderNode* rootRenderNode = reinterpret_cast<RootRenderNode*>(rootNodePtr);
+ ScopedRemovedRenderNodeObserver observer(env);
env->GetLongArrayRegion(frameInfo, 0, frameInfoSize, proxy->frameInfo());
- int ret = proxy->syncAndDrawFrame();
- rootRenderNode->processMaybeRemovedNodes(env);
- return ret;
+ return proxy->syncAndDrawFrame(&observer);
}
static void android_view_ThreadedRenderer_destroy(JNIEnv* env, jobject clazz,
jlong proxyPtr, jlong rootNodePtr) {
+ ScopedRemovedRenderNodeObserver observer(env);
RootRenderNode* rootRenderNode = reinterpret_cast<RootRenderNode*>(rootNodePtr);
rootRenderNode->destroy();
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
- proxy->destroy();
+ proxy->destroy(&observer);
}
static void android_view_ThreadedRenderer_registerAnimatingRenderNode(JNIEnv* env, jobject clazz,
@@ -542,9 +545,10 @@
static void android_view_ThreadedRenderer_buildLayer(JNIEnv* env, jobject clazz,
jlong proxyPtr, jlong nodePtr) {
+ ScopedRemovedRenderNodeObserver observer(env);
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
RenderNode* node = reinterpret_cast<RenderNode*>(nodePtr);
- proxy->buildLayer(node);
+ proxy->buildLayer(node, &observer);
}
static jboolean android_view_ThreadedRenderer_copyLayerInto(JNIEnv* env, jobject clazz,
@@ -579,8 +583,9 @@
static void android_view_ThreadedRenderer_destroyHardwareResources(JNIEnv* env, jobject clazz,
jlong proxyPtr) {
+ ScopedRemovedRenderNodeObserver observer(env);
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
- proxy->destroyHardwareResources();
+ proxy->destroyHardwareResources(&observer);
}
static void android_view_ThreadedRenderer_trimMemory(JNIEnv* env, jobject clazz,
@@ -733,10 +738,11 @@
{ "nInitialize", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_initialize },
{ "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
{ "nPauseSurface", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_pauseSurface },
+ { "nSetStopped", "(JZ)V", (void*) android_view_ThreadedRenderer_setStopped },
{ "nSetup", "(JIIFII)V", (void*) android_view_ThreadedRenderer_setup },
{ "nSetLightCenter", "(JFFF)V", (void*) android_view_ThreadedRenderer_setLightCenter },
{ "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
- { "nSyncAndDrawFrame", "(J[JIJ)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
+ { "nSyncAndDrawFrame", "(J[JI)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
{ "nDestroy", "(JJ)V", (void*) android_view_ThreadedRenderer_destroy },
{ "nRegisterAnimatingRenderNode", "(JJ)V", (void*) android_view_ThreadedRenderer_registerAnimatingRenderNode },
{ "nInvokeFunctor", "(JZ)V", (void*) android_view_ThreadedRenderer_invokeFunctor },
diff --git a/core/res/res/drawable/ic_corp_user_badge.xml b/core/res/res/drawable/ic_corp_user_badge.xml
new file mode 100644
index 0000000..23809d5
--- /dev/null
+++ b/core/res/res/drawable/ic_corp_user_badge.xml
@@ -0,0 +1,24 @@
+<!--
+Copyright (C) 2016 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="36dp"
+ android:height="36dp"
+ android:viewportWidth="36.0"
+ android:viewportHeight="36.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M18,0C8.06,-0 0,8.06 0,18C0,27.94 8.06,36 18,36C27.94,36 36,27.94 36,18C36,8.06 27.94,0 18,0zM15.5,10.5L20.5,10.5L21.75,11.75L21.75,13L24.66,13C25.57,13 26.34,13.74 26.34,14.66L26.34,18C26.34,18.92 25.57,19.66 24.66,19.66L19.66,19.66L19.66,18.41L16.34,18.41L16.34,19.66L11.34,19.66C10.43,19.66 9.66,18.92 9.66,18L9.66,14.66C9.66,13.74 10.43,13 11.34,13L14.25,13L14.25,11.78L15.5,10.5zM15.5,11.75L15.5,13L20.5,13L20.5,11.75L15.5,11.75zM10.5,20.5L16.34,20.5L16.34,21.75L19.66,21.75L19.66,20.5L25.5,20.5L25.5,23.84C25.5,24.76 24.76,25.5 23.84,25.5L12.16,25.5C11.24,25.5 10.5,24.76 10.5,23.84L10.5,20.5z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_input_extract_action_done.xml b/core/res/res/drawable/ic_input_extract_action_done.xml
new file mode 100644
index 0000000..a0ebf92
--- /dev/null
+++ b/core/res/res/drawable/ic_input_extract_action_done.xml
@@ -0,0 +1,4 @@
+<vector android:height="24dp" android:viewportHeight="48.0"
+ android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FFFFFF" android:pathData="M18,32.34L9.66,24l-2.83,2.83L18,38l24,-24 -2.83,-2.83z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_input_extract_action_go.xml b/core/res/res/drawable/ic_input_extract_action_go.xml
new file mode 100644
index 0000000..c24f5a0
--- /dev/null
+++ b/core/res/res/drawable/ic_input_extract_action_go.xml
@@ -0,0 +1,4 @@
+<vector android:height="24dp" android:viewportHeight="48.0"
+ android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FFFFFF" android:pathData="M6,22h28.34l-7.17,-7.17L30,12l12,12 -12,12 -2.83,-2.83L34.34,26H6z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_input_extract_action_next.xml b/core/res/res/drawable/ic_input_extract_action_next.xml
new file mode 100644
index 0000000..fa0b178
--- /dev/null
+++ b/core/res/res/drawable/ic_input_extract_action_next.xml
@@ -0,0 +1,4 @@
+<vector android:height="24dp" android:viewportHeight="48.0"
+ android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FFFFFF" android:pathData="M23.17,14.83L30.34,22H2v4h28.34l-7.17,7.17L26,36l12,-12 -12,-12 -2.83,2.83zM40,12v24h4V12h-4z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_input_extract_action_previous.xml b/core/res/res/drawable/ic_input_extract_action_previous.xml
new file mode 100644
index 0000000..5e1823c
--- /dev/null
+++ b/core/res/res/drawable/ic_input_extract_action_previous.xml
@@ -0,0 +1,4 @@
+<vector android:height="24dp" android:viewportHeight="48.0"
+ android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FFFFFF" android:pathData="M22.83,14.83L15.66,22H44v4H15.66l7.17,7.17L20,36 8,24l12,-12 2.83,2.83zM6,12v24H2V12h4z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_input_extract_action_return.xml b/core/res/res/drawable/ic_input_extract_action_return.xml
new file mode 100644
index 0000000..c46a4a2
--- /dev/null
+++ b/core/res/res/drawable/ic_input_extract_action_return.xml
@@ -0,0 +1,4 @@
+<vector android:height="24dp" android:viewportHeight="48.0"
+ android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FFFFFF" android:pathData="M38,14v8H11.66l7.17,-7.17L16,12 4,24l12,12 2.83,-2.83L11.66,26H42V14z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_input_extract_action_search.xml b/core/res/res/drawable/ic_input_extract_action_search.xml
new file mode 100644
index 0000000..fd1dcea
--- /dev/null
+++ b/core/res/res/drawable/ic_input_extract_action_search.xml
@@ -0,0 +1,4 @@
+<vector android:height="24dp" android:viewportHeight="48.0"
+ android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FFFFFF" android:pathData="M31,28h-1.59l-0.55,-0.55C30.82,25.18 32,22.23 32,19c0,-7.18 -5.82,-13 -13,-13S6,11.82 6,19s5.82,13 13,13c3.23,0 6.18,-1.18 8.45,-3.13l0.55,0.55L28,31l10,9.98L40.98,38 31,28zM19,28c-4.97,0 -9,-4.03 -9,-9s4.03,-9 9,-9 9,4.03 9,9 -4.03,9 -9,9z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_input_extract_action_send.xml b/core/res/res/drawable/ic_input_extract_action_send.xml
new file mode 100644
index 0000000..0f3754b
--- /dev/null
+++ b/core/res/res/drawable/ic_input_extract_action_send.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="36dp"
+ android:height="36dp"
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0">
+ <path
+ android:pathData="M4.02,42L46,24 4.02,6 4,20l30,4 -30,4z"
+ android:fillColor="#FFFFFF"/>
+</vector>
diff --git a/core/res/res/drawable/input_extract_action_bg_material_dark.xml b/core/res/res/drawable/input_extract_action_bg_material_dark.xml
new file mode 100644
index 0000000..2457bb9
--- /dev/null
+++ b/core/res/res/drawable/input_extract_action_bg_material_dark.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/input_extract_action_bg_pressed_material_dark"
+ android:state_pressed="true"/>
+ <item android:drawable="@drawable/input_extract_action_bg_normal_material_dark"/>
+</selector>
diff --git a/core/res/res/drawable/input_extract_action_bg_normal_material_dark.xml b/core/res/res/drawable/input_extract_action_bg_normal_material_dark.xml
new file mode 100644
index 0000000..9e36253
--- /dev/null
+++ b/core/res/res/drawable/input_extract_action_bg_normal_material_dark.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
+ <solid android:color="@color/material_deep_teal_200"/>
+</shape>
diff --git a/core/res/res/drawable/input_extract_action_bg_pressed_material_dark.xml b/core/res/res/drawable/input_extract_action_bg_pressed_material_dark.xml
new file mode 100644
index 0000000..2328ce3
--- /dev/null
+++ b/core/res/res/drawable/input_extract_action_bg_pressed_material_dark.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
+ <solid android:color="@color/material_deep_teal_100"/>
+</shape>
diff --git a/core/res/res/layout-watch/input_method_extract_view.xml b/core/res/res/layout-watch/input_method_extract_view.xml
new file mode 100644
index 0000000..cd921f1
--- /dev/null
+++ b/core/res/res/layout-watch/input_method_extract_view.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<android.inputmethodservice.CompactExtractEditLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:baselineAligned="false">
+
+ <android.inputmethodservice.ExtractEditText
+ android:id="@id/inputExtractEditText"
+ android:layout_width="0dp"
+ android:layout_height="24dp"
+ android:background="@null"
+ android:singleLine="true"
+ android:inputType="text"
+ android:layout_weight="1"
+ android:fontFamily="sans-serif-condensed-light"
+ android:textColor="@color/primary_text_default_material_dark"
+ android:textColorHighlight="@color/accent_material_dark"
+ android:textSize="18dp"
+ android:cursorVisible="false"
+ android:gravity="bottom|right"
+ />
+
+ <FrameLayout
+ android:id="@id/inputExtractAccessories"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dp"
+ android:visibility="visible">
+ <ImageButton
+ android:id="@id/inputExtractAction"
+ android:layout_width="@dimen/input_extract_action_button_width"
+ android:layout_height="@dimen/input_extract_action_button_width"
+ android:background="@drawable/input_extract_action_bg_material_dark"
+ android:padding="4dp"
+ android:scaleType="centerInside" />
+ </FrameLayout>
+</android.inputmethodservice.CompactExtractEditLayout>
diff --git a/core/res/res/values-round-watch/dimens.xml b/core/res/res/values-round-watch/dimens.xml
new file mode 100644
index 0000000..f4b250c
--- /dev/null
+++ b/core/res/res/values-round-watch/dimens.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/assets/res/any/dimens.xml
+**
+** Copyright 2016, 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>
+ <!-- each of these are relative to the display size -->
+ <item name="input_extract_layout_height" type="fraction">25.2%</item>
+ <item name="input_extract_layout_padding_left" type="fraction">7.5%</item>
+ <item name="input_extract_layout_padding_left_no_action" type="fraction">@fraction/input_extract_layout_padding_right</item>
+ <item name="input_extract_layout_padding_right" type="fraction">21.4%</item>
+ <item name="input_extract_text_margin_bottom" type="fraction">5.5%</item>
+ <item name="input_extract_action_margin_bottom" type="fraction">2.1%</item>
+ <item name="input_extract_action_button_width" type="dimen">32dp</item>
+ <item name="input_extract_action_button_height" type="dimen">32dp</item>
+</resources>
diff --git a/core/res/res/values-w170dp-notround-watch/dimens.xml b/core/res/res/values-w170dp-notround-watch/dimens.xml
new file mode 100644
index 0000000..9f30ac1
--- /dev/null
+++ b/core/res/res/values-w170dp-notround-watch/dimens.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/assets/res/any/dimens.xml
+**
+** Copyright 2016, 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>
+ <!-- each of these are relative to the display size -->
+ <item name="input_extract_layout_padding_right" type="fraction">7.5%</item>
+</resources>
diff --git a/core/res/res/values-w320dp/dimens.xml b/core/res/res/values-w320dp/dimens.xml
new file mode 100644
index 0000000..ad6d2ec
--- /dev/null
+++ b/core/res/res/values-w320dp/dimens.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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>
+ <!-- The platform's desired fixed width for a dialog along the major axis
+ (the screen is in landscape). This may be either a fraction or a dimension.-->
+ <item type="dimen" name="dialog_fixed_width_major">320dp</item>
+ <!-- The platform's desired fixed width for a dialog along the minor axis
+ (the screen is in portrait). This may be either a fraction or a dimension.-->
+ <item type="dimen" name="dialog_fixed_width_minor">320dp</item>
+</resources>
diff --git a/core/res/res/values-watch/dimens.xml b/core/res/res/values-watch/dimens.xml
new file mode 100644
index 0000000..f79a0a5
--- /dev/null
+++ b/core/res/res/values-watch/dimens.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/assets/res/any/dimens.xml
+**
+** Copyright 2016, 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>
+ <!-- each of these are relative to the display size -->
+ <item name="input_extract_layout_height" type="fraction">17.5%</item>
+ <item name="input_extract_layout_padding_left" type="fraction">3.6%</item>
+ <item name="input_extract_layout_padding_left_no_action" type="fraction">@fraction/input_extract_layout_padding_right</item>
+ <item name="input_extract_layout_padding_right" type="fraction">2.5%</item>
+ <item name="input_extract_text_margin_bottom" type="fraction">0%</item>
+ <item name="input_extract_action_margin_bottom" type="fraction">0%</item>
+ <item name="input_extract_action_button_width" type="dimen">24dp</item>
+ <item name="input_extract_action_button_height" type="dimen">24dp</item>
+</resources>
diff --git a/core/res/res/values-watch/themes.xml b/core/res/res/values-watch/themes.xml
index 756a94b..6d6065f 100644
--- a/core/res/res/values-watch/themes.xml
+++ b/core/res/res/values-watch/themes.xml
@@ -18,6 +18,7 @@
<style name="Theme.Dialog.AppError" parent="Theme.Micro.Dialog.AppError" />
<style name="Theme.Holo.Dialog.Alert" parent="Theme.Micro.Dialog.Alert" />
<style name="Theme.Holo.Light.Dialog.Alert" parent="Theme.Micro.Dialog.Alert" />
+ <style name="Theme.InputMethod" parent="Theme.Micro.InputMethod" />
<style name="Theme.Material.Dialog.Alert" parent="Theme.Micro.Dialog.Alert" />
<style name="Theme.Material.Light.Dialog.Alert" parent="Theme.Micro.Dialog.Alert" />
</resources>
diff --git a/core/res/res/values-watch/themes_device_defaults.xml b/core/res/res/values-watch/themes_device_defaults.xml
index 61753b1..66509fb 100644
--- a/core/res/res/values-watch/themes_device_defaults.xml
+++ b/core/res/res/values-watch/themes_device_defaults.xml
@@ -19,14 +19,16 @@
<style name="Theme.DeviceDefault.Dialog" parent="Theme.Micro.Dialog" />
<style name="Theme.DeviceDefault.DialogWhenLarge" parent="Theme.Micro.Dialog" />
<style name="Theme.DeviceDefault.Dialog.Alert" parent="Theme.Micro.Dialog.Alert" />
+ <style name="Theme.DeviceDefault.InputMethod" parent="Theme.Micro.InputMethod" />
+ <style name="Theme.DeviceDefault.Panel" parent="Theme.Micro.Panel" />
<style name="Theme.DeviceDefault.Light" parent="Theme.Micro.Light" />
<style name="Theme.DeviceDefault.Light.NoActionBar" parent="Theme.Micro.Light" />
<style name="Theme.DeviceDefault.Light.DarkActionBar" parent="Theme.Micro.Light" />
<style name="Theme.DeviceDefault.Light.Dialog" parent="Theme.Micro.Dialog" />
<style name="Theme.DeviceDefault.Light.DialogWhenLarge" parent="Theme.Micro.Dialog" />
<style name="Theme.DeviceDefault.Light.Dialog.Alert" parent="Theme.Micro.Dialog.Alert" />
+ <style name="Theme.DeviceDefault.Light.Panel" parent="Theme.Micro.Light.Panel" />
<style name="Theme.DeviceDefault.Settings" parent="Theme.Micro" />
<style name="Theme.DeviceDefault.Wallpaper" parent="Theme.Micro" />
-
</resources>
diff --git a/core/res/res/values/colors_material.xml b/core/res/res/values/colors_material.xml
index 7399fa9..c8ca116 100644
--- a/core/res/res/values/colors_material.xml
+++ b/core/res/res/values/colors_material.xml
@@ -75,7 +75,9 @@
<color name="material_grey_100">#fff5f5f5</color>
<color name="material_grey_50">#fffafafa</color>
+ <color name="material_deep_teal_100">#ffb2dfdb</color>
<color name="material_deep_teal_200">#ff80cbc4</color>
+ <color name="material_deep_teal_300">#ff4db6ac</color>
<color name="material_deep_teal_500">#ff009688</color>
<color name="material_blue_grey_800">#ff37474f</color>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index a21f276..9aec1bb 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -112,10 +112,10 @@
<!-- The platform's desired fixed width for a dialog along the major axis
(the screen is in landscape). This may be either a fraction or a dimension.-->
- <item type="dimen" name="dialog_fixed_width_major">320dp</item>
+ <item type="dimen" name="dialog_fixed_width_major">100%</item>
<!-- The platform's desired fixed width for a dialog along the minor axis
(the screen is in portrait). This may be either a fraction or a dimension.-->
- <item type="dimen" name="dialog_fixed_width_minor">320dp</item>
+ <item type="dimen" name="dialog_fixed_width_minor">100%</item>
<!-- The platform's desired fixed height for a dialog along the major axis
(the screen is in portrait). This may be either a fraction or a dimension.-->
<item type="dimen" name="dialog_fixed_height_major">80%</item>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index b4f95dc..96731cf 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -4018,12 +4018,6 @@
<!-- Lock-to-app unlock password string -->
<string name="lock_to_app_unlock_password">Ask for password before unpinning</string>
- <!-- Multi-Window strings -->
- <!-- Warning message when an app that got forced to be resizable gets shown in split-screen -->
- <string name="dock_forced_resizable">App may not work with split-screen.</string>
- <!-- Warning message when we try to dock a non-resizeble tasks and launch it in fullscreen instead. -->
- <string name="dock_non_resizeble_failed_to_dock_text">App does not support split-screen.</string>
-
<!-- Notification shown when device owner silently installs a package [CHAR LIMIT=NONE] -->
<string name="package_installed_device_owner">Installed by your administrator</string>
<!-- Notification shown when device owner silently updates a package [CHAR LIMIT=NONE] -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 2215bd4..9342eb1 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -613,8 +613,6 @@
<java-symbol type="string" name="display_manager_overlay_display_name" />
<java-symbol type="string" name="display_manager_overlay_display_secure_suffix" />
<java-symbol type="string" name="display_manager_overlay_display_title" />
- <java-symbol type="string" name="dock_forced_resizable" />
- <java-symbol type="string" name="dock_non_resizeble_failed_to_dock_text" />
<java-symbol type="string" name="double_tap_toast" />
<java-symbol type="string" name="durationDays" />
<java-symbol type="string" name="durationDayHours" />
@@ -1267,6 +1265,7 @@
<java-symbol type="drawable" name="ic_corp_badge" />
<java-symbol type="drawable" name="ic_corp_badge_off" />
<java-symbol type="drawable" name="ic_corp_icon_badge" />
+ <java-symbol type="drawable" name="ic_corp_user_badge" />
<java-symbol type="drawable" name="ic_corp_badge_no_background" />
<java-symbol type="drawable" name="ic_corp_icon" />
<java-symbol type="drawable" name="ic_corp_statusbar_icon" />
@@ -2543,4 +2542,23 @@
<java-symbol type="id" name="titleDividerNoCustom" />
<java-symbol type="bool" name="config_sustainedPerformanceModeSupported" />
+
+ <!-- Wearable input extract edit view -->
+ <java-symbol type="drawable" name="ic_input_extract_action_go" />
+ <java-symbol type="drawable" name="ic_input_extract_action_search" />
+ <java-symbol type="drawable" name="ic_input_extract_action_send" />
+ <java-symbol type="drawable" name="ic_input_extract_action_next" />
+ <java-symbol type="drawable" name="ic_input_extract_action_done" />
+ <java-symbol type="drawable" name="ic_input_extract_action_previous" />
+ <java-symbol type="drawable" name="ic_input_extract_action_return" />
+
+ <java-symbol type="fraction" name="input_extract_layout_height" />
+ <java-symbol type="fraction" name="input_extract_layout_padding_left" />
+ <java-symbol type="fraction" name="input_extract_layout_padding_left_no_action" />
+ <java-symbol type="fraction" name="input_extract_layout_padding_right" />
+ <java-symbol type="fraction" name="input_extract_text_margin_bottom" />
+ <java-symbol type="fraction" name="input_extract_action_margin_bottom" />
+
+ <java-symbol type="dimen" name="input_extract_action_button_width" />
+ <java-symbol type="dimen" name="input_extract_action_button_height" />
</resources>
diff --git a/core/res/res/values/themes_micro.xml b/core/res/res/values/themes_micro.xml
index 478d66c..25a6e00 100644
--- a/core/res/res/values/themes_micro.xml
+++ b/core/res/res/values/themes_micro.xml
@@ -83,4 +83,18 @@
<item name="fontFamily">sans-serif-condensed-light</item>
<item name="textColor">@color/micro_text_light</item>
</style>
+
+ <style name="Theme.Micro.Panel" parent="Theme.Material.Panel" />
+ <style name="Theme.Micro.Light.Panel" parent="Theme.Material.Light.Panel" />
+
+ <!-- Default theme for material style input methods, which is used by the
+ {@link android.inputmethodservice.InputMethodService} class.
+ This inherits from Theme.Panel, but sets up IME appropriate animations
+ and a few custom attributes. -->
+ <style name="Theme.Micro.InputMethod" parent="Theme.Micro.Panel">
+ <item name="windowAnimationStyle">@style/Animation.InputMethod</item>
+ <item name="imeFullscreenBackground">#1e282c</item>
+ <item name="imeExtractEnterAnimation">@anim/input_method_extract_enter</item>
+ <item name="imeExtractExitAnimation">@anim/input_method_extract_exit</item>
+ </style>
</resources>
diff --git a/core/tests/notificationtests/Android.mk b/core/tests/notificationtests/Android.mk
index be2e6bf..702218c 100644
--- a/core/tests/notificationtests/Android.mk
+++ b/core/tests/notificationtests/Android.mk
@@ -11,6 +11,9 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
LOCAL_PACKAGE_NAME := NotificationStressTests
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ub-uiautomator
+
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/core/tests/notificationtests/src/android/app/NotificationStressTest.java b/core/tests/notificationtests/src/android/app/NotificationStressTest.java
index 4cb617e..6e86c37 100644
--- a/core/tests/notificationtests/src/android/app/NotificationStressTest.java
+++ b/core/tests/notificationtests/src/android/app/NotificationStressTest.java
@@ -16,15 +16,19 @@
package android.app;
-
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+import android.os.Build;
+import android.os.RemoteException;
import android.os.SystemClock;
+import android.support.test.uiautomator.UiDevice;
import android.test.InstrumentationTestCase;
import android.test.RepetitiveTest;
-import android.test.TimedTest;
+import android.util.Log;
+import java.lang.InterruptedException;
+import java.lang.reflect.Method;
import java.util.Random;
/**
@@ -34,51 +38,78 @@
public class NotificationStressTest extends InstrumentationTestCase {
private static final int NUM_ITERATIONS = 200;
+ private static final int NUM_ITERATIONS_2 = 30;
+ private static final int LONG_TIMEOUT = 2000;
+ // 50 notifications per app: defined as Variable MAX_PACKAGE_NOTIFICATIONS in
+ // NotificationManagerService.java
+ private static final int MAX_NOTIFCATIONS = 50;
private static final int[] ICONS = new int[] {
- android.R.drawable.stat_notify_call_mute,
- android.R.drawable.stat_notify_chat,
- android.R.drawable.stat_notify_error,
- android.R.drawable.stat_notify_missed_call,
- android.R.drawable.stat_notify_more,
- android.R.drawable.stat_notify_sdcard,
- android.R.drawable.stat_notify_sdcard_prepare,
- android.R.drawable.stat_notify_sdcard_usb,
- android.R.drawable.stat_notify_sync,
- android.R.drawable.stat_notify_sync_noanim,
- android.R.drawable.stat_notify_voicemail,
+ android.R.drawable.stat_notify_call_mute,
+ android.R.drawable.stat_notify_chat,
+ android.R.drawable.stat_notify_error,
+ android.R.drawable.stat_notify_missed_call,
+ android.R.drawable.stat_notify_more,
+ android.R.drawable.stat_notify_sdcard,
+ android.R.drawable.stat_notify_sdcard_prepare,
+ android.R.drawable.stat_notify_sdcard_usb,
+ android.R.drawable.stat_notify_sync,
+ android.R.drawable.stat_notify_sync_noanim,
+ android.R.drawable.stat_notify_voicemail,
};
private final Random mRandom = new Random();
private Context mContext;
private NotificationManager mNotificationManager;
- private int notifyId = 0;
+ private UiDevice mDevice = null;
+ private int mNotifyId = 0;
@Override
protected void setUp() throws Exception {
super.setUp();
+ mDevice = UiDevice.getInstance(getInstrumentation());
mContext = getInstrumentation().getContext();
mNotificationManager = (NotificationManager) mContext.getSystemService(
Context.NOTIFICATION_SERVICE);
+ mDevice.setOrientationNatural();
+ mNotificationManager.cancelAll();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
+ mDevice.unfreezeRotation();
mNotificationManager.cancelAll();
}
- @RepetitiveTest(numIterations=NUM_ITERATIONS)
+ @RepetitiveTest(numIterations = NUM_ITERATIONS)
public void testNotificationStress() {
// Cancel one of every five notifications to vary load on notification manager
- if (notifyId % 5 == 4) {
- mNotificationManager.cancel(notifyId - 4);
+ if (mNotifyId % 5 == 4) {
+ mNotificationManager.cancel(mNotifyId - 4);
}
- sendNotification(notifyId++, "testNotificationStressNotify");
+ sendNotification(mNotifyId++, "testNotificationStressNotify");
+ }
+
+ @RepetitiveTest(numIterations = NUM_ITERATIONS_2)
+ public void testNotificationsWithShadeStress() throws Exception {
+ mDevice.openNotification();
+ Thread.sleep(LONG_TIMEOUT);
+ for (int j = 0; j < MAX_NOTIFCATIONS; j++) {
+ sendNotification(mNotifyId++, "testNotificationStressNotify");
+ }
+ Thread.sleep(500);
+ assertTrue(mNotificationManager.getActiveNotifications().length == MAX_NOTIFCATIONS);
+ for (int j = 0; j < MAX_NOTIFCATIONS; j++) {
+ mNotificationManager.cancel(--mNotifyId);
+ }
+ if (isLockScreen()) {
+ fail("Notification stress test failed, back to lockscreen");
+ }
}
private void sendNotification(int id, CharSequence text) {
// Fill in arbitrary content
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
+ Intent intent = new Intent(Intent.ACTION_VIEW);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
CharSequence title = text + " " + id;
CharSequence subtitle = String.valueOf(System.currentTimeMillis());
@@ -90,8 +121,19 @@
.setContentTitle(title)
.setContentText(subtitle)
.setContentIntent(pendingIntent)
+ .setPriority(Notification.PRIORITY_HIGH)
.build();
mNotificationManager.notify(id, notification);
SystemClock.sleep(10);
}
+
+ private boolean isLockScreen() {
+ KeyguardManager myKM = (KeyguardManager) mContext
+ .getSystemService(Context.KEYGUARD_SERVICE);
+ if (myKM.inKeyguardRestrictedInputMode()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
}
diff --git a/graphics/java/android/graphics/FontFamily.java b/graphics/java/android/graphics/FontFamily.java
index f741e3c..e48bf79 100644
--- a/graphics/java/android/graphics/FontFamily.java
+++ b/graphics/java/android/graphics/FontFamily.java
@@ -17,8 +17,12 @@
package android.graphics;
import android.content.res.AssetManager;
+import android.util.Log;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
import java.util.List;
/**
@@ -27,6 +31,9 @@
* @hide
*/
public class FontFamily {
+
+ private static String TAG = "FontFamily";
+
/**
* @hide
*/
@@ -62,7 +69,15 @@
}
public boolean addFont(String path, int ttcIndex) {
- return nAddFont(mNativePtr, path, ttcIndex);
+ try (FileInputStream file = new FileInputStream(path)) {
+ FileChannel fileChannel = file.getChannel();
+ long fontSize = fileChannel.size();
+ ByteBuffer fontBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fontSize);
+ return nAddFont(mNativePtr, fontBuffer, ttcIndex);
+ } catch (IOException e) {
+ Log.e(TAG, "Error mapping font file " + path);
+ return false;
+ }
}
public boolean addFontWeightStyle(ByteBuffer font, int ttcIndex, List<FontListParser.Axis> axes,
@@ -76,7 +91,7 @@
private static native long nCreateFamily(String lang, int variant);
private static native void nUnrefFamily(long nativePtr);
- private static native boolean nAddFont(long nativeFamily, String path, int ttcIndex);
+ private static native boolean nAddFont(long nativeFamily, ByteBuffer font, int ttcIndex);
private static native boolean nAddFontWeightStyle(long nativeFamily, ByteBuffer font,
int ttcIndex, List<FontListParser.Axis> listOfAxis,
int weight, boolean isItalic);
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index be816f7..0606b0b 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -248,16 +248,17 @@
tests/unit/FatVectorTests.cpp \
tests/unit/GlopBuilderTests.cpp \
tests/unit/GpuMemoryTrackerTests.cpp \
+ tests/unit/GradientCacheTests.cpp \
tests/unit/LayerUpdateQueueTests.cpp \
tests/unit/LinearAllocatorTests.cpp \
tests/unit/MatrixTests.cpp \
tests/unit/OffscreenBufferPoolTests.cpp \
tests/unit/RenderNodeTests.cpp \
tests/unit/SkiaBehaviorTests.cpp \
+ tests/unit/SnapshotTests.cpp \
tests/unit/StringUtilsTests.cpp \
tests/unit/TextDropShadowCacheTests.cpp \
- tests/unit/VectorDrawableTests.cpp \
- tests/unit/GradientCacheTests.cpp
+ tests/unit/VectorDrawableTests.cpp
ifeq (true, $(HWUI_NEW_OPS))
LOCAL_SRC_FILES += \
diff --git a/libs/hwui/BakedOpState.cpp b/libs/hwui/BakedOpState.cpp
index b70d586..9f98241 100644
--- a/libs/hwui/BakedOpState.cpp
+++ b/libs/hwui/BakedOpState.cpp
@@ -50,7 +50,7 @@
}
// resolvedClipRect = intersect(parentMatrix * localClip, parentClip)
- clipState = snapshot.mutateClipArea().serializeIntersectedClip(allocator,
+ clipState = snapshot.serializeIntersectedClip(allocator,
recordedOp.localClip, *(snapshot.transform));
LOG_ALWAYS_FATAL_IF(!clipState, "must clip!");
@@ -85,8 +85,7 @@
ResolvedRenderState::ResolvedRenderState(LinearAllocator& allocator, Snapshot& snapshot,
const Matrix4& localTransform, const ClipBase* localClip) {
transform.loadMultiply(*snapshot.transform, localTransform);
- clipState = snapshot.mutateClipArea().serializeIntersectedClip(allocator,
- localClip, *(snapshot.transform));
+ clipState = snapshot.serializeIntersectedClip(allocator, localClip, *(snapshot.transform));
clippedBounds = clipState->rect;
clipSideFlags = OpClipSideFlags::Full;
localProjectionPathMask = nullptr;
diff --git a/libs/hwui/ClipArea.cpp b/libs/hwui/ClipArea.cpp
index f886dda..35fe06d 100644
--- a/libs/hwui/ClipArea.cpp
+++ b/libs/hwui/ClipArea.cpp
@@ -217,6 +217,7 @@
void ClipArea::clipRectWithTransform(const Rect& r, const mat4* transform,
SkRegion::Op op) {
+ if (op == SkRegion::kReplace_Op) mReplaceOpObserved = true;
if (!mPostViewportClipObserved && op == SkRegion::kIntersect_Op) op = SkRegion::kReplace_Op;
onClipUpdated();
switch (mMode) {
@@ -233,6 +234,7 @@
}
void ClipArea::clipRegion(const SkRegion& region, SkRegion::Op op) {
+ if (op == SkRegion::kReplace_Op) mReplaceOpObserved = true;
if (!mPostViewportClipObserved && op == SkRegion::kIntersect_Op) op = SkRegion::kReplace_Op;
onClipUpdated();
enterRegionMode();
@@ -242,6 +244,7 @@
void ClipArea::clipPathWithTransform(const SkPath& path, const mat4* transform,
SkRegion::Op op) {
+ if (op == SkRegion::kReplace_Op) mReplaceOpObserved = true;
if (!mPostViewportClipObserved && op == SkRegion::kIntersect_Op) op = SkRegion::kReplace_Op;
onClipUpdated();
SkMatrix skTransform;
@@ -379,6 +382,7 @@
serialization->rect.set(mClipRegion.getBounds());
break;
}
+ serialization->intersectWithRoot = mReplaceOpObserved;
// TODO: this is only done for draw time, should eventually avoid for record time
serialization->rect.snapToPixelBoundaries();
mLastSerialization = serialization;
diff --git a/libs/hwui/ClipArea.h b/libs/hwui/ClipArea.h
index 1654eb8..6eb2eef 100644
--- a/libs/hwui/ClipArea.h
+++ b/libs/hwui/ClipArea.h
@@ -103,6 +103,7 @@
: mode(ClipMode::Rectangle)
, rect(rect) {}
const ClipMode mode;
+ bool intersectWithRoot = false;
// Bounds of the clipping area, used to define the scissor, and define which
// portion of the stencil is updated/used
Rect rect;
@@ -173,8 +174,8 @@
return mMode == ClipMode::RectangleList;
}
- const ClipBase* serializeClip(LinearAllocator& allocator);
- const ClipBase* serializeIntersectedClip(LinearAllocator& allocator,
+ WARN_UNUSED_RESULT const ClipBase* serializeClip(LinearAllocator& allocator);
+ WARN_UNUSED_RESULT const ClipBase* serializeIntersectedClip(LinearAllocator& allocator,
const ClipBase* recordedClip, const Matrix4& recordedClipTransform);
void applyClip(const ClipBase* recordedClip, const Matrix4& recordedClipTransform);
@@ -214,6 +215,7 @@
ClipMode mMode;
bool mPostViewportClipObserved = false;
+ bool mReplaceOpObserved = false;
/**
* If mLastSerialization is non-null, it represents an already serialized copy
diff --git a/libs/hwui/FrameBuilder.cpp b/libs/hwui/FrameBuilder.cpp
index 0401f2d..f12e523 100644
--- a/libs/hwui/FrameBuilder.cpp
+++ b/libs/hwui/FrameBuilder.cpp
@@ -462,7 +462,7 @@
int count = mCanvasState.save(SaveFlags::MatrixClip);
// apply state from RecordedOp (clip first, since op's clip is transformed by current matrix)
- mCanvasState.writableSnapshot()->mutateClipArea().applyClip(op.localClip,
+ mCanvasState.writableSnapshot()->applyClip(op.localClip,
*mCanvasState.currentSnapshot()->transform);
mCanvasState.concatMatrix(op.localMatrix);
diff --git a/libs/hwui/OpDumper.cpp b/libs/hwui/OpDumper.cpp
index c34cfbe..cab93e8 100644
--- a/libs/hwui/OpDumper.cpp
+++ b/libs/hwui/OpDumper.cpp
@@ -33,10 +33,15 @@
op.localMatrix.mapRect(localBounds);
output << sOpNameLut[op.opId] << " " << localBounds;
- if (op.localClip && !op.localClip->rect.contains(localBounds)) {
+ if (op.localClip
+ && (!op.localClip->rect.contains(localBounds) || op.localClip->intersectWithRoot)) {
output << std::fixed << std::setprecision(0)
<< " clip=" << op.localClip->rect
<< " mode=" << (int)op.localClip->mode;
+
+ if (op.localClip->intersectWithRoot) {
+ output << " iwr";
+ }
}
}
diff --git a/libs/hwui/PathParser.cpp b/libs/hwui/PathParser.cpp
index 4e9ac9c..7e85333 100644
--- a/libs/hwui/PathParser.cpp
+++ b/libs/hwui/PathParser.cpp
@@ -156,6 +156,12 @@
return;
}
+bool PathParser::isVerbValid(char verb) {
+ verb = tolower(verb);
+ return verb == 'a' || verb == 'c' || verb == 'h' || verb == 'l' || verb == 'm' || verb == 'q'
+ || verb == 's' || verb == 't' || verb == 'v' || verb == 'z';
+}
+
void PathParser::getPathDataFromString(PathData* data, ParseResult* result,
const char* pathStr, size_t strLen) {
if (pathStr == NULL) {
@@ -171,6 +177,12 @@
end = nextStart(pathStr, strLen, end);
std::vector<float> points;
getFloats(&points, result, pathStr, start, end);
+ if (!isVerbValid(pathStr[start])) {
+ result->failureOccurred = true;
+ result->failureMessage = "Invalid pathData. Failure occurred at position "
+ + std::to_string(start) + " of path: " + pathStr;
+ }
+ // If either verb or points is not valid, return immediately.
if (result->failureOccurred) {
return;
}
@@ -182,10 +194,15 @@
}
if ((end - start) == 1 && start < strLen) {
+ if (!isVerbValid(pathStr[start])) {
+ result->failureOccurred = true;
+ result->failureMessage = "Invalid pathData. Failure occurred at position "
+ + std::to_string(start) + " of path: " + pathStr;
+ return;
+ }
data->verbs.push_back(pathStr[start]);
data->verbSizes.push_back(0);
}
- return;
}
void PathParser::dump(const PathData& data) {
@@ -218,7 +235,8 @@
// Check if there is valid data coming out of parsing the string.
if (pathData.verbs.size() == 0) {
result->failureOccurred = true;
- result->failureMessage = "No verbs found in the string for pathData";
+ result->failureMessage = "No verbs found in the string for pathData: ";
+ result->failureMessage += pathStr;
return;
}
VectorDrawableUtils::verbsToPath(skPath, pathData);
diff --git a/libs/hwui/PathParser.h b/libs/hwui/PathParser.h
index c4bbb74..180a7a3 100644
--- a/libs/hwui/PathParser.h
+++ b/libs/hwui/PathParser.h
@@ -44,6 +44,7 @@
ANDROID_API static void getPathDataFromString(PathData* outData, ParseResult* result,
const char* pathStr, size_t strLength);
static void dump(const PathData& data);
+ static bool isVerbValid(char verb);
};
}; // namespace uirenderer
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 9578486..ea06fcd 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -81,14 +81,14 @@
#endif
}
-void RenderNode::setStagingDisplayList(DisplayList* displayList) {
+void RenderNode::setStagingDisplayList(DisplayList* displayList, TreeObserver* observer) {
mNeedsDisplayListSync = true;
delete mStagingDisplayList;
mStagingDisplayList = displayList;
// If mParentCount == 0 we are the sole reference to this RenderNode,
// so immediately free the old display list
if (!mParentCount && !mStagingDisplayList) {
- deleteDisplayList(nullptr);
+ deleteDisplayList(observer);
}
}
diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h
index b0136cf..acdc3d8 100644
--- a/libs/hwui/RenderNode.h
+++ b/libs/hwui/RenderNode.h
@@ -117,7 +117,7 @@
void debugDumpLayers(const char* prefix);
- ANDROID_API void setStagingDisplayList(DisplayList* newData);
+ ANDROID_API void setStagingDisplayList(DisplayList* newData, TreeObserver* observer);
void computeOrdering();
diff --git a/libs/hwui/Snapshot.cpp b/libs/hwui/Snapshot.cpp
index d784280..2c9c9d9 100644
--- a/libs/hwui/Snapshot.cpp
+++ b/libs/hwui/Snapshot.cpp
@@ -242,6 +242,33 @@
#endif
}
+static Snapshot* getClipRoot(Snapshot* target) {
+ while (target->previous && target->previous->previous) {
+ target = target->previous;
+ }
+ return target;
+}
+
+const ClipBase* Snapshot::serializeIntersectedClip(LinearAllocator& allocator,
+ const ClipBase* recordedClip, const Matrix4& recordedClipTransform) {
+ auto target = this;
+ if (CC_UNLIKELY(recordedClip && recordedClip->intersectWithRoot)) {
+ // Clip must be intersected with root, instead of current clip.
+ target = getClipRoot(this);
+ }
+
+ return target->mClipArea->serializeIntersectedClip(allocator,
+ recordedClip, recordedClipTransform);
+}
+
+void Snapshot::applyClip(const ClipBase* recordedClip, const Matrix4& transform) {
+ if (CC_UNLIKELY(recordedClip && recordedClip->intersectWithRoot)) {
+ // current clip is being replaced, but must intersect with clip root
+ *mClipArea = *(getClipRoot(this)->mClipArea);
+ }
+ mClipArea->applyClip(recordedClip, transform);
+}
+
///////////////////////////////////////////////////////////////////////////////
// Queries
///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index 3a01d04..d8f926e 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -170,6 +170,10 @@
const ClipArea& getClipArea() const { return *mClipArea; }
ClipArea& mutateClipArea() { return *mClipArea; }
+ WARN_UNUSED_RESULT const ClipBase* serializeIntersectedClip(LinearAllocator& allocator,
+ const ClipBase* recordedClip, const Matrix4& recordedClipTransform);
+ void applyClip(const ClipBase* clip, const Matrix4& transform);
+
/**
* Resets the clip to the specified rect.
*/
diff --git a/libs/hwui/hwui/MinikinSkia.cpp b/libs/hwui/hwui/MinikinSkia.cpp
index b9e3358..b39de26 100644
--- a/libs/hwui/hwui/MinikinSkia.cpp
+++ b/libs/hwui/hwui/MinikinSkia.cpp
@@ -22,8 +22,9 @@
namespace android {
-MinikinFontSkia::MinikinFontSkia(SkTypeface *typeface) :
- mTypeface(typeface) {
+MinikinFontSkia::MinikinFontSkia(SkTypeface* typeface, const void* fontData, size_t fontSize,
+ int ttcIndex) :
+ mTypeface(typeface), mFontData(fontData), mFontSize(fontSize), mTtcIndex(ttcIndex) {
}
MinikinFontSkia::~MinikinFontSkia() {
@@ -66,22 +67,38 @@
bounds->mBottom = skBounds.fBottom;
}
-bool MinikinFontSkia::GetTable(uint32_t tag, uint8_t *buf, size_t *size) {
- if (buf == NULL) {
- const size_t tableSize = mTypeface->getTableSize(tag);
- *size = tableSize;
- return tableSize != 0;
- } else {
- const size_t actualSize = mTypeface->getTableData(tag, 0, *size, buf);
- *size = actualSize;
- return actualSize != 0;
+const void* MinikinFontSkia::GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy) {
+ // we don't have a buffer to the font data, copy to own buffer
+ const size_t tableSize = mTypeface->getTableSize(tag);
+ *size = tableSize;
+ if (tableSize == 0) {
+ return nullptr;
}
+ void* buf = malloc(tableSize);
+ if (buf == nullptr) {
+ return nullptr;
+ }
+ mTypeface->getTableData(tag, 0, tableSize, buf);
+ *destroy = free;
+ return buf;
}
SkTypeface *MinikinFontSkia::GetSkTypeface() const {
return mTypeface;
}
+const void* MinikinFontSkia::GetFontData() const {
+ return mFontData;
+}
+
+size_t MinikinFontSkia::GetFontSize() const {
+ return mFontSize;
+}
+
+int MinikinFontSkia::GetFontIndex() const {
+ return mTtcIndex;
+}
+
int32_t MinikinFontSkia::GetUniqueId() const {
return mTypeface->uniqueID();
}
diff --git a/libs/hwui/hwui/MinikinSkia.h b/libs/hwui/hwui/MinikinSkia.h
index 1d50168..dbc65f9 100644
--- a/libs/hwui/hwui/MinikinSkia.h
+++ b/libs/hwui/hwui/MinikinSkia.h
@@ -28,7 +28,8 @@
class ANDROID_API MinikinFontSkia : public MinikinFont {
public:
// Note: this takes ownership of the reference (will unref on dtor)
- explicit MinikinFontSkia(SkTypeface *typeface);
+ explicit MinikinFontSkia(SkTypeface *typeface, const void* fontData, size_t fontSize,
+ int ttcIndex);
~MinikinFontSkia();
@@ -38,20 +39,30 @@
void GetBounds(MinikinRect* bounds, uint32_t glyph_id,
const MinikinPaint &paint) const;
- // If buf is NULL, just update size
- bool GetTable(uint32_t tag, uint8_t *buf, size_t *size);
+ const void* GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy);
int32_t GetUniqueId() const;
SkTypeface* GetSkTypeface() const;
+ // Access to underlying raw font bytes
+ const void* GetFontData() const;
+ size_t GetFontSize() const;
+ int GetFontIndex() const;
+
static uint32_t packPaintFlags(const SkPaint* paint);
static void unpackPaintFlags(SkPaint* paint, uint32_t paintFlags);
// set typeface and fake bold/italic parameters
static void populateSkPaint(SkPaint* paint, const MinikinFont* font, FontFakery fakery);
private:
- SkTypeface *mTypeface;
+ SkTypeface* mTypeface;
+
+ // A raw pointer to the font data - it should be owned by some other object with
+ // lifetime at least as long as this object.
+ const void* mFontData;
+ size_t mFontSize;
+ int mTtcIndex;
};
} // namespace android
diff --git a/libs/hwui/hwui/Typeface.cpp b/libs/hwui/hwui/Typeface.cpp
index fa8ad5d..c583988 100644
--- a/libs/hwui/hwui/Typeface.cpp
+++ b/libs/hwui/hwui/Typeface.cpp
@@ -66,7 +66,10 @@
ALOGD("makeFontCollection adding %s", fn);
SkTypeface *skFace = SkTypeface::CreateFromFile(fn);
if (skFace != NULL) {
- MinikinFont *font = new MinikinFontSkia(skFace);
+ // TODO: might be a nice optimization to get access to the underlying font
+ // data, but would require us opening the file ourselves and passing that
+ // to the appropriate Create method of SkTypeface.
+ MinikinFont *font = new MinikinFontSkia(skFace, NULL, 0, 0);
family->addFont(font);
font->Unref();
} else {
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 63fa788..890d4a1 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -76,15 +76,15 @@
}
CanvasContext::~CanvasContext() {
- destroy();
+ destroy(nullptr);
mRenderThread.renderState().unregisterCanvasContext(this);
}
-void CanvasContext::destroy() {
+void CanvasContext::destroy(TreeObserver* observer) {
stopDrawing();
setSurface(nullptr);
- freePrefetechedLayers();
- destroyHardwareResources();
+ freePrefetchedLayers(observer);
+ destroyHardwareResources(observer);
mAnimationContext->destroy();
#if !HWUI_NEW_OPS
if (mCanvas) {
@@ -113,18 +113,11 @@
mBufferPreserved = mEglManager.setPreserveBuffer(mEglSurface, preserveBuffer);
mHaveNewSurface = true;
mSwapHistory.clear();
- makeCurrent();
} else {
mRenderThread.removeFrameCallback(this);
}
}
-void CanvasContext::requireSurface() {
- LOG_ALWAYS_FATAL_IF(mEglSurface == EGL_NO_SURFACE,
- "requireSurface() called but no surface set!");
- makeCurrent();
-}
-
void CanvasContext::setSwapBehavior(SwapBehavior swapBehavior) {
mSwapBehavior = swapBehavior;
}
@@ -146,6 +139,18 @@
return mRenderThread.removeFrameCallback(this);
}
+void CanvasContext::setStopped(bool stopped) {
+ if (mStopped != stopped) {
+ mStopped = stopped;
+ if (mStopped) {
+ mRenderThread.removeFrameCallback(this);
+ if (mEglManager.isCurrent(mEglSurface)) {
+ mEglManager.makeCurrent(EGL_NO_SURFACE);
+ }
+ }
+ }
+}
+
// TODO: don't pass viewport size, it's automatic via EGL
void CanvasContext::setup(int width, int height, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) {
@@ -172,7 +177,9 @@
mOpaque = opaque;
}
-void CanvasContext::makeCurrent() {
+bool CanvasContext::makeCurrent() {
+ if (mStopped) return false;
+
// TODO: Figure out why this workaround is needed, see b/13913604
// In the meantime this matches the behavior of GLRenderer, so it is not a regression
EGLint error = 0;
@@ -180,6 +187,7 @@
if (error) {
setSurface(nullptr);
}
+ return !error;
}
static bool wasSkipped(FrameInfo* info) {
@@ -222,7 +230,7 @@
mAnimationContext->runRemainingAnimations(info);
GL_CHECKPOINT(MODERATE);
- freePrefetechedLayers();
+ freePrefetchedLayers(info.observer);
GL_CHECKPOINT(MODERATE);
if (CC_UNLIKELY(!mNativeSurface.get())) {
@@ -569,25 +577,24 @@
}
void CanvasContext::markLayerInUse(RenderNode* node) {
- if (mPrefetechedLayers.erase(node)) {
+ if (mPrefetchedLayers.erase(node)) {
node->decStrong(nullptr);
}
}
-static void destroyPrefetechedNode(RenderNode* node) {
- ALOGW("Incorrectly called buildLayer on View: %s, destroying layer...", node->getName());
- node->destroyHardwareResources(nullptr);
- node->decStrong(nullptr);
-}
-
-void CanvasContext::freePrefetechedLayers() {
- if (mPrefetechedLayers.size()) {
- std::for_each(mPrefetechedLayers.begin(), mPrefetechedLayers.end(), destroyPrefetechedNode);
- mPrefetechedLayers.clear();
+void CanvasContext::freePrefetchedLayers(TreeObserver* observer) {
+ if (mPrefetchedLayers.size()) {
+ for (auto& node : mPrefetchedLayers) {
+ ALOGW("Incorrectly called buildLayer on View: %s, destroying layer...",
+ node->getName());
+ node->destroyHardwareResources(observer);
+ node->decStrong(observer);
+ }
+ mPrefetchedLayers.clear();
}
}
-void CanvasContext::buildLayer(RenderNode* node) {
+void CanvasContext::buildLayer(RenderNode* node, TreeObserver* observer) {
ATRACE_CALL();
if (!mEglManager.hasEglContext()) return;
#if !HWUI_NEW_OPS
@@ -599,6 +606,7 @@
TreeInfo info(TreeInfo::MODE_FULL, *this);
info.damageAccumulator = &mDamageAccumulator;
+ info.observer = observer;
#if HWUI_NEW_OPS
info.layerUpdateQueue = &mLayerUpdateQueue;
#else
@@ -628,7 +636,7 @@
#endif
node->incStrong(nullptr);
- mPrefetechedLayers.insert(node);
+ mPrefetchedLayers.insert(node);
}
bool CanvasContext::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) {
@@ -636,12 +644,12 @@
return LayerRenderer::copyLayer(mRenderThread.renderState(), layer->backingLayer(), bitmap);
}
-void CanvasContext::destroyHardwareResources() {
+void CanvasContext::destroyHardwareResources(TreeObserver* observer) {
stopDrawing();
if (mEglManager.hasEglContext()) {
- freePrefetechedLayers();
+ freePrefetchedLayers(observer);
for (const sp<RenderNode>& node : mRenderNodes) {
- node->destroyHardwareResources(nullptr);
+ node->destroyHardwareResources(observer);
}
Caches& caches = Caches::getInstance();
// Make sure to release all the textures we were owning as there won't
@@ -671,7 +679,7 @@
}
Layer* CanvasContext::createTextureLayer() {
- requireSurface();
+ mEglManager.initialize();
return LayerRenderer::createTextureLayer(mRenderThread.renderState());
}
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index 6d0889e..52df3abe 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -82,27 +82,28 @@
void initialize(Surface* surface);
void updateSurface(Surface* surface);
bool pauseSurface(Surface* surface);
+ void setStopped(bool stopped);
bool hasSurface() { return mNativeSurface.get(); }
void setup(int width, int height, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
void setLightCenter(const Vector3& lightCenter);
void setOpaque(bool opaque);
- void makeCurrent();
+ bool makeCurrent();
void prepareTree(TreeInfo& info, int64_t* uiFrameInfo,
int64_t syncQueued, RenderNode* target);
void draw();
- void destroy();
+ void destroy(TreeObserver* observer);
// IFrameCallback, Choreographer-driven frame callback entry point
virtual void doFrame() override;
void prepareAndDraw(RenderNode* node);
- void buildLayer(RenderNode* node);
+ void buildLayer(RenderNode* node, TreeObserver* observer);
bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap);
void markLayerInUse(RenderNode* node);
- void destroyHardwareResources();
+ void destroyHardwareResources(TreeObserver* observer);
static void trimMemory(RenderThread& thread, int level);
static void invokeFunctor(RenderThread& thread, Functor* functor);
@@ -172,9 +173,8 @@
friend class android::uirenderer::RenderState;
void setSurface(Surface* window);
- void requireSurface();
- void freePrefetechedLayers();
+ void freePrefetchedLayers(TreeObserver* observer);
void waitOnFences();
@@ -185,6 +185,7 @@
EglManager& mEglManager;
sp<Surface> mNativeSurface;
EGLSurface mEglSurface = EGL_NO_SURFACE;
+ bool mStopped = false;
bool mBufferPreserved = false;
SwapBehavior mSwapBehavior = kSwap_default;
struct SwapHistory {
@@ -218,7 +219,7 @@
FrameInfoVisualizer mProfiler;
std::unique_ptr<FrameMetricsReporter> mFrameMetricsReporter;
- std::set<RenderNode*> mPrefetechedLayers;
+ std::set<RenderNode*> mPrefetchedLayers;
// Stores the bounds of the main content.
Rect mContentDrawBounds;
diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp
index e8b9725..ed472ac 100644
--- a/libs/hwui/renderthread/DrawFrameTask.cpp
+++ b/libs/hwui/renderthread/DrawFrameTask.cpp
@@ -65,11 +65,12 @@
}
}
-int DrawFrameTask::drawFrame() {
+int DrawFrameTask::drawFrame(TreeObserver* observer) {
LOG_ALWAYS_FATAL_IF(!mContext, "Cannot drawFrame with no CanvasContext!");
mSyncResult = kSync_OK;
mSyncQueued = systemTime(CLOCK_MONOTONIC);
+ mObserver = observer;
postAndWait();
return mSyncResult;
@@ -88,6 +89,7 @@
bool canDrawThisFrame;
{
TreeInfo info(TreeInfo::MODE_FULL, *mContext);
+ info.observer = mObserver;
canUnblockUiThread = syncFrameState(info);
canDrawThisFrame = info.out.canDrawThisFrame;
}
@@ -113,7 +115,7 @@
ATRACE_CALL();
int64_t vsync = mFrameInfo[static_cast<int>(FrameInfoIndex::Vsync)];
mRenderThread->timeLord().vsyncReceived(vsync);
- mContext->makeCurrent();
+ bool canDraw = mContext->makeCurrent();
Caches::getInstance().textureCache.resetMarkInUse(mContext);
for (size_t i = 0; i < mLayers.size(); i++) {
@@ -124,8 +126,9 @@
// This is after the prepareTree so that any pending operations
// (RenderNode tree state, prefetched layers, etc...) will be flushed.
- if (CC_UNLIKELY(!mContext->hasSurface())) {
+ if (CC_UNLIKELY(!mContext->hasSurface() || !canDraw)) {
mSyncResult |= kSync_LostSurfaceRewardIfFound;
+ info.out.canDrawThisFrame = false;
}
if (info.out.hasAnimations) {
diff --git a/libs/hwui/renderthread/DrawFrameTask.h b/libs/hwui/renderthread/DrawFrameTask.h
index cae251a9..9bba065 100644
--- a/libs/hwui/renderthread/DrawFrameTask.h
+++ b/libs/hwui/renderthread/DrawFrameTask.h
@@ -62,7 +62,7 @@
void pushLayerUpdate(DeferredLayerUpdater* layer);
void removeLayerUpdate(DeferredLayerUpdater* layer);
- int drawFrame();
+ int drawFrame(TreeObserver* observer);
int64_t* frameInfo() { return mFrameInfo; }
@@ -87,6 +87,7 @@
int mSyncResult;
int64_t mSyncQueued;
+ TreeObserver* mObserver;
int64_t mFrameInfo[UI_THREAD_FRAME_INFO_SIZE];
};
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index 8def7ad..ac6a28f 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -270,12 +270,6 @@
// Ensure we always have a valid surface & context
surface = mPBufferSurface;
}
- // TODO: Temporary to help diagnose b/27286867
- if (mCurrentSurface == mPBufferSurface || surface == mPBufferSurface) {
- ALOGD("Switching from surface %p%s to %p%s", mCurrentSurface,
- mCurrentSurface == mPBufferSurface ? " (pbuffer)" : "",
- surface, surface == mPBufferSurface ? " (pbuffer)" : "");
- }
if (!eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
if (errOut) {
*errOut = eglGetError();
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 16dd108..c5a2dc7 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -52,14 +52,6 @@
MethodInvokeRenderTask* task = new MethodInvokeRenderTask((RunnableMethod) Bridge_ ## method); \
ARGS(method) *args = (ARGS(method) *) task->payload()
-namespace DumpFlags {
- enum {
- FrameStats = 1 << 0,
- Reset = 1 << 1,
- JankStats = 1 << 2,
- };
-};
-
CREATE_BRIDGE4(createContext, RenderThread* thread, bool translucent,
RenderNode* rootRenderNode, IContextFactory* contextFactory) {
return new CanvasContext(*args->thread, args->translucent,
@@ -175,6 +167,18 @@
return (bool) postAndWait(task);
}
+CREATE_BRIDGE2(setStopped, CanvasContext* context, bool stopped) {
+ args->context->setStopped(args->stopped);
+ return nullptr;
+}
+
+void RenderProxy::setStopped(bool stopped) {
+ SETUP_TASK(setStopped);
+ args->context = mContext;
+ args->stopped = stopped;
+ postAndWait(task);
+}
+
CREATE_BRIDGE6(setup, CanvasContext* context, int width, int height,
float lightRadius, uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) {
args->context->setup(args->width, args->height, args->lightRadius,
@@ -222,18 +226,19 @@
return mDrawFrameTask.frameInfo();
}
-int RenderProxy::syncAndDrawFrame() {
- return mDrawFrameTask.drawFrame();
+int RenderProxy::syncAndDrawFrame(TreeObserver* observer) {
+ return mDrawFrameTask.drawFrame(observer);
}
-CREATE_BRIDGE1(destroy, CanvasContext* context) {
- args->context->destroy();
+CREATE_BRIDGE2(destroy, CanvasContext* context, TreeObserver* observer) {
+ args->context->destroy(args->observer);
return nullptr;
}
-void RenderProxy::destroy() {
+void RenderProxy::destroy(TreeObserver* observer) {
SETUP_TASK(destroy);
args->context = mContext;
+ args->observer = observer;
// destroyCanvasAndSurface() needs a fence as when it returns the
// underlying BufferQueue is going to be released from under
// the render thread.
@@ -287,15 +292,16 @@
return layer;
}
-CREATE_BRIDGE2(buildLayer, CanvasContext* context, RenderNode* node) {
- args->context->buildLayer(args->node);
+CREATE_BRIDGE3(buildLayer, CanvasContext* context, RenderNode* node, TreeObserver* observer) {
+ args->context->buildLayer(args->node, args->observer);
return nullptr;
}
-void RenderProxy::buildLayer(RenderNode* node) {
+void RenderProxy::buildLayer(RenderNode* node, TreeObserver* observer) {
SETUP_TASK(buildLayer);
args->context = mContext;
args->node = node;
+ args->observer = observer;
postAndWait(task);
}
@@ -332,15 +338,16 @@
postAndWait(task);
}
-CREATE_BRIDGE1(destroyHardwareResources, CanvasContext* context) {
- args->context->destroyHardwareResources();
+CREATE_BRIDGE2(destroyHardwareResources, CanvasContext* context, TreeObserver* observer) {
+ args->context->destroyHardwareResources(args->observer);
return nullptr;
}
-void RenderProxy::destroyHardwareResources() {
+void RenderProxy::destroyHardwareResources(TreeObserver* observer) {
SETUP_TASK(destroyHardwareResources);
args->context = mContext;
- post(task);
+ args->observer = observer;
+ postAndWait(task);
}
CREATE_BRIDGE2(trimMemory, RenderThread* thread, int level) {
@@ -422,6 +429,9 @@
if (args->dumpFlags & DumpFlags::Reset) {
args->context->resetFrameStats();
}
+ if (args->dumpFlags & DumpFlags::JankStats) {
+ args->thread->jankTracker().dump(args->fd);
+ }
return nullptr;
}
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index 8d65a82..32d3283 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -42,6 +42,7 @@
class DisplayList;
class Layer;
class Rect;
+class TreeObserver;
namespace renderthread {
@@ -49,6 +50,14 @@
class RenderThread;
class RenderProxyBridge;
+namespace DumpFlags {
+ enum {
+ FrameStats = 1 << 0,
+ Reset = 1 << 1,
+ JankStats = 1 << 2,
+ };
+};
+
/*
* RenderProxy is strictly single threaded. All methods must be invoked on the owning
* thread. It is important to note that RenderProxy may be deleted while it has
@@ -70,26 +79,27 @@
ANDROID_API void initialize(const sp<Surface>& surface);
ANDROID_API void updateSurface(const sp<Surface>& surface);
ANDROID_API bool pauseSurface(const sp<Surface>& surface);
+ ANDROID_API void setStopped(bool stopped);
ANDROID_API void setup(int width, int height, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
ANDROID_API void setLightCenter(const Vector3& lightCenter);
ANDROID_API void setOpaque(bool opaque);
ANDROID_API int64_t* frameInfo();
- ANDROID_API int syncAndDrawFrame();
- ANDROID_API void destroy();
+ ANDROID_API int syncAndDrawFrame(TreeObserver* observer);
+ ANDROID_API void destroy(TreeObserver* observer);
ANDROID_API static void invokeFunctor(Functor* functor, bool waitForCompletion);
ANDROID_API void runWithGlContext(RenderTask* task);
ANDROID_API DeferredLayerUpdater* createTextureLayer();
- ANDROID_API void buildLayer(RenderNode* node);
+ ANDROID_API void buildLayer(RenderNode* node, TreeObserver* observer);
ANDROID_API bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap& bitmap);
ANDROID_API void pushLayerUpdate(DeferredLayerUpdater* layer);
ANDROID_API void cancelLayerUpdate(DeferredLayerUpdater* layer);
ANDROID_API void detachSurfaceTexture(DeferredLayerUpdater* layer);
- ANDROID_API void destroyHardwareResources();
+ ANDROID_API void destroyHardwareResources(TreeObserver* observer);
ANDROID_API static void trimMemory(int level);
ANDROID_API static void overrideProperty(const char* name, const char* value);
diff --git a/libs/hwui/tests/common/TestUtils.h b/libs/hwui/tests/common/TestUtils.h
index 5492035..5f4ebc0 100644
--- a/libs/hwui/tests/common/TestUtils.h
+++ b/libs/hwui/tests/common/TestUtils.h
@@ -146,7 +146,7 @@
if (setup) {
TestCanvas canvas(props.getWidth(), props.getHeight());
setup(props, canvas);
- node->setStagingDisplayList(canvas.finishRecording());
+ node->setStagingDisplayList(canvas.finishRecording(), nullptr);
}
node->setPropertyFieldsDirty(0xFFFFFFFF);
return node;
@@ -157,7 +157,7 @@
TestCanvas canvas(node.stagingProperties().getWidth(),
node.stagingProperties().getHeight());
contentCallback(canvas);
- node.setStagingDisplayList(canvas.finishRecording());
+ node.setStagingDisplayList(canvas.finishRecording(), nullptr);
}
/**
diff --git a/libs/hwui/tests/common/scenes/GlyphStressAnimation.cpp b/libs/hwui/tests/common/scenes/GlyphStressAnimation.cpp
index 63c067b..f184411 100644
--- a/libs/hwui/tests/common/scenes/GlyphStressAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/GlyphStressAnimation.cpp
@@ -59,6 +59,6 @@
0, 100 * (i + 2), kBidi_Force_LTR, paint, nullptr);
}
- container->setStagingDisplayList(canvas.finishRecording());
+ container->setStagingDisplayList(canvas.finishRecording(), nullptr);
}
};
diff --git a/libs/hwui/tests/common/scenes/ListViewAnimation.cpp b/libs/hwui/tests/common/scenes/ListViewAnimation.cpp
index ab368c05..8035dc4 100644
--- a/libs/hwui/tests/common/scenes/ListViewAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/ListViewAnimation.cpp
@@ -76,7 +76,7 @@
// draw it to parent DisplayList
canvas.drawRenderNode(cards[ci].get());
}
- listView->setStagingDisplayList(canvas.finishRecording());
+ listView->setStagingDisplayList(canvas.finishRecording(), nullptr);
}
private:
SkBitmap createRandomCharIcon() {
diff --git a/libs/hwui/tests/macrobench/TestSceneRunner.cpp b/libs/hwui/tests/macrobench/TestSceneRunner.cpp
index 58c0876..c5af061 100644
--- a/libs/hwui/tests/macrobench/TestSceneRunner.cpp
+++ b/libs/hwui/tests/macrobench/TestSceneRunner.cpp
@@ -95,7 +95,7 @@
testContext.waitForVsync();
nsecs_t vsync = systemTime(CLOCK_MONOTONIC);
UiFrameInfoBuilder(proxy->frameInfo()).setVsync(vsync, vsync);
- proxy->syncAndDrawFrame();
+ proxy->syncAndDrawFrame(nullptr);
}
proxy->resetProfileInfo();
@@ -110,7 +110,7 @@
ATRACE_NAME("UI-Draw Frame");
UiFrameInfoBuilder(proxy->frameInfo()).setVsync(vsync, vsync);
scene->doFrame(i);
- proxy->syncAndDrawFrame();
+ proxy->syncAndDrawFrame(nullptr);
}
if (opts.reportFrametimeWeight) {
proxy->fence();
@@ -122,5 +122,5 @@
}
}
- proxy->dumpProfileInfo(STDOUT_FILENO, 0);
+ proxy->dumpProfileInfo(STDOUT_FILENO, DumpFlags::JankStats);
}
diff --git a/libs/hwui/tests/unit/ClipAreaTests.cpp b/libs/hwui/tests/unit/ClipAreaTests.cpp
index 822d04f..b864703 100644
--- a/libs/hwui/tests/unit/ClipAreaTests.cpp
+++ b/libs/hwui/tests/unit/ClipAreaTests.cpp
@@ -132,8 +132,7 @@
auto serializedClip = area.serializeClip(allocator);
ASSERT_NE(nullptr, serializedClip);
ASSERT_EQ(ClipMode::Rectangle, serializedClip->mode);
- auto clipRect = reinterpret_cast<const ClipRect*>(serializedClip);
- EXPECT_EQ(Rect(200, 200), clipRect->rect);
+ EXPECT_EQ(Rect(200, 200), serializedClip->rect);
EXPECT_EQ(serializedClip, area.serializeClip(allocator))
<< "Requery of clip on unmodified ClipArea must return same pointer.";
}
@@ -192,8 +191,7 @@
auto resolvedClip = area.serializeIntersectedClip(allocator, &recordedClip, translateScale);
ASSERT_NE(nullptr, resolvedClip);
ASSERT_EQ(ClipMode::Rectangle, resolvedClip->mode);
- EXPECT_EQ(Rect(100, 100, 200, 200),
- reinterpret_cast<const ClipRect*>(resolvedClip)->rect);
+ EXPECT_EQ(Rect(100, 100, 200, 200), resolvedClip->rect);
EXPECT_EQ(resolvedClip, area.serializeIntersectedClip(allocator, &recordedClip, translateScale))
<< "Must return previous serialization, since input is same";
diff --git a/libs/hwui/tests/unit/FrameBuilderTests.cpp b/libs/hwui/tests/unit/FrameBuilderTests.cpp
index 0ea246f..9877439 100644
--- a/libs/hwui/tests/unit/FrameBuilderTests.cpp
+++ b/libs/hwui/tests/unit/FrameBuilderTests.cpp
@@ -1946,5 +1946,28 @@
EXPECT_MATRIX_APPROX_EQ(Matrix4::identity(), observedData.rectMatrix);
}
+RENDERTHREAD_TEST(FrameBuilder, clip_replace) {
+ class ClipReplaceTestRenderer : public TestRendererBase {
+ public:
+ void onColorOp(const ColorOp& op, const BakedOpState& state) override {
+ EXPECT_EQ(0, mIndex++);
+ EXPECT_TRUE(op.localClip->intersectWithRoot);
+ EXPECT_EQ(Rect(20, 10, 30, 40), state.computedState.clipState->rect)
+ << "Expect resolved clip to be intersection of viewport clip and clip op";
+ }
+ };
+ auto node = TestUtils::createNode(20, 20, 30, 30,
+ [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.clipRect(0, -20, 10, 30, SkRegion::kReplace_Op);
+ canvas.drawColor(SK_ColorWHITE, SkXfermode::Mode::kSrcOver_Mode);
+ });
+
+ FrameBuilder frameBuilder(sEmptyLayerUpdateQueue, SkRect::MakeLTRB(10, 10, 40, 40), 50, 50,
+ TestUtils::createSyncedNodeList(node), sLightGeometry, Caches::getInstance());
+ ClipReplaceTestRenderer renderer;
+ frameBuilder.replayBakedOps<TestDispatcher>(renderer);
+ EXPECT_EQ(1, renderer.getIndex());
+}
+
} // namespace uirenderer
} // namespace android
diff --git a/libs/hwui/tests/unit/RecordingCanvasTests.cpp b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
index 58376c6..c49ff71 100644
--- a/libs/hwui/tests/unit/RecordingCanvasTests.cpp
+++ b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
@@ -569,6 +569,19 @@
EXPECT_CLIP_RECT(Rect(-100, -100, 300, 300), dl->getOps()[0]->localClip);
}
+TEST(RecordingCanvas, replaceClipIntersectWithRoot) {
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 100, [](RecordingCanvas& canvas) {
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.clipRect(-10, -10, 110, 110, SkRegion::kReplace_Op);
+ canvas.drawColor(SK_ColorWHITE, SkXfermode::Mode::kSrcOver_Mode);
+ canvas.restore();
+ });
+ ASSERT_EQ(1u, dl->getOps().size()) << "Must have one op";
+ // first clip must be preserved, even if it extends beyond canvas bounds
+ EXPECT_CLIP_RECT(Rect(-10, -10, 110, 110), dl->getOps()[0]->localClip);
+ EXPECT_TRUE(dl->getOps()[0]->localClip->intersectWithRoot);
+}
+
TEST(RecordingCanvas, insertReorderBarrier) {
auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
canvas.drawRect(0, 0, 400, 400, SkPaint());
diff --git a/libs/hwui/tests/unit/SnapshotTests.cpp b/libs/hwui/tests/unit/SnapshotTests.cpp
new file mode 100644
index 0000000..11797a8
--- /dev/null
+++ b/libs/hwui/tests/unit/SnapshotTests.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Snapshot.h>
+
+#include <tests/common/TestUtils.h>
+
+using namespace android::uirenderer;
+
+TEST(Snapshot, serializeIntersectedClip) {
+ auto actualRoot = TestUtils::makeSnapshot(Matrix4::identity(), Rect(0, 0, 100, 100));
+ auto root = TestUtils::makeSnapshot(Matrix4::identity(), Rect(10, 10, 90, 90));
+ auto child = TestUtils::makeSnapshot(Matrix4::identity(), Rect(50, 50, 90, 90));
+ root->previous = actualRoot.get();
+ child->previous = root.get();
+
+ LinearAllocator allocator;
+ ClipRect rect(Rect(0, 0, 75, 75));
+ {
+ auto intersectWithChild = child->serializeIntersectedClip(allocator,
+ &rect, Matrix4::identity());
+ ASSERT_NE(nullptr, intersectWithChild);
+ EXPECT_EQ(Rect(50, 50, 75, 75), intersectWithChild->rect) << "Expect intersect with child";
+ }
+
+ rect.intersectWithRoot = true;
+ {
+ auto intersectWithRoot = child->serializeIntersectedClip(allocator,
+ &rect, Matrix4::identity());
+ ASSERT_NE(nullptr, intersectWithRoot);
+ EXPECT_EQ(Rect(10, 10, 75, 75), intersectWithRoot->rect) << "Expect intersect with root";
+ }
+}
+
+TEST(Snapshot, applyClip) {
+ auto actualRoot = TestUtils::makeSnapshot(Matrix4::identity(), Rect(0, 0, 100, 100));
+ auto root = TestUtils::makeSnapshot(Matrix4::identity(), Rect(10, 10, 90, 90));
+ root->previous = actualRoot.get();
+
+ ClipRect rect(Rect(0, 0, 75, 75));
+ {
+ auto child = TestUtils::makeSnapshot(Matrix4::identity(), Rect(50, 50, 90, 90));
+ child->previous = root.get();
+ child->applyClip(&rect, Matrix4::identity());
+
+ EXPECT_TRUE(child->getClipArea().isSimple());
+ EXPECT_EQ(Rect(50, 50, 75, 75), child->getRenderTargetClip());
+ }
+
+ {
+ rect.intersectWithRoot = true;
+ auto child = TestUtils::makeSnapshot(Matrix4::identity(), Rect(50, 50, 90, 90));
+ child->previous = root.get();
+ child->applyClip(&rect, Matrix4::identity());
+
+ EXPECT_TRUE(child->getClipArea().isSimple());
+ EXPECT_EQ(Rect(10, 10, 75, 75), child->getRenderTargetClip());
+ }
+}
diff --git a/libs/hwui/tests/unit/VectorDrawableTests.cpp b/libs/hwui/tests/unit/VectorDrawableTests.cpp
index 7208547..796169e 100644
--- a/libs/hwui/tests/unit/VectorDrawableTests.cpp
+++ b/libs/hwui/tests/unit/VectorDrawableTests.cpp
@@ -231,11 +231,12 @@
};
const StringPath sStringPaths[] = {
- {"3e...3", false},
- {"L.M.F.A.O", false},
- {"m 1 1", true},
- {"z", true},
- {"1-2e34567", false}
+ {"3e...3", false}, // Not starting with a verb and ill-formatted float
+ {"L.M.F.A.O", false}, // No floats following verbs
+ {"m 1 1", true}, // Valid path data
+ {"z", true}, // Valid path data
+ {"1-2e34567", false}, // Not starting with a verb and ill-formatted float
+ {"f 4 5", false} // Invalid verb
};
diff --git a/libs/hwui/utils/TestWindowContext.cpp b/libs/hwui/utils/TestWindowContext.cpp
index b0431ce..b3195c4 100644
--- a/libs/hwui/utils/TestWindowContext.cpp
+++ b/libs/hwui/utils/TestWindowContext.cpp
@@ -104,8 +104,8 @@
}
void finishDrawing() {
- mRootNode->setStagingDisplayList(mCanvas->finishRecording());
- mProxy->syncAndDrawFrame();
+ mRootNode->setStagingDisplayList(mCanvas->finishRecording(), nullptr);
+ mProxy->syncAndDrawFrame(nullptr);
// Surprisingly, calling mProxy->fence() here appears to make no difference to
// the timings we record.
}
diff --git a/location/java/android/location/GnssClock.java b/location/java/android/location/GnssClock.java
index df42a73..d1b1be9 100644
--- a/location/java/android/location/GnssClock.java
+++ b/location/java/android/location/GnssClock.java
@@ -22,7 +22,8 @@
/**
* A class containing a GPS clock timestamp.
- * It represents a measurement of the GPS receiver's clock.
+ *
+ * <p>It represents a measurement of the GPS receiver's clock.
*/
public final class GnssClock implements Parcelable {
// The following enumerations must be in sync with the values declared in gps.h
@@ -85,7 +86,7 @@
}
/**
- * Returns true if {@link #getLeapSecond()} is available, false otherwise.
+ * Returns {@code true} if {@link #getLeapSecond()} is available, {@code false} otherwise.
*/
public boolean hasLeapSecond() {
return isFlagSet(HAS_LEAP_SECOND);
@@ -93,10 +94,12 @@
/**
* Gets the leap second associated with the clock's time.
- * The sign of the value is defined by the following equation:
- * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000
*
- * The value is only available if {@link #hasLeapSecond()} is true.
+ * <p>The sign of the value is defined by the following equation:
+ * <pre>
+ * UtcTimeNanos = TimeNanos + (FullBiasNanos + BiasNanos) - LeapSecond * 1,000,000,000</pre>
+ *
+ * <p>The value is only available if {@link #hasLeapSecond()} is {@code true}.
*/
public int getLeapSecond() {
return mLeapSecond;
@@ -123,18 +126,15 @@
}
/**
- * Gets the GNSS receiver internal clock value in nanoseconds.
+ * Gets the GNSS receiver internal hardware clock value in nanoseconds.
*
- * For 'local hardware clock' this value is expected to be monotonically increasing during the
- * reporting session. The real GPS time can be derived by compensating
- * {@link #getFullBiasNanos()} (when it is available) from this value.
+ * <p>This value is expected to be monotonically increasing while the hardware clock remains
+ * powered on. For the case of a hardware clock that is not continuously on, see the
+ * {@link #getHardwareClockDiscontinuityCount} field. The GPS time can be derived by adding
+ * {@link #getFullBiasNanos()} and {@link #getBiasNanos()} (when they are available) to this
+ * value. Sub-nanosecond accuracy can be provided by means of {@link #getBiasNanos()}.
*
- * For 'GPS time' this value is expected to be the best estimation of current GPS time that GPS
- * receiver can achieve. {@link #getTimeUncertaintyNanos()} should be available when GPS time is
- * specified.
- *
- * Sub-nanosecond accuracy can be provided by means of {@link #getBiasNanos()}.
- * The reported time includes {@link #getTimeUncertaintyNanos()}.
+ * <p>The error estimate for this value (if applicable) is {@link #getTimeUncertaintyNanos()}.
*/
public long getTimeNanos() {
return mTimeNanos;
@@ -150,7 +150,8 @@
}
/**
- * Returns true if {@link #getTimeUncertaintyNanos()} is available, false otherwise.
+ * Returns {@code true} if {@link #getTimeUncertaintyNanos()} is available, {@code false}
+ * otherwise.
*/
public boolean hasTimeUncertaintyNanos() {
return isFlagSet(HAS_TIME_UNCERTAINTY);
@@ -158,9 +159,13 @@
/**
* Gets the clock's time Uncertainty (1-Sigma) in nanoseconds.
- * The uncertainty is represented as an absolute (single sided) value.
*
- * The value is only available if {@link #hasTimeUncertaintyNanos()} is true.
+ * <p>The uncertainty is represented as an absolute (single sided) value.
+ *
+ * <p>The value is only available if {@link #hasTimeUncertaintyNanos()} is {@code true}.
+ *
+ * <p>This value is often effectively zero (it is the reference clock by which all other times
+ * and time uncertainties are measured), and thus this field may often be 0, or not provided.
*/
public double getTimeUncertaintyNanos() {
return mTimeUncertaintyNanos;
@@ -187,7 +192,7 @@
}
/**
- * Returns true if {@link #getFullBiasNanos()} is available, false otherwise.
+ * Returns {@code true} if {@link #getFullBiasNanos()} is available, {@code false} otherwise.
*/
public boolean hasFullBiasNanos() {
return isFlagSet(HAS_FULL_BIAS);
@@ -197,14 +202,18 @@
* Gets the difference between hardware clock ({@link #getTimeNanos()}) inside GPS receiver and
* the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
*
- * This value is available if the receiver has estimated GPS time. If the computed time is for a
- * non-GPS constellation, the time offset of that constellation to GPS has to be applied to fill
- * this value. The value contains the 'bias uncertainty' {@link #getBiasUncertaintyNanos()} in
- * it, and it should be used for quality check. The value is only available if
- * {@link #hasFullBiasNanos()} is true.
+ * <p>This value is available if the receiver has estimated GPS time. If the computed time is
+ * for a non-GPS constellation, the time offset of that constellation to GPS has to be applied
+ * to fill this value. The value is only available if {@link #hasFullBiasNanos()} is
+ * {@code true}.
*
- * The sign of the value is defined by the following equation:
- * local estimate of GPS time = time_ns + (full_bias_ns + bias_ns)
+ * <p>The error estimate for the sum of this field and {@link #getBiasNanos} is
+ * {@link #getBiasUncertaintyNanos()}.
+ *
+ * <p>The sign of the value is defined by the following equation:
+ *
+ * <pre>
+ * local estimate of GPS time = TimeNanos + (FullBiasNanos + BiasNanos)</pre>
*/
public long getFullBiasNanos() {
return mFullBiasNanos;
@@ -231,7 +240,7 @@
}
/**
- * Returns true if {@link #getBiasNanos()} is available, false otherwise.
+ * Returns {@code true} if {@link #getBiasNanos()} is available, {@code false} otherwise.
*/
public boolean hasBiasNanos() {
return isFlagSet(HAS_BIAS);
@@ -239,9 +248,14 @@
/**
* Gets the clock's sub-nanosecond bias.
- * The reported bias includes {@link #getBiasUncertaintyNanos()}.
*
- * The value is only available if {@link #hasBiasNanos()} is true.
+ * <p>See the description of how this field is part of converting from hardware clock time, to
+ * GPS time, in {@link #getFullBiasNanos()}.
+ *
+ * <p>The error estimate for the sum of this field and {@link #getFullBiasNanos} is
+ * {@link #getBiasUncertaintyNanos()}.
+ *
+ * <p>The value is only available if {@link #hasBiasNanos()} is {@code true}.
*/
public double getBiasNanos() {
return mBiasNanos;
@@ -268,7 +282,8 @@
}
/**
- * Returns true if {@link #getBiasUncertaintyNanos()} is available, false otherwise.
+ * Returns {@code true} if {@link #getBiasUncertaintyNanos()} is available, {@code false}
+ * otherwise.
*/
public boolean hasBiasUncertaintyNanos() {
return isFlagSet(HAS_BIAS_UNCERTAINTY);
@@ -277,7 +292,10 @@
/**
* Gets the clock's Bias Uncertainty (1-Sigma) in nanoseconds.
*
- * The value is only available if {@link #hasBiasUncertaintyNanos()} is true.
+ * <p>See the description of how this field provides the error estimate in the conversion from
+ * hardware clock time, to GPS time, in {@link #getFullBiasNanos()}.
+ *
+ * <p>The value is only available if {@link #hasBiasUncertaintyNanos()} is {@code true}.
*/
public double getBiasUncertaintyNanos() {
return mBiasUncertaintyNanos;
@@ -304,7 +322,8 @@
}
/**
- * Returns true if {@link #getDriftNanosPerSecond()} is available, false otherwise.
+ * Returns {@code true} if {@link #getDriftNanosPerSecond()} is available, {@code false}
+ * otherwise.
*/
public boolean hasDriftNanosPerSecond() {
return isFlagSet(HAS_DRIFT);
@@ -312,10 +331,12 @@
/**
* Gets the clock's Drift in nanoseconds per second.
- * A positive value indicates that the frequency is higher than the nominal frequency.
- * The reported drift includes {@link #getDriftUncertaintyNanosPerSecond()}.
*
- * The value is only available if {@link #hasDriftNanosPerSecond()} is true.
+ * <p>A positive value indicates that the frequency is higher than the nominal (e.g. GPS master
+ * clock) frequency. The error estimate for this reported drift is
+ * {@link #getDriftUncertaintyNanosPerSecond()}.
+ *
+ * <p>The value is only available if {@link #hasDriftNanosPerSecond()} is {@code true}.
*/
public double getDriftNanosPerSecond() {
return mDriftNanosPerSecond;
@@ -342,7 +363,8 @@
}
/**
- * Returns true if {@link #getDriftUncertaintyNanosPerSecond()} is available, false otherwise.
+ * Returns {@code true} if {@link #getDriftUncertaintyNanosPerSecond()} is available,
+ * {@code false} otherwise.
*/
public boolean hasDriftUncertaintyNanosPerSecond() {
return isFlagSet(HAS_DRIFT_UNCERTAINTY);
@@ -351,7 +373,8 @@
/**
* Gets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second.
*
- * The value is only available if {@link #hasDriftUncertaintyNanosPerSecond()} is true.
+ * <p>The value is only available if {@link #hasDriftUncertaintyNanosPerSecond()} is
+ * {@code true}.
*/
public double getDriftUncertaintyNanosPerSecond() {
return mDriftUncertaintyNanosPerSecond;
@@ -368,7 +391,29 @@
}
/**
- * Gets count of last hardware clock discontinuity.
+ * Resets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second.
+ * @hide
+ */
+ @TestApi
+ public void resetDriftUncertaintyNanosPerSecond() {
+ resetFlag(HAS_DRIFT_UNCERTAINTY);
+ mDriftUncertaintyNanosPerSecond = Double.NaN;
+ }
+
+ /**
+ * Gets count of hardware clock discontinuities.
+ *
+ * <p>When this value stays the same, vs. a value in a previously reported {@link GnssClock}, it
+ * can be safely assumed that the {@code TimeNanos} value has been derived from a clock that has
+ * been running continuously - e.g. a single continuously powered crystal oscillator, and thus
+ * the {@code (FullBiasNanos + BiasNanos)} offset can be modelled with traditional clock bias
+ * & drift models.
+ *
+ * <p>Each time this value changes, vs. the value in a previously reported {@link GnssClock},
+ * that suggests the hardware clock may have experienced a discontinuity (e.g. a power cycle or
+ * other anomaly), so that any assumptions about modelling a smoothly changing
+ * {@code (FullBiasNanos + BiasNanos)} offset, and a smoothly growing {@code (TimeNanos)}
+ * between this and the previously reported {@code GnssClock}, should be reset.
*/
public int getHardwareClockDiscontinuityCount() {
return mHardwareClockDiscontinuityCount;
@@ -383,16 +428,6 @@
mHardwareClockDiscontinuityCount = value;
}
- /**
- * Resets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second.
- * @hide
- */
- @TestApi
- public void resetDriftUncertaintyNanosPerSecond() {
- resetFlag(HAS_DRIFT_UNCERTAINTY);
- mDriftUncertaintyNanosPerSecond = Double.NaN;
- }
-
public static final Creator<GnssClock> CREATOR = new Creator<GnssClock>() {
@Override
public GnssClock createFromParcel(Parcel parcel) {
diff --git a/location/java/android/location/GnssMeasurement.java b/location/java/android/location/GnssMeasurement.java
index d78ccee..761ee22 100644
--- a/location/java/android/location/GnssMeasurement.java
+++ b/location/java/android/location/GnssMeasurement.java
@@ -67,18 +67,21 @@
public @interface MultipathIndicator {}
/**
- * The indicator is not available or it is unknown.
+ * The indicator is not available or the presence or absence of multipath is unknown.
*/
public static final int MULTIPATH_INDICATOR_UNKNOWN = 0;
/**
- * The measurement has been indicated to use multi-path.
+ * The measurement shows signs of multi-path.
*/
public static final int MULTIPATH_INDICATOR_DETECTED = 1;
/**
- * The measurement has been indicated not tu use multi-path.
+ * The measurement shows no signs of multi-path.
*/
+ public static final int MULTIPATH_INDICATOR_NOT_DETECTED = 2;
+
+ /** @removed */
public static final int MULTIPATH_INDICATOR_NOT_USED = 2;
/** This GNSS measurement's tracking state is invalid or unknown. */
@@ -192,15 +195,17 @@
}
/**
- * Gets the Pseudo-random number (PRN).
- * Range: [1, 32]
+ * Gets the satellite ID.
+ *
+ * <p>Interpretation depends on {@link #getConstellationType()}.
+ * See {@link GnssStatus#getSvid(int)}.
*/
public int getSvid() {
return mSvid;
}
/**
- * Sets the Pseud-random number (PRN).
+ * Sets the Satellite ID.
* @hide
*/
@TestApi
@@ -209,7 +214,10 @@
}
/**
- * Getst the constellation type.
+ * Gets the constellation type.
+ *
+ * <p>The return value is one of those constants with {@code CONSTELLATION_} prefix in
+ * {@link GnssStatus}.
*/
@GnssStatus.ConstellationType
public int getConstellationType() {
@@ -228,13 +236,14 @@
/**
* Gets the time offset at which the measurement was taken in nanoseconds.
*
- * The reference receiver's time from which this is offset is specified by
+ * <p>The reference receiver's time from which this is offset is specified by
* {@link GnssClock#getTimeNanos()}.
*
- * The sign of this value is given by the following equation:
- * measurement time = time_ns + time_offset_ns
+ * <p>The sign of this value is given by the following equation:
+ * <pre>
+ * measurement time = TimeNanos + TimeOffsetNanos</pre>
*
- * The value provides an individual time-stamp for the measurement, and allows sub-nanosecond
+ * <p>The value provides an individual time-stamp for the measurement, and allows sub-nanosecond
* accuracy.
*/
public double getTimeOffsetNanos() {
@@ -252,9 +261,10 @@
/**
* Gets per-satellite sync state.
- * It represents the current sync state for the associated satellite.
*
- * This value helps interpret {@link #getReceivedSvTimeNanos()}.
+ * <p>It represents the current sync state for the associated satellite.
+ *
+ * <p>This value helps interpret {@link #getReceivedSvTimeNanos()}.
*/
public int getState() {
return mState;
@@ -271,7 +281,8 @@
/**
* Gets a string representation of the 'sync state'.
- * For internal and logging use only.
+ *
+ * <p>For internal and logging use only.
*/
private String getStateString() {
if (mState == STATE_UNKNOWN) {
@@ -335,66 +346,79 @@
/**
* Gets the received GNSS satellite time, at the measurement time, in nanoseconds.
*
- * For GPS & QZSS, this is:
- * Received GPS Time-of-Week at the measurement time, in nanoseconds.
- * The value is relative to the beginning of the current GPS week.
+ * <p>For GPS & QZSS, this is:
+ * <ul>
+ * <li>Received GPS Time-of-Week at the measurement time, in nanoseconds.</li>
+ * <li>The value is relative to the beginning of the current GPS week.</li>
+ * </ul>
*
- * Given the highest sync state that can be achieved, per each satellite, valid range
- * for this field can be:
+ * <p>Given the highest sync state that can be achieved, per each satellite, valid range
+ * for this field can be:
+ * <pre>
* Searching : [ 0 ] : STATE_UNKNOWN
* C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK is set
* Bit sync : [ 0 20ms ] : STATE_BIT_SYNC is set
* Subframe sync : [ 0 6s ] : STATE_SUBFRAME_SYNC is set
- * TOW decoded : [ 0 1week ] : STATE_TOW_DECODED is set
+ * TOW decoded : [ 0 1week ] : STATE_TOW_DECODED is set</pre>
*
- * Note well: if there is any ambiguity in integer millisecond,
- * STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field.
+ * <p>Note well: if there is any ambiguity in integer millisecond, {@code STATE_MSEC_AMBIGUOUS}
+ * should be set accordingly, in the 'state' field.
*
- * This value must be populated if 'state' != STATE_UNKNOWN.
+ * <p>This value must be populated if 'state' != {@code STATE_UNKNOWN}.
*
- * For Glonass, this is:
- * Received Glonass time of day, at the measurement time in nanoseconds.
+ * <p>For Glonass, this is:
+ * <ul>
+ * <li>Received Glonass time of day, at the measurement time in nanoseconds.</li>
+ * </ul>
*
- * Given the highest sync state that can be achieved, per each satellite, valid range for
- * this field can be:
+ * <p>Given the highest sync state that can be achieved, per each satellite, valid range for
+ * this field can be:
+ * <pre>
* Searching : [ 0 ] : STATE_UNKNOWN
* C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK is set
- * Symbol sync : [ 0 10ms ] : STATE_SYMBOL_SYNC is set
- * Bit sync : [ 0 20ms ] : STATE_BIT_SYNC is set
- * String sync : [ 0 2s ] : STATE_GLO_STRING_SYNC is set
- * Time of day : [ 0 1day ] : STATE_GLO_TOD_DECODED is set
+ * Symbol sync : [ 0 10ms ] : STATE_SYMBOL_SYNC is set
+ * Bit sync : [ 0 20ms ] : STATE_BIT_SYNC is set
+ * String sync : [ 0 2s ] : STATE_GLO_STRING_SYNC is set
+ * Time of day : [ 0 1day ] : STATE_GLO_TOD_DECODED is set</pre>
*
- * For Beidou, this is:
- * Received Beidou time of week, at the measurement time in nanoseconds.
+ * <p>For Beidou, this is:
+ * <ul>
+ * <li>Received Beidou time of week, at the measurement time in nanoseconds.</li>
+ * </ul>
*
- * Given the highest sync state that can be achieved, per each satellite, valid range for
- * this field can be:
+ * <p>Given the highest sync state that can be achieved, per each satellite, valid range for
+ * this field can be:
+ * <pre>
* Searching : [ 0 ] : STATE_UNKNOWN
* C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK is set
* Bit sync (D2) : [ 0 2ms ] : STATE_BDS_D2_BIT_SYNC is set
* Bit sync (D1) : [ 0 20ms ] : STATE_BIT_SYNC is set
* Subframe (D2) : [ 0 0.6s ] : STATE_BDS_D2_SUBFRAME_SYNC is set
* Subframe (D1) : [ 0 6s ] : STATE_SUBFRAME_SYNC is set
- * Time of week : [ 0 1week ] : STATE_TOW_DECODED is set
+ * Time of week : [ 0 1week ] : STATE_TOW_DECODED is set</pre>
*
- * For Galileo, this is:
- * Received Galileo time of week, at the measurement time in nanoseconds.
+ * <p>For Galileo, this is:
+ * <ul>
+ * <li>Received Galileo time of week, at the measurement time in nanoseconds.</li>
+ * </ul>
+ * <pre>
+ * E1BC code lock : [ 0 4ms ] : STATE_GAL_E1BC_CODE_LOCK is set
+ * E1C 2nd code lock: [ 0 100ms ] : STATE_GAL_E1C_2ND_CODE_LOCK is set
+ * E1B page : [ 0 2s ] : STATE_GAL_E1B_PAGE_SYNC is set
+ * Time of week : [ 0 1week ] : STATE_GAL_TOW_DECODED is set</pre>
*
- * E1BC code lock : [ 0 4ms ] : STATE_GAL_E1BC_CODE_LOCK is set
- * E1C 2nd code lock : [ 0 100ms ] : STATE_GAL_E1C_2ND_CODE_LOCK is set
+ * <p>For SBAS, this is:
+ * <ul>
+ * <li>Received SBAS time, at the measurement time in nanoseconds.</li>
+ * </ul>
*
- * E1B page : [ 0 2s ] : STATE_GAL_E1B_PAGE_SYNC is set
- * Time of week : [ 0 1week ] : STATE_GAL_TOW_DECODED is set
- *
- * For SBAS, this is:
- * Received SBAS time, at the measurement time in nanoseconds.
- *
- * Given the highest sync state that can be achieved, per each satellite, valid range for
- * this field can be:
+ * <p>Given the highest sync state that can be achieved, per each satellite, valid range for
+ * this field can be:
+ * <pre>
* Searching : [ 0 ] : STATE_UNKNOWN
* C/A code lock : [ 0 1ms ] : STATE_CODE_LOCK is set
* Symbol sync : [ 0 2ms ] : STATE_SYMBOL_SYNC is set
- * Message : [ 0 1s ] : STATE_SBAS_SYNC is set
+ * Message : [ 0 1s ] : STATE_SBAS_SYNC is set</pre>
*/
public long getReceivedSvTimeNanos() {
return mReceivedSvTimeNanos;
@@ -410,7 +434,7 @@
}
/**
- * Gets the received GNSS time uncertainty (1-Sigma) in nanoseconds.
+ * Gets the error estimate (1-sigma) for the received GNSS time, in nanoseconds.
*/
public long getReceivedSvTimeUncertaintyNanos() {
return mReceivedSvTimeUncertaintyNanos;
@@ -427,9 +451,10 @@
/**
* Gets the Carrier-to-noise density in dB-Hz.
- * Range: [0, 63].
*
- * The value contains the measured C/N0 for the signal at the antenna input.
+ * <p>Typical range: 10-50 db-Hz.
+ *
+ * <p>The value contains the measured C/N0 for the signal at the antenna input.
*/
public double getCn0DbHz() {
return mCn0DbHz;
@@ -447,16 +472,18 @@
/**
* Gets the Pseudorange rate at the timestamp in m/s.
*
- * The reported value includes {@link #getPseudorangeRateUncertaintyMetersPerSecond()}.
+ * <p>The error estimate for this value is
+ * {@link #getPseudorangeRateUncertaintyMetersPerSecond()}.
*
- * The value is uncorrected, hence corrections for receiver and satellite clock frequency errors
- * should not be included.
+ * <p>The value is uncorrected, i.e. corrections for receiver and satellite clock frequency
+ * errors are not included.
*
- * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. The
+ * <p>A positive 'uncorrected' value indicates that the SV is moving away from the receiver. The
* sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler shift'
* is given by the equation:
*
- * pseudorange rate = -k * doppler shift (where k is a constant)
+ * <pre>
+ * pseudorange rate = -k * doppler shift (where k is a constant)</pre>
*/
public double getPseudorangeRateMetersPerSecond() {
return mPseudorangeRateMetersPerSecond;
@@ -473,7 +500,8 @@
/**
* Gets the pseudorange's rate uncertainty (1-Sigma) in m/s.
- * The uncertainty is represented as an absolute (single sided) value.
+ *
+ * <p>The uncertainty is represented as an absolute (single sided) value.
*/
public double getPseudorangeRateUncertaintyMetersPerSecond() {
return mPseudorangeRateUncertaintyMetersPerSecond;
@@ -490,7 +518,8 @@
/**
* Gets 'Accumulated Delta Range' state.
- * It indicates whether {@link #getAccumulatedDeltaRangeMeters()} is reset or there is a
+ *
+ * <p>It indicates whether {@link #getAccumulatedDeltaRangeMeters()} is reset or there is a
* cycle slip (indicating 'loss of lock').
*/
public int getAccumulatedDeltaRangeState() {
@@ -508,7 +537,8 @@
/**
* Gets a string representation of the 'Accumulated Delta Range state'.
- * For internal and logging use only.
+ *
+ * <p>For internal and logging use only.
*/
private String getAccumulatedDeltaRangeStateString() {
if (mAccumulatedDeltaRangeState == ADR_STATE_UNKNOWN) {
@@ -536,14 +566,17 @@
/**
* Gets the accumulated delta range since the last channel reset, in meters.
- * The reported value includes {@link #getAccumulatedDeltaRangeUncertaintyMeters()}.
*
- * The availability of the value is represented by {@link #getAccumulatedDeltaRangeState()}.
+ * <p>The error estimate for this value is {@link #getAccumulatedDeltaRangeUncertaintyMeters()}.
*
- * A positive value indicates that the SV is moving away from the receiver.
+ * <p>The availability of the value is represented by {@link #getAccumulatedDeltaRangeState()}.
+ *
+ * <p>A positive value indicates that the SV is moving away from the receiver.
* The sign of {@link #getAccumulatedDeltaRangeMeters()} and its relation to the sign of
* {@link #getCarrierPhase()} is given by the equation:
- * accumulated delta range = -k * carrier phase (where k is a constant)
+ *
+ * <pre>
+ * accumulated delta range = -k * carrier phase (where k is a constant)</pre>
*/
public double getAccumulatedDeltaRangeMeters() {
return mAccumulatedDeltaRangeMeters;
@@ -560,9 +593,10 @@
/**
* Gets the accumulated delta range's uncertainty (1-Sigma) in meters.
- * The uncertainty is represented as an absolute (single sided) value.
*
- * The status of the value is represented by {@link #getAccumulatedDeltaRangeState()}.
+ * <p>The uncertainty is represented as an absolute (single sided) value.
+ *
+ * <p>The status of the value is represented by {@link #getAccumulatedDeltaRangeState()}.
*/
public double getAccumulatedDeltaRangeUncertaintyMeters() {
return mAccumulatedDeltaRangeUncertaintyMeters;
@@ -571,7 +605,7 @@
/**
* Sets the accumulated delta range's uncertainty (1-sigma) in meters.
*
- * The status of the value is represented by {@link #getAccumulatedDeltaRangeState()}.
+ * <p>The status of the value is represented by {@link #getAccumulatedDeltaRangeState()}.
*
* @hide
*/
@@ -581,17 +615,20 @@
}
/**
- * Returns true if {@link #getCarrierFrequencyHz()} is available, false otherwise.
+ * Returns {@code true} if {@link #getCarrierFrequencyHz()} is available, {@code false}
+ * otherwise.
*/
public boolean hasCarrierFrequencyHz() {
return isFlagSet(HAS_CARRIER_FREQUENCY);
}
/**
- * Gets the carrier frequency at which codes and messages are modulated, it can be L1 or L2.
- * If the field is not set, the carrier frequency corresponds to L1.
+ * Gets the carrier frequency at which codes and messages are modulated.
*
- * The value is only available if {@link #hasCarrierFrequencyHz()} is true.
+ * <p>For GPS, e.g., it can be L1 or L2. If the field is not set, it is the primary common use
+ * frequency, e.g. L1 for GPS.
+ *
+ * <p>The value is only available if {@link #hasCarrierFrequencyHz()} is {@code true}.
*/
public float getCarrierFrequencyHz() {
return mCarrierFrequencyHz;
@@ -618,7 +655,7 @@
}
/**
- * Returns true if {@link #getCarrierCycles()} is available, false otherwise.
+ * Returns {@code true} if {@link #getCarrierCycles()} is available, {@code false} otherwise.
*/
public boolean hasCarrierCycles() {
return isFlagSet(HAS_CARRIER_CYCLES);
@@ -626,9 +663,10 @@
/**
* The number of full carrier cycles between the satellite and the receiver.
- * The reference frequency is given by the value of {@link #getCarrierFrequencyHz()}.
*
- * The value is only available if {@link #hasCarrierCycles()} is true.
+ * <p>The reference frequency is given by the value of {@link #getCarrierFrequencyHz()}.
+ *
+ * <p>The value is only available if {@link #hasCarrierCycles()} is {@code true}.
*/
public long getCarrierCycles() {
return mCarrierCycles;
@@ -655,7 +693,7 @@
}
/**
- * Returns true if {@link #getCarrierPhase()} is available, false otherwise.
+ * Returns {@code true} if {@link #getCarrierPhase()} is available, {@code false} otherwise.
*/
public boolean hasCarrierPhase() {
return isFlagSet(HAS_CARRIER_PHASE);
@@ -663,13 +701,16 @@
/**
* Gets the RF phase detected by the receiver.
- * Range: [0.0, 1.0].
- * This is usually the fractional part of the complete carrier phase measurement.
*
- * The reference frequency is given by the value of {@link #getCarrierFrequencyHz()}.
- * The reported carrier-phase includes {@link #getCarrierPhaseUncertainty()}.
+ * <p>Range: [0.0, 1.0].
*
- * The value is only available if {@link #hasCarrierPhase()} is true.
+ * <p>This is the fractional part of the complete carrier phase measurement.
+ *
+ * <p>The reference frequency is given by the value of {@link #getCarrierFrequencyHz()}.
+ *
+ * <p>The error estimate for this value is {@link #getCarrierPhaseUncertainty()}.
+ *
+ * <p>The value is only available if {@link #hasCarrierPhase()} is {@code true}.
*/
public double getCarrierPhase() {
return mCarrierPhase;
@@ -696,7 +737,8 @@
}
/**
- * Returns true if {@link #getCarrierPhaseUncertainty()} is available, false otherwise.
+ * Returns {@code true} if {@link #getCarrierPhaseUncertainty()} is available, {@code false}
+ * otherwise.
*/
public boolean hasCarrierPhaseUncertainty() {
return isFlagSet(HAS_CARRIER_PHASE_UNCERTAINTY);
@@ -704,9 +746,10 @@
/**
* Gets the carrier-phase's uncertainty (1-Sigma).
- * The uncertainty is represented as an absolute (single sided) value.
*
- * The value is only available if {@link #hasCarrierPhaseUncertainty()} is true.
+ * <p>The uncertainty is represented as an absolute (single sided) value.
+ *
+ * <p>The value is only available if {@link #hasCarrierPhaseUncertainty()} is {@code true}.
*/
public double getCarrierPhaseUncertainty() {
return mCarrierPhaseUncertainty;
@@ -751,7 +794,8 @@
/**
* Gets a string representation of the 'multi-path indicator'.
- * For internal and logging use only.
+ *
+ * <p>For internal and logging use only.
*/
private String getMultipathIndicatorString() {
switch(mMultipathIndicator) {
@@ -767,7 +811,7 @@
}
/**
- * Returns true if {@link #getSnrInDb()} is available, false otherwise.
+ * Returns {@code true} if {@link #getSnrInDb()} is available, {@code false} otherwise.
*/
public boolean hasSnrInDb() {
return isFlagSet(HAS_SNR);
@@ -776,7 +820,7 @@
/**
* Gets the Signal-to-Noise ratio (SNR) in dB.
*
- * The value is only available if {@link #hasSnrInDb()} is true.
+ * <p>The value is only available if {@link #hasSnrInDb()} is {@code true}.
*/
public double getSnrInDb() {
return mSnrInDb;
diff --git a/location/java/android/location/GnssMeasurementsEvent.java b/location/java/android/location/GnssMeasurementsEvent.java
index ec252a8..3151694 100644
--- a/location/java/android/location/GnssMeasurementsEvent.java
+++ b/location/java/android/location/GnssMeasurementsEvent.java
@@ -16,6 +16,7 @@
package android.location;
+import android.annotation.TestApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.os.Parcel;
@@ -33,29 +34,11 @@
* Events are delivered to registered instances of {@link Callback}.
*/
public final class GnssMeasurementsEvent implements Parcelable {
- /**
- * The status of the GNSS measurements event.
- * @hide
- */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_GNSS_LOCATION_DISABLED})
- public @interface GnssMeasurementsStatus {}
-
- /**
- * The system does not support tracking of GNSS Measurements. This status will not change in the
- * future.
- */
+ /** @removed */
public static final int STATUS_NOT_SUPPORTED = 0;
-
- /**
- * GNSS Measurements are successfully being tracked, it will receive updates once they are
- * available.
- */
+ /** @removed */
public static final int STATUS_READY = 1;
-
- /**
- * GNSS provider or Location is disabled, updates will not be received until they are enabled.
- */
+ /** @removed */
public static final int STATUS_GNSS_LOCATION_DISABLED = 2;
private final GnssClock mClock;
@@ -68,6 +51,32 @@
* {@link LocationManager#registerGnssMeasurementsCallback}.
*/
public static abstract class Callback {
+ /**
+ * The status of the GNSS measurements event.
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_LOCATION_DISABLED})
+ public @interface GnssMeasurementsStatus {}
+
+ /**
+ * The system does not support tracking of GNSS Measurements.
+ *
+ * <p>This status will not change in the future.
+ */
+ public static final int STATUS_NOT_SUPPORTED = 0;
+
+ /**
+ * GNSS Measurements are successfully being tracked, it will receive updates once they are
+ * available.
+ */
+ public static final int STATUS_READY = 1;
+
+ /**
+ * GPS provider or Location is disabled, updates will not be received until they are
+ * enabled.
+ */
+ public static final int STATUS_LOCATION_DISABLED = 2;
/**
* Reports the latest collected GNSS Measurements.
@@ -80,6 +89,10 @@
public void onStatusChanged(@GnssMeasurementsStatus int status) {}
}
+ /**
+ * @hide
+ */
+ @TestApi
public GnssMeasurementsEvent(GnssClock clock, GnssMeasurement[] measurements) {
if (clock == null) {
throw new InvalidParameterException("Parameter 'clock' must not be null.");
@@ -94,6 +107,10 @@
mReadOnlyMeasurements = Collections.unmodifiableCollection(measurementCollection);
}
+ /**
+ * Gets the GNSS receiver clock information associated with the measurements for the current
+ * event.
+ */
@NonNull
public GnssClock getClock() {
return mClock;
diff --git a/location/java/android/location/GnssNavigationMessage.aidl b/location/java/android/location/GnssNavigationMessage.aidl
new file mode 100644
index 0000000..1cdd510
--- /dev/null
+++ b/location/java/android/location/GnssNavigationMessage.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2016, 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.location;
+
+parcelable GnssNavigationMessage;
diff --git a/location/java/android/location/GnssNavigationMessage.java b/location/java/android/location/GnssNavigationMessage.java
index a5eace8..aa26111 100644
--- a/location/java/android/location/GnssNavigationMessage.java
+++ b/location/java/android/location/GnssNavigationMessage.java
@@ -34,7 +34,7 @@
private static final byte[] EMPTY_ARRAY = new byte[0];
/**
- * The type of the GPS Clock.
+ * The type of the GNSS Navigation Message
* @hide
*/
@Retention(RetentionPolicy.SOURCE)
@@ -81,6 +81,51 @@
*/
public static final int STATUS_PARITY_REBUILT = (1<<1);
+ /**
+ * Used for receiving GNSS satellite Navigation Messages from the GNSS engine.
+ *
+ * <p>You can implement this interface and call
+ * {@link LocationManager#registerGnssNavigationMessageCallback}.
+ */
+ public static abstract class Callback {
+ /**
+ * The status of GNSS measurements event.
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_LOCATION_DISABLED})
+ public @interface GnssNavigationMessageStatus {}
+
+ /**
+ * The system does not support tracking of GNSS Navigation Messages.
+ *
+ * This status will not change in the future.
+ */
+ public static final int STATUS_NOT_SUPPORTED = 0;
+
+ /**
+ * GNSS Navigation Messages are successfully being tracked, it will receive updates once
+ * they are available.
+ */
+ public static final int STATUS_READY = 1;
+
+ /**
+ * GNSS provider or Location is disabled, updated will not be received until they are
+ * enabled.
+ */
+ public static final int STATUS_LOCATION_DISABLED = 2;
+
+ /**
+ * Returns the latest collected GNSS Navigation Message.
+ */
+ public void onGnssNavigationMessageReceived(GnssNavigationMessage event) {}
+
+ /**
+ * Returns the latest status of the GNSS Navigation Messages sub-system.
+ */
+ public void onStatusChanged(@GnssNavigationMessageStatus int status) {}
+ }
+
// End enumerations in sync with gps.h
private int mType;
@@ -170,15 +215,16 @@
}
/**
- * Gets the Pseudo-random number.
- * Range: [1, 32].
+ * Gets the satellite ID.
+ *
+ * <p>Range varies by constellation. See definition at {@code GnssStatus#getSvid(int)}
*/
public int getSvid() {
return mSvid;
}
/**
- * Sets the Pseud-random number.
+ * Sets the satellite ID.
* @hide
*/
@TestApi
@@ -187,10 +233,25 @@
}
/**
- * Gets the Message Identifier.
- * It provides an index so the complete Navigation Message can be assembled. i.e. for L1 C/A
- * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message.
- * Subframe 1, 2, 3 does not contain a 'frame id' and this might be reported as -1.
+ * Gets the Message identifier.
+ *
+ * <p>This provides an index to help with complete Navigation Message assembly. Similar
+ * identifiers within the data bits themselves often supplement this information, in ways even
+ * more specific to each message type; see the relevant satellite constellation ICDs for
+ * details.
+ *
+ * <ul>
+ * <li> For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame id' of the
+ * navigation message, in the range of 1-25 (Subframe 1, 2, 3 does not contain a 'frame id' and
+ * this value can be set to -1.)</li>
+ * <li> For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5.</li>
+ * <li> For BeiDou D1, this refers to the frame number in the range of 1-24</li>
+ * <li> For Beidou D2, this refers to the frame number, in the range of 1-120</li>
+ * <li> For Galileo F/NAV nominal frame structure, this refers to the subframe number, in the
+ * range of 1-12</li>
+ * <li> For Galileo I/NAV nominal frame structure, this refers to the subframe number in the
+ * range of 1-24</li>
+ * </ul>
*/
public int getMessageId() {
return mMessageId;
@@ -206,10 +267,18 @@
}
/**
- * Gets the Sub-message Identifier.
- * If required by {@link #getType()}, this value contains a sub-index within the current message
- * (or frame) that is being transmitted. i.e. for L1 C/A the sub-message identifier corresponds
- * to the sub-frame Id of the navigation message.
+ * Gets the sub-message identifier, relevant to the {@link #getType()} of the message.
+ *
+ * <ul>
+ * <li> For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to the subframe
+ * number of the navigation message, in the range of 1-5.</li>
+ * <li>For Glonass L1 C/A, this refers to the String number, in the range from 1-15</li>
+ * <li>For Galileo F/NAV, this refers to the page type in the range 1-6</li>
+ * <li>For Galileo I/NAV, this refers to the word type in the range 1-10+</li>
+ * <li>For Galileo in particular, the type information embedded within the data bits may be even
+ * more useful in interpretation, than the nominal page and word types provided in this
+ * field.</li>
+ * </ul>
*/
public int getSubmessageId() {
return mSubmessageId;
@@ -225,8 +294,25 @@
}
/**
- * Gets the data associated with the Navigation Message.
- * The bytes (or words) specified using big endian format (MSB first).
+ * Gets the data of the reported GPS message.
+ *
+ * <p>The bytes (or words) specified using big endian format (MSB first).
+ *
+ * <ul>
+ * <li>For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit words. Each
+ * word (30 bits) should be fit into the last 30 bits in a 4-byte word (skip B31 and B32), with
+ * MSB first, for a total of 40 bytes, covering a time period of 6, 6, and 0.6 seconds,
+ * respectively.</li>
+ * <li>For Glonass L1 C/A, each string contains 85 data bits, including the checksum. These
+ * bits should be fit into 11 bytes, with MSB first (skip B86-B88), covering a time period of 2
+ * seconds.</li>
+ * <li>For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols excluded). Each
+ * word should be fit into 30-bytes, with MSB first (skip B239, B240), covering a time period of
+ * 10 seconds.</li>
+ * <li>For Galileo I/NAV, each page contains 2 page parts, even and odd, with a total of 2x114 =
+ * 228 bits, (sync & tail excluded) that should be fit into 29 bytes, with MSB first (skip
+ * B229-B232).</li>
+ * </ul>
*/
@NonNull
public byte[] getData() {
diff --git a/location/java/android/location/GnssNavigationMessageCallbackTransport.java b/location/java/android/location/GnssNavigationMessageCallbackTransport.java
index 4204b99..1eafd02 100644
--- a/location/java/android/location/GnssNavigationMessageCallbackTransport.java
+++ b/location/java/android/location/GnssNavigationMessageCallbackTransport.java
@@ -20,12 +20,12 @@
import android.os.RemoteException;
/**
- * A handler class to manage transport callback for {@link GnssNavigationMessageEvent.Callback}.
+ * A handler class to manage transport callback for {@link GnssNavigationMessage.Callback}.
*
* @hide
*/
class GnssNavigationMessageCallbackTransport
- extends LocalListenerHelper<GnssNavigationMessageEvent.Callback> {
+ extends LocalListenerHelper<GnssNavigationMessage.Callback> {
private final ILocationManager mLocationManager;
private final IGnssNavigationMessageListener mListenerTransport = new ListenerTransport();
@@ -51,11 +51,11 @@
private class ListenerTransport extends IGnssNavigationMessageListener.Stub {
@Override
- public void onGnssNavigationMessageReceived(final GnssNavigationMessageEvent event) {
- ListenerOperation<GnssNavigationMessageEvent.Callback> operation =
- new ListenerOperation<GnssNavigationMessageEvent.Callback>() {
+ public void onGnssNavigationMessageReceived(final GnssNavigationMessage event) {
+ ListenerOperation<GnssNavigationMessage.Callback> operation =
+ new ListenerOperation<GnssNavigationMessage.Callback>() {
@Override
- public void execute(GnssNavigationMessageEvent.Callback callback)
+ public void execute(GnssNavigationMessage.Callback callback)
throws RemoteException {
callback.onGnssNavigationMessageReceived(event);
}
@@ -65,10 +65,10 @@
@Override
public void onStatusChanged(final int status) {
- ListenerOperation<GnssNavigationMessageEvent.Callback> operation =
- new ListenerOperation<GnssNavigationMessageEvent.Callback>() {
+ ListenerOperation<GnssNavigationMessage.Callback> operation =
+ new ListenerOperation<GnssNavigationMessage.Callback>() {
@Override
- public void execute(GnssNavigationMessageEvent.Callback callback)
+ public void execute(GnssNavigationMessage.Callback callback)
throws RemoteException {
callback.onStatusChanged(status);
}
diff --git a/location/java/android/location/GnssNavigationMessageEvent.java b/location/java/android/location/GnssNavigationMessageEvent.java
index 992dfc3..f7e5665 100644
--- a/location/java/android/location/GnssNavigationMessageEvent.java
+++ b/location/java/android/location/GnssNavigationMessageEvent.java
@@ -28,10 +28,11 @@
/**
* A class implementing a container for data associated with a navigation message event.
* Events are delivered to registered instances of {@link Callback}.
+ * @removed
*/
public final class GnssNavigationMessageEvent implements Parcelable {
/**
- * The status of GPS measurements event.
+ * The status of GNSS measurements event.
* @hide
*/
@Retention(RetentionPolicy.SOURCE)
@@ -39,38 +40,40 @@
public @interface GnssNavigationMessageStatus {}
/**
- * The system does not support tracking of GPS Navigation Messages. This status will not change
- * in the future.
+ * The system does not support tracking of GNSS Navigation Messages.
+ *
+ * This status will not change in the future.
*/
public static final int STATUS_NOT_SUPPORTED = 0;
/**
- * GPS Navigation Messages are successfully being tracked, it will receive updates once they are
- * available.
+ * GNSS Navigation Messages are successfully being tracked, it will receive updates once they
+ * are available.
*/
public static final int STATUS_READY = 1;
/**
- * GPS provider or Location is disabled, updated will not be received until they are enabled.
+ * GNSS provider or Location is disabled, updated will not be received until they are enabled.
*/
public static final int STATUS_GNSS_LOCATION_DISABLED = 2;
private final GnssNavigationMessage mNavigationMessage;
/**
- * Used for receiving GPS satellite Navigation Messages from the GPS engine.
- * You can implement this interface and call
+ * Used for receiving GNSS satellite Navigation Messages from the GNSS engine.
+ *
+ * <p>You can implement this interface and call
* {@link LocationManager#registerGnssNavigationMessageCallback}.
*/
public static abstract class Callback {
/**
- * Returns the latest collected GPS Navigation Message.
+ * Returns the latest collected GNSS Navigation Message.
*/
public void onGnssNavigationMessageReceived(GnssNavigationMessageEvent event) {}
/**
- * Returns the latest status of the GPS Navigation Messages sub-system.
+ * Returns the latest status of the GNSS Navigation Messages sub-system.
*/
public void onStatusChanged(@GnssNavigationMessageStatus int status) {}
}
diff --git a/location/java/android/location/GnssNmeaListener.java b/location/java/android/location/GnssNmeaListener.java
index 6c9b08a..756ae49 100644
--- a/location/java/android/location/GnssNmeaListener.java
+++ b/location/java/android/location/GnssNmeaListener.java
@@ -23,8 +23,9 @@
* See <a href="http://en.wikipedia.org/wiki/NMEA_0183">NMEA 0183</a> for more details.
* You can implement this interface and call {@link LocationManager#addNmeaListener}
* to receive NMEA data from the GNSS engine.
+* @removed
*/
public interface GnssNmeaListener {
/** Called when an NMEA message is received. */
void onNmeaReceived(long timestamp, String nmea);
-}
\ No newline at end of file
+}
diff --git a/location/java/android/location/GnssStatus.java b/location/java/android/location/GnssStatus.java
index d76feec..e834c30 100644
--- a/location/java/android/location/GnssStatus.java
+++ b/location/java/android/location/GnssStatus.java
@@ -23,9 +23,11 @@
/**
* This class represents the current state of the GNSS engine.
- * This class is used in conjunction with the {@link GnssStatusCallback}.
+ * This class is used in conjunction with the {@link GnssStatus.Callback}.
*/
public final class GnssStatus {
+ // these must match the definitions in gps.h
+
/** Unknown constellation type. */
public static final int CONSTELLATION_UNKNOWN = 0;
/** Constellation type constant for GPS. */
@@ -41,16 +43,6 @@
/** Constellation type constant for Galileo. */
public static final int CONSTELLATION_GALILEO = 6;
- /**
- * Constellation type.
- * @hide
- */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({CONSTELLATION_UNKNOWN, CONSTELLATION_GPS, CONSTELLATION_SBAS, CONSTELLATION_GLONASS,
- CONSTELLATION_QZSS, CONSTELLATION_BEIDOU, CONSTELLATION_GALILEO})
- public @interface ConstellationType {}
-
- // these must match the definitions in gps.h
/** @hide */
public static final int GNSS_SV_FLAGS_NONE = 0;
/** @hide */
@@ -67,6 +59,42 @@
/** @hide */
public static final int CONSTELLATION_TYPE_MASK = 0xf;
+ /**
+ * Used for receiving notifications when GNSS events happen.
+ */
+ public static abstract class Callback {
+ /**
+ * Called when GNSS system has started.
+ */
+ public void onStarted() {}
+
+ /**
+ * Called when GNSS system has stopped.
+ */
+ public void onStopped() {}
+
+ /**
+ * Called when the GNSS system has received its first fix since starting.
+ * @param ttffMillis the time from start to first fix in milliseconds.
+ */
+ public void onFirstFix(int ttffMillis) {}
+
+ /**
+ * Called periodically to report GNSS satellite status.
+ * @param status the current status of all satellites.
+ */
+ public void onSatelliteStatusChanged(GnssStatus status) {}
+ }
+
+ /**
+ * Constellation type.
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({CONSTELLATION_UNKNOWN, CONSTELLATION_GPS, CONSTELLATION_SBAS, CONSTELLATION_GLONASS,
+ CONSTELLATION_QZSS, CONSTELLATION_BEIDOU, CONSTELLATION_GALILEO})
+ public @interface ConstellationType {}
+
/* These package private values are modified by the LocationManager class */
/* package */ int[] mSvidWithFlags;
/* package */ float[] mCn0DbHz;
@@ -83,15 +111,21 @@
mAzimuths = azimuths;
}
+ /** @removed */
+ public int getNumSatellites() {
+ return getSatelliteCount();
+ }
+
/**
* Gets the total number of satellites in satellite list.
*/
- public int getNumSatellites() {
+ public int getSatelliteCount() {
return mSvCount;
}
/**
- * Retrieves the constellation type of the satellite at the specified position.
+ * Retrieves the constellation type of the satellite at the specified index.
+ *
* @param satIndex the index of the satellite in the list.
*/
@ConstellationType
@@ -101,7 +135,30 @@
}
/**
- * Retrieves the pseudo-random number of the satellite at the specified position.
+ * Gets the identification number for the satellite at the specific index.
+ *
+ * <p>This svid is pseudo-random number for most constellations. It is FCN & OSN number for
+ * Glonass.
+ *
+ * <p>The distinction is made by looking at constellation field
+ * {@link #getConstellationType(int)} Expected values are in the range of:
+ *
+ * <ul>
+ * <li>GPS: 1-32</li>
+ * <li>SBAS: 120-151, 183-192</li>
+ * <li>GLONASS:
+ * <ul>
+ * <li>The least significant 8 bits, signed, are the orbital slot number (OSN) in the range
+ * from 1-24, if known, or -127 if unknown</li>
+ * <li>The next least signficant 8 bits, signed, are the frequency channel number (FCN) in the
+ * range from -7 to +6, if known, and -127, if unknown</li>
+ * <li>At least one of the two (FCN & OSN) shall be set to a known value</li>
+ * </ul></li>
+ * <li>QZSS: 193-200</li>
+ * <li>Galileo: 1-36</li>
+ * <li>Beidou: 1-37</li>
+ * </ul>
+ *
* @param satIndex the index of the satellite in the list.
*/
public int getSvid(int satIndex) {
@@ -109,7 +166,9 @@
}
/**
- * Retrieves the signal-noise ration of the satellite at the specified position.
+ * Retrieves the carrier-to-noise density at the antenna of the satellite at the specified index
+ * in dB-Hz.
+ *
* @param satIndex the index of the satellite in the list.
*/
public float getCn0DbHz(int satIndex) {
@@ -117,7 +176,8 @@
}
/**
- * Retrieves the elevation of the satellite at the specified position.
+ * Retrieves the elevation of the satellite at the specified index.
+ *
* @param satIndex the index of the satellite in the list.
*/
public float getElevationDegrees(int satIndex) {
@@ -125,31 +185,46 @@
}
/**
- * Retrieves the azimuth the satellite at the specified position.
+ * Retrieves the azimuth the satellite at the specified index.
+ *
* @param satIndex the index of the satellite in the list.
*/
public float getAzimuthDegrees(int satIndex) {
return mAzimuths[satIndex];
}
- /**
- * Detects whether the satellite at the specified position has ephemeris data.
- * @param satIndex the index of the satellite in the list.
- */
+ /** @removed */
public boolean hasEphemeris(int satIndex) {
- return (mSvidWithFlags[satIndex] & GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA) != 0;
+ return hasEphemerisData(satIndex);
}
/**
- * Detects whether the satellite at the specified position has almanac data.
+ * Reports whether the satellite at the specified index has ephemeris data.
+ *
* @param satIndex the index of the satellite in the list.
*/
+ public boolean hasEphemerisData(int satIndex) {
+ return (mSvidWithFlags[satIndex] & GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA) != 0;
+ }
+
+ /** @removed */
public boolean hasAlmanac(int satIndex) {
+ return hasAlmanacData(satIndex);
+ }
+
+ /**
+ * Reports whether the satellite at the specified index has almanac data.
+ *
+ * @param satIndex the index of the satellite in the list.
+ */
+ public boolean hasAlmanacData(int satIndex) {
return (mSvidWithFlags[satIndex] & GNSS_SV_FLAGS_HAS_ALMANAC_DATA) != 0;
}
/**
- * Detects whether the satellite at the specified position is used in fix.
+ * Reports whether the satellite at the specified index was used in the calculation of the most
+ * recent position fix.
+ *
* @param satIndex the index of the satellite in the list.
*/
public boolean usedInFix(int satIndex) {
diff --git a/location/java/android/location/GnssStatusCallback.java b/location/java/android/location/GnssStatusCallback.java
index 0d2955a..bf295ef 100644
--- a/location/java/android/location/GnssStatusCallback.java
+++ b/location/java/android/location/GnssStatusCallback.java
@@ -18,6 +18,7 @@
/**
* Used for receiving notifications when GNSS events happen.
+ * @removed
*/
public abstract class GnssStatusCallback {
/**
diff --git a/location/java/android/location/GpsSatellite.java b/location/java/android/location/GpsSatellite.java
index 820f5746..788d01e 100644
--- a/location/java/android/location/GpsSatellite.java
+++ b/location/java/android/location/GpsSatellite.java
@@ -18,8 +18,12 @@
/**
* This class represents the current state of a GPS satellite.
+ *
* This class is used in conjunction with the {@link GpsStatus} class.
+ *
+ * @deprecated use {@link GnssStatus} and {@link GnssStatus.Callback}.
*/
+@Deprecated
public final class GpsSatellite {
/* These package private values are modified by the GpsStatus class */
boolean mValid;
diff --git a/location/java/android/location/GpsStatus.java b/location/java/android/location/GpsStatus.java
index bc518f9..038247b 100644
--- a/location/java/android/location/GpsStatus.java
+++ b/location/java/android/location/GpsStatus.java
@@ -24,8 +24,12 @@
/**
* This class represents the current state of the GPS engine.
- * This class is used in conjunction with the {@link Listener} interface.
+ *
+ * <p>This class is used in conjunction with the {@link Listener} interface.
+ *
+ * @deprecated use {@link GnssStatus} and {@link GnssStatus.Callback}.
*/
+@Deprecated
public final class GpsStatus {
private static final int NUM_SATELLITES = 255;
@@ -102,7 +106,9 @@
/**
* Used for receiving notifications when GPS status has changed.
+ * @deprecated use {@link GnssStatus.Callback} instead.
*/
+ @Deprecated
public interface Listener {
/**
* Called to report changes in the GPS status.
@@ -130,7 +136,9 @@
* See <a href="http://en.wikipedia.org/wiki/NMEA_0183">NMEA 0183</a> for more details.
* You can implement this interface and call {@link LocationManager#addNmeaListener}
* to receive NMEA data from the GPS engine.
+ * @deprecated use {@link OnNmeaMessageListener} instead.
*/
+ @Deprecated
public interface NmeaListener {
void onNmeaReceived(long timestamp, String nmea);
}
diff --git a/location/java/android/location/IGnssNavigationMessageListener.aidl b/location/java/android/location/IGnssNavigationMessageListener.aidl
index de6129c..3e49b5b 100644
--- a/location/java/android/location/IGnssNavigationMessageListener.aidl
+++ b/location/java/android/location/IGnssNavigationMessageListener.aidl
@@ -16,12 +16,12 @@
package android.location;
-import android.location.GnssNavigationMessageEvent;
+import android.location.GnssNavigationMessage;
/**
* {@hide}
*/
oneway interface IGnssNavigationMessageListener {
- void onGnssNavigationMessageReceived(in GnssNavigationMessageEvent event);
+ void onGnssNavigationMessageReceived(in GnssNavigationMessage event);
void onStatusChanged(in int status);
}
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 28db099..b246360 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -70,10 +70,16 @@
new HashMap<>();
private final HashMap<GpsStatus.NmeaListener, GnssStatusListenerTransport> mGpsNmeaListeners =
new HashMap<>();
- private final HashMap<GnssStatusCallback, GnssStatusListenerTransport> mGnssStatusListeners =
+ private final HashMap<GnssStatusCallback, GnssStatusListenerTransport>
+ mOldGnssStatusListeners = new HashMap<>();
+ private final HashMap<GnssStatus.Callback, GnssStatusListenerTransport> mGnssStatusListeners =
new HashMap<>();
- private final HashMap<GnssNmeaListener, GnssStatusListenerTransport> mGnssNmeaListeners =
+ private final HashMap<GnssNmeaListener, GnssStatusListenerTransport> mOldGnssNmeaListeners =
new HashMap<>();
+ private final HashMap<OnNmeaMessageListener, GnssStatusListenerTransport> mGnssNmeaListeners =
+ new HashMap<>();
+ private final HashMap<GnssNavigationMessageEvent.Callback, GnssNavigationMessage.Callback>
+ mNavigationMessageBridge = new HashMap<>();
private GnssStatus mGnssStatus;
private int mTimeToFirstFix;
@@ -1392,8 +1398,10 @@
private final GpsStatus.Listener mGpsListener;
private final GpsStatus.NmeaListener mGpsNmeaListener;
- private final GnssStatusCallback mGnssCallback;
- private final GnssNmeaListener mGnssNmeaListener;
+ private final GnssStatusCallback mOldGnssCallback;
+ private final GnssStatus.Callback mGnssCallback;
+ private final GnssNmeaListener mOldGnssNmeaListener;
+ private final OnNmeaMessageListener mGnssNmeaListener;
private class GnssHandler extends Handler {
public GnssHandler(Handler handler) {
@@ -1408,7 +1416,7 @@
int length = mNmeaBuffer.size();
for (int i = 0; i < length; i++) {
Nmea nmea = mNmeaBuffer.get(i);
- mGnssNmeaListener.onNmeaReceived(nmea.mTimestamp, nmea.mNmea);
+ mGnssNmeaListener.onNmeaMessage(nmea.mNmea, nmea.mTimestamp);
}
mNmeaBuffer.clear();
}
@@ -1456,7 +1464,8 @@
mGnssHandler = new GnssHandler(handler);
mGpsNmeaListener = null;
mNmeaBuffer = null;
- mGnssCallback = new GnssStatusCallback() {
+ mOldGnssCallback = null;
+ mGnssCallback = new GnssStatus.Callback() {
@Override
public void onStarted() {
mGpsListener.onGpsStatusChanged(GpsStatus.GPS_EVENT_STARTED);
@@ -1477,6 +1486,7 @@
mGpsListener.onGpsStatusChanged(GpsStatus.GPS_EVENT_SATELLITE_STATUS);
}
};
+ mOldGnssNmeaListener = null;
mGnssNmeaListener = null;
}
@@ -1489,10 +1499,12 @@
mGnssHandler = new GnssHandler(handler);
mGpsNmeaListener = listener;
mNmeaBuffer = new ArrayList<Nmea>();
+ mOldGnssCallback = null;
mGnssCallback = null;
- mGnssNmeaListener = new GnssNmeaListener() {
+ mOldGnssNmeaListener = null;
+ mGnssNmeaListener = new OnNmeaMessageListener() {
@Override
- public void onNmeaReceived(long timestamp, String nmea) {
+ public void onNmeaMessage(String nmea, long timestamp) {
mGpsNmeaListener.onNmeaReceived(timestamp, nmea);
}
};
@@ -1503,8 +1515,45 @@
}
GnssStatusListenerTransport(GnssStatusCallback callback, Handler handler) {
+ mOldGnssCallback = callback;
+ mGnssCallback = new GnssStatus.Callback() {
+ @Override
+ public void onStarted() {
+ mOldGnssCallback.onStarted();
+ }
+
+ @Override
+ public void onStopped() {
+ mOldGnssCallback.onStopped();
+ }
+
+ @Override
+ public void onFirstFix(int ttff) {
+ mOldGnssCallback.onFirstFix(ttff);
+ }
+
+ @Override
+ public void onSatelliteStatusChanged(GnssStatus status) {
+ mOldGnssCallback.onSatelliteStatusChanged(status);
+ }
+ };
+ mGnssHandler = new GnssHandler(handler);
+ mOldGnssNmeaListener = null;
+ mGnssNmeaListener = null;
+ mNmeaBuffer = null;
+ mGpsListener = null;
+ mGpsNmeaListener = null;
+ }
+
+ GnssStatusListenerTransport(GnssStatus.Callback callback) {
+ this(callback, null);
+ }
+
+ GnssStatusListenerTransport(GnssStatus.Callback callback, Handler handler) {
+ mOldGnssCallback = null;
mGnssCallback = callback;
mGnssHandler = new GnssHandler(handler);
+ mOldGnssNmeaListener = null;
mGnssNmeaListener = null;
mNmeaBuffer = null;
mGpsListener = null;
@@ -1517,7 +1566,29 @@
GnssStatusListenerTransport(GnssNmeaListener listener, Handler handler) {
mGnssCallback = null;
+ mOldGnssCallback = null;
mGnssHandler = new GnssHandler(handler);
+ mOldGnssNmeaListener = listener;
+ mGnssNmeaListener = new OnNmeaMessageListener() {
+ @Override
+ public void onNmeaMessage(String message, long timestamp) {
+ mOldGnssNmeaListener.onNmeaReceived(timestamp, message);
+ }
+ };
+ mGpsListener = null;
+ mGpsNmeaListener = null;
+ mNmeaBuffer = new ArrayList<Nmea>();
+ }
+
+ GnssStatusListenerTransport(OnNmeaMessageListener listener) {
+ this(listener, null);
+ }
+
+ GnssStatusListenerTransport(OnNmeaMessageListener listener, Handler handler) {
+ mOldGnssCallback = null;
+ mGnssCallback = null;
+ mGnssHandler = new GnssHandler(handler);
+ mOldGnssNmeaListener = null;
mGnssNmeaListener = listener;
mGpsListener = null;
mGpsNmeaListener = null;
@@ -1589,7 +1660,7 @@
* @return true if the listener was successfully added
*
* @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
- * @deprecated use {@link #registerGnssStatusCallback(GnssStatusCallback)} instead.
+ * @deprecated use {@link #registerGnssStatusCallback(GnssStatus.Callback)} instead.
*/
@Deprecated
@RequiresPermission(ACCESS_FINE_LOCATION)
@@ -1617,6 +1688,7 @@
* Removes a GPS status listener.
*
* @param listener GPS status listener object to remove
+ * @deprecated use {@link #unregisterGnssStatusCallback(GnssStatus.Callback)} instead.
*/
@Deprecated
public void removeGpsStatusListener(GpsStatus.Listener listener) {
@@ -1630,7 +1702,6 @@
}
}
-
/**
* Registers a GNSS status listener.
*
@@ -1639,6 +1710,7 @@
* @return true if the listener was successfully added
*
* @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
+ * @removed
*/
@RequiresPermission(ACCESS_FINE_LOCATION)
public boolean registerGnssStatusCallback(GnssStatusCallback callback) {
@@ -1654,10 +1726,73 @@
* @return true if the listener was successfully added
*
* @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
+ * @removed
*/
@RequiresPermission(ACCESS_FINE_LOCATION)
public boolean registerGnssStatusCallback(GnssStatusCallback callback, Handler handler) {
boolean result;
+ if (mOldGnssStatusListeners.get(callback) != null) {
+ // listener is already registered
+ return true;
+ }
+ try {
+ GnssStatusListenerTransport transport =
+ new GnssStatusListenerTransport(callback, handler);
+ result = mService.registerGnssStatusCallback(transport, mContext.getPackageName());
+ if (result) {
+ mOldGnssStatusListeners.put(callback, transport);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+
+ return result;
+ }
+
+ /**
+ * Removes a GNSS status listener.
+ *
+ * @param callback GNSS status listener object to remove
+ * @removed
+ */
+ public void unregisterGnssStatusCallback(GnssStatusCallback callback) {
+ try {
+ GnssStatusListenerTransport transport = mOldGnssStatusListeners.remove(callback);
+ if (transport != null) {
+ mService.unregisterGnssStatusCallback(transport);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Registers a GNSS status listener.
+ *
+ * @param callback GNSS status listener object to register
+ *
+ * @return true if the listener was successfully added
+ *
+ * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
+ */
+ @RequiresPermission(ACCESS_FINE_LOCATION)
+ public boolean registerGnssStatusCallback(GnssStatus.Callback callback) {
+ return registerGnssStatusCallback(callback, null);
+ }
+
+ /**
+ * Registers a GNSS status listener.
+ *
+ * @param callback GNSS status listener object to register
+ * @param handler the handler that the callback runs on.
+ *
+ * @return true if the listener was successfully added
+ *
+ * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
+ */
+ @RequiresPermission(ACCESS_FINE_LOCATION)
+ public boolean registerGnssStatusCallback(GnssStatus.Callback callback, Handler handler) {
+ boolean result;
if (mGnssStatusListeners.get(callback) != null) {
// listener is already registered
return true;
@@ -1681,7 +1816,7 @@
*
* @param callback GNSS status listener object to remove
*/
- public void unregisterGnssStatusCallback(GnssStatusCallback callback) {
+ public void unregisterGnssStatusCallback(GnssStatus.Callback callback) {
try {
GnssStatusListenerTransport transport = mGnssStatusListeners.remove(callback);
if (transport != null) {
@@ -1700,7 +1835,7 @@
* @return true if the listener was successfully added
*
* @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
- * @deprecated use {@link #addNmeaListener(GnssNmeaListener)} instead.
+ * @deprecated use {@link #addNmeaListener(OnNmeaMessageListener)} instead.
*/
@Deprecated
@RequiresPermission(ACCESS_FINE_LOCATION)
@@ -1728,6 +1863,7 @@
* Removes an NMEA listener.
*
* @param listener a {@link GpsStatus.NmeaListener} object to remove
+ * @deprecated use {@link #removeNmeaListener(OnNmeaMessageListener)} instead.
*/
@Deprecated
public void removeNmeaListener(GpsStatus.NmeaListener listener) {
@@ -1749,6 +1885,7 @@
* @return true if the listener was successfully added
*
* @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
+ * @removed
*/
@RequiresPermission(ACCESS_FINE_LOCATION)
public boolean addNmeaListener(GnssNmeaListener listener) {
@@ -1764,6 +1901,7 @@
* @return true if the listener was successfully added
*
* @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
+ * @removed
*/
@RequiresPermission(ACCESS_FINE_LOCATION)
public boolean addNmeaListener(GnssNmeaListener listener, Handler handler) {
@@ -1778,6 +1916,69 @@
new GnssStatusListenerTransport(listener, handler);
result = mService.registerGnssStatusCallback(transport, mContext.getPackageName());
if (result) {
+ mOldGnssNmeaListeners.put(listener, transport);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+
+ return result;
+ }
+
+ /**
+ * Removes an NMEA listener.
+ *
+ * @param listener a {@link GnssNmeaListener} object to remove
+ * @removed
+ */
+ public void removeNmeaListener(GnssNmeaListener listener) {
+ try {
+ GnssStatusListenerTransport transport = mOldGnssNmeaListeners.remove(listener);
+ if (transport != null) {
+ mService.unregisterGnssStatusCallback(transport);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Adds an NMEA listener.
+ *
+ * @param listener a {@link OnNmeaMessageListener} object to register
+ *
+ * @return true if the listener was successfully added
+ *
+ * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
+ */
+ @RequiresPermission(ACCESS_FINE_LOCATION)
+ public boolean addNmeaListener(OnNmeaMessageListener listener) {
+ return addNmeaListener(listener, null);
+ }
+
+ /**
+ * Adds an NMEA listener.
+ *
+ * @param listener a {@link OnNmeaMessageListener} object to register
+ * @param handler the handler that the listener runs on.
+ *
+ * @return true if the listener was successfully added
+ *
+ * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
+ */
+ @RequiresPermission(ACCESS_FINE_LOCATION)
+ public boolean addNmeaListener(OnNmeaMessageListener listener, Handler handler) {
+ boolean result;
+
+ if (mGpsNmeaListeners.get(listener) != null) {
+ // listener is already registered
+ return true;
+ }
+ try {
+ GnssStatusListenerTransport transport =
+ new GnssStatusListenerTransport(listener, handler);
+ result = mService.registerGnssStatusCallback(transport, mContext.getPackageName());
+ if (result) {
mGnssNmeaListeners.put(listener, transport);
}
} catch (RemoteException e) {
@@ -1790,9 +1991,9 @@
/**
* Removes an NMEA listener.
*
- * @param listener a {@link GnssNmeaListener} object to remove
+ * @param listener a {@link OnNmeaMessageListener} object to remove
*/
- public void removeNmeaListener(GnssNmeaListener listener) {
+ public void removeNmeaListener(OnNmeaMessageListener listener) {
try {
GnssStatusListenerTransport transport = mGnssNmeaListeners.remove(listener);
if (transport != null) {
@@ -1843,7 +2044,8 @@
* No-op method to keep backward-compatibility.
* Don't use it. Use {@link #unregisterGnssMeasurementsCallback} instead.
* @hide
- * @deprecated
+ * @deprecated use {@link #unregisterGnssMeasurementsCallback(GnssMeasurementsEvent.Callback)}
+ * instead.
*/
@Deprecated
@SystemApi
@@ -1872,10 +2074,23 @@
}
/**
- * Registers a GPS Navigation Message callback.
+ * No-op method to keep backward-compatibility.
+ * Don't use it. Use {@link #unregisterGnssNavigationMessageCallback} instead.
+ * @hide
+ * @deprecated use {@link #unregisterGnssNavigationMessageCallback(GnssMeasurements.Callback)}
+ * instead
+ */
+ @Deprecated
+ @SystemApi
+ public void removeGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) {
+ }
+
+ /**
+ * Registers a GNSS Navigation Message callback.
*
* @param callback a {@link GnssNavigationMessageEvent.Callback} object to register.
* @return {@code true} if the callback was added successfully, {@code false} otherwise.
+ * @removed
*/
public boolean registerGnssNavigationMessageCallback(
GnssNavigationMessageEvent.Callback callback) {
@@ -1883,40 +2098,80 @@
}
/**
- * Registers a GPS Navigation Message callback.
+ * Registers a GNSS Navigation Message callback.
*
* @param callback a {@link GnssNavigationMessageEvent.Callback} object to register.
* @param handler the handler that the callback runs on.
* @return {@code true} if the callback was added successfully, {@code false} otherwise.
+ * @removed
+ */
+ @RequiresPermission(ACCESS_FINE_LOCATION)
+ public boolean registerGnssNavigationMessageCallback(
+ final GnssNavigationMessageEvent.Callback callback, Handler handler) {
+ GnssNavigationMessage.Callback bridge = new GnssNavigationMessage.Callback() {
+ @Override
+ public void onGnssNavigationMessageReceived(GnssNavigationMessage message) {
+ GnssNavigationMessageEvent event = new GnssNavigationMessageEvent(message);
+ callback.onGnssNavigationMessageReceived(event);
+ }
+
+ @Override
+ public void onStatusChanged(int status) {
+ callback.onStatusChanged(status);
+ }
+ };
+ mNavigationMessageBridge.put(callback, bridge);
+ return mGnssNavigationMessageCallbackTransport.add(bridge, handler);
+ }
+
+ /**
+ * Unregisters a GNSS Navigation Message callback.
+ *
+ * @param callback a {@link GnssNavigationMessageEvent.Callback} object to remove.
+ * @removed
+ */
+ public void unregisterGnssNavigationMessageCallback(
+ GnssNavigationMessageEvent.Callback callback) {
+ mGnssNavigationMessageCallbackTransport.remove(
+ mNavigationMessageBridge.remove(
+ callback));
+ }
+
+ /**
+ * Registers a GNSS Navigation Message callback.
+ *
+ * @param callback a {@link GnssNavigationMessage.Callback} object to register.
+ * @return {@code true} if the callback was added successfully, {@code false} otherwise.
+ */
+ public boolean registerGnssNavigationMessageCallback(
+ GnssNavigationMessage.Callback callback) {
+ return registerGnssNavigationMessageCallback(callback, null);
+ }
+
+ /**
+ * Registers a GNSS Navigation Message callback.
+ *
+ * @param callback a {@link GnssNavigationMessage.Callback} object to register.
+ * @param handler the handler that the callback runs on.
+ * @return {@code true} if the callback was added successfully, {@code false} otherwise.
*/
@RequiresPermission(ACCESS_FINE_LOCATION)
public boolean registerGnssNavigationMessageCallback(
- GnssNavigationMessageEvent.Callback callback, Handler handler) {
+ GnssNavigationMessage.Callback callback, Handler handler) {
return mGnssNavigationMessageCallbackTransport.add(callback, handler);
}
/**
- * Unregisters a GPS Navigation Message callback.
+ * Unregisters a GNSS Navigation Message callback.
*
- * @param callback a {@link GnssNavigationMessageEvent.Callback} object to remove.
+ * @param callback a {@link GnssNavigationMessage.Callback} object to remove.
*/
public void unregisterGnssNavigationMessageCallback(
- GnssNavigationMessageEvent.Callback callback) {
+ GnssNavigationMessage.Callback callback) {
mGnssNavigationMessageCallbackTransport.remove(callback);
}
/**
- * No-op method to keep backward-compatibility.
- * Don't use it. Use {@link #unregisterGnssNavigationMessageCallback} instead.
- * @hide
- * @deprecated
- */
- @Deprecated
- @SystemApi
- public void removeGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) {
- }
-
- /**
* Retrieves information about the current status of the GPS engine.
* This should only be called from the {@link GpsStatus.Listener#onGpsStatusChanged}
* callback to ensure that the data is copied atomically.
diff --git a/location/java/android/location/OnNmeaMessageListener.java b/location/java/android/location/OnNmeaMessageListener.java
new file mode 100644
index 0000000..ccf6ce8
--- /dev/null
+++ b/location/java/android/location/OnNmeaMessageListener.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 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.location;
+
+/**
+* Used for receiving NMEA sentences from the GNSS.
+* NMEA 0183 is a standard for communicating with marine electronic devices
+* and is a common method for receiving data from a GNSS, typically over a serial port.
+* See <a href="http://en.wikipedia.org/wiki/NMEA_0183">NMEA 0183</a> for more details.
+* You can implement this interface and call {@link LocationManager#addNmeaListener}
+* to receive NMEA data from the GNSS engine.
+*/
+public interface OnNmeaMessageListener {
+ /**
+ * Called when an NMEA message is received.
+ * @param message NMEA message
+ * @param timestamp milliseconds since January 1, 1970.
+ */
+ void onNmeaMessage(String message, long timestamp);
+}
diff --git a/media/java/android/media/tv/TvRecordingClient.java b/media/java/android/media/tv/TvRecordingClient.java
index a5ff29f..2613376 100644
--- a/media/java/android/media/tv/TvRecordingClient.java
+++ b/media/java/android/media/tv/TvRecordingClient.java
@@ -158,7 +158,7 @@
* <p>The application may supply the URI for a TV program for filling in program specific data
* fields in the {@link android.media.tv.TvContract.RecordedPrograms} table.
* A non-null {@code programHint} implies the started recording should be of that specific
- * program, whereas null {@code programHint} does not impose such a requirement and the
+ * program, whereas null {@code programUri} does not impose such a requirement and the
* recording can span across multiple TV programs. In either case, the application must call
* {@link TvRecordingClient#stopRecording()} to stop the recording.
*
diff --git a/media/java/android/mtp/MtpServer.java b/media/java/android/mtp/MtpServer.java
index 3814630..61fbfb9 100644
--- a/media/java/android/mtp/MtpServer.java
+++ b/media/java/android/mtp/MtpServer.java
@@ -23,12 +23,14 @@
public class MtpServer implements Runnable {
private long mNativeContext; // accessed by native methods
+ private final MtpDatabase mDatabase;
static {
System.loadLibrary("media_jni");
}
public MtpServer(MtpDatabase database, boolean usePtp) {
+ mDatabase = database;
native_setup(database, usePtp);
database.setServer(this);
}
@@ -42,6 +44,7 @@
public void run() {
native_run();
native_cleanup();
+ mDatabase.close();
}
public void sendObjectAdded(int handle) {
diff --git a/packages/ExtServices/res/values/strings.xml b/packages/ExtServices/res/values/strings.xml
index 0763403..b77ff10 100644
--- a/packages/ExtServices/res/values/strings.xml
+++ b/packages/ExtServices/res/values/strings.xml
@@ -17,4 +17,5 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">Android Services Library</string>
<string name="notification_ranker">Android Notification Ranking Service</string>
+ <string name="notification_ranker_autobundle_explanation">Auto-grouping updated by Ranking Service</string>
</resources>
diff --git a/packages/ExtServices/src/android/ext/services/notification/Ranker.java b/packages/ExtServices/src/android/ext/services/notification/Ranker.java
index 0b2b1a4..3ef2aea 100644
--- a/packages/ExtServices/src/android/ext/services/notification/Ranker.java
+++ b/packages/ExtServices/src/android/ext/services/notification/Ranker.java
@@ -16,16 +16,36 @@
package android.ext.services.notification;
+import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
+
+import android.os.Bundle;
+import android.service.notification.Adjustment;
import android.service.notification.NotificationRankerService;
import android.service.notification.StatusBarNotification;
import android.util.Log;
+import android.util.Slog;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import android.ext.services.R;
/**
* Class that provides an updatable ranker module for the notification manager..
*/
public final class Ranker extends NotificationRankerService {
private static final String TAG = "RocketRanker";
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);;
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+
+ private static final int AUTOBUNDLE_AT_COUNT = 4;
+ private static final String AUTOBUNDLE_KEY = "ranker_bundle";
+
+ // Map of package : notification keys. Only contains notifications that are not bundled
+ // by the app (aka no group or sort key).
+ Map<String, LinkedHashSet<String>> mUnbundledNotifications;
@Override
public Adjustment onNotificationEnqueued(StatusBarNotification sbn, int importance,
@@ -37,10 +57,146 @@
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
if (DEBUG) Log.i(TAG, "POSTED " + sbn.getKey());
+ try {
+ List<String> notificationsToBundle = new ArrayList<>();
+ if (!sbn.isGroup()) {
+ // Not grouped by the app, add to the list of notifications for the app;
+ // send bundling update if app exceeds the autobundling limit.
+ synchronized (mUnbundledNotifications) {
+ LinkedHashSet<String> notificationsForPackage
+ = mUnbundledNotifications.get(sbn.getPackageName());
+ if (notificationsForPackage == null) {
+ notificationsForPackage = new LinkedHashSet<>();
+ }
+ if (notificationsForPackage.contains(sbn.getKey())) {
+ return;
+ }
+ notificationsForPackage.add(sbn.getKey());
+ mUnbundledNotifications.put(sbn.getPackageName(), notificationsForPackage);
+
+ if (notificationsForPackage.size() >= AUTOBUNDLE_AT_COUNT) {
+ // Autobundle all but the most recently posted (not updated) notification.
+ int count = 0;
+ for (String key : notificationsForPackage) {
+ if (count < notificationsForPackage.size() - 1) {
+ notificationsToBundle.add(key);
+ }
+ count++;
+ }
+ }
+ }
+ if (notificationsToBundle.size() > 0) {
+ adjustAutobundlingSummary(sbn.getPackageName(), notificationsToBundle.get(0),
+ true);
+ adjustNotificationBundling(sbn.getPackageName(), notificationsToBundle, true);
+ }
+ } else {
+ // Grouped, but not by us. Send updates to unautobundle, if we bundled it.
+ maybeUnbundle(sbn, false);
+ }
+ } catch (Exception e) {
+ Slog.e(TAG, "Failure processing new notification", e);
+ }
+ }
+
+ @Override
+ public void onNotificationRemoved(StatusBarNotification sbn) {
+ try {
+ maybeUnbundle(sbn, true);
+ } catch (Exception e) {
+ Slog.e(TAG, "Error processing canceled notification", e);
+ }
+ }
+
+ /**
+ * Un-autobundles notifications that are now grouped by the app. Additionally cancels
+ * autobundling if the status change of this notification resulted in the loose notification
+ * count being under the limit.
+ */
+ private void maybeUnbundle(StatusBarNotification sbn, boolean notificationGone) {
+ List<String> notificationsToUnAutobundle = new ArrayList<>();
+ boolean removeSummary = false;
+ synchronized (mUnbundledNotifications) {
+ LinkedHashSet<String> notificationsForPackage
+ = mUnbundledNotifications.get(sbn.getPackageName());
+ if (notificationsForPackage == null || notificationsForPackage.size() == 0) {
+ return;
+ }
+ if (notificationsForPackage.remove(sbn.getKey())) {
+ if (!notificationGone) {
+ // Add the current notification to the unbundling list if it still exists.
+ notificationsToUnAutobundle.add(sbn.getKey());
+ }
+ // If the status change of this notification has brought the number of loose
+ // notifications back below the limit, remove the summary and un-autobundle.
+ if (notificationsForPackage.size() == AUTOBUNDLE_AT_COUNT - 1) {
+ removeSummary = true;
+ for (String key : notificationsForPackage) {
+ notificationsToUnAutobundle.add(key);
+ }
+ }
+ }
+ }
+ if (notificationsToUnAutobundle.size() > 0) {
+ if (removeSummary) {
+ adjustAutobundlingSummary(sbn.getPackageName(), null, false);
+ }
+ adjustNotificationBundling(sbn.getPackageName(), notificationsToUnAutobundle, false);
+ }
}
@Override
public void onListenerConnected() {
if (DEBUG) Log.i(TAG, "CONNECTED");
+ mUnbundledNotifications = new HashMap<>();
+ for (StatusBarNotification sbn : getActiveNotifications()) {
+ onNotificationPosted(sbn);
+ }
}
+
+ private void adjustAutobundlingSummary(String packageName, String key, boolean summaryNeeded) {
+ Bundle signals = new Bundle();
+ if (summaryNeeded) {
+ signals.putBoolean(Adjustment.NEEDS_AUTOGROUPING_KEY, true);
+ signals.putString(Adjustment.GROUP_KEY_OVERRIDE_KEY, AUTOBUNDLE_KEY);
+ } else {
+ signals.putBoolean(Adjustment.NEEDS_AUTOGROUPING_KEY, false);
+ }
+ Adjustment adjustment = new Adjustment(packageName, key, IMPORTANCE_UNSPECIFIED, signals,
+ getContext().getString(R.string.notification_ranker_autobundle_explanation), null);
+ if (DEBUG) {
+ Log.i(TAG, "Summary update for: " + packageName + " "
+ + (summaryNeeded ? "adding" : "removing"));
+ }
+ try {
+ adjustNotification(adjustment);
+ } catch (Exception e) {
+ Slog.e(TAG, "Adjustment failed", e);
+ }
+
+ }
+ private void adjustNotificationBundling(String packageName, List<String> keys, boolean bundle) {
+ List<Adjustment> adjustments = new ArrayList<>();
+ for (String key : keys) {
+ adjustments.add(createBundlingAdjustment(packageName, key, bundle));
+ if (DEBUG) Log.i(TAG, "Sending bundling adjustment for: " + key);
+ }
+ try {
+ adjustNotifications(adjustments);
+ } catch (Exception e) {
+ Slog.e(TAG, "Adjustments failed", e);
+ }
+ }
+
+ private Adjustment createBundlingAdjustment(String packageName, String key, boolean bundle) {
+ Bundle signals = new Bundle();
+ if (bundle) {
+ signals.putString(Adjustment.GROUP_KEY_OVERRIDE_KEY, AUTOBUNDLE_KEY);
+ } else {
+ signals.putString(Adjustment.GROUP_KEY_OVERRIDE_KEY, null);
+ }
+ return new Adjustment(packageName, key, IMPORTANCE_UNSPECIFIED, signals,
+ getContext().getString(R.string.notification_ranker_autobundle_explanation), null);
+ }
+
}
\ No newline at end of file
diff --git a/packages/Keyguard/src/com/android/keyguard/PasswordTextView.java b/packages/Keyguard/src/com/android/keyguard/PasswordTextView.java
index 6eea81b..7dba545 100644
--- a/packages/Keyguard/src/com/android/keyguard/PasswordTextView.java
+++ b/packages/Keyguard/src/com/android/keyguard/PasswordTextView.java
@@ -148,8 +148,9 @@
protected void onDraw(Canvas canvas) {
float totalDrawingWidth = getDrawingWidth();
float currentDrawPosition;
- if ((mGravity & Gravity.START) != 0) {
- if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
+ if ((mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) {
+ if ((mGravity & Gravity.RELATIVE_LAYOUT_DIRECTION) != 0
+ && getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
currentDrawPosition = getWidth() - getPaddingRight() - totalDrawingWidth;
} else {
currentDrawPosition = getPaddingLeft();
@@ -163,7 +164,7 @@
float yPosition =
(getHeight() - getPaddingBottom() - getPaddingTop()) / 2 + getPaddingTop();
canvas.clipRect(getPaddingLeft(), getPaddingTop(),
- getWidth()-getPaddingRight(), getHeight()-getPaddingBottom());
+ getWidth() - getPaddingRight(), getHeight() - getPaddingBottom());
float charLength = bounds.right - bounds.left;
for (int i = 0; i < length; i++) {
CharState charState = mTextChars.get(i);
diff --git a/packages/MtpDocumentsProvider/jni/com_android_mtp_AppFuse.cpp b/packages/MtpDocumentsProvider/jni/com_android_mtp_AppFuse.cpp
index eb96015..7c8806e 100644
--- a/packages/MtpDocumentsProvider/jni/com_android_mtp_AppFuse.cpp
+++ b/packages/MtpDocumentsProvider/jni/com_android_mtp_AppFuse.cpp
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
#define LOG_TAG "AppFuseJNI"
#include "utils/Log.h"
@@ -451,7 +450,7 @@
ScopedFd fd(static_cast<int>(jfd));
AppFuse appfuse(env, self);
- ALOGD("Start fuse loop.");
+ ALOGV("Start fuse loop.");
while (true) {
FuseRequest request;
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index a560e3c..084acac 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -850,5 +850,7 @@
<!-- Description for a custom screen zoom level. This shows the requested display
density in raw pixels per inch rather than using a relative description. [CHAR LIMIT=24] -->
<string name="screen_zoom_summary_custom">Custom (<xliff:g id="densityDpi" example="160">%d</xliff:g>)</string>
+ <!-- Label for Help and feedback menu item -->
+ <string name="help_feedback_label">Help & feedback</string>
</resources>
diff --git a/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java b/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java
new file mode 100644
index 0000000..320cd58
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2012 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.settingslib;
+
+import android.app.Activity;
+import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources.Theme;
+import android.net.Uri;
+import android.text.TextUtils;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
+
+import java.net.URISyntaxException;
+import java.util.Locale;
+
+/**
+ * Functions to easily prepare contextual help menu option items with an intent that opens up the
+ * browser to a particular URL, while taking into account the preferred language and app version.
+ */
+public class HelpUtils {
+ private final static String TAG = HelpUtils.class.getSimpleName();
+
+ private static final int MENU_HELP = Menu.FIRST + 100;
+
+ /**
+ * Help URL query parameter key for the preferred language.
+ */
+ private final static String PARAM_LANGUAGE_CODE = "hl";
+
+ /**
+ * Help URL query parameter key for the app version.
+ */
+ private final static String PARAM_VERSION = "version";
+
+ // Constants for help intents.
+ private static final String EXTRA_CONTEXT = "EXTRA_CONTEXT";
+ private static final String EXTRA_THEME = "EXTRA_THEME";
+ private static final String EXTRA_PRIMARY_COLOR = "EXTRA_PRIMARY_COLOR";
+ private static final String EXTRA_BACKUP_URI = "EXTRA_BACKUP_URI";
+
+ /**
+ * Cached version code to prevent repeated calls to the package manager.
+ */
+ private static String sCachedVersionCode = null;
+
+ /** Static helper that is not instantiable*/
+ private HelpUtils() { }
+
+ public static boolean prepareHelpMenuItem(Activity activity, Menu menu, String helpUri,
+ String backupContext) {
+ MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_feedback_label);
+ return prepareHelpMenuItem(activity, helpItem, helpUri, backupContext);
+ }
+
+ public static boolean prepareHelpMenuItem(Activity activity, Menu menu, int helpUriResource,
+ String backupContext) {
+ MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_feedback_label);
+ return prepareHelpMenuItem(activity, helpItem, activity.getString(helpUriResource),
+ backupContext);
+ }
+
+ /**
+ * Prepares the help menu item by doing the following.
+ * - If the helpUrlString is empty or null, the help menu item is made invisible.
+ * - Otherwise, this makes the help menu item visible and sets the intent for the help menu
+ * item to view the URL.
+ *
+ * @return returns whether the help menu item has been made visible.
+ */
+ public static boolean prepareHelpMenuItem(final Activity activity, MenuItem helpMenuItem,
+ String helpUriString, String backupContext) {
+ if (TextUtils.isEmpty(helpUriString)) {
+ // The help url string is empty or null, so set the help menu item to be invisible.
+ helpMenuItem.setVisible(false);
+
+ // return that the help menu item is not visible (i.e. false)
+ return false;
+ } else {
+ final Intent intent = getHelpIntent(activity, helpUriString, backupContext);
+
+ // Set the intent to the help menu item, show the help menu item in the overflow
+ // menu, and make it visible.
+ if (intent != null) {
+ helpMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ try {
+ activity.startActivityForResult(intent, 0);
+ } catch (ActivityNotFoundException exc) {
+ Log.e(TAG, "No activity found for intent: " + intent);
+ }
+ return true;
+ }
+ });
+ helpMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+ helpMenuItem.setVisible(true);
+ } else {
+ helpMenuItem.setVisible(false);
+ return false;
+ }
+
+ // return that the help menu item is visible (i.e., true)
+ return true;
+ }
+ }
+
+ public static Intent getHelpIntent(Context context, String helpUriString,
+ String backupContext) {
+ // Try to handle as Intent Uri, otherwise just treat as Uri.
+ try {
+ Intent intent = Intent.parseUri(helpUriString,
+ Intent.URI_ANDROID_APP_SCHEME | Intent.URI_INTENT_SCHEME);
+ addIntentParameters(context, intent, backupContext);
+ ComponentName component = intent.resolveActivity(context.getPackageManager());
+ if (component != null) {
+ return intent;
+ } else if (intent.hasExtra(EXTRA_BACKUP_URI)) {
+ // This extra contains a backup URI for when the intent isn't available.
+ return getHelpIntent(context, intent.getStringExtra(EXTRA_BACKUP_URI),
+ backupContext);
+ } else {
+ return null;
+ }
+ } catch (URISyntaxException e) {
+ }
+ // The help url string exists, so first add in some extra query parameters.
+ final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUriString));
+
+ // Then, create an intent that will be fired when the user
+ // selects this help menu item.
+ Intent intent = new Intent(Intent.ACTION_VIEW, fullUri);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ return intent;
+ }
+
+ private static void addIntentParameters(Context context, Intent intent, String backupContext) {
+ if (!intent.hasExtra(EXTRA_CONTEXT)) {
+ // Insert some context if none exists.
+ intent.putExtra(EXTRA_CONTEXT, backupContext);
+ }
+ intent.putExtra(EXTRA_THEME, 1 /* Light, dark action bar */);
+ Theme theme = context.getTheme();
+ TypedValue typedValue = new TypedValue();
+ theme.resolveAttribute(android.R.attr.colorPrimary, typedValue, true);
+ intent.putExtra(EXTRA_PRIMARY_COLOR, context.getColor(typedValue.resourceId));
+ }
+
+ /**
+ * Adds two query parameters into the Uri, namely the language code and the version code
+ * of the app's package as gotten via the context.
+ * @return the uri with added query parameters
+ */
+ public static Uri uriWithAddedParameters(Context context, Uri baseUri) {
+ Uri.Builder builder = baseUri.buildUpon();
+
+ // Add in the preferred language
+ builder.appendQueryParameter(PARAM_LANGUAGE_CODE, Locale.getDefault().toString());
+
+ // Add in the package version code
+ if (sCachedVersionCode == null) {
+ // There is no cached version code, so try to get it from the package manager.
+ try {
+ // cache the version code
+ PackageInfo info = context.getPackageManager().getPackageInfo(
+ context.getPackageName(), 0);
+ sCachedVersionCode = Integer.toString(info.versionCode);
+
+ // append the version code to the uri
+ builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode);
+ } catch (NameNotFoundException e) {
+ // Cannot find the package name, so don't add in the version parameter
+ // This shouldn't happen.
+ Log.wtf(TAG, "Invalid package name for context", e);
+ }
+ } else {
+ builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode);
+ }
+
+ // Build the full uri and return it
+ return builder.build();
+ }
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/Utils.java b/packages/SettingsLib/src/com/android/settingslib/Utils.java
index 586f269..ca0b86a 100644
--- a/packages/SettingsLib/src/com/android/settingslib/Utils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/Utils.java
@@ -15,7 +15,7 @@
import android.os.BatteryManager;
import android.os.UserManager;
import com.android.internal.util.UserIcons;
-import com.android.settingslib.drawable.CircleFramedDrawable;
+import com.android.settingslib.drawable.UserIconDrawable;
import java.text.NumberFormat;
@@ -73,21 +73,22 @@
/**
* Returns a circular icon for a user.
*/
- public static Drawable getUserIcon(Context context, UserManager um, UserInfo user) {
+ public static UserIconDrawable getUserIcon(Context context, UserManager um, UserInfo user) {
+ final int iconSize = UserIconDrawable.getSizeForList(context);
if (user.isManagedProfile()) {
// We use predefined values for managed profiles
Bitmap b = BitmapFactory.decodeResource(context.getResources(),
com.android.internal.R.drawable.ic_corp_icon);
- return CircleFramedDrawable.getInstance(context, b);
+ return new UserIconDrawable(iconSize).setIcon(b).bake();
}
if (user.iconPath != null) {
Bitmap icon = um.getUserIcon(user.id);
if (icon != null) {
- return CircleFramedDrawable.getInstance(context, icon);
+ return new UserIconDrawable(iconSize).setIcon(icon).bake();
}
}
- return CircleFramedDrawable.getInstance(context, UserIcons.convertToBitmap(
- UserIcons.getDefaultUserIcon(user.id, /* light= */ false)));
+ return new UserIconDrawable(iconSize).setIconDrawable(
+ UserIcons.getDefaultUserIcon(user.id, /* light= */ false)).bake();
}
/** Formats the ratio of amount/total as a percentage. */
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
index 6052ccd..7f0e27a 100755
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
@@ -399,6 +399,9 @@
// Copy previous profile list into removedProfiles
removedProfiles.clear();
removedProfiles.addAll(profiles);
+ if (DEBUG) {
+ Log.d(TAG,"Current Profiles" + profiles.toString());
+ }
profiles.clear();
if (uuids == null) {
@@ -415,6 +418,13 @@
}
}
+ if ((mHfpClientProfile != null) &&
+ BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree_AG) &&
+ BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.Handsfree)) {
+ profiles.add(mHfpClientProfile);
+ removedProfiles.remove(mHfpClientProfile);
+ }
+
if (BluetoothUuid.containsAnyUuid(uuids, A2dpProfile.SINK_UUIDS) &&
mA2dpProfile != null) {
profiles.add(mA2dpProfile);
@@ -425,7 +435,7 @@
mA2dpSinkProfile != null) {
profiles.add(mA2dpSinkProfile);
removedProfiles.remove(mA2dpSinkProfile);
- }
+ }
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.ObexObjectPush) &&
mOppProfile != null) {
@@ -461,5 +471,9 @@
profiles.remove(mPbapProfile);
removedProfiles.add(mPbapProfile);
}
+
+ if (DEBUG) {
+ Log.d(TAG,"New Profiles" + profiles.toString());
+ }
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/drawable/UserIconDrawable.java b/packages/SettingsLib/src/com/android/settingslib/drawable/UserIconDrawable.java
new file mode 100644
index 0000000..32478a7
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/drawable/UserIconDrawable.java
@@ -0,0 +1,428 @@
+/*
+ * Copyright (C) 2016 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.settingslib.drawable;
+
+import android.annotation.NonNull;
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorFilter;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.PixelFormat;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
+import android.graphics.PorterDuffXfermode;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.Shader;
+import android.graphics.drawable.Drawable;
+
+import com.android.settingslib.R;
+
+/**
+ * Converts the user avatar icon to a circularly clipped one with an optional badge and frame
+ */
+public class UserIconDrawable extends Drawable implements Drawable.Callback {
+
+ private Drawable mUserDrawable;
+ private Bitmap mUserIcon;
+ private Bitmap mBitmap; // baked representation. Required for transparent border around badge
+ private final Paint mIconPaint = new Paint();
+ private final Paint mPaint = new Paint();
+ private final Matrix mIconMatrix = new Matrix();
+ private float mIntrinsicRadius;
+ private float mDisplayRadius;
+ private float mPadding = 0;
+ private int mSize = 0; // custom "intrinsic" size for this drawable if non-zero
+ private boolean mInvalidated = true;
+ private ColorStateList mTintColor = null;
+ private PorterDuff.Mode mTintMode = PorterDuff.Mode.SRC_ATOP;
+
+ private float mFrameWidth;
+ private float mFramePadding;
+ private ColorStateList mFrameColor = null;
+ private Paint mFramePaint;
+
+ private Drawable mBadge;
+ private Paint mClearPaint;
+ private float mBadgeRadius;
+ private float mBadgeMargin;
+
+ /**
+ * Gets the system default managed-user badge as a drawable
+ * @param context
+ * @return drawable containing just the badge
+ */
+ public static Drawable getManagedUserBadgeDrawable(Context context) {
+ int displayDensity = context.getResources().getDisplayMetrics().densityDpi;
+ return context.getResources().getDrawableForDensity(
+ com.android.internal.R.drawable.ic_corp_user_badge,
+ displayDensity, context.getTheme());
+ }
+
+ /**
+ * Gets the preferred list-item size of this drawable.
+ * @param context
+ * @return size in pixels
+ */
+ public static int getSizeForList(Context context) {
+ return (int) context.getResources().getDimension(R.dimen.circle_avatar_size);
+ }
+
+ public UserIconDrawable() {
+ this(0);
+ }
+
+ /**
+ * Use this constructor if the drawable is intended to be placed in listviews
+ * @param intrinsicSize if 0, the intrinsic size will come from the icon itself
+ */
+ public UserIconDrawable(int intrinsicSize) {
+ super();
+ mIconPaint.setAntiAlias(true);
+ mIconPaint.setFilterBitmap(true);
+ mPaint.setFilterBitmap(true);
+ mPaint.setAntiAlias(true);
+ if (intrinsicSize > 0) {
+ setBounds(0, 0, intrinsicSize, intrinsicSize);
+ setIntrinsicSize(intrinsicSize);
+ }
+ setIcon(null);
+ }
+
+ public UserIconDrawable setIcon(Bitmap icon) {
+ if (mUserDrawable != null) {
+ mUserDrawable.setCallback(null);
+ mUserDrawable = null;
+ }
+ mUserIcon = icon;
+ if (mUserIcon == null) {
+ mIconPaint.setShader(null);
+ mBitmap = null;
+ } else {
+ mIconPaint.setShader(new BitmapShader(icon, Shader.TileMode.CLAMP,
+ Shader.TileMode.CLAMP));
+ }
+ onBoundsChange(getBounds());
+ return this;
+ }
+
+ public UserIconDrawable setIconDrawable(Drawable icon) {
+ if (mUserDrawable != null) {
+ mUserDrawable.setCallback(null);
+ }
+ mUserIcon = null;
+ mUserDrawable = icon;
+ if (mUserDrawable == null) {
+ mBitmap = null;
+ } else {
+ mUserDrawable.setCallback(this);
+ }
+ onBoundsChange(getBounds());
+ return this;
+ }
+
+ public UserIconDrawable setBadge(Drawable badge) {
+ mBadge = badge;
+ if (mBadge != null) {
+ if (mClearPaint == null) {
+ mClearPaint = new Paint();
+ mClearPaint.setAntiAlias(true);
+ mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
+ mClearPaint.setStyle(Paint.Style.FILL);
+ }
+ // update metrics
+ onBoundsChange(getBounds());
+ } else {
+ invalidateSelf();
+ }
+ return this;
+ }
+
+ public UserIconDrawable setBadgeIfManagedUser(Context context, int userId) {
+ Drawable badge = null;
+ boolean isManaged = context.getSystemService(DevicePolicyManager.class)
+ .getProfileOwnerAsUser(userId) != null;
+ if (isManaged) {
+ badge = getManagedUserBadgeDrawable(context);
+ }
+ return setBadge(badge);
+ }
+
+ public void setBadgeRadius(float radius) {
+ mBadgeRadius = radius;
+ onBoundsChange(getBounds());
+ }
+
+ public void setBadgeMargin(float margin) {
+ mBadgeMargin = margin;
+ onBoundsChange(getBounds());
+ }
+
+ /**
+ * Sets global padding of icon/frame. Doesn't effect the badge.
+ * @param padding
+ */
+ public void setPadding(float padding) {
+ mPadding = padding;
+ onBoundsChange(getBounds());
+ }
+
+ private void initFramePaint() {
+ if (mFramePaint == null) {
+ mFramePaint = new Paint();
+ mFramePaint.setStyle(Paint.Style.STROKE);
+ mFramePaint.setAntiAlias(true);
+ }
+ }
+
+ public void setFrameWidth(float width) {
+ initFramePaint();
+ mFrameWidth = width;
+ mFramePaint.setStrokeWidth(width);
+ onBoundsChange(getBounds());
+ }
+
+ public void setFramePadding(float padding) {
+ initFramePaint();
+ mFramePadding = padding;
+ onBoundsChange(getBounds());
+ }
+
+ public void setFrameColor(int color) {
+ initFramePaint();
+ mFramePaint.setColor(color);
+ invalidateSelf();
+ }
+
+ public void setFrameColor(ColorStateList colorList) {
+ initFramePaint();
+ mFrameColor = colorList;
+ invalidateSelf();
+ }
+
+ /**
+ * This sets the "intrinsic" size of this drawable. Useful for views which use the drawable's
+ * intrinsic size for layout. It is independent of the bounds.
+ * @param size if 0, the intrinsic size will be set to the displayed icon's size
+ */
+ public void setIntrinsicSize(int size) {
+ mSize = size;
+ }
+
+ @Override
+ public void draw(Canvas canvas) {
+ if (mInvalidated) {
+ rebake();
+ }
+ if (mBitmap != null) {
+ if (mTintColor == null) {
+ mPaint.setColorFilter(null);
+ } else {
+ int color = mTintColor.getColorForState(getState(), mTintColor.getDefaultColor());
+ if (mPaint.getColorFilter() == null) {
+ mPaint.setColorFilter(new PorterDuffColorFilter(color, mTintMode));
+ } else {
+ ((PorterDuffColorFilter) mPaint.getColorFilter()).setMode(mTintMode);
+ ((PorterDuffColorFilter) mPaint.getColorFilter()).setColor(color);
+ }
+ }
+
+ canvas.drawBitmap(mBitmap, 0, 0, mPaint);
+ }
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ mPaint.setAlpha(alpha);
+ super.invalidateSelf();
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter colorFilter) {
+ }
+
+ @Override
+ public void setTintList(ColorStateList tintList) {
+ mTintColor = tintList;
+ super.invalidateSelf();
+ }
+
+ @Override
+ public void setTintMode(@NonNull PorterDuff.Mode mode) {
+ mTintMode = mode;
+ super.invalidateSelf();
+ }
+
+ /**
+ * This 'bakes' the current state of this icon into a bitmap and removes/recycles the source
+ * bitmap/drawable. Use this when no more changes will be made and an intrinsic size is set.
+ * This effectively turns this into a static drawable.
+ */
+ public UserIconDrawable bake() {
+ if (mSize <= 0) {
+ throw new IllegalStateException("Baking requires an explicit intrinsic size");
+ }
+ onBoundsChange(new Rect(0, 0, mSize, mSize));
+ rebake();
+ mFrameColor = null;
+ mFramePaint = null;
+ mClearPaint = null;
+ if (mUserDrawable != null) {
+ mUserDrawable.setCallback(null);
+ mUserDrawable = null;
+ } else if (mUserIcon != null) {
+ mUserIcon.recycle();
+ mUserIcon = null;
+ }
+ return this;
+ }
+
+ private void rebake() {
+ mInvalidated = false;
+
+ if (mBitmap == null || (mUserDrawable == null && mUserIcon == null)) {
+ return;
+ }
+
+ final Canvas canvas = new Canvas(mBitmap);
+ canvas.drawColor(0, PorterDuff.Mode.CLEAR);
+
+ if(mUserDrawable != null) {
+ mUserDrawable.draw(canvas);
+ } else if (mUserIcon != null) {
+ int saveId = canvas.save();
+ canvas.concat(mIconMatrix);
+ canvas.drawCircle(mUserIcon.getWidth() * 0.5f, mUserIcon.getHeight() * 0.5f,
+ mIntrinsicRadius, mIconPaint);
+ canvas.restoreToCount(saveId);
+ }
+
+ if (mFrameColor != null) {
+ mFramePaint.setColor(mFrameColor.getColorForState(getState(), Color.TRANSPARENT));
+ }
+ if ((mFrameWidth + mFramePadding) > 0.001f) {
+ float radius = mDisplayRadius - mPadding - mFrameWidth * 0.5f;
+ canvas.drawCircle(getBounds().exactCenterX(), getBounds().exactCenterY(),
+ radius, mFramePaint);
+ }
+
+ if ((mBadge != null) && (mBadgeRadius > 0.001f)) {
+ final float badgeDiameter = mBadgeRadius * 2f;
+ final float badgeTop = mBitmap.getHeight() - badgeDiameter;
+ float badgeLeft = mBitmap.getWidth() - badgeDiameter;
+
+ mBadge.setBounds((int) badgeLeft, (int) badgeTop,
+ (int) (badgeLeft + badgeDiameter), (int) (badgeTop + badgeDiameter));
+
+ final float borderRadius = mBadge.getBounds().width() * 0.5f + mBadgeMargin;
+ canvas.drawCircle(badgeLeft + mBadgeRadius, badgeTop + mBadgeRadius,
+ borderRadius, mClearPaint);
+
+ mBadge.draw(canvas);
+ }
+ }
+
+ @Override
+ protected void onBoundsChange(Rect bounds) {
+ if (bounds.isEmpty() || (mUserIcon == null && mUserDrawable == null)) {
+ return;
+ }
+
+ // re-create bitmap if applicable
+ float newDisplayRadius = Math.min(bounds.width(), bounds.height()) * 0.5f;
+ int size = (int) (newDisplayRadius * 2);
+ if (mBitmap == null || size != ((int) (mDisplayRadius * 2))) {
+ mDisplayRadius = newDisplayRadius;
+ if (mBitmap != null) {
+ mBitmap.recycle();
+ }
+ mBitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
+ }
+
+ // update metrics
+ mDisplayRadius = Math.min(bounds.width(), bounds.height()) * 0.5f;
+ final float iconRadius = mDisplayRadius - mFrameWidth - mFramePadding - mPadding;
+ RectF dstRect = new RectF(bounds.exactCenterX() - iconRadius,
+ bounds.exactCenterY() - iconRadius,
+ bounds.exactCenterX() + iconRadius,
+ bounds.exactCenterY() + iconRadius);
+ if (mUserDrawable != null) {
+ Rect rounded = new Rect();
+ dstRect.round(rounded);
+ mIntrinsicRadius = Math.min(mUserDrawable.getIntrinsicWidth(),
+ mUserDrawable.getIntrinsicHeight()) * 0.5f;
+ mUserDrawable.setBounds(rounded);
+ } else if (mUserIcon != null) {
+ // Build square-to-square transformation matrix
+ final float iconCX = mUserIcon.getWidth() * 0.5f;
+ final float iconCY = mUserIcon.getHeight() * 0.5f;
+ mIntrinsicRadius = Math.min(iconCX, iconCY);
+ RectF srcRect = new RectF(iconCX - mIntrinsicRadius, iconCY - mIntrinsicRadius,
+ iconCX + mIntrinsicRadius, iconCY + mIntrinsicRadius);
+ mIconMatrix.setRectToRect(srcRect, dstRect, Matrix.ScaleToFit.FILL);
+ }
+
+ invalidateSelf();
+ }
+
+ @Override
+ public void invalidateSelf() {
+ super.invalidateSelf();
+ mInvalidated = true;
+ }
+
+ @Override
+ public boolean isStateful() {
+ return mFrameColor != null && mFrameColor.isStateful();
+ }
+
+ @Override
+ public int getOpacity() {
+ return PixelFormat.TRANSLUCENT;
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return (mSize <= 0 ? (int) mIntrinsicRadius * 2 : mSize);
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return getIntrinsicWidth();
+ }
+
+ @Override
+ public void invalidateDrawable(@NonNull Drawable who) {
+ invalidateSelf();
+ }
+
+ @Override
+ public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
+ scheduleSelf(what, when);
+ }
+
+ @Override
+ public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
+ unscheduleSelf(what);
+ }
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java b/packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java
index f9fa805f..750601d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java
+++ b/packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java
@@ -33,7 +33,7 @@
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import com.android.internal.util.UserIcons;
-import com.android.settingslib.drawable.CircleFramedDrawable;
+import com.android.settingslib.drawable.UserIconDrawable;
import com.android.settingslib.R;
@@ -71,7 +71,8 @@
}
private static Drawable encircle(Context context, Drawable icon) {
- return CircleFramedDrawable.getInstance(context, UserIcons.convertToBitmap(icon));
+ return new UserIconDrawable(UserIconDrawable.getSizeForList(context))
+ .setIconDrawable(icon).bake();
}
}
private ArrayList<UserDetails> data;
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 61c9f2b..5621642 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -1942,7 +1942,7 @@
}
private final class UpgradeController {
- private static final int SETTINGS_VERSION = 126;
+ private static final int SETTINGS_VERSION = 127;
private final int mUserId;
@@ -2167,6 +2167,36 @@
currentVersion = 126;
}
+ if (currentVersion == 126) {
+ // Version 126: copy the primary values of LOCK_SCREEN_SHOW_NOTIFICATIONS and
+ // LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS into managed profile.
+ if (mUserManager.isManagedProfile(userId)) {
+ final SettingsState systemSecureSettings =
+ getSecureSettingsLocked(UserHandle.USER_SYSTEM);
+
+ final Setting showNotifications = systemSecureSettings.getSettingLocked(
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS);
+ if (showNotifications != null) {
+ final SettingsState secureSettings = getSecureSettingsLocked(userId);
+ secureSettings.insertSettingLocked(
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
+ showNotifications.getValue(),
+ SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ final Setting allowPrivate = systemSecureSettings.getSettingLocked(
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS);
+ if (allowPrivate != null) {
+ final SettingsState secureSettings = getSecureSettingsLocked(userId);
+ secureSettings.insertSettingLocked(
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
+ allowPrivate.getValue(),
+ SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+ }
+ currentVersion = 127;
+ }
+
// vXXX: Add new settings above this point.
// Return the current version.
diff --git a/packages/SystemUI/res/color/qs_user_detail_avatar_frame.xml b/packages/SystemUI/res/color/qs_user_detail_avatar_frame.xml
new file mode 100644
index 0000000..20251c2
--- /dev/null
+++ b/packages/SystemUI/res/color/qs_user_detail_avatar_frame.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2016 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_activated="true" android:color="@color/current_user_border_color" />
+ <item android:color="@android:color/transparent" />
+</selector>
\ No newline at end of file
diff --git a/packages/SystemUI/res/color/qs_user_detail_avatar_tint.xml b/packages/SystemUI/res/color/qs_user_detail_avatar_tint.xml
new file mode 100644
index 0000000..2b75c36
--- /dev/null
+++ b/packages/SystemUI/res/color/qs_user_detail_avatar_tint.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2016 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_enabled="false" android:color="@color/qs_tile_disabled_color" />
+ <item android:color="@android:color/transparent" />
+</selector>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/battery_detail.xml b/packages/SystemUI/res/layout/battery_detail.xml
index 8e7feec94..1f24ab0 100644
--- a/packages/SystemUI/res/layout/battery_detail.xml
+++ b/packages/SystemUI/res/layout/battery_detail.xml
@@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="72dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/colorAccent" />
<com.android.systemui.ResizingSpace
diff --git a/packages/SystemUI/res/layout/forced_resizable_activity.xml b/packages/SystemUI/res/layout/forced_resizable_activity.xml
index df245bc..9cf9f6e 100644
--- a/packages/SystemUI/res/layout/forced_resizable_activity.xml
+++ b/packages/SystemUI/res/layout/forced_resizable_activity.xml
@@ -22,6 +22,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:text="@string/forced_resizable_info_text"
+ android:text="@string/dock_forced_resizable"
android:textColor="#ffffff"/>
</FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml b/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml
index 9c2c0ab..3865020 100644
--- a/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml
+++ b/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml
@@ -22,8 +22,17 @@
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:paddingBottom="8dp">
+ <ImageView
+ android:id="@+id/keyboard_shortcuts_icon"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginEnd="32dp"
+ android:layout_gravity="center_vertical"
+ android:visibility="gone"
+ android:layout_alignParentStart="true"/>
<TextView
android:id="@+id/keyboard_shortcuts_keyword"
+ android:layout_toEndOf="@+id/keyboard_shortcuts_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="12dp"
diff --git a/packages/SystemUI/res/layout/keyguard_user_switcher_item.xml b/packages/SystemUI/res/layout/keyguard_user_switcher_item.xml
index c6e453a..d685528 100644
--- a/packages/SystemUI/res/layout/keyguard_user_switcher_item.xml
+++ b/packages/SystemUI/res/layout/keyguard_user_switcher_item.xml
@@ -33,14 +33,18 @@
<TextView android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginEnd="16dp"
+ android:layout_marginEnd="13dp"
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.UserSwitcher.UserName"
/>
<com.android.systemui.statusbar.phone.UserAvatarView android:id="@+id/user_picture"
- android:layout_width="@dimen/max_avatar_size"
- android:layout_height="@dimen/max_avatar_size"
+ android:layout_width="@dimen/framed_avatar_size"
+ android:layout_height="@dimen/framed_avatar_size"
android:contentDescription="@null"
+ android:backgroundTint="@color/qs_user_detail_avatar_tint"
+ android:backgroundTintMode="src_atop"
sysui:frameWidth="@dimen/keyguard_user_switcher_border_thickness"
- sysui:framePadding="6dp"
- sysui:activeFrameColor="@color/current_user_border_color" />
+ sysui:framePadding="2.5dp"
+ sysui:badgeDiameter="18dp"
+ sysui:badgeMargin="1dp"
+ sysui:frameColor="@color/qs_user_detail_avatar_frame" />
</com.android.systemui.qs.tiles.UserDetailItemView>
diff --git a/packages/SystemUI/res/layout/qs_tile_label.xml b/packages/SystemUI/res/layout/qs_tile_label.xml
index b0dca9a..cce9c0f 100644
--- a/packages/SystemUI/res/layout/qs_tile_label.xml
+++ b/packages/SystemUI/res/layout/qs_tile_label.xml
@@ -26,9 +26,7 @@
android:gravity="center_horizontal"
android:minLines="2"
android:padding="0dp"
- android:fontFamily="sans-serif-condensed"
- android:textStyle="normal"
- android:textSize="@dimen/qs_tile_text_size"
+ android:textAppearance="@style/TextAppearance.QS.TileLabel"
android:clickable="false" />
<ImageView android:id="@+id/restricted_padlock"
android:layout_width="@dimen/qs_tile_text_size"
diff --git a/packages/SystemUI/res/layout/qs_user_detail_item.xml b/packages/SystemUI/res/layout/qs_user_detail_item.xml
index 661d74a..58fc069 100644
--- a/packages/SystemUI/res/layout/qs_user_detail_item.xml
+++ b/packages/SystemUI/res/layout/qs_user_detail_item.xml
@@ -33,12 +33,16 @@
<com.android.systemui.statusbar.phone.UserAvatarView
android:id="@+id/user_picture"
- android:layout_width="@dimen/max_avatar_size"
- android:layout_height="@dimen/max_avatar_size"
- android:layout_marginBottom="10dp"
+ android:layout_width="@dimen/framed_avatar_size"
+ android:layout_height="@dimen/framed_avatar_size"
+ android:layout_marginBottom="7dp"
+ android:backgroundTint="@color/qs_user_detail_avatar_tint"
+ android:backgroundTintMode="src_atop"
systemui:frameWidth="2dp"
- systemui:framePadding="6dp"
- systemui:activeFrameColor="@color/current_user_border_color"/>
+ systemui:framePadding="2.5dp"
+ systemui:badgeDiameter="18dp"
+ systemui:badgeMargin="1dp"
+ systemui:frameColor="@color/qs_user_detail_avatar_frame"/>
<LinearLayout
android:layout_width="wrap_content"
diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml
index 3dca77d..7c4ce15 100644
--- a/packages/SystemUI/res/layout/super_status_bar.xml
+++ b/packages/SystemUI/res/layout/super_status_bar.xml
@@ -55,6 +55,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/heads_up_scrim_height"
android:background="@drawable/heads_up_scrim"
+ sysui:ignoreRightInset="true"
android:importantForAccessibility="no"/>
<include layout="@layout/status_bar"
diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml
index 6dd8c52..1543360 100644
--- a/packages/SystemUI/res/values/attrs.xml
+++ b/packages/SystemUI/res/values/attrs.xml
@@ -53,10 +53,14 @@
<enum name="vertical" value="1" />
</attr>
<declare-styleable name="UserAvatarView">
+ <attr name="avatarPadding" format="dimension" />
<attr name="frameWidth" format="dimension" />
<attr name="framePadding" format="dimension" />
+ <!-- {@deprecated Use a statelist in frameColor instead.} -->
<attr name="activeFrameColor" format="color" />
- <attr name="frameColor" />
+ <attr name="frameColor" format="color" />
+ <attr name="badgeDiameter" format="dimension" />
+ <attr name="badgeMargin" format="dimension" />
</declare-styleable>
<declare-styleable name="UserDetailItemView">
<attr name="regularFontFamily" format="string" />
diff --git a/packages/SystemUI/res/values/config_tv.xml b/packages/SystemUI/res/values/config_tv.xml
index 22b7578..40e3b12 100644
--- a/packages/SystemUI/res/values/config_tv.xml
+++ b/packages/SystemUI/res/values/config_tv.xml
@@ -16,6 +16,10 @@
<resources>
<!-- Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows,
+ when the PIP menu is shown with settings. -->
+ <string translatable="false" name="pip_settings_bounds">"662 54 1142 324"</string>
+
+ <!-- Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows,
when the PIP menu is shown in center. -->
<string translatable="false" name="pip_menu_bounds">"596 280 1324 690"</string>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index a4eadbf..cf2e338 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -388,6 +388,9 @@
quick settings header -->
<dimen name="max_avatar_size">48dp</dimen>
+ <!-- Size of user icon + frame in the qs/keyguard user picker (incl. frame) -->
+ <dimen name="framed_avatar_size">54dp</dimen>
+
<!-- Margin on the left side of the carrier text on Keyguard -->
<dimen name="keyguard_carrier_text_margin">16dp</dimen>
diff --git a/packages/SystemUI/res/values/dimens_tv.xml b/packages/SystemUI/res/values/dimens_tv.xml
index 4e6a4b1..f536f86 100644
--- a/packages/SystemUI/res/values/dimens_tv.xml
+++ b/packages/SystemUI/res/values/dimens_tv.xml
@@ -57,4 +57,6 @@
<!-- Extra space around the PIP control button icon to match with the focused circle -->
<dimen name="tv_pip_button_icon_padding">5dp</dimen>
+ <!-- Values for entering Recents and exiting Recents -->
+ <dimen name="recents_tv_home_recents_shift">125dip</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/integers_tv.xml b/packages/SystemUI/res/values/integers_tv.xml
index 20cd330..6984d5a 100644
--- a/packages/SystemUI/res/values/integers_tv.xml
+++ b/packages/SystemUI/res/values/integers_tv.xml
@@ -17,5 +17,11 @@
<integer name="item_scale_anim_duration">150</integer>
<integer name="dismiss_short_duration">200</integer>
<integer name="dismiss_long_duration">400</integer>
+
<integer name="recents_tv_pip_focus_anim_duration">200</integer>
+
+ <!-- Duration for how long it takes cards to slide in or out when going to and from recents. -->
+ <integer name="recents_home_duration">400</integer>
+ <!-- Delay between the start of slide in animation for each card. -->
+ <integer name="recents_home_delay">40</integer>
</resources>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 060e050..c536c1a 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1557,9 +1557,6 @@
<!-- Accessibility action for moving down the docked stack divider [CHAR LIMIT=NONE] -->
<string name="accessibility_action_divider_move_right">Move right</string>
- <!-- Text that gets shown on top of current activity to inform the user that the system force-resized the current activity and that things might crash/not work properly [CHAR LIMIT=NONE] -->
- <string name="forced_resizable_info_text">App may not work with multi-window</string>
-
<!-- Accessibility description of a QS tile while editing positions [CHAR LIMIT=NONE] -->
<string name="accessibility_qs_edit_tile_label">Position <xliff:g id="position" example="2">%1$d</xliff:g>, <xliff:g id="tile_name" example="Wi-Fi">%2$s</xliff:g>. Double tap to edit.</string>
@@ -1587,4 +1584,10 @@
<!-- Accessibility label for window when QS editing is happening [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_quick_settings_edit">Quick settings editor.</string>
+ <!-- Multi-Window strings -->
+ <!-- Text that gets shown on top of current activity to inform the user that the system force-resized the current activity and that things might crash/not work properly [CHAR LIMIT=NONE] -->
+ <string name="dock_forced_resizable">App may not work with split-screen.</string>
+ <!-- Warning message when we try to dock a non-resizeble tasks and launch it in fullscreen instead. -->
+ <string name="dock_non_resizeble_failed_to_dock_text">App does not support split-screen.</string>
+
</resources>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 2b134af..5db35b1 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -180,6 +180,11 @@
<item name="android:textColor">@color/data_usage_secondary</item>
</style>
+ <style name="TextAppearance.QS.TileLabel">
+ <item name="android:textSize">@dimen/qs_tile_text_size</item>
+ <item name="android:fontFamily">sans-serif-condensed</item>
+ </style>
+
<style name="BaseBrightnessDialogContainer">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
diff --git a/packages/SystemUI/src/com/android/systemui/BitmapHelper.java b/packages/SystemUI/src/com/android/systemui/BitmapHelper.java
deleted file mode 100644
index 1933bbc..0000000
--- a/packages/SystemUI/src/com/android/systemui/BitmapHelper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2014 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;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapShader;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.RectF;
-import android.graphics.Shader;
-
-public class BitmapHelper {
- /**
- * Generate a new bitmap (width x height pixels, ARGB_8888) with the input bitmap scaled
- * to fit and clipped to an inscribed circle.
- * @param input Bitmap to resize and clip
- * @param width Width of output bitmap (and diameter of circle)
- * @param height Height of output bitmap
- * @return A shiny new bitmap for you to use
- */
- public static Bitmap createCircularClip(Bitmap input, int width, int height) {
- if (input == null) return null;
-
- final int inWidth = input.getWidth();
- final int inHeight = input.getHeight();
- final Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- final Canvas canvas = new Canvas(output);
- final Paint paint = new Paint();
- paint.setShader(new BitmapShader(input, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
- paint.setAntiAlias(true);
- final RectF srcRect = new RectF(0, 0, inWidth, inHeight);
- final RectF dstRect = new RectF(0, 0, width, height);
- final Matrix m = new Matrix();
- m.setRectToRect(srcRect, dstRect, Matrix.ScaleToFit.CENTER);
- canvas.setMatrix(m);
- canvas.drawCircle(inWidth / 2, inHeight / 2, inWidth / 2, paint);
- return output;
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java
index 0d822cb..0798590 100644
--- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java
+++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java
@@ -250,7 +250,6 @@
FalsingLog.i("onSucccessfulUnlock", "");
}
mDataCollector.onSucccessfulUnlock();
- sessionExitpoint(true /* force */);
}
public void onBouncerShown() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
index de8eec4..4d959d8 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
@@ -157,7 +157,7 @@
for (QSTile<?> tile : tiles) {
QSTileBaseView tileView = mQsPanel.getTileView(tile);
final TextView label = ((QSTileView) tileView).getLabel();
- final View tileIcon = tileView.getIcon();
+ final View tileIcon = tileView.getIcon().getIconView();
if (count < mNumQuickTiles && mAllowFancy) {
// Quick tiles.
QSTileBaseView quickTileView = mQuickQsPanel.getTileView(tile);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSContainer.java b/packages/SystemUI/src/com/android/systemui/qs/QSContainer.java
index 0af5fa6..e3a4909 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSContainer.java
@@ -47,10 +47,10 @@
private final Rect mQsBounds = new Rect();
private int mHeightOverride = -1;
- private QSPanel mQSPanel;
+ protected QSPanel mQSPanel;
private QSDetail mQSDetail;
protected BaseStatusBarHeader mHeader;
- private float mQsExpansion;
+ protected float mQsExpansion;
private boolean mQsExpanded;
private boolean mHeaderAnimating;
private boolean mKeyguardShowing;
@@ -162,14 +162,18 @@
}
private void updateBottom() {
- int heightOverride = mHeightOverride != -1 ? mHeightOverride : getMeasuredHeight();
- int height = mQSCustomizer.isCustomizing() ? mQSCustomizer.getHeight()
- : (int) (mQsExpansion * (heightOverride - mHeader.getCollapsedHeight()))
- + mHeader.getCollapsedHeight();
+ int height = calculateContainerHeight();
setBottom(getTop() + height);
mQSDetail.setBottom(getTop() + height);
}
+ protected int calculateContainerHeight() {
+ int heightOverride = mHeightOverride != -1 ? mHeightOverride : getMeasuredHeight();
+ return mQSCustomizer.isCustomizing() ? mQSCustomizer.getHeight()
+ : (int) (mQsExpansion * (heightOverride - mHeader.getCollapsedHeight()))
+ + mHeader.getCollapsedHeight();
+ }
+
private void updateQsState() {
boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling || mHeaderAnimating;
mQSPanel.setExpanded(mQsExpanded);
@@ -302,4 +306,8 @@
updateQsState();
}
};
+
+ public int getQsMinExpansionHeight() {
+ return mHeader.getHeight();
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
index 546f8c3..6c224f7 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
@@ -30,9 +30,9 @@
public class QSIconView extends ViewGroup {
- private final View mIcon;
- private final int mIconSizePx;
- private final int mTilePaddingBelowIconPx;
+ protected final View mIcon;
+ protected final int mIconSizePx;
+ protected final int mTilePaddingBelowIconPx;
private boolean mAnimationEnabled = true;
public QSIconView(Context context) {
@@ -50,6 +50,10 @@
mAnimationEnabled = false;
}
+ public View getIconView() {
+ return mIcon;
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int w = MeasureSpec.getSize(widthMeasureSpec);
@@ -109,11 +113,11 @@
return icon;
}
- protected static int exactly(int size) {
+ protected final int exactly(int size) {
return MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
}
- protected static void layout(View child, int left, int top) {
+ protected final void layout(View child, int left, int top) {
child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight());
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index a05818a..1149c59 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -85,20 +85,7 @@
R.layout.quick_settings_brightness_dialog, this, false);
addView(mBrightnessView);
- mTileLayout = (QSTileLayout) LayoutInflater.from(mContext).inflate(
- R.layout.qs_paged_tile_layout, this, false);
- addView((View) mTileLayout);
- findViewById(android.R.id.edit).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(final View v) {
- mHost.startRunnableDismissingKeyguard(new Runnable() {
- @Override
- public void run() {
- showEdit(v);
- }
- });
- }
- });
+ setupTileLayout();
mFooter = new QSFooter(this, context);
addView(mFooter.getView());
@@ -111,6 +98,14 @@
}
+ protected void setupTileLayout() {
+ mTileLayout = (QSTileLayout) LayoutInflater.from(mContext).inflate(
+ R.layout.qs_paged_tile_layout, this, false);
+ addView((View) mTileLayout);
+ findViewById(android.R.id.edit).setOnClickListener(view ->
+ mHost.startRunnableDismissingKeyguard(() -> showEdit(view)));
+ }
+
public boolean isShowingCustomize() {
return mCustomizePanel != null && mCustomizePanel.isCustomizing();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index 57a1a4a..c3766e8 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -33,7 +33,6 @@
/** View that represents a standard quick settings tile. **/
public class QSTileView extends QSTileBaseView {
protected final Context mContext;
- private QSIconView mIconView;
private final int mTileSpacingPx;
private int mTilePaddingTopPx;
@@ -44,7 +43,6 @@
super(context, icon);
mContext = context;
- mIconView = icon;
final Resources res = context.getResources();
mTileSpacingPx = res.getDimensionPixelSize(R.dimen.qs_tile_spacing);
@@ -82,13 +80,13 @@
}
protected void createLabel() {
- final Resources res = mContext.getResources();
View view = LayoutInflater.from(mContext).inflate(R.layout.qs_tile_label, null);
mLabel = (TextView) view.findViewById(R.id.tile_label);
mPadLock = (ImageView) view.findViewById(R.id.restricted_padlock);
addView(view);
}
+ @Override
protected void handleStateChanged(QSTile.State state) {
super.handleStateChanged(state);
if (!Objects.equal(mLabel.getText(), state.label)) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
index 6969e25..1e3c458 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
@@ -19,9 +19,9 @@
private static final String TAG = "TileLayout";
protected int mColumns;
- private int mCellWidth;
- private int mCellHeight;
- private int mCellMargin;
+ protected int mCellWidth;
+ protected int mCellHeight;
+ protected int mCellMargin;
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
private int mCellMarginTop;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java b/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java
index 6114573..6b20681 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java
@@ -138,7 +138,7 @@
mListening = listening;
try {
if (listening) {
- if (mServiceManager.getType() == TileService.TILE_MODE_PASSIVE) {
+ if (!mServiceManager.isActiveTile()) {
mServiceManager.setBindRequested(true);
mService.onStartListening();
}
@@ -209,7 +209,7 @@
} catch (RemoteException e) {
}
try {
- if (mServiceManager.getType() == TileService.TILE_MODE_ACTIVE) {
+ if (mServiceManager.isActiveTile()) {
mServiceManager.setBindRequested(true);
mService.onStartListening();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
index 8910d44..5a26a4a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
@@ -15,8 +15,6 @@
*/
package com.android.systemui.qs.external;
-import libcore.util.Objects;
-
import android.app.AppGlobals;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -25,6 +23,7 @@
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ServiceInfo;
import android.net.Uri;
import android.os.Handler;
@@ -34,9 +33,11 @@
import android.service.quicksettings.IQSService;
import android.service.quicksettings.IQSTileService;
import android.service.quicksettings.Tile;
+import android.service.quicksettings.TileService;
import android.support.annotation.VisibleForTesting;
import android.util.ArraySet;
import android.util.Log;
+import libcore.util.Objects;
import java.util.Set;
@@ -98,6 +99,17 @@
}
}
+ public boolean isActiveTile() {
+ try {
+ ServiceInfo info = mContext.getPackageManager().getServiceInfo(mIntent.getComponent(),
+ PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.GET_META_DATA);
+ return info.metaData != null
+ && info.metaData.getBoolean(TileService.META_DATA_ACTIVE_TILE, false);
+ } catch (NameNotFoundException e) {
+ return false;
+ }
+ }
+
/**
* Binds just long enough to send any queued messages, then unbinds.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
index 664ddd6..ab21532 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
@@ -21,7 +21,6 @@
import android.os.Handler;
import android.os.UserHandle;
import android.service.quicksettings.IQSTileService;
-import android.service.quicksettings.TileService;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
@@ -51,7 +50,6 @@
private int mPriority;
private boolean mJustBound;
private long mLastUpdate;
- private int mType;
private boolean mShowingDialog;
// Whether we have a pending bind going out to the service without a response yet.
// This defaults to true to ensure tiles start out unavailable.
@@ -69,25 +67,11 @@
mServices = tileServices;
mHandler = handler;
mStateManager = tileLifecycleManager;
- mType = tileServices.getContext().getSharedPreferences(PREFS_FILE, 0)
- .getInt(tileLifecycleManager.getComponent().flattenToString(),
- TileService.TILE_MODE_UNSET);
mStateManager.setQSService(tileServices);
- if (mType == TileService.TILE_MODE_UNSET) {
- bindService();
- mStateManager.onTileAdded();
- }
}
- public int getType() {
- return mType;
- }
-
- public void setType(int type) {
- mServices.getContext().getSharedPreferences(PREFS_FILE, 0).edit()
- .putInt(mStateManager.getComponent().flattenToString(), type).commit();
- mType = type;
- mServices.recalculateBindAllowance();
+ public boolean isActiveTile() {
+ return mStateManager.isActiveTile();
}
public void setShowingDialog(boolean dialog) {
@@ -114,7 +98,7 @@
public void setLastUpdate(long lastUpdate) {
mLastUpdate = lastUpdate;
- if (mBound && mType == TileService.TILE_MODE_ACTIVE) {
+ if (mBound && isActiveTile()) {
mStateManager.onStopListening();
setBindRequested(false);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
index 5bb2a35..f36d013 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
@@ -153,7 +153,7 @@
return;
}
TileServiceManager service = mServices.get(customTile);
- if (service.getType() != TileService.TILE_MODE_ACTIVE) {
+ if (!service.isActiveTile()) {
return;
}
service.setBindRequested(true);
@@ -165,17 +165,6 @@
}
@Override
- public void setTileMode(ComponentName component, int mode) {
- verifyCaller(component.getPackageName());
- CustomTile customTile = getTileForComponent(component);
- if (customTile != null) {
- synchronized (mServices) {
- mServices.get(customTile).setType(mode);
- }
- }
- }
-
- @Override
public void updateQsTile(Tile tile) {
ComponentName componentName = tile.getComponentName();
verifyCaller(componentName.getPackageName());
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
index 2032783..e494fd8 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
@@ -25,6 +25,7 @@
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.RelativeSizeSpan;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnAttachStateChangeListener;
@@ -207,18 +208,21 @@
}
}
});
+ final TextView batterySaverTitle =
+ (TextView) mCurrentView.findViewById(android.R.id.title);
+ final TextView batterySaverSummary =
+ (TextView) mCurrentView.findViewById(android.R.id.summary);
if (mCharging) {
- ((TextView) mCurrentView.findViewById(android.R.id.title)).setText(
- R.string.battery_detail_charging_summary);
- mCurrentView.findViewById(android.R.id.icon).setVisibility(View.INVISIBLE);
+ mCurrentView.findViewById(R.id.switch_container).setAlpha(.7f);
+ batterySaverTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
+ batterySaverTitle.setText(R.string.battery_detail_charging_summary);
mCurrentView.findViewById(android.R.id.toggle).setVisibility(View.GONE);
mCurrentView.findViewById(R.id.switch_container).setClickable(false);
} else {
- ((TextView) mCurrentView.findViewById(android.R.id.title)).setText(
- R.string.battery_detail_switch_title);
- ((TextView) mCurrentView.findViewById(android.R.id.summary)).setText(
- R.string.battery_detail_switch_summary);
- mCurrentView.findViewById(android.R.id.icon).setVisibility(View.VISIBLE);
+ mCurrentView.findViewById(R.id.switch_container).setAlpha(1);
+ batterySaverTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
+ batterySaverTitle.setText(R.string.battery_detail_switch_title);
+ batterySaverSummary.setText(R.string.battery_detail_switch_summary);
mCurrentView.findViewById(android.R.id.toggle).setVisibility(View.VISIBLE);
mCurrentView.findViewById(R.id.switch_container).setClickable(true);
mCurrentView.findViewById(R.id.switch_container).setOnClickListener(this);
@@ -227,7 +231,7 @@
private void bindBatteryInfo(BatteryInfo info) {
SpannableStringBuilder builder = new SpannableStringBuilder();
- builder.append(info.batteryPercentString, new RelativeSizeSpan(2),
+ builder.append(info.batteryPercentString, new RelativeSizeSpan(2.6f),
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
if (info.remainingLabel != null) {
if (mContext.getResources().getBoolean(R.bool.quick_settings_wide)) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java
index fcf758b..99eae02 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java
@@ -30,6 +30,7 @@
import android.widget.TextView;
import com.android.internal.util.ArrayUtils;
+import com.android.settingslib.drawable.UserIconDrawable;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.UserAvatarView;
@@ -87,25 +88,29 @@
return (UserDetailItemView) convertView;
}
- public void bind(String name, Bitmap picture) {
+ public void bind(String name, Bitmap picture, int userId) {
mName.setText(name);
- mAvatar.setBitmap(picture);
+ mAvatar.setAvatarWithBadge(picture, userId);
}
- public void bind(String name, Drawable picture) {
+ public void bind(String name, Drawable picture, int userId) {
mName.setText(name);
- mAvatar.setDrawable(picture);
+ mAvatar.setDrawableWithBadge(picture, userId);
+ }
+
+ public void setAvatarEnabled(boolean enabled) {
+ mAvatar.setEnabled(enabled);
}
public void setDisabledByAdmin(boolean disabled) {
mRestrictedPadlock.setVisibility(disabled ? View.VISIBLE : View.GONE);
mName.setEnabled(!disabled);
- mAvatar.setDisabled(disabled);
+ mAvatar.setEnabled(!disabled);
}
public void setEnabled(boolean enabled) {
mName.setEnabled(enabled);
- mAvatar.setDisabled(!enabled);
+ mAvatar.setEnabled(enabled);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
index da98762..d4fa765 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
@@ -76,9 +76,9 @@
}
String name = getName(mContext, item);
if (item.picture == null) {
- v.bind(name, getDrawable(mContext, item));
+ v.bind(name, getDrawable(mContext, item), item.resolveId());
} else {
- v.bind(name, item.picture);
+ v.bind(name, item.picture, item.info.id);
}
v.setActivated(item.isCurrent);
v.setDisabledByAdmin(item.isDisabledByAdmin);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index aba05aa..fda340d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -17,6 +17,7 @@
package com.android.systemui.recents;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
+import static android.view.View.MeasureSpec;
import android.app.ActivityManager;
import android.app.ActivityOptions;
@@ -36,7 +37,6 @@
import android.util.MutableBoolean;
import android.view.AppTransitionAnimationSpec;
import android.view.LayoutInflater;
-import android.view.View;
import android.view.ViewConfiguration;
import com.android.internal.logging.MetricsLogger;
@@ -45,7 +45,6 @@
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.DockedTopTaskEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
-import com.android.systemui.recents.events.activity.ForcedResizableEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
import com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent;
@@ -125,13 +124,6 @@
loader.loadTasks(mContext, plan, launchOpts);
}
}
-
- @Override
- public void onActivityForcedResizable(String packageName, int taskId) {
- EventBus.getDefault().sendOntoMainThread(
- new ForcedResizableEvent(packageName, taskId));
-
- }
}
protected static RecentsTaskLoadPlan sInstanceLoadPlan;
@@ -608,23 +600,25 @@
mDummyStackView.setTasks(stack, false /* allowNotifyStackChanges */);
Rect taskViewBounds = stackLayout.getUntransformedTaskViewBounds();
- int taskViewWidth = taskViewBounds.width();
- synchronized (mHeaderBarLock) {
- if (mHeaderBar.getMeasuredWidth() != taskViewWidth ||
- mHeaderBar.getMeasuredHeight() != mTaskBarHeight) {
- mHeaderBar.measure(
- View.MeasureSpec.makeMeasureSpec(taskViewWidth, View.MeasureSpec.EXACTLY),
- View.MeasureSpec.makeMeasureSpec(mTaskBarHeight, View.MeasureSpec.EXACTLY));
+ if (!taskViewBounds.isEmpty()) {
+ int taskViewWidth = taskViewBounds.width();
+ synchronized (mHeaderBarLock) {
+ if (mHeaderBar.getMeasuredWidth() != taskViewWidth ||
+ mHeaderBar.getMeasuredHeight() != mTaskBarHeight) {
+ mHeaderBar.measure(
+ MeasureSpec.makeMeasureSpec(taskViewWidth, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(mTaskBarHeight, MeasureSpec.EXACTLY));
+ }
+ mHeaderBar.layout(0, 0, taskViewWidth, mTaskBarHeight);
}
- mHeaderBar.layout(0, 0, taskViewWidth, mTaskBarHeight);
- }
- // Update the transition bitmap to match the new header bar height
- if (mThumbTransitionBitmapCache == null ||
- (mThumbTransitionBitmapCache.getWidth() != taskViewWidth) ||
- (mThumbTransitionBitmapCache.getHeight() != mTaskBarHeight)) {
- mThumbTransitionBitmapCache = Bitmap.createBitmap(taskViewWidth,
- mTaskBarHeight, Bitmap.Config.ARGB_8888);
+ // Update the transition bitmap to match the new header bar height
+ if (mThumbTransitionBitmapCache == null ||
+ (mThumbTransitionBitmapCache.getWidth() != taskViewWidth) ||
+ (mThumbTransitionBitmapCache.getHeight() != mTaskBarHeight)) {
+ mThumbTransitionBitmapCache = Bitmap.createBitmap(taskViewWidth,
+ mTaskBarHeight, Bitmap.Config.ARGB_8888);
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/ForcedResizableEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/ForcedResizableEvent.java
deleted file mode 100644
index cdcabf0..0000000
--- a/packages/SystemUI/src/com/android/systemui/recents/events/activity/ForcedResizableEvent.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2016 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.recents.events.activity;
-
-import com.android.systemui.recents.events.EventBus;
-
-/**
- * Sent when recents received the information that an activity got forced resizable, and we need
- * to inform the user about that.
- */
-public class ForcedResizableEvent extends EventBus.Event {
-
- public final String packageName;
- public final int taskId;
-
- public ForcedResizableEvent(String packageName, int taskId) {
- this.packageName = packageName;
- this.taskId = taskId;
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index 1a4b40f..2d5addb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -144,6 +144,7 @@
public void onPinnedActivityRestartAttempt() { }
public void onPinnedStackAnimationEnded() { }
public void onActivityForcedResizable(String packageName, int taskId) { }
+ public void onActivityDismissingDockedStack() { }
}
/**
@@ -182,6 +183,11 @@
mHandler.obtainMessage(H.ON_ACTIVITY_FORCED_RESIZABLE, taskId, 0, packageName)
.sendToTarget();
}
+
+ @Override
+ public void onActivityDismissingDockedStack() throws RemoteException {
+ mHandler.sendEmptyMessage(H.ON_ACTIVITY_DISMISSING_DOCKED_STACK);
+ }
};
/**
@@ -1091,6 +1097,7 @@
private static final int ON_PINNED_ACTIVITY_RESTART_ATTEMPT = 3;
private static final int ON_PINNED_STACK_ANIMATION_ENDED = 4;
private static final int ON_ACTIVITY_FORCED_RESIZABLE = 5;
+ private static final int ON_ACTIVITY_DISMISSING_DOCKED_STACK = 6;
@Override
public void handleMessage(Message msg) {
@@ -1126,6 +1133,12 @@
}
break;
}
+ case ON_ACTIVITY_DISMISSING_DOCKED_STACK: {
+ for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
+ mTaskStackListeners.get(i).onActivityDismissingDockedStack();
+ }
+ break;
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvActivity.java b/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvActivity.java
index f9f851a..13e1a14 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvActivity.java
@@ -37,14 +37,12 @@
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
-import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.LaunchTaskFailedEvent;
import com.android.systemui.recents.events.activity.ToggleRecentsEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
-import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
import com.android.systemui.recents.events.ui.UserInteractionEvent;
import com.android.systemui.recents.events.ui.focus.DismissFocusedTaskViewEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
@@ -53,7 +51,9 @@
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
+import com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder;
import com.android.systemui.recents.tv.views.RecentsTvView;
+import com.android.systemui.recents.tv.views.TaskStackHorizontalGridView;
import com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.tv.pip.PipManager;
@@ -76,11 +76,14 @@
private RecentsPackageMonitor mPackageMonitor;
private long mLastTabKeyEventTime;
private boolean mIgnoreAltTabRelease;
+ private boolean mLaunchedFromHome;
private RecentsTvView mRecentsView;
private View mPipView;
private TaskStackHorizontalViewAdapter mTaskStackViewAdapter;
+ private TaskStackHorizontalGridView mTaskStackHorizontalGridView;
private FinishRecentsRunnable mFinishLaunchHomeRunnable;
+ private HomeRecentsEnterExitAnimationHolder mHomeRecentsEnterExitAnimationHolder;
private final PipManager mPipManager = PipManager.getInstance();
private final PipManager.Listener mPipListener = new PipManager.Listener() {
@@ -174,6 +177,7 @@
if (!plan.hasTasks()) {
loader.preloadTasks(plan, -1, launchState.launchedFromHome);
}
+ mLaunchedFromHome = launchState.launchedFromHome;
TaskStack stack = plan.getTaskStack();
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
loadOpts.runningTaskId = launchState.launchedToTaskId;
@@ -187,7 +191,8 @@
Collections.reverse(stackTasks);
if (mTaskStackViewAdapter == null) {
mTaskStackViewAdapter = new TaskStackHorizontalViewAdapter(stackTasks);
- mRecentsView.setTaskStackViewAdapter(mTaskStackViewAdapter);
+ mTaskStackHorizontalGridView = mRecentsView
+ .setTaskStackViewAdapter(mTaskStackViewAdapter);
} else {
mTaskStackViewAdapter.setNewStackTasks(stackTasks);
}
@@ -229,17 +234,24 @@
}
void dismissRecentsToHome(boolean animateTaskViews) {
- DismissRecentsToHomeAnimationStarted dismissEvent =
- new DismissRecentsToHomeAnimationStarted(animateTaskViews);
- dismissEvent.addPostAnimationCallback(mFinishLaunchHomeRunnable);
- dismissEvent.addPostAnimationCallback(new Runnable() {
+ Runnable closeSystemWindows = new Runnable() {
@Override
public void run() {
Recents.getSystemServices().sendCloseSystemWindows(
BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
}
- });
- EventBus.getDefault().send(dismissEvent);
+ };
+ DismissRecentsToHomeAnimationStarted dismissEvent =
+ new DismissRecentsToHomeAnimationStarted(animateTaskViews);
+ dismissEvent.addPostAnimationCallback(mFinishLaunchHomeRunnable);
+ dismissEvent.addPostAnimationCallback(closeSystemWindows);
+
+ if(mTaskStackHorizontalGridView.getChildCount() > 0) {
+ mHomeRecentsEnterExitAnimationHolder.startExitAnimation(dismissEvent);
+ } else {
+ closeSystemWindows.run();
+ mFinishLaunchHomeRunnable.run();
+ }
}
boolean dismissRecentsToHomeIfVisible(boolean animated) {
@@ -319,6 +331,19 @@
// Update the recent tasks
updateRecentsTasks();
+ mHomeRecentsEnterExitAnimationHolder = new HomeRecentsEnterExitAnimationHolder(
+ getApplicationContext(), mTaskStackHorizontalGridView);
+ if(mTaskStackHorizontalGridView != null &&
+ mTaskStackHorizontalGridView.getChildCount() > 0) {
+ if(mLaunchedFromHome) {
+ mHomeRecentsEnterExitAnimationHolder.setEnterFromHomeStartingAnimationValues();
+ } else {
+ mHomeRecentsEnterExitAnimationHolder.setEnterFromAppStartingAnimationValues();
+ }
+ } else {
+ mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
+ }
+
// If this is a new instance from a configuration change, then we have to manually trigger
// the enter animation state, or if recents was relaunched by AM, without going through
// the normal mechanisms
@@ -340,6 +365,9 @@
@Override
public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
+ if(mLaunchedFromHome) {
+ mHomeRecentsEnterExitAnimationHolder.startEnterAnimation();
+ }
EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
}
@@ -444,12 +472,6 @@
}
}
- public final void onBusEvent(EnterRecentsWindowLastAnimationFrameEvent event) {
- EventBus.getDefault().send(new UpdateFreeformTaskViewVisibilityEvent(true));
- mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
- mRecentsView.invalidate();
- }
-
public final void onBusEvent(CancelEnterRecentsWindowAnimationEvent event) {
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
int launchToTaskId = launchState.launchedToTaskId;
@@ -489,6 +511,11 @@
@Override
public boolean onPreDraw() {
mRecentsView.getViewTreeObserver().removeOnPreDrawListener(this);
+ if(mLaunchedFromHome) {
+ mHomeRecentsEnterExitAnimationHolder.setEnterFromHomeStartingAnimationValues();
+ } else {
+ mHomeRecentsEnterExitAnimationHolder.setEnterFromAppStartingAnimationValues();
+ }
// We post to make sure that this information is delivered after this traversals is
// finished.
mRecentsView.post(new Runnable() {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvImpl.java b/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvImpl.java
index fb62aff..fd31872 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvImpl.java
@@ -25,15 +25,19 @@
import android.os.SystemClock;
import android.os.UserHandle;
+import com.android.systemui.SystemUIApplication;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivityLaunchState;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsImpl;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent;
+import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.TaskStack;
+import com.android.systemui.recents.model.ThumbnailData;
import com.android.systemui.recents.tv.views.TaskCardView;
+import com.android.systemui.statusbar.tv.TvStatusBar;
public class RecentsTvImpl extends RecentsImpl{
public final static String RECENTS_TV_ACTIVITY =
@@ -81,16 +85,7 @@
}
if (!useThumbnailTransition) {
- // If there is no thumbnail transition, but is launching from home into recents, then
- // use a quick home transition and do the animation from home
- if (hasRecentTasks) {
- ActivityOptions opts = getHomeTransitionActivityOptions();
- startRecentsActivity(topTask, opts, true /* fromHome */, false /* fromThumbnail */);
- } else {
- // Otherwise we do the normal fade from an unknown source
- ActivityOptions opts = getUnknownTransitionActivityOptions();
- startRecentsActivity(topTask, opts, true /* fromHome */, false /* fromThumbnail */);
- }
+ startRecentsActivity(topTask, null, true /* fromHome */, false /* fromThumbnail */);
}
mLastToggleTime = SystemClock.elapsedRealtime();
}
@@ -124,14 +119,26 @@
*/
private ActivityOptions getThumbnailTransitionActivityOptionsForTV(
ActivityManager.RunningTaskInfo topTask) {
- Bitmap thumbnail = mThumbTransitionBitmapCache;
Rect rect = TaskCardView.getStartingCardThumbnailRect(mContext);
- if (thumbnail != null) {
+ SystemServicesProxy ssp = Recents.getSystemServices();
+ ThumbnailData thumbnailData = ssp.getTaskThumbnail(topTask.id);
+ if (thumbnailData.thumbnail != null) {
+ Bitmap thumbnail = Bitmap.createScaledBitmap(thumbnailData.thumbnail, rect.width(),
+ rect.height(), false);
return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView,
- null, (int) rect.left, (int) rect.top,
- (int) rect.width(), (int) rect.height(), mHandler, null);
+ thumbnail, (int) rect.left, (int) rect.top, (int) rect.width(),
+ (int) rect.height(), mHandler, null);
}
// If both the screenshot and thumbnail fails, then just fall back to the default transition
return getUnknownTransitionActivityOptions();
}
+
+ @Override
+ public void onVisibilityChanged(Context context, boolean visible) {
+ SystemUIApplication app = (SystemUIApplication) context;
+ TvStatusBar statusBar = app.getComponent(TvStatusBar.class);
+ if (statusBar != null) {
+ statusBar.updateRecentsVisibility(visible);
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/DismissAnimationsHolder.java b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/DismissAnimationsHolder.java
index 8996d0b..fbcfa97 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/DismissAnimationsHolder.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/DismissAnimationsHolder.java
@@ -18,9 +18,8 @@
import android.animation.Animator;
import android.content.res.Resources;
-import android.support.v4.view.animation.FastOutSlowInInterpolator;
-import android.view.View;
import android.widget.LinearLayout;
+import com.android.systemui.Interpolators;
import com.android.systemui.recents.tv.views.TaskCardView;
import com.android.systemui.R;
@@ -28,7 +27,6 @@
public class DismissAnimationsHolder {
private LinearLayout mDismissArea;
private LinearLayout mTaskCardView;
- private FastOutSlowInInterpolator mFastOutSlowIn;
private int mCardYDelta;
private long mShortDuration;
private long mLongDuration;
@@ -36,7 +34,6 @@
public DismissAnimationsHolder(TaskCardView taskCardView) {
mTaskCardView = (LinearLayout) taskCardView.findViewById(R.id.recents_tv_card);
mDismissArea = (LinearLayout) taskCardView.findViewById(R.id.card_dismiss);
- mFastOutSlowIn = new FastOutSlowInInterpolator();
Resources res = taskCardView.getResources();
mCardYDelta = res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_shift_down);
@@ -45,36 +42,42 @@
}
public void startEnterAnimation() {
- mDismissArea.animate().setDuration(mShortDuration);
- mDismissArea.animate().setInterpolator(mFastOutSlowIn);
- mDismissArea.animate().alpha(1.0f);
+ mDismissArea.animate()
+ .setDuration(mShortDuration)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
+ .alpha(1.0f);
- mTaskCardView.animate().setDuration(mShortDuration);
- mTaskCardView.animate().setInterpolator(mFastOutSlowIn);
- mTaskCardView.animate().translationYBy(mCardYDelta);
- mTaskCardView.animate().alpha(0.5f);
+ mTaskCardView.animate()
+ .setDuration(mShortDuration)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
+ .translationYBy(mCardYDelta)
+ .alpha(0.5f);
}
public void startExitAnimation() {
- mDismissArea.animate().setDuration(mShortDuration);
- mDismissArea.animate().setInterpolator(mFastOutSlowIn);
- mDismissArea.animate().alpha(0.0f);
+ mDismissArea.animate()
+ .setDuration(mShortDuration)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
+ .alpha(0.0f);
- mTaskCardView.animate().setDuration(mShortDuration);
- mTaskCardView.animate().setInterpolator(mFastOutSlowIn);
- mTaskCardView.animate().translationYBy(-mCardYDelta);
- mTaskCardView.animate().alpha(1.0f);
+ mTaskCardView.animate()
+ .setDuration(mShortDuration)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
+ .translationYBy(-mCardYDelta)
+ .alpha(1.0f);
}
public void startDismissAnimation(Animator.AnimatorListener listener) {
- mDismissArea.animate().setDuration(mShortDuration);
- mDismissArea.animate().setInterpolator(mFastOutSlowIn);
- mDismissArea.animate().alpha(0.0f);
+ mDismissArea.animate()
+ .setDuration(mShortDuration)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
+ .alpha(0.0f);
- mTaskCardView.animate().setDuration(mLongDuration);
- mTaskCardView.animate().setInterpolator(mFastOutSlowIn);
- mTaskCardView.animate().translationYBy(mCardYDelta);
- mTaskCardView.animate().alpha(0.0f);
- mTaskCardView.animate().setListener(listener);
+ mTaskCardView.animate()
+ .setDuration(mLongDuration)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
+ .translationYBy(mCardYDelta)
+ .alpha(0.0f)
+ .setListener(listener);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java
new file mode 100644
index 0000000..278de87
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2016 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.recents.tv.animations;
+
+import android.content.Context;
+import com.android.systemui.Interpolators;
+import com.android.systemui.R;
+import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
+import com.android.systemui.recents.tv.views.TaskCardView;
+import com.android.systemui.recents.tv.views.TaskStackHorizontalGridView;
+
+
+public class HomeRecentsEnterExitAnimationHolder {
+
+ private Context mContext;
+ private TaskStackHorizontalGridView mGridView;
+ private long mDelay;
+ private int mDuration;
+ private int mTranslationX;
+
+ public HomeRecentsEnterExitAnimationHolder(Context context,
+ TaskStackHorizontalGridView gridView) {
+ mContext = context;
+ mGridView = gridView;
+ mTranslationX = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.recents_tv_home_recents_shift);
+ mDelay = mContext.getResources().getInteger(R.integer.recents_home_delay);
+ mDuration = mContext.getResources().getInteger(R.integer.recents_home_duration);
+ }
+
+ public void startEnterAnimation() {
+ for(int i = 0; i < mGridView.getChildCount(); i++) {
+ TaskCardView view = (TaskCardView) mGridView.getChildAt(i);
+ view.setTranslationX(-mTranslationX);
+ view.setAlpha(0.0f);
+ view.animate()
+ .alpha(1.0f)
+ .translationX(0)
+ .setDuration(mDuration)
+ .setStartDelay(mDelay * i)
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+ }
+ }
+
+ public void startExitAnimation(DismissRecentsToHomeAnimationStarted dismissEvent) {
+ for(int i = mGridView.getChildCount() - 1; i >= 0; i--) {
+ TaskCardView view = (TaskCardView) mGridView.getChildAt(i);
+ view.animate()
+ .alpha(0.0f)
+ .translationXBy(-mTranslationX)
+ .setDuration(mDuration)
+ .setStartDelay(mDelay * (mGridView.getChildCount() - 1 - i))
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+ if(i == 0) {
+ view.animate().setListener(dismissEvent.getAnimationTrigger()
+ .decrementOnAnimationEnd());
+ dismissEvent.getAnimationTrigger().increment();
+ }
+ }
+ }
+
+ public void setEnterFromHomeStartingAnimationValues() {
+ for(int i = 0; i < mGridView.getChildCount(); i++) {
+ TaskCardView view = (TaskCardView) mGridView.getChildAt(i);
+ view.setTranslationX(-mTranslationX);
+ view.setAlpha(0.0f);
+ }
+ }
+
+ public void setEnterFromAppStartingAnimationValues() {
+ for(int i = 0; i < mGridView.getChildCount(); i++) {
+ TaskCardView view = (TaskCardView) mGridView.getChildAt(i);
+ view.setTranslationX(0);
+ view.setAlpha(1.0f);
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvTransitionHelper.java
index a69f8a2..fb1127e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvTransitionHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvTransitionHelper.java
@@ -16,8 +16,10 @@
package com.android.systemui.recents.tv.views;
import android.annotation.Nullable;
+import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Context;
+import android.graphics.Bitmap;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
@@ -120,8 +122,10 @@
}
try {
Rect taskRect = taskView.getFocusedThumbnailRect();
+ Bitmap thumbnail = Bitmap.createScaledBitmap(task.thumbnail, taskRect.width(),
+ taskRect.height(), false);
WindowManagerGlobal.getWindowManagerService()
- .overridePendingAppTransitionAspectScaledThumb(task.thumbnail, taskRect.left,
+ .overridePendingAppTransitionAspectScaledThumb(thumbnail, taskRect.left,
taskRect.top, taskRect.width(), taskRect.height(), callback, true);
} catch (RemoteException e) {
Log.w(TAG, "Failed to override transition: " + e);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java
index 9da8eed..53fdf62 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java
@@ -18,7 +18,10 @@
import android.content.Context;
import android.graphics.Rect;
import android.os.Handler;
+import android.support.v7.widget.DefaultItemAnimator;
+import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowInsets;
@@ -32,15 +35,15 @@
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
+import com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent;
import com.android.systemui.recents.events.activity.LaunchTvTaskEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.tv.animations.RecentsRowFocusAnimationHolder;
-
-import java.util.ArrayList;
-import java.util.List;
+import android.support.v7.widget.RecyclerView.OnScrollListener;
+import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
/**
* Top level layout of recents for TV. This will show the TaskStacks using a HorizontalGridView.
@@ -58,7 +61,7 @@
private Rect mSystemInsets = new Rect();
private RecentsTvTransitionHelper mTransitionHelper;
private Handler mHandler;
-
+ private OnScrollListener mScrollListener;
public RecentsTvView(Context context) {
this(context, null);
}
@@ -111,8 +114,7 @@
if (mTaskStackHorizontalView != null) {
Task task = mTaskStackHorizontalView.getFocusedTask();
if (task != null) {
- SystemServicesProxy ssp = Recents.getSystemServices();
- ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
+ launchTaskFomRecents(task);
return true;
}
}
@@ -125,25 +127,53 @@
TaskStack stack = mTaskStackHorizontalView.getStack();
Task task = stack.getLaunchTarget();
if (task != null) {
- SystemServicesProxy ssp = Recents.getSystemServices();
- ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
+ launchTaskFomRecents(task);
return true;
}
}
return false;
}
- /** Launches a given task. */
- public boolean launchTask(Task task, Rect taskBounds, int destinationStack) {
- if (mTaskStackHorizontalView != null) {
- // Iterate the stack views and try and find the given task.
- if (mTaskStackHorizontalView.getChildViewForTask(task) != null) {
- SystemServicesProxy ssp = Recents.getSystemServices();
- ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
- return true;
+ /**
+ * Launch the given task from recents with animation. If the task is not focused, this will
+ * attempt to scroll to focus the task before launching.
+ * @param task
+ */
+ private void launchTaskFomRecents(final Task task) {
+ if(task != mTaskStackHorizontalView.getFocusedTask()) {
+ if(mScrollListener != null) {
+ mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
}
+ mScrollListener = new OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ super.onScrollStateChanged(recyclerView, newState);
+ if(newState == RecyclerView.SCROLL_STATE_IDLE) {
+ TaskCardView cardView = mTaskStackHorizontalView.getChildViewForTask(task);
+ if(cardView != null) {
+ mTransitionHelper.launchTaskFromRecents(mStack, task,
+ mTaskStackHorizontalView, cardView, null, INVALID_STACK_ID);
+ } else {
+ // This should not happen normally. If this happens then the data in
+ // the grid view was altered during the scroll. Log error and launch
+ // task with no animation.
+ Log.e(TAG, "Card view for task : " + task + ", returned null.");
+ SystemServicesProxy ssp = Recents.getSystemServices();
+ ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
+ }
+ mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
+ }
+ }
+ };
+ mTaskStackHorizontalView.addOnScrollListener(mScrollListener);
+ mTaskStackHorizontalView.setSelectedPositionSmooth(
+ ((TaskStackHorizontalViewAdapter) mTaskStackHorizontalView.getAdapter())
+ .getPositionOfTask(task));
+ } else {
+ mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView,
+ mTaskStackHorizontalView.getChildViewForTask(task), null,
+ INVALID_STACK_ID);
}
- return false;
}
/**
@@ -218,9 +248,15 @@
}
}
- public void setTaskStackViewAdapter(TaskStackHorizontalViewAdapter taskStackViewAdapter) {
+ public TaskStackHorizontalGridView setTaskStackViewAdapter(
+ TaskStackHorizontalViewAdapter taskStackViewAdapter) {
if(mTaskStackHorizontalView != null) {
mTaskStackHorizontalView.setAdapter(taskStackViewAdapter);
}
+ return mTaskStackHorizontalView;
+ }
+
+ public TaskStackHorizontalGridView getGridView() {
+ return mTaskStackHorizontalView;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java
index d605748..99d478b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java
@@ -64,6 +64,7 @@
@Override
protected void onFinishInflate() {
+ super.onFinishInflate();
mThumbnailView = (ImageView) findViewById(R.id.card_view_thumbnail);
mTitleTextView = (TextView) findViewById(R.id.card_title_text);
mBadgeView = (ImageView) findViewById(R.id.card_extra_badge);
@@ -91,13 +92,6 @@
public Rect getFocusedThumbnailRect() {
Rect r = new Rect();
mThumbnailView.getGlobalVisibleRect(r);
- TypedValue out = new TypedValue();
- getContext().getResources().getValue(R.integer.selected_scale, out, true);
- float deltaScale = (out.getFloat() - 1.0f) / 2;
- r.set((int) (r.left - r.left * deltaScale),
- (int) (r.top - r.top * deltaScale),
- (int) (r.right + r.right * deltaScale),
- (int) (r.bottom + r.bottom * deltaScale));
return r;
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java
index 3788719..97712ea 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java
@@ -131,4 +131,9 @@
mTaskList.remove(position);
notifyItemRemoved(position);
}
+
+ public int getPositionOfTask(Task task) {
+ int position = mTaskList.indexOf(task);
+ return (position >= 0) ? position : 0;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
index 9eec2ce..fd8df99 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
@@ -116,6 +116,7 @@
// window transition
EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
+ stackView.cancelAllTaskViewAnimations();
if (screenPinningRequested) {
// Request screen pinning after the animation runs
@@ -133,6 +134,7 @@
// window transition
EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
+ stackView.cancelAllTaskViewAnimations();
}
};
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index f8ed700..6e585ae 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -146,6 +146,8 @@
AnimateableViewBounds mViewBounds;
private AnimatorSet mTransformAnimation;
+ private ObjectAnimator mDimAnimator;
+ private ObjectAnimator mOutlineAnimator;
private final TaskViewTransform mTargetAnimationTransform = new TaskViewTransform();
private ArrayList<Animator> mTmpAnimators = new ArrayList<>();
@@ -308,14 +310,14 @@
} else {
// Both the progress and the update are a function of the bounds movement of the task
if (Float.compare(getDimAlpha(), toTransform.dimAlpha) != 0) {
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, DIM_ALPHA, getDimAlpha(),
+ mDimAnimator = ObjectAnimator.ofFloat(this, DIM_ALPHA, getDimAlpha(),
toTransform.dimAlpha);
- mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, anim));
+ mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, mDimAnimator));
}
if (Float.compare(mViewBounds.getAlpha(), toTransform.viewOutlineAlpha) != 0) {
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, VIEW_OUTLINE_ALPHA,
+ mOutlineAnimator = ObjectAnimator.ofFloat(this, VIEW_OUTLINE_ALPHA,
mViewBounds.getAlpha(), toTransform.viewOutlineAlpha);
- mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, anim));
+ mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, mOutlineAnimator));
}
if (updateCallback != null) {
ValueAnimator updateCallbackAnim = ValueAnimator.ofInt(0, 1);
@@ -358,6 +360,8 @@
*/
public void cancelTransformAnimation() {
Utilities.cancelAnimationWithoutCallbacks(mTransformAnimation);
+ Utilities.cancelAnimationWithoutCallbacks(mDimAnimator);
+ Utilities.cancelAnimationWithoutCallbacks(mOutlineAnimator);
}
/** Enables/disables handling touch on this task view. */
@@ -537,13 +541,15 @@
@Override
public void onStartLaunchTargetEnterAnimation(TaskViewTransform transform, int duration,
boolean screenPinningEnabled, ReferenceCountedTrigger postAnimationTrigger) {
+ Utilities.cancelAnimationWithoutCallbacks(mDimAnimator);
+
// Dim the view after the app window transitions down into recents
postAnimationTrigger.increment();
AnimationProps animation = new AnimationProps(duration, Interpolators.ALPHA_OUT);
- Animator anim = animation.apply(AnimationProps.DIM_ALPHA, ObjectAnimator.ofFloat(this,
+ mDimAnimator = animation.apply(AnimationProps.DIM_ALPHA, ObjectAnimator.ofFloat(this,
DIM_ALPHA_WITHOUT_HEADER, getDimAlpha(), transform.dimAlpha));
- anim.addListener(postAnimationTrigger.decrementOnAnimationEnd());
- anim.start();
+ mDimAnimator.addListener(postAnimationTrigger.decrementOnAnimationEnd());
+ mDimAnimator.start();
if (screenPinningEnabled) {
showActionButton(true /* fadeIn */, duration /* fadeInDuration */);
@@ -553,11 +559,13 @@
@Override
public void onStartLaunchTargetLaunchAnimation(int duration, boolean screenPinningRequested,
ReferenceCountedTrigger postAnimationTrigger) {
+ Utilities.cancelAnimationWithoutCallbacks(mDimAnimator);
+
// Un-dim the view before/while launching the target
AnimationProps animation = new AnimationProps(duration, Interpolators.ALPHA_OUT);
- Animator anim = animation.apply(AnimationProps.DIM_ALPHA, ObjectAnimator.ofFloat(this,
+ mDimAnimator = animation.apply(AnimationProps.DIM_ALPHA, ObjectAnimator.ofFloat(this,
DIM_ALPHA, getDimAlpha(), 0));
- anim.start();
+ mDimAnimator.start();
postAnimationTrigger.increment();
hideActionButton(true /* fadeOut */, duration,
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java b/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java
index 9b56037..9294ecd 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java
@@ -20,12 +20,14 @@
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
-import android.util.ArrayMap;
import android.util.ArraySet;
+import android.widget.Toast;
+import com.android.systemui.R;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.AppTransitionFinishedEvent;
-import com.android.systemui.recents.events.activity.ForcedResizableEvent;
+import com.android.systemui.recents.misc.SystemServicesProxy;
+import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;
import com.android.systemui.stackdivider.events.StartedDragingEvent;
import com.android.systemui.stackdivider.events.StoppedDragingEvent;
@@ -53,6 +55,18 @@
public ForcedResizableInfoActivityController(Context context) {
mContext = context;
EventBus.getDefault().register(this);
+ SystemServicesProxy.getInstance(context).registerTaskStackListener(
+ new TaskStackListener() {
+ @Override
+ public void onActivityForcedResizable(String packageName, int taskId) {
+ activityForcedResizable(packageName, taskId);
+ }
+
+ @Override
+ public void onActivityDismissingDockedStack() {
+ activityDismissingDockedStack();
+ }
+ });
}
public void notifyDockedStackExistsChanged(boolean exists) {
@@ -61,14 +75,6 @@
}
}
- public final void onBusEvent(ForcedResizableEvent forcedResizableEvent) {
- if (debounce(forcedResizableEvent.packageName)) {
- return;
- }
- mPendingTaskIds.add(forcedResizableEvent.taskId);
- postTimeout();
- }
-
public final void onBusEvent(AppTransitionFinishedEvent event) {
if (!mDividerDraging) {
showPending();
@@ -85,6 +91,20 @@
showPending();
}
+ private void activityForcedResizable(String packageName, int taskId) {
+ if (debounce(packageName)) {
+ return;
+ }
+ mPendingTaskIds.add(taskId);
+ postTimeout();
+ }
+
+ private void activityDismissingDockedStack() {
+ Toast toast = Toast.makeText(mContext, R.string.dock_non_resizeble_failed_to_dock_text,
+ Toast.LENGTH_SHORT);
+ toast.show();
+ }
+
private void showPending() {
mHandler.removeCallbacks(mTimeoutRunnable);
for (int i = mPendingTaskIds.size() - 1; i >= 0; i--) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 7ca7d12..e25f9de 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -618,6 +618,19 @@
return mOnKeyguard;
}
+ public void removeAllChildren() {
+ List<ExpandableNotificationRow> notificationChildren
+ = mChildrenContainer.getNotificationChildren();
+ ArrayList<ExpandableNotificationRow> clonedList = new ArrayList<>(notificationChildren);
+ for (int i = 0; i < clonedList.size(); i++) {
+ ExpandableNotificationRow row = clonedList.get(i);
+ mChildrenContainer.removeNotification(row);
+ mHeaderUtil.restoreNotificationHeader(row);
+ row.setIsChildInGroup(false, null);
+ }
+ onChildrenCountChanged();
+ }
+
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
index 977a77d..fff1491 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
@@ -17,16 +17,24 @@
package com.android.systemui.statusbar;
import android.app.AlertDialog;
+import android.app.AppGlobals;
import android.app.Dialog;
+import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageInfo;
+import android.content.pm.ResolveInfo;
+import android.graphics.drawable.Icon;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.hardware.input.InputManager;
import android.os.Handler;
import android.os.Looper;
+import android.os.RemoteException;
import android.util.Log;
import android.util.SparseArray;
import android.view.ContextThemeWrapper;
@@ -42,8 +50,10 @@
import android.view.WindowManager.KeyboardShortcutsReceiver;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.TextView;
+import com.android.internal.app.AssistUtils;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
@@ -58,7 +68,6 @@
*/
public final class KeyboardShortcuts {
private static final String TAG = KeyboardShortcuts.class.getSimpleName();
-
private final SparseArray<String> mSpecialCharacterNames = new SparseArray<>();
private final SparseArray<String> mModifierNames = new SparseArray<>();
private final SparseArray<Drawable> mSpecialCharacterDrawables = new SparseArray<>();
@@ -66,6 +75,7 @@
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Context mContext;
+ private final IPackageManager mPackageManager;
private final OnClickListener dialogCloseListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dismissKeyboardShortcutsDialog();
@@ -77,6 +87,7 @@
public KeyboardShortcuts(Context context) {
this.mContext = new ContextThemeWrapper(context, android.R.style.Theme_Material_Light);
+ this.mPackageManager = AppGlobals.getPackageManager();
loadResources(context);
}
@@ -254,68 +265,11 @@
@Override
public void onKeyboardShortcutsReceived(
final List<KeyboardShortcutGroup> result) {
- KeyboardShortcutGroup systemGroup = new KeyboardShortcutGroup(
- mContext.getString(R.string.keyboard_shortcut_group_system), true);
- systemGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(R.string.keyboard_shortcut_group_system_home),
- KeyEvent.KEYCODE_ENTER, KeyEvent.META_META_ON));
- systemGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(R.string.keyboard_shortcut_group_system_back),
- KeyEvent.KEYCODE_DEL, KeyEvent.META_META_ON));
- systemGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(R.string.keyboard_shortcut_group_system_recents),
- KeyEvent.KEYCODE_TAB, KeyEvent.META_ALT_ON));
- systemGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_system_notifications),
- KeyEvent.KEYCODE_N, KeyEvent.META_META_ON));
- systemGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_system_shortcuts_helper),
- KeyEvent.KEYCODE_SLASH, KeyEvent.META_META_ON));
- systemGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_system_switch_input),
- KeyEvent.KEYCODE_SPACE, KeyEvent.META_META_ON));
- result.add(systemGroup);
-
- KeyboardShortcutGroup applicationGroup = new KeyboardShortcutGroup(
- mContext.getString(R.string.keyboard_shortcut_group_applications),
- true);
- applicationGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_applications_assist),
- KeyEvent.KEYCODE_UNKNOWN, KeyEvent.META_META_ON));
- applicationGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_applications_browser),
- KeyEvent.KEYCODE_B, KeyEvent.META_META_ON));
- applicationGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_applications_contacts),
- KeyEvent.KEYCODE_C, KeyEvent.META_META_ON));
- applicationGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_applications_email),
- KeyEvent.KEYCODE_E, KeyEvent.META_META_ON));
- applicationGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_applications_im),
- KeyEvent.KEYCODE_T, KeyEvent.META_META_ON));
- applicationGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_applications_music),
- KeyEvent.KEYCODE_P, KeyEvent.META_META_ON));
- applicationGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_applications_youtube),
- KeyEvent.KEYCODE_Y, KeyEvent.META_META_ON));
- applicationGroup.addItem(new KeyboardShortcutInfo(
- mContext.getString(
- R.string.keyboard_shortcut_group_applications_calendar),
- KeyEvent.KEYCODE_L, KeyEvent.META_META_ON));
- result.add(applicationGroup);
-
+ result.add(getSystemShortcuts());
+ final KeyboardShortcutGroup appShortcuts = getDefaultApplicationShortcuts();
+ if (appShortcuts != null) {
+ result.add(appShortcuts);
+ }
showKeyboardShortcutsDialog(result);
}
}, deviceId);
@@ -331,6 +285,160 @@
}
}
+ private KeyboardShortcutGroup getSystemShortcuts() {
+ final KeyboardShortcutGroup systemGroup = new KeyboardShortcutGroup(
+ mContext.getString(R.string.keyboard_shortcut_group_system), true);
+ systemGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_system_home),
+ KeyEvent.KEYCODE_ENTER,
+ KeyEvent.META_META_ON));
+ systemGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_system_back),
+ KeyEvent.KEYCODE_DEL,
+ KeyEvent.META_META_ON));
+ systemGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_system_recents),
+ KeyEvent.KEYCODE_TAB,
+ KeyEvent.META_ALT_ON));
+ systemGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(
+ R.string.keyboard_shortcut_group_system_notifications),
+ KeyEvent.KEYCODE_N,
+ KeyEvent.META_META_ON));
+ systemGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(
+ R.string.keyboard_shortcut_group_system_shortcuts_helper),
+ KeyEvent.KEYCODE_SLASH,
+ KeyEvent.META_META_ON));
+ systemGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(
+ R.string.keyboard_shortcut_group_system_switch_input),
+ KeyEvent.KEYCODE_SPACE,
+ KeyEvent.META_META_ON));
+ return systemGroup;
+ }
+
+ private KeyboardShortcutGroup getDefaultApplicationShortcuts() {
+ final int userId = mContext.getUserId();
+ final KeyboardShortcutGroup applicationGroup = new KeyboardShortcutGroup(
+ mContext.getString(R.string.keyboard_shortcut_group_applications),
+ true);
+
+ // Assist.
+ final AssistUtils assistUtils = new AssistUtils(mContext);
+ final ComponentName assistComponent = assistUtils.getAssistComponentForUser(userId);
+ PackageInfo assistPackageInfo = null;
+ try {
+ assistPackageInfo = mPackageManager.getPackageInfo(
+ assistComponent.getPackageName(), 0, userId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "PackageManagerService is dead");
+ }
+
+ if (assistPackageInfo != null) {
+ final Icon assistIcon = Icon.createWithResource(
+ assistPackageInfo.applicationInfo.packageName,
+ assistPackageInfo.applicationInfo.icon);
+
+ applicationGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_applications_assist),
+ assistIcon,
+ KeyEvent.KEYCODE_UNKNOWN,
+ KeyEvent.META_META_ON));
+ }
+
+ // Browser.
+ final Icon browserIcon = getIconForIntentCategory(Intent.CATEGORY_APP_BROWSER, userId);
+ if (browserIcon != null) {
+ applicationGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_applications_browser),
+ browserIcon,
+ KeyEvent.KEYCODE_B,
+ KeyEvent.META_META_ON));
+ }
+
+
+ // Contacts.
+ final Icon contactsIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CONTACTS, userId);
+ if (contactsIcon != null) {
+ applicationGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_applications_contacts),
+ contactsIcon,
+ KeyEvent.KEYCODE_C,
+ KeyEvent.META_META_ON));
+ }
+
+ // Email.
+ final Icon emailIcon = getIconForIntentCategory(Intent.CATEGORY_APP_EMAIL, userId);
+ if (emailIcon != null) {
+ applicationGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_applications_email),
+ emailIcon,
+ KeyEvent.KEYCODE_E,
+ KeyEvent.META_META_ON));
+ }
+
+ // Messaging.
+ final Icon messagingIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MESSAGING, userId);
+ if (messagingIcon != null) {
+ applicationGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_applications_im),
+ messagingIcon,
+ KeyEvent.KEYCODE_T,
+ KeyEvent.META_META_ON));
+ }
+
+ // Music.
+ final Icon musicIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MUSIC, userId);
+ if (musicIcon != null) {
+ applicationGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_applications_music),
+ musicIcon,
+ KeyEvent.KEYCODE_P,
+ KeyEvent.META_META_ON));
+ }
+
+ // Calendar.
+ final Icon calendarIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CALENDAR, userId);
+ if (calendarIcon != null) {
+ applicationGroup.addItem(new KeyboardShortcutInfo(
+ mContext.getString(R.string.keyboard_shortcut_group_applications_calendar),
+ calendarIcon,
+ KeyEvent.KEYCODE_L,
+ KeyEvent.META_META_ON));
+ }
+
+ return applicationGroup.getItems().size() == 0 ? null : applicationGroup;
+ }
+
+ private Icon getIconForIntentCategory(String intentCategory, int userId) {
+ final Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.addCategory(intentCategory);
+
+ final PackageInfo packageInfo = getPackageInfoForIntent(intent, userId);
+ if (packageInfo != null && packageInfo.applicationInfo.icon != 0) {
+ return Icon.createWithResource(
+ packageInfo.applicationInfo.packageName,
+ packageInfo.applicationInfo.icon);
+ }
+ return null;
+ }
+
+ private PackageInfo getPackageInfoForIntent(Intent intent, int userId) {
+ try {
+ ResolveInfo handler;
+ handler = mPackageManager.resolveIntent(
+ intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), 0, userId);
+ if (handler == null || handler.activityInfo == null) {
+ return null;
+ }
+ return mPackageManager.getPackageInfo(handler.activityInfo.packageName, 0, userId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "PackageManagerService is dead", e);
+ return null;
+ }
+ }
+
private void showKeyboardShortcutsDialog(
final List<KeyboardShortcutGroup> keyboardShortcutGroups) {
// Need to post on the main thread.
@@ -394,9 +502,23 @@
}
View shortcutView = inflater.inflate(R.layout.keyboard_shortcut_app_item,
shortcutContainer, false);
- TextView textView = (TextView) shortcutView
+
+ if (info.getIcon() != null) {
+ ImageView shortcutIcon = (ImageView) shortcutView
+ .findViewById(R.id.keyboard_shortcuts_icon);
+ shortcutIcon.setImageIcon(info.getIcon());
+ shortcutIcon.setVisibility(View.VISIBLE);
+ }
+
+ TextView shortcutKeyword = (TextView) shortcutView
.findViewById(R.id.keyboard_shortcuts_keyword);
- textView.setText(info.getLabel());
+ shortcutKeyword.setText(info.getLabel());
+ if (info.getIcon() != null) {
+ RelativeLayout.LayoutParams lp =
+ (RelativeLayout.LayoutParams) shortcutKeyword.getLayoutParams();
+ lp.removeRule(RelativeLayout.ALIGN_PARENT_START);
+ shortcutKeyword.setLayoutParams(lp);
+ }
ViewGroup shortcutItemsContainer = (ViewGroup) shortcutView
.findViewById(R.id.keyboard_shortcuts_item_container);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index c9fe2bd..6570221 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Map;
import java.util.Objects;
/**
@@ -257,16 +258,21 @@
}
public void add(Entry entry, RankingMap ranking) {
- mEntries.put(entry.notification.getKey(), entry);
- updateRankingAndSort(ranking);
+ synchronized (mEntries) {
+ mEntries.put(entry.notification.getKey(), entry);
+ }
mGroupManager.onEntryAdded(entry);
+ updateRankingAndSort(ranking);
}
public Entry remove(String key, RankingMap ranking) {
- Entry removed = mEntries.remove(key);
+ Entry removed = null;
+ synchronized (mEntries) {
+ removed = mEntries.remove(key);
+ }
if (removed == null) return null;
- updateRankingAndSort(ranking);
mGroupManager.onEntryRemoved(removed);
+ updateRankingAndSort(ranking);
return removed;
}
@@ -316,9 +322,30 @@
return Ranking.IMPORTANCE_UNSPECIFIED;
}
+ public String getOverrideGroupKey(String key) {
+ if (mRankingMap != null) {
+ mRankingMap.getRanking(key, mTmpRanking);
+ return mTmpRanking.getOverrideGroupKey();
+ }
+ return null;
+ }
+
private void updateRankingAndSort(RankingMap ranking) {
if (ranking != null) {
mRankingMap = ranking;
+ synchronized (mEntries) {
+ final int N = mEntries.size();
+ for (int i = 0; i < N; i++) {
+ Entry entry = mEntries.valueAt(i);
+ final StatusBarNotification oldSbn = entry.notification.clone();
+ final String overrideGroupKey = getOverrideGroupKey(entry.key);
+ if (!Objects.equals(oldSbn.getOverrideGroupKey(), overrideGroupKey)) {
+ entry.notification.setOverrideGroupKey(overrideGroupKey);
+ mGroupManager.onEntryUpdated(entry, oldSbn);
+ }
+ //mGroupManager.onEntryBundlingUpdated(entry, getOverrideGroupKey(entry.key));
+ }
+ }
}
filterAndSort();
}
@@ -328,16 +355,18 @@
public void filterAndSort() {
mSortedAndFiltered.clear();
- final int N = mEntries.size();
- for (int i = 0; i < N; i++) {
- Entry entry = mEntries.valueAt(i);
- StatusBarNotification sbn = entry.notification;
+ synchronized (mEntries) {
+ final int N = mEntries.size();
+ for (int i = 0; i < N; i++) {
+ Entry entry = mEntries.valueAt(i);
+ StatusBarNotification sbn = entry.notification;
- if (shouldFilterOut(sbn)) {
- continue;
+ if (shouldFilterOut(sbn)) {
+ continue;
+ }
+
+ mSortedAndFiltered.add(entry);
}
-
- mSortedAndFiltered.add(entry);
}
Collections.sort(mSortedAndFiltered, mRankingComparator);
@@ -398,16 +427,17 @@
NotificationData.Entry e = mSortedAndFiltered.get(active);
dumpEntry(pw, indent, active, e);
}
-
- int M = mEntries.size();
- pw.print(indent);
- pw.println("inactive notifications: " + (M - active));
- int inactiveCount = 0;
- for (int i = 0; i < M; i++) {
- Entry entry = mEntries.valueAt(i);
- if (!mSortedAndFiltered.contains(entry)) {
- dumpEntry(pw, indent, inactiveCount, entry);
- inactiveCount++;
+ synchronized (mEntries) {
+ int M = mEntries.size();
+ pw.print(indent);
+ pw.println("inactive notifications: " + (M - active));
+ int inactiveCount = 0;
+ for (int i = 0; i < M; i++) {
+ Entry entry = mEntries.valueAt(i);
+ if (!mSortedAndFiltered.contains(entry)) {
+ dumpEntry(pw, indent, inactiveCount, entry);
+ inactiveCount++;
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index f7a6b271..a27ec28 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -26,6 +26,7 @@
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Objects;
/**
* A class to handle notifications and their corresponding groups.
@@ -121,6 +122,15 @@
}
}
+ public void onEntryBundlingUpdated(final NotificationData.Entry updated,
+ final String overrideGroupKey) {
+ final StatusBarNotification oldSbn = updated.notification.clone();
+ if (!Objects.equals(oldSbn.getOverrideGroupKey(), overrideGroupKey)) {
+ updated.notification.setOverrideGroupKey(overrideGroupKey);
+ onEntryUpdated(updated, oldSbn);
+ }
+ }
+
private void updateSuppression(NotificationGroup group) {
if (group == null) {
return;
@@ -129,7 +139,7 @@
group.suppressed = group.summary != null && !group.expanded
&& (group.children.size() == 1
|| (group.children.size() == 0
- && !group.summary.notification.getNotification().isGroupChild()
+ && group.summary.notification.getNotification().isGroupSummary()
&& hasIsolatedChildren(group)));
if (prevSuppressed != group.suppressed) {
mListener.onGroupsChanged();
@@ -173,7 +183,7 @@
public boolean isOnlyChildInSuppressedGroup(StatusBarNotification sbn) {
return isGroupSuppressed(sbn.getGroupKey())
- && sbn.getNotification().isGroupChild()
+ && !sbn.getNotification().isGroupSummary()
&& getTotalNumberOfChildren(sbn) == 1;
}
@@ -278,11 +288,12 @@
}
return sbn.getNotification().isGroupSummary();
}
+
private boolean isGroupChild(StatusBarNotification sbn) {
if (isIsolated(sbn)) {
return false;
}
- return sbn.getNotification().isGroupChild();
+ return sbn.isGroup() && !sbn.getNotification().isGroupSummary();
}
private String getGroupKey(StatusBarNotification sbn) {
@@ -335,7 +346,7 @@
private boolean shouldIsolate(StatusBarNotification sbn) {
NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey());
- return sbn.getNotification().isGroupChild()
+ return (sbn.isGroup() && !sbn.getNotification().isGroupSummary())
&& (sbn.getNotification().fullScreenIntent != null
|| notificationGroup == null
|| !notificationGroup.expanded
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 45e94f7..62c0fa9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -306,7 +306,7 @@
// Calculate quick setting heights.
int oldMaxHeight = mQsMaxExpansionHeight;
- mQsMinExpansionHeight = mKeyguardShowing ? 0 : mQsContainer.getHeader().getHeight();
+ mQsMinExpansionHeight = mKeyguardShowing ? 0 : mQsContainer.getQsMinExpansionHeight();
mQsMaxExpansionHeight = mQsContainer.getDesiredHeight();
positionClockAndNotifications();
if (mQsExpanded && mQsFullyExpanded) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index c9bb15d..c4b7932 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -845,15 +845,19 @@
};
public void cancelPeek() {
+ boolean cancelled = mPeekPending;
if (mPeekAnimator != null) {
+ cancelled = true;
mPeekAnimator.cancel();
}
removeCallbacks(mPeekRunnable);
mPeekPending = false;
- // When peeking, we already tell mBar that we expanded ourselves. Make sure that we also
- // notify mBar that we might have closed ourselves.
- notifyBarPanelExpansionChanged();
+ if (cancelled) {
+ // When peeking, we already tell mBar that we expanded ourselves. Make sure that we also
+ // notify mBar that we might have closed ourselves.
+ notifyBarPanelExpansionChanged();
+ }
}
public void expand(final boolean animate) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index bf58592..d036fe4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1525,6 +1525,9 @@
// we are only transfering this notification to its parent, don't generate an animation
mStackScroller.setChildTransferInProgress(true);
}
+ if (remove.isSummaryWithChildren()) {
+ remove.removeAllChildren();
+ }
mStackScroller.removeView(remove);
mStackScroller.setChildTransferInProgress(false);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 902fd3d..cc3b4bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -41,7 +41,9 @@
private Runnable mHideExpandedRunnable = new Runnable() {
@Override
public void run() {
- mBar.makeExpandedInvisible();
+ if (mPanelFraction == 0.0f) {
+ mBar.makeExpandedInvisible();
+ }
}
};
@@ -135,6 +137,7 @@
super.onTrackingStarted();
mBar.onTrackingStarted();
mScrimController.onTrackingStarted();
+ removePendingHideExpandedRunnables();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
index e8170fb..ea9a5a5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
@@ -45,7 +45,7 @@
import com.android.systemui.tuner.TunerService;
public class QuickStatusBarHeader extends BaseStatusBarHeader implements
- NextAlarmChangeCallback, OnClickListener {
+ NextAlarmChangeCallback, OnClickListener, OnUserInfoChangedListener {
private static final String TAG = "QuickStatusBarHeader";
@@ -54,7 +54,7 @@
private ActivityStarter mActivityStarter;
private NextAlarmController mNextAlarmController;
private SettingsButton mSettingsButton;
- private View mSettingsContainer;
+ protected View mSettingsContainer;
private TextView mAlarmStatus;
private TextView mAlarmStatusCollapsed;
@@ -75,19 +75,19 @@
private QuickQSPanel mHeaderQsPanel;
private boolean mShowEmergencyCallsOnly;
- private MultiUserSwitch mMultiUserSwitch;
+ protected MultiUserSwitch mMultiUserSwitch;
private ImageView mMultiUserAvatar;
private float mDateTimeTranslation;
private float mDateTimeAlarmTranslation;
private float mDateScaleFactor;
- private float mGearTranslation;
+ protected float mGearTranslation;
private TouchAnimator mSecondHalfAnimator;
private TouchAnimator mFirstHalfAnimator;
private TouchAnimator mDateSizeAnimator;
private TouchAnimator mAlarmTranslation;
- private TouchAnimator mSettingsAlpha;
+ protected TouchAnimator mSettingsAlpha;
private float mExpansionAmount;
private QSTileHost mHost;
@@ -172,6 +172,11 @@
.addFloat(mDateTimeGroup, "scaleY", 1, mDateScaleFactor)
.setStartDelay(.36f)
.build();
+
+ updateSettingsAnimator();
+ }
+
+ protected void updateSettingsAnimator() {
mSettingsAlpha = new TouchAnimator.Builder()
.addFloat(mSettingsContainer, "translationY", -mGearTranslation, 0)
.addFloat(mMultiUserSwitch, "translationY", -mGearTranslation, 0)
@@ -241,7 +246,7 @@
@Override
protected void onDetachedFromWindow() {
setListening(false);
- mHost.getUserInfoController().remListener(mUserListener);
+ mHost.getUserInfoController().remListener(this);
mHost.getNetworkController().removeEmergencyListener(this);
super.onDetachedFromWindow();
}
@@ -275,7 +280,7 @@
updateVisibilities();
}
- private void updateVisibilities() {
+ protected void updateVisibilities() {
updateAlarmVisibilities();
mEmergencyOnly.setVisibility(mExpanded && mShowEmergencyCallsOnly
? View.VISIBLE : View.INVISIBLE);
@@ -365,7 +370,7 @@
@Override
public void setUserInfoController(UserInfoController userInfoController) {
- userInfoController.addListener(mUserListener);
+ userInfoController.addListener(this);
}
@Override
@@ -379,10 +384,8 @@
}
}
- private final OnUserInfoChangedListener mUserListener = new OnUserInfoChangedListener() {
- @Override
- public void onUserInfoChanged(String name, Drawable picture) {
- mMultiUserAvatar.setImageDrawable(picture);
- }
- };
+ @Override
+ public void onUserInfoChanged(String name, Drawable picture) {
+ mMultiUserAvatar.setImageDrawable(picture);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UserAvatarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UserAvatarView.java
index 093a827..dc1b35d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UserAvatarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UserAvatarView.java
@@ -17,69 +17,57 @@
package com.android.systemui.statusbar.phone;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
-import android.graphics.BitmapShader;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
-import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
+import com.android.settingslib.drawable.UserIconDrawable;
import com.android.systemui.R;
/**
- * A view that displays a user image cropped to a circle with a frame.
+ * A view that displays a user image cropped to a circle with an optional frame.
*/
public class UserAvatarView extends View {
- private int mActiveFrameColor;
- private int mFrameColor;
- private float mFrameWidth;
- private float mFramePadding;
- private Bitmap mBitmap;
- private Drawable mDrawable;
- private boolean mIsDisabled;
-
- private final Paint mFramePaint = new Paint();
- private final Paint mBitmapPaint = new Paint();
- private final Matrix mDrawMatrix = new Matrix();
-
- private float mScale = 1;
+ private final UserIconDrawable mDrawable = new UserIconDrawable();
public UserAvatarView(Context context, AttributeSet attrs,
int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
+
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.UserAvatarView, defStyleAttr, defStyleRes);
final int N = a.getIndexCount();
for (int i = 0; i < N; i++) {
int attr = a.getIndex(i);
switch (attr) {
+ case R.styleable.UserAvatarView_avatarPadding:
+ setAvatarPadding(a.getDimension(attr, 0));
+ break;
case R.styleable.UserAvatarView_frameWidth:
setFrameWidth(a.getDimension(attr, 0));
break;
case R.styleable.UserAvatarView_framePadding:
setFramePadding(a.getDimension(attr, 0));
break;
- case R.styleable.UserAvatarView_activeFrameColor:
- setActiveFrameColor(a.getColor(attr, 0));
- break;
case R.styleable.UserAvatarView_frameColor:
- setFrameColor(a.getColor(attr, 0));
+ setFrameColor(a.getColorStateList(attr));
+ break;
+ case R.styleable.UserAvatarView_badgeDiameter:
+ setBadgeDiameter(a.getDimension(attr, 0));
+ break;
+ case R.styleable.UserAvatarView_badgeMargin:
+ setBadgeMargin(a.getDimension(attr, 0));
break;
}
}
a.recycle();
-
- mFramePaint.setAntiAlias(true);
- mFramePaint.setStyle(Paint.Style.STROKE);
- mBitmapPaint.setAntiAlias(true);
+ setBackground(mDrawable);
}
public UserAvatarView(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -94,180 +82,61 @@
this(context, null);
}
+ /**
+ * @deprecated use {@link #setAvatar(Bitmap)} instead.
+ */
+ @Deprecated
public void setBitmap(Bitmap bitmap) {
- setDrawable(null);
- mBitmap = bitmap;
- if (mBitmap != null) {
- mBitmapPaint.setShader(new BitmapShader(
- bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
- } else {
- mBitmapPaint.setShader(null);
- }
- configureBounds();
- invalidate();
+ setAvatar(bitmap);
}
- public void setFrameColor(int frameColor) {
- mFrameColor = frameColor;
- invalidate();
- }
-
- public void setActiveFrameColor(int activeFrameColor) {
- mActiveFrameColor = activeFrameColor;
- invalidate();
+ public void setFrameColor(ColorStateList color) {
+ mDrawable.setFrameColor(color);
}
public void setFrameWidth(float frameWidth) {
- mFrameWidth = frameWidth;
- invalidate();
+ mDrawable.setFrameWidth(frameWidth);
}
public void setFramePadding(float framePadding) {
- mFramePadding = framePadding;
- invalidate();
+ mDrawable.setFramePadding(framePadding);
}
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- configureBounds();
+ public void setAvatarPadding(float avatarPadding) {
+ mDrawable.setPadding(avatarPadding);
}
- public void configureBounds() {
- int vwidth = getWidth() - mPaddingLeft - mPaddingRight;
- int vheight = getHeight() - mPaddingTop - mPaddingBottom;
-
- int dwidth;
- int dheight;
- if (mBitmap != null) {
- dwidth = mBitmap.getWidth();
- dheight = mBitmap.getHeight();
- } else if (mDrawable != null) {
- vwidth -= 2 * (mFrameWidth - 1);
- vheight -= 2 * (mFrameWidth - 1);
- dwidth = vwidth;
- dheight = vheight;
- mDrawable.setBounds(0, 0, dwidth, dheight);
- } else {
- return;
- }
-
- float scale;
- float dx;
- float dy;
-
- scale = Math.min((float) vwidth / (float) dwidth,
- (float) vheight / (float) dheight);
-
- dx = (int) ((vwidth - dwidth * scale) * 0.5f + 0.5f);
- dy = (int) ((vheight - dheight * scale) * 0.5f + 0.5f);
-
- mDrawMatrix.setScale(scale, scale);
- mDrawMatrix.postTranslate(dx, dy);
- mScale = scale;
+ public void setBadgeDiameter(float diameter) {
+ mDrawable.setBadgeRadius(diameter * 0.5f);
}
- @Override
- protected void onDraw(Canvas canvas) {
- int frameColor = isActivated() ? mActiveFrameColor : mFrameColor;
- float halfW = getWidth() / 2f;
- float halfH = getHeight() / 2f;
- float halfSW = Math.min(halfH, halfW);
- updateDrawableIfDisabled();
- if (mBitmap != null && mScale > 0) {
- int saveCount = canvas.getSaveCount();
- canvas.save();
- canvas.translate(mPaddingLeft, mPaddingTop);
- canvas.concat(mDrawMatrix);
- float halfBW = mBitmap.getWidth() / 2f;
- float halfBH = mBitmap.getHeight() / 2f;
- float halfBSW = Math.min(halfBH, halfBW);
- canvas.drawCircle(halfBW, halfBH, halfBSW - mFrameWidth / mScale + 1, mBitmapPaint);
- canvas.restoreToCount(saveCount);
- } else if (mDrawable != null && mScale > 0) {
- int saveCount = canvas.getSaveCount();
- canvas.save();
- canvas.translate(mPaddingLeft, mPaddingTop);
- canvas.translate(mFrameWidth - 1, mFrameWidth - 1);
- canvas.concat(mDrawMatrix);
- mDrawable.draw(canvas);
- canvas.restoreToCount(saveCount);
- }
- if (frameColor != 0) {
- mFramePaint.setColor(frameColor);
- mFramePaint.setStrokeWidth(mFrameWidth);
- canvas.drawCircle(halfW, halfH, halfSW + (mFramePadding - mFrameWidth) / 2f,
- mFramePaint);
- }
+ public void setBadgeMargin(float margin) {
+ mDrawable.setBadgeMargin(margin);
+ }
+
+ public void setAvatar(Bitmap avatar) {
+ mDrawable.setIcon(avatar);
+ mDrawable.setBadge(null);
+ }
+
+ public void setAvatarWithBadge(Bitmap avatar, int userId) {
+ mDrawable.setIcon(avatar);
+ mDrawable.setBadgeIfManagedUser(getContext(), userId);
}
public void setDrawable(Drawable d) {
- if (mDrawable != null) {
- mDrawable.setCallback(null);
- unscheduleDrawable(mDrawable);
+ if (d instanceof UserIconDrawable) {
+ throw new RuntimeException("Recursively adding UserIconDrawable");
}
- mDrawable = d;
- if (d != null) {
- d.setCallback(this);
- if (d.isStateful()) {
- d.setState(getDrawableState());
- }
- d.setLayoutDirection(getLayoutDirection());
- configureBounds();
- }
- if (d != null) {
- mBitmap = null;
- }
- configureBounds();
- invalidate();
+ mDrawable.setIconDrawable(d);
+ mDrawable.setBadge(null);
}
- @Override
- public void invalidateDrawable(Drawable dr) {
- if (dr == mDrawable) {
- invalidate();
- } else {
- super.invalidateDrawable(dr);
+ public void setDrawableWithBadge(Drawable d, int userId) {
+ if (d instanceof UserIconDrawable) {
+ throw new RuntimeException("Recursively adding UserIconDrawable");
}
- }
-
- @Override
- protected boolean verifyDrawable(Drawable who) {
- return who == mDrawable || super.verifyDrawable(who);
- }
-
- @Override
- protected void drawableStateChanged() {
- super.drawableStateChanged();
- if (mDrawable != null && mDrawable.isStateful()) {
- mDrawable.setState(getDrawableState());
- }
- }
-
- public void setDisabled(boolean disabled) {
- if (mIsDisabled == disabled) {
- return;
- }
- mIsDisabled = disabled;
- invalidate();
- }
-
- private void updateDrawableIfDisabled() {
- int disabledColor = getContext().getColor(R.color.qs_tile_disabled_color);
- PorterDuffColorFilter filter = new PorterDuffColorFilter(disabledColor,
- PorterDuff.Mode.SRC_ATOP);
- if (mBitmap != null) {
- if (mIsDisabled) {
- mBitmapPaint.setColorFilter(filter);
- } else {
- mBitmapPaint.setColorFilter(null);
- }
- } else if (mDrawable != null) {
- if (mIsDisabled) {
- mDrawable.setColorFilter(filter);
- } else {
- mDrawable.setColorFilter(null);
- }
- }
+ mDrawable.setIconDrawable(d);
+ mDrawable.setBadgeIfManagedUser(getContext(), userId);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
index fb310a6..c39d718 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
@@ -253,17 +253,13 @@
UserDetailItemView v = (UserDetailItemView) convertView;
String name = getName(mContext, item);
- Drawable drawable;
if (item.picture == null) {
- drawable = getDrawable(mContext, item).mutate();
+ v.bind(name, getDrawable(mContext, item).mutate(), item.resolveId());
} else {
- drawable = new BitmapDrawable(mContext.getResources(), item.picture);
+ v.bind(name, item.picture, item.info.id);
}
// Disable the icon if switching is disabled
- if (!item.isSwitchToEnabled) {
- drawable.setTint(mContext.getColor(R.color.qs_tile_disabled_color));
- }
- v.bind(name, drawable);
+ v.setAvatarEnabled(item.isSwitchToEnabled);
convertView.setActivated(item.isCurrent);
convertView.setTag(item);
return convertView;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java
index 85ac755..bae5bda 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java
@@ -26,7 +26,6 @@
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.RemoteException;
@@ -37,7 +36,7 @@
import android.util.Pair;
import com.android.internal.util.UserIcons;
-import com.android.systemui.BitmapHelper;
+import com.android.settingslib.drawable.UserIconDrawable;
import com.android.systemui.R;
import java.util.ArrayList;
@@ -155,8 +154,8 @@
Drawable avatar = null;
Bitmap rawAvatar = um.getUserIcon(userId);
if (rawAvatar != null) {
- avatar = new BitmapDrawable(mContext.getResources(),
- BitmapHelper.createCircularClip(rawAvatar, avatarSize, avatarSize));
+ avatar = new UserIconDrawable(avatarSize)
+ .setIcon(rawAvatar).setBadgeIfManagedUser(mContext, userId).bake();
} else {
avatar = UserIcons.getDefaultUserIcon(isGuest? UserHandle.USER_NULL : userId,
/* light= */ true);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
index ea0bdf2..c82ba3b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -50,7 +50,6 @@
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.util.UserIcons;
import com.android.settingslib.RestrictedLockUtils;
-import com.android.systemui.BitmapHelper;
import com.android.systemui.GuestResumeSessionReceiver;
import com.android.systemui.R;
import com.android.systemui.SystemUISecondaryUserService;
@@ -197,8 +196,6 @@
boolean canSwitchUsers = mUserManager.canSwitchUsers();
UserInfo currentUserInfo = null;
UserRecord guestRecord = null;
- int avatarSize = mContext.getResources()
- .getDimensionPixelSize(R.dimen.max_avatar_size);
for (UserInfo info : infos) {
boolean isCurrent = currentId == info.id;
@@ -219,8 +216,10 @@
picture = mUserManager.getUserIcon(info.id);
if (picture != null) {
- picture = BitmapHelper.createCircularClip(
- picture, avatarSize, avatarSize);
+ int avatarSize = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.max_avatar_size);
+ picture = Bitmap.createScaledBitmap(
+ picture, avatarSize, avatarSize, true);
}
}
int index = isCurrent ? 0 : records.size();
@@ -664,8 +663,7 @@
if (item.isAddUser) {
return context.getDrawable(R.drawable.ic_add_circle_qs);
}
- return UserIcons.getDefaultUserIcon(item.isGuest ? UserHandle.USER_NULL : item.info.id,
- /* light= */ true);
+ return UserIcons.getDefaultUserIcon(item.resolveId(), /* light= */ true);
}
public void refresh() {
@@ -718,6 +716,13 @@
isSwitchToEnabled);
}
+ public int resolveId() {
+ if (isGuest || info == null) {
+ return UserHandle.USER_NULL;
+ }
+ return info.id;
+ }
+
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("UserRecord(");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 0e3ec19..7c5cdfb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -299,7 +299,7 @@
setDimAmount((Float) animation.getAnimatedValue());
}
};
- private ViewGroup mQsContainer;
+ protected ViewGroup mQsContainer;
private boolean mContinuousShadowUpdate;
private ViewTreeObserver.OnPreDrawListener mShadowUpdater
= new ViewTreeObserver.OnPreDrawListener() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
index f9bb5e3..450001f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
@@ -19,6 +19,7 @@
import android.content.ComponentName;
import android.graphics.Rect;
import android.os.IBinder;
+import android.os.RemoteException;
import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
import android.view.View;
@@ -29,12 +30,22 @@
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.tv.pip.PipManager;
-/*
+/**
* Status bar implementation for "large screen" products that mostly present no on-screen nav
*/
public class TvStatusBar extends BaseStatusBar {
+ /**
+ * Tracking calls to View.setSystemUiVisibility().
+ */
+ int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
+
+ /**
+ * Last value sent to window manager.
+ */
+ private int mLastDispatchedSystemUiVisibility = ~View.SYSTEM_UI_FLAG_VISIBLE;
+
@Override
public void setIcon(String slot, StatusBarIcon icon) {
}
@@ -207,4 +218,30 @@
@Override
public void clickTile(ComponentName tile) {
}
+
+ @Override
+ public void start() {
+ super.start();
+ putComponent(TvStatusBar.class, this);
+ }
+
+ public void updateRecentsVisibility(boolean visible) {
+ // Update the recents visibility flag
+ if (visible) {
+ mSystemUiVisibility |= View.RECENT_APPS_VISIBLE;
+ } else {
+ mSystemUiVisibility &= ~View.RECENT_APPS_VISIBLE;
+ }
+ notifyUiVisibilityChanged(mSystemUiVisibility);
+ }
+
+ private void notifyUiVisibilityChanged(int vis) {
+ try {
+ if (mLastDispatchedSystemUiVisibility != vis) {
+ mWindowManagerService.statusBarVisibilityChanged(vis);
+ mLastDispatchedSystemUiVisibility = vis;
+ }
+ } catch (RemoteException ex) {
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
index fe54090..a445e77 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
@@ -36,6 +36,7 @@
import android.os.RemoteException;
import android.os.SystemProperties;
import android.util.Log;
+import android.util.Pair;
import com.android.systemui.Prefs;
import com.android.systemui.R;
@@ -63,6 +64,20 @@
private static final int MAX_RUNNING_TASKS_COUNT = 10;
/**
+ * List of package and class name which are considered as Settings,
+ * so PIP location should be adjusted to the left of the side panel.
+ */
+ private static final List<Pair<String, String>> sSettingsPackageAndClassNamePairList;
+ static {
+ sSettingsPackageAndClassNamePairList = new ArrayList<>();
+ sSettingsPackageAndClassNamePairList.add(new Pair<String, String>(
+ "com.android.tv.settings", null));
+ sSettingsPackageAndClassNamePairList.add(new Pair<String, String>(
+ "com.google.android.leanbacklauncher",
+ "com.google.android.leanbacklauncher.settings.HomeScreenSettingsActivity"));
+ }
+
+ /**
* State when there's no PIP.
*/
public static final int STATE_NO_PIP = 0;
@@ -108,6 +123,7 @@
private int mSuspendPipResizingReason;
private Context mContext;
+ private SystemServicesProxy mSystemServiceProxy;
private PipRecentsOverlayManager mPipRecentsOverlayManager;
private IActivityManager mActivityManager;
private MediaSessionManager mMediaSessionManager;
@@ -117,6 +133,8 @@
private List<MediaListener> mMediaListeners = new ArrayList<>();
private Rect mCurrentPipBounds;
private Rect mPipBounds;
+ private Rect mDefaultPipBounds;
+ private Rect mSettingsPipBounds;
private Rect mMenuModePipBounds;
private Rect mRecentsPipBounds;
private Rect mRecentsFocusedPipBounds;
@@ -176,8 +194,10 @@
mInitialized = true;
mContext = context;
Resources res = context.getResources();
- mPipBounds = Rect.unflattenFromString(res.getString(
+ mDefaultPipBounds = Rect.unflattenFromString(res.getString(
com.android.internal.R.string.config_defaultPictureInPictureBounds));
+ mSettingsPipBounds = Rect.unflattenFromString(res.getString(
+ R.string.pip_settings_bounds));
mMenuModePipBounds = Rect.unflattenFromString(res.getString(
R.string.pip_menu_bounds));
mRecentsPipBounds = Rect.unflattenFromString(res.getString(
@@ -186,9 +206,11 @@
R.string.pip_recents_focused_bounds));
mRecentsFocusChangedAnimationDurationMs = res.getInteger(
R.integer.recents_tv_pip_focus_anim_duration);
+ mPipBounds = mDefaultPipBounds;
mActivityManager = ActivityManagerNative.getDefault();
- SystemServicesProxy.getInstance(context).registerTaskStackListener(mTaskStackListener);
+ mSystemServiceProxy = SystemServicesProxy.getInstance(context);
+ mSystemServiceProxy.registerTaskStackListener(mTaskStackListener);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_MEDIA_RESOURCE_GRANTED);
mContext.registerReceiver(mBroadcastReceiver, intentFilter);
@@ -522,10 +544,25 @@
return PLAYBACK_STATE_UNAVAILABLE;
}
+ private static boolean isSettingsShown(ComponentName topActivity) {
+ for (Pair<String, String> componentName : sSettingsPackageAndClassNamePairList) {
+ String packageName = componentName.first;
+ if (topActivity.getPackageName().equals(componentName.first)) {
+ String className = componentName.second;
+ if (className == null || topActivity.getClassName().equals(className)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
private TaskStackListener mTaskStackListener = new TaskStackListener() {
@Override
public void onTaskStackChanged() {
if (mState != STATE_NO_PIP) {
+ boolean hasPip = false;
+
StackInfo stackInfo = null;
try {
stackInfo = mActivityManager.getStackInfo(PINNED_STACK_ID);
@@ -541,11 +578,32 @@
for (int i = stackInfo.taskIds.length - 1; i >= 0; --i) {
if (stackInfo.taskIds[i] == mPipTaskId) {
// PIP task is still alive.
- return;
+ hasPip = true;
+ break;
}
}
- // PIP task doesn't exist anymore in PINNED_STACK.
- closePipInternal(true);
+ if (!hasPip) {
+ // PIP task doesn't exist anymore in PINNED_STACK.
+ closePipInternal(true);
+ return;
+ }
+ }
+ if (mState == STATE_PIP_OVERLAY) {
+ try {
+ List<RunningTaskInfo> runningTasks = mActivityManager.getTasks(1, 0);
+ if (runningTasks == null || runningTasks.size() == 0) {
+ return;
+ }
+ RunningTaskInfo topTask = runningTasks.get(0);
+ Rect bounds = isSettingsShown(topTask.topActivity)
+ ? mSettingsPipBounds : mDefaultPipBounds;
+ if (mPipBounds != bounds) {
+ mPipBounds = bounds;
+ resizePinnedStack(STATE_PIP_OVERLAY);
+ }
+ } catch (RemoteException e) {
+ Log.d(TAG, "Failed to detect top activity", e);
+ }
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceManagerTests.java b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceManagerTests.java
index f24b541..1e27603 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceManagerTests.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceManagerTests.java
@@ -18,7 +18,6 @@
import android.content.ComponentName;
import android.os.Handler;
import android.os.HandlerThread;
-import android.service.quicksettings.TileService;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.systemui.SysuiTestCase;
import org.mockito.ArgumentCaptor;
@@ -42,11 +41,10 @@
mTileServices = Mockito.mock(TileServices.class);
Mockito.when(mTileServices.getContext()).thenReturn(mContext);
mTileLifecycle = Mockito.mock(TileLifecycleManager.class);
+ Mockito.when(mTileLifecycle.isActiveTile()).thenReturn(false);
ComponentName componentName = new ComponentName(mContext,
TileServiceManagerTests.class);
Mockito.when(mTileLifecycle.getComponent()).thenReturn(componentName);
- mContext.getSharedPreferences(TileServiceManager.PREFS_FILE, 0).edit()
- .putInt(componentName.flattenToString(), TileService.TILE_MODE_PASSIVE).commit();
mTileServiceManager = new TileServiceManager(mTileServices, mHandler, mTileLifecycle);
}
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index b3613df..ea3cffe 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -2135,6 +2135,9 @@
// Suggestion -> Overflow -> Remove.
ACTION_SETTINGS_DISMISS_SUGGESTION = 387;
+ // Settings > Apps > Gear > Special Access > Premium SMS access
+ PREMIUM_SMS_ACCESS = 388;
+
// Add new aosp constants above this line.
// END OF AOSP CONSTANTS
}
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java
index 3e7466f..613f890 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java
@@ -363,12 +363,6 @@
private void enableFeatures() {
resetStreamState();
- if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
- mMotionEventInjector = new MotionEventInjector(mContext.getMainLooper());
- addFirstEventHandler(mMotionEventInjector);
- mAms.setMotionEventInjector(mMotionEventInjector);
- }
-
if ((mEnabledFeatures & FLAG_FEATURE_AUTOCLICK) != 0) {
mAutoclickController = new AutoclickController(mContext, mUserId);
addFirstEventHandler(mAutoclickController);
@@ -384,6 +378,12 @@
addFirstEventHandler(mMagnificationGestureHandler);
}
+ if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
+ mMotionEventInjector = new MotionEventInjector(mContext.getMainLooper());
+ addFirstEventHandler(mMotionEventInjector);
+ mAms.setMotionEventInjector(mMotionEventInjector);
+ }
+
if ((mEnabledFeatures & FLAG_FEATURE_FILTER_KEY_EVENTS) != 0) {
mKeyboardInterceptor = new KeyboardInterceptor(mAms);
addFirstEventHandler(mKeyboardInterceptor);
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index 2741733..01d4ad6 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -1795,9 +1795,8 @@
}
userState.mSoftKeyboardShowMode = 0;
userState.mServiceChangingSoftKeyboardMode = null;
+ notifySoftKeyboardShowModeChangedLocked(userState.mSoftKeyboardShowMode);
}
-
- notifySoftKeyboardShowModeChangedLocked(userState.mSoftKeyboardShowMode);
}
}
@@ -4355,6 +4354,7 @@
}
} else if (mAccessibilitySoftKeyboardModeUri.equals(uri)) {
if (readSoftKeyboardShowModeChangedLocked(userState)) {
+ notifySoftKeyboardShowModeChangedLocked(userState.mSoftKeyboardShowMode);
onUserStateChangedLocked(userState);
}
}
diff --git a/services/accessibility/java/com/android/server/accessibility/MagnificationController.java b/services/accessibility/java/com/android/server/accessibility/MagnificationController.java
index b2196bf..fb1ef37 100644
--- a/services/accessibility/java/com/android/server/accessibility/MagnificationController.java
+++ b/services/accessibility/java/com/android/server/accessibility/MagnificationController.java
@@ -156,10 +156,10 @@
final float offsetY = sentSpec.offsetY;
// Compute the new center and update spec as needed.
- final float centerX = (mMagnifiedBounds.width() / 2.0f
- + mMagnifiedBounds.left - offsetX) / scale;
- final float centerY = (mMagnifiedBounds.height() / 2.0f
- + mMagnifiedBounds.top - offsetY) / scale;
+ final float centerX = (mMagnifiedBounds.width() / 2.0f - offsetX) / scale
+ + mMagnifiedBounds.left;
+ final float centerY = (mMagnifiedBounds.height() / 2.0f - offsetY) / scale
+ + mMagnifiedBounds.top;
if (updateSpec) {
setScaleAndCenter(scale, centerX, centerY, false);
} else {
@@ -256,7 +256,7 @@
public float getCenterX() {
synchronized (mLock) {
return (mMagnifiedBounds.width() / 2.0f
- + mMagnifiedBounds.left - getOffsetX()) / getScale();
+ - getOffsetX()) / getScale() + mMagnifiedBounds.left;
}
}
@@ -279,7 +279,7 @@
public float getCenterY() {
synchronized (mLock) {
return (mMagnifiedBounds.height() / 2.0f
- + mMagnifiedBounds.top - getOffsetY()) / getScale();
+ - getOffsetY()) / getScale() + mMagnifiedBounds.top;
}
}
diff --git a/services/core/java/com/android/server/BatteryService.java b/services/core/java/com/android/server/BatteryService.java
index 48e96aa..8753992 100644
--- a/services/core/java/com/android/server/BatteryService.java
+++ b/services/core/java/com/android/server/BatteryService.java
@@ -124,6 +124,7 @@
private boolean mLastBatteryLevelCritical;
private int mLastMaxChargingCurrent;
private int mLastMaxChargingVoltage;
+ private int mLastChargeCounter;
private int mInvalidCharger;
private int mLastInvalidCharger;
@@ -341,6 +342,7 @@
+ ", chargerWirelessOnline=" + mBatteryProps.chargerWirelessOnline
+ ", maxChargingCurrent" + mBatteryProps.maxChargingCurrent
+ ", maxChargingVoltage" + mBatteryProps.maxChargingVoltage
+ + ", chargeCounter" + mBatteryProps.batteryChargeCounter
+ ", batteryStatus=" + mBatteryProps.batteryStatus
+ ", batteryHealth=" + mBatteryProps.batteryHealth
+ ", batteryPresent=" + mBatteryProps.batteryPresent
@@ -373,6 +375,7 @@
mBatteryProps.batteryTemperature != mLastBatteryTemperature ||
mBatteryProps.maxChargingCurrent != mLastMaxChargingCurrent ||
mBatteryProps.maxChargingVoltage != mLastMaxChargingVoltage ||
+ mBatteryProps.batteryChargeCounter != mLastChargeCounter ||
mInvalidCharger != mLastInvalidCharger)) {
if (mPlugType != mLastPlugType) {
@@ -501,6 +504,7 @@
mLastBatteryTemperature = mBatteryProps.batteryTemperature;
mLastMaxChargingCurrent = mBatteryProps.maxChargingCurrent;
mLastMaxChargingVoltage = mBatteryProps.maxChargingVoltage;
+ mLastChargeCounter = mBatteryProps.batteryChargeCounter;
mLastBatteryLevelCritical = mBatteryLevelCritical;
mLastInvalidCharger = mInvalidCharger;
}
@@ -527,6 +531,7 @@
intent.putExtra(BatteryManager.EXTRA_INVALID_CHARGER, mInvalidCharger);
intent.putExtra(BatteryManager.EXTRA_MAX_CHARGING_CURRENT, mBatteryProps.maxChargingCurrent);
intent.putExtra(BatteryManager.EXTRA_MAX_CHARGING_VOLTAGE, mBatteryProps.maxChargingVoltage);
+ intent.putExtra(BatteryManager.EXTRA_CHARGE_COUNTER, mBatteryProps.batteryChargeCounter);
if (DEBUG) {
Slog.d(TAG, "Sending ACTION_BATTERY_CHANGED. level:" + mBatteryProps.batteryLevel +
", scale:" + BATTERY_SCALE + ", status:" + mBatteryProps.batteryStatus +
@@ -540,7 +545,8 @@
", Wireless powered:" + mBatteryProps.chargerWirelessOnline +
", icon:" + icon + ", invalid charger:" + mInvalidCharger +
", maxChargingCurrent:" + mBatteryProps.maxChargingCurrent +
- ", maxChargingVoltage:" + mBatteryProps.maxChargingVoltage);
+ ", maxChargingVoltage:" + mBatteryProps.maxChargingVoltage +
+ ", chargeCounter:" + mBatteryProps.batteryChargeCounter);
}
mHandler.post(new Runnable() {
@@ -772,6 +778,7 @@
pw.println(" Wireless powered: " + mBatteryProps.chargerWirelessOnline);
pw.println(" Max charging current: " + mBatteryProps.maxChargingCurrent);
pw.println(" Max charging voltage: " + mBatteryProps.maxChargingVoltage);
+ pw.println(" Charge counter: " + mBatteryProps.batteryChargeCounter);
pw.println(" status: " + mBatteryProps.batteryStatus);
pw.println(" health: " + mBatteryProps.batteryHealth);
pw.println(" present: " + mBatteryProps.batteryPresent);
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java
index ccb4647..6a08191 100644
--- a/services/core/java/com/android/server/DeviceIdleController.java
+++ b/services/core/java/com/android/server/DeviceIdleController.java
@@ -39,7 +39,9 @@
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
+import android.net.ConnectivityManager;
import android.net.INetworkPolicyManager;
+import android.net.NetworkInfo;
import android.net.Uri;
import android.os.BatteryStats;
import android.os.Binder;
@@ -114,6 +116,7 @@
private IBatteryStats mBatteryStats;
private PowerManagerInternal mLocalPowerManager;
private PowerManager mPowerManager;
+ private ConnectivityService mConnectivityService;
private AlarmManagerService.LocalService mLocalAlarmManager;
private INetworkPolicyManager mNetworkPolicyManager;
private DisplayManager mDisplayManager;
@@ -128,6 +131,7 @@
private boolean mLightEnabled;
private boolean mDeepEnabled;
private boolean mForceIdle;
+ private boolean mNetworkConnected;
private boolean mScreenOn;
private boolean mCharging;
private boolean mNotMoving;
@@ -173,16 +177,20 @@
private static final int LIGHT_STATE_PRE_IDLE = 3;
/** Device is in the light idle state, trying to stay asleep as much as possible. */
private static final int LIGHT_STATE_IDLE = 4;
+ /** Device is in the light idle state, we want to go in to idle maintenance but are
+ * waiting for network connectivity before doing so. */
+ private static final int LIGHT_STATE_WAITING_FOR_NETWORK = 5;
/** Device is in the light idle state, but temporarily out of idle to do regular maintenance. */
- private static final int LIGHT_STATE_IDLE_MAINTENANCE = 5;
+ private static final int LIGHT_STATE_IDLE_MAINTENANCE = 6;
/** Device light idle state is overriden, now applying deep doze state. */
- private static final int LIGHT_STATE_OVERRIDE = 6;
+ private static final int LIGHT_STATE_OVERRIDE = 7;
private static String lightStateToString(int state) {
switch (state) {
case LIGHT_STATE_ACTIVE: return "ACTIVE";
case LIGHT_STATE_INACTIVE: return "INACTIVE";
case LIGHT_STATE_PRE_IDLE: return "PRE_IDLE";
case LIGHT_STATE_IDLE: return "IDLE";
+ case LIGHT_STATE_WAITING_FOR_NETWORK: return "WAITING_FOR_NETWORK";
case LIGHT_STATE_IDLE_MAINTENANCE: return "IDLE_MAINTENANCE";
case LIGHT_STATE_OVERRIDE: return "OVERRIDE";
default: return Integer.toString(state);
@@ -315,17 +323,27 @@
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override public void onReceive(Context context, Intent intent) {
- if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
- int plugged = intent.getIntExtra("plugged", 0);
- updateChargingLocked(plugged != 0);
- } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
- if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
- Uri data = intent.getData();
- String ssp;
- if (data != null && (ssp = data.getSchemeSpecificPart()) != null) {
- removePowerSaveWhitelistAppInternal(ssp);
+ switch (intent.getAction()) {
+ case ConnectivityManager.CONNECTIVITY_ACTION: {
+ synchronized (DeviceIdleController.this) {
+ updateConnectivityStateLocked(intent);
}
- }
+ } break;
+ case Intent.ACTION_BATTERY_CHANGED: {
+ synchronized (DeviceIdleController.this) {
+ int plugged = intent.getIntExtra("plugged", 0);
+ updateChargingLocked(plugged != 0);
+ }
+ } break;
+ case Intent.ACTION_PACKAGE_REMOVED: {
+ if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
+ Uri data = intent.getData();
+ String ssp;
+ if (data != null && (ssp = data.getSchemeSpecificPart()) != null) {
+ removePowerSaveWhitelistAppInternal(ssp);
+ }
+ }
+ } break;
}
}
};
@@ -1318,6 +1336,7 @@
readConfigFileLocked();
updateWhitelistAppIdsLocked();
+ mNetworkConnected = true;
mScreenOn = true;
// Start out assuming we are charging. If we aren't, we will at least get
// a battery update the next time the level drops.
@@ -1343,6 +1362,8 @@
mActiveIdleWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"deviceidle_maint");
mActiveIdleWakeLock.setReferenceCounted(false);
+ mConnectivityService = (ConnectivityService)ServiceManager.getService(
+ Context.CONNECTIVITY_SERVICE);
mLocalAlarmManager = getLocalService(AlarmManagerService.LocalService.class);
mNetworkPolicyManager = INetworkPolicyManager.Stub.asInterface(
ServiceManager.getService(Context.NETWORK_POLICY_SERVICE));
@@ -1395,11 +1416,14 @@
filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme("package");
+ filter = new IntentFilter();
+ filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
getContext().registerReceiver(mReceiver, filter);
mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
mLocalAlarmManager.setDeviceIdleUserWhitelist(mPowerSaveWhitelistUserAppIdArray);
mDisplayManager.registerDisplayListener(mDisplayListener, null);
+ updateConnectivityStateLocked(null);
updateDisplayLocked();
}
}
@@ -1680,6 +1704,35 @@
}
}
+ void updateConnectivityStateLocked(Intent connIntent) {
+ if (mConnectivityService != null) {
+ NetworkInfo ni = mConnectivityService.getActiveNetworkInfo();
+ boolean conn;
+ if (ni == null) {
+ conn = false;
+ } else {
+ if (connIntent == null) {
+ conn = ni.isConnected();
+ } else {
+ final int networkType =
+ connIntent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE,
+ ConnectivityManager.TYPE_NONE);
+ if (ni.getType() != networkType) {
+ return;
+ }
+ conn = !connIntent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,
+ false);
+ }
+ }
+ if (conn != mNetworkConnected) {
+ mNetworkConnected = conn;
+ if (conn && mLightState == LIGHT_STATE_WAITING_FOR_NETWORK) {
+ stepLightIdleStateLocked("network");
+ }
+ }
+ }
+ }
+
void updateDisplayLocked() {
mCurDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
// We consider any situation where the display is showing something to be it on,
@@ -1778,7 +1831,7 @@
if (mForceIdle) {
mForceIdle = false;
if (mScreenOn || mCharging) {
- becomeActiveLocked("exit-force-idle", Process.myUid());
+ becomeActiveLocked("exit-force", Process.myUid());
}
}
}
@@ -1834,22 +1887,33 @@
mHandler.sendEmptyMessage(MSG_REPORT_IDLE_ON_LIGHT);
break;
case LIGHT_STATE_IDLE:
- // We have been idling long enough, now it is time to do some work.
- mActiveIdleOpCount = 1;
- mActiveIdleWakeLock.acquire();
- mMaintenanceStartTime = SystemClock.elapsedRealtime();
- if (mCurIdleBudget < mConstants.LIGHT_IDLE_MAINTENANCE_MIN_BUDGET) {
- mCurIdleBudget = mConstants.LIGHT_IDLE_MAINTENANCE_MIN_BUDGET;
- } else if (mCurIdleBudget > mConstants.LIGHT_IDLE_MAINTENANCE_MAX_BUDGET) {
- mCurIdleBudget = mConstants.LIGHT_IDLE_MAINTENANCE_MAX_BUDGET;
+ case LIGHT_STATE_WAITING_FOR_NETWORK:
+ if (mNetworkConnected || mLightState == LIGHT_STATE_WAITING_FOR_NETWORK) {
+ // We have been idling long enough, now it is time to do some work.
+ mActiveIdleOpCount = 1;
+ mActiveIdleWakeLock.acquire();
+ mMaintenanceStartTime = SystemClock.elapsedRealtime();
+ if (mCurIdleBudget < mConstants.LIGHT_IDLE_MAINTENANCE_MIN_BUDGET) {
+ mCurIdleBudget = mConstants.LIGHT_IDLE_MAINTENANCE_MIN_BUDGET;
+ } else if (mCurIdleBudget > mConstants.LIGHT_IDLE_MAINTENANCE_MAX_BUDGET) {
+ mCurIdleBudget = mConstants.LIGHT_IDLE_MAINTENANCE_MAX_BUDGET;
+ }
+ scheduleLightAlarmLocked(mCurIdleBudget);
+ if (DEBUG) Slog.d(TAG,
+ "Moved from LIGHT_STATE_IDLE to LIGHT_STATE_IDLE_MAINTENANCE.");
+ mLightState = LIGHT_STATE_IDLE_MAINTENANCE;
+ EventLogTags.writeDeviceIdleLight(mLightState, reason);
+ addEvent(EVENT_LIGHT_MAINTENANCE);
+ mHandler.sendEmptyMessage(MSG_REPORT_IDLE_OFF);
+ } else {
+ // We'd like to do maintenance, but currently don't have network
+ // connectivity... let's try to wait until the network comes back.
+ // We'll only wait for another full idle period, however, and then give up.
+ scheduleLightAlarmLocked(mNextLightIdleDelay);
+ if (DEBUG) Slog.d(TAG, "Moved to LIGHT_WAITING_FOR_NETWORK.");
+ mLightState = LIGHT_STATE_WAITING_FOR_NETWORK;
+ EventLogTags.writeDeviceIdleLight(mLightState, reason);
}
- scheduleLightAlarmLocked(mCurIdleBudget);
- if (DEBUG) Slog.d(TAG,
- "Moved from LIGHT_STATE_IDLE to LIGHT_STATE_IDLE_MAINTENANCE.");
- mLightState = LIGHT_STATE_IDLE_MAINTENANCE;
- EventLogTags.writeDeviceIdleLight(mLightState, reason);
- addEvent(EVENT_LIGHT_MAINTENANCE);
- mHandler.sendEmptyMessage(MSG_REPORT_IDLE_OFF);
break;
}
}
@@ -2209,13 +2273,6 @@
void scheduleLightAlarmLocked(long delay) {
if (DEBUG) Slog.d(TAG, "scheduleLightAlarmLocked(" + delay + ")");
- if (mMotionSensor == null) {
- // If there is no motion sensor on this device, then we won't schedule
- // alarms, because we can't determine if the device is not moving. This effectively
- // turns off normal execution of device idling, although it is still possible to
- // manually poke it by pretending like the alarm is going off.
- return;
- }
mNextLightAlarmTime = SystemClock.elapsedRealtime() + delay;
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
mNextLightAlarmTime, "DeviceIdleController.light", mLightAlarmListener, mHandler);
@@ -2430,9 +2487,14 @@
pw.println(" Print this help text.");
pw.println(" step [light|deep]");
pw.println(" Immediately step to next state, without waiting for alarm.");
- pw.println(" force-idle");
+ pw.println(" force-idle [light|deep]");
pw.println(" Force directly into idle mode, regardless of other device state.");
- pw.println(" Use \"step\" to get out.");
+ pw.println(" force-inactive");
+ pw.println(" Force to be inactive, ready to freely step idle states.");
+ pw.println(" unforce");
+ pw.println(" Resume normal functioning after force-idle or force-inactive.");
+ pw.println(" get [light|deep|force|screen|charging|network]");
+ pw.println(" Retrieve the current given state.");
pw.println(" disable [light|deep|all]");
pw.println(" Completely disable device idle mode.");
pw.println(" enable [light|deep|all]");
@@ -2472,12 +2534,10 @@
String arg = shell.getNextArg();
try {
if (arg == null || "deep".equals(arg)) {
- exitForceIdleLocked();
stepIdleStateLocked("s:shell");
pw.print("Stepped to deep: ");
pw.println(stateToString(mState));
} else if ("light".equals(arg)) {
- exitForceIdleLocked();
stepLightIdleStateLocked("s:shell");
pw.print("Stepped to light: "); pw.println(lightStateToString(mLightState));
} else {
@@ -2492,29 +2552,104 @@
null);
synchronized (this) {
long token = Binder.clearCallingIdentity();
+ String arg = shell.getNextArg();
try {
- if (!mDeepEnabled) {
- pw.println("Unable to go idle; not enabled");
- return -1;
- }
- mForceIdle = true;
- becomeInactiveIfAppropriateLocked();
- int curState = mState;
- while (curState != STATE_IDLE) {
- stepIdleStateLocked("s:shell");
- if (curState == mState) {
- pw.print("Unable to go idle; stopped at ");
- pw.println(stateToString(mState));
- exitForceIdleLocked();
+ if (arg == null || "deep".equals(arg)) {
+ if (!mDeepEnabled) {
+ pw.println("Unable to go deep idle; not enabled");
return -1;
}
- curState = mState;
+ mForceIdle = true;
+ becomeInactiveIfAppropriateLocked();
+ int curState = mState;
+ while (curState != STATE_IDLE) {
+ stepIdleStateLocked("s:shell");
+ if (curState == mState) {
+ pw.print("Unable to go deep idle; stopped at ");
+ pw.println(stateToString(mState));
+ exitForceIdleLocked();
+ return -1;
+ }
+ curState = mState;
+ }
+ pw.println("Now forced in to deep idle mode");
+ } else if ("light".equals(arg)) {
+ mForceIdle = true;
+ becomeInactiveIfAppropriateLocked();
+ int curLightState = mLightState;
+ while (curLightState != LIGHT_STATE_IDLE) {
+ stepIdleStateLocked("s:shell");
+ if (curLightState == mLightState) {
+ pw.print("Unable to go light idle; stopped at ");
+ pw.println(lightStateToString(mLightState));
+ exitForceIdleLocked();
+ return -1;
+ }
+ curLightState = mLightState;
+ }
+ pw.println("Now forced in to light idle mode");
+ } else {
+ pw.println("Unknown idle mode: " + arg);
}
- pw.println("Now forced in to idle mode");
} finally {
Binder.restoreCallingIdentity(token);
}
}
+ } else if ("force-inactive".equals(cmd)) {
+ getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
+ null);
+ synchronized (this) {
+ long token = Binder.clearCallingIdentity();
+ try {
+ mForceIdle = true;
+ becomeInactiveIfAppropriateLocked();
+ pw.print("Light state: ");
+ pw.print(lightStateToString(mLightState));
+ pw.print(", deep state: ");
+ pw.println(stateToString(mState));
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+ } else if ("unforce".equals(cmd)) {
+ getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
+ null);
+ synchronized (this) {
+ long token = Binder.clearCallingIdentity();
+ try {
+ exitForceIdleLocked();
+ pw.print("Light state: ");
+ pw.print(lightStateToString(mLightState));
+ pw.print(", deep state: ");
+ pw.println(stateToString(mState));
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+ } else if ("get".equals(cmd)) {
+ getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
+ null);
+ synchronized (this) {
+ String arg = shell.getNextArg();
+ if (arg != null) {
+ long token = Binder.clearCallingIdentity();
+ try {
+ switch (arg) {
+ case "light": pw.println(lightStateToString(mLightState)); break;
+ case "deep": pw.println(stateToString(mState)); break;
+ case "force": pw.println(mForceIdle); break;
+ case "screen": pw.println(mScreenOn); break;
+ case "charging": pw.println(mCharging); break;
+ case "network": pw.println(mNetworkConnected); break;
+ default: pw.println("Unknown get option: " + arg); break;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ } else {
+ pw.println("Argument required");
+ }
+ }
} else if ("disable".equals(cmd)) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
null);
@@ -2829,6 +2964,7 @@
pw.print(" mMotionSensor="); pw.println(mMotionSensor);
pw.print(" mCurDisplay="); pw.println(mCurDisplay);
pw.print(" mScreenOn="); pw.println(mScreenOn);
+ pw.print(" mNetworkConnected="); pw.println(mNetworkConnected);
pw.print(" mCharging="); pw.println(mCharging);
pw.print(" mMotionActive="); pw.println(mMotionListener.active);
pw.print(" mNotMoving="); pw.println(mNotMoving);
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 8a0a62a..810270d 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -2884,7 +2884,6 @@
}
if (response == null) throw new IllegalArgumentException("response is null");
if (account == null) throw new IllegalArgumentException("account is null");
- if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null");
int userId = UserHandle.getCallingUserId();
long identityToken = clearCallingIdentity();
try {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 4852788..0f48d21 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1467,6 +1467,7 @@
static final int NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG = 65;
static final int NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG = 66;
static final int NOTIFY_FORCED_RESIZABLE_MSG = 67;
+ static final int NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG = 68;
static final int FIRST_ACTIVITY_STACK_MSG = 100;
static final int FIRST_BROADCAST_QUEUE_MSG = 200;
@@ -2056,6 +2057,21 @@
}
break;
}
+ case NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG: {
+ synchronized (ActivityManagerService.this) {
+ for (int i = mTaskStackListeners.beginBroadcast() - 1; i >= 0; i--) {
+ try {
+ // Make a one-way callback to the listener
+ mTaskStackListeners.getBroadcastItem(i)
+ .onActivityDismissingDockedStack();
+ } catch (RemoteException e){
+ // Handled by the RemoteCallbackList
+ }
+ }
+ mTaskStackListeners.finishBroadcast();
+ }
+ break;
+ }
case NOTIFY_CLEARTEXT_NETWORK_MSG: {
final int uid = msg.arg1;
final byte[] firstPacket = (byte[]) msg.obj;
@@ -15641,8 +15657,8 @@
pw.println(totalPss - cachedPss);
}
}
- long lostRAM = memInfo.getTotalSizeKb()
- - totalPss - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
+ long lostRAM = memInfo.getTotalSizeKb() - (totalPss - totalSwapPss)
+ - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
- memInfo.getKernelUsedSizeKb() - memInfo.getZramTotalSizeKb();
if (!isCompact) {
pw.print(" Used RAM: "); pw.print(stringifyKBSize(totalPss - cachedPss
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 4ec1f61..fdcc242 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1650,6 +1650,13 @@
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
final ActivityRecord r = activities.get(activityNdx);
if (r.finishing) {
+ // Normally the screenshot will be taken in makeInvisible(). When an activity
+ // is finishing, we no longer change its visibility, but we still need to take
+ // the screenshots if startPausingLocked decided it should be taken.
+ if (r.mUpdateTaskThumbnailWhenHidden) {
+ r.updateThumbnailLocked(screenshotActivitiesLocked(r), null);
+ r.mUpdateTaskThumbnailWhenHidden = false;
+ }
continue;
}
final boolean isTop = r == top;
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 7b2a370..8395083 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -152,6 +152,7 @@
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.am.ActivityManagerService.ANIMATE;
import static com.android.server.am.ActivityManagerService.FIRST_SUPERVISOR_STACK_MSG;
+import static com.android.server.am.ActivityManagerService.NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG;
import static com.android.server.am.ActivityManagerService.NOTIFY_FORCED_RESIZABLE_MSG;
import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
@@ -1810,7 +1811,7 @@
if (DEBUG_STACK) Slog.d(TAG_STACK,
"findTaskToMoveToFront: moved to front of stack=" + task.stack);
- showNonResizeableDockToastIfNeeded(task, INVALID_STACK_ID, task.stack.mStackId);
+ handleNonResizableTaskIfNeeded(task, INVALID_STACK_ID, task.stack.mStackId);
}
boolean canUseActivityOptionsLaunchBounds(ActivityOptions options, int launchStackId) {
@@ -2392,7 +2393,7 @@
resumeFocusedStackTopActivityLocked();
}
- showNonResizeableDockToastIfNeeded(task, preferredLaunchStackId, stackId);
+ handleNonResizableTaskIfNeeded(task, preferredLaunchStackId, stackId);
return (preferredLaunchStackId == stackId);
}
@@ -3363,15 +3364,19 @@
}
}
- void showNonResizeableDockToastIfNeeded(
+ void handleNonResizableTaskIfNeeded(
TaskRecord task, int preferredStackId, int actualStackId) {
- if (!isStackDockedInEffect(actualStackId) && preferredStackId != DOCKED_STACK_ID) {
+ if ((!isStackDockedInEffect(actualStackId) && preferredStackId != DOCKED_STACK_ID)
+ || task.isHomeTask()) {
return;
}
if (!task.canGoInDockedStack()) {
// Display a warning toast that we tried to put a non-dockable task in the docked stack.
- mWindowManager.scheduleShowNonResizeableDockToast(task.taskId);
+ mService.mHandler.sendEmptyMessage(NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG);
+
+ // Dismiss docked stack.
+ mService.moveTasksToFullscreenStack(DOCKED_STACK_ID, false);
} else if (task.mResizeMode == RESIZE_MODE_FORCE_RESIZEABLE) {
String packageName = task.getTopActivity() != null
? task.getTopActivity().appInfo.packageName : null;
diff --git a/services/core/java/com/android/server/am/ActivityStartInterceptor.java b/services/core/java/com/android/server/am/ActivityStartInterceptor.java
index 76dfd01..785dd47 100644
--- a/services/core/java/com/android/server/am/ActivityStartInterceptor.java
+++ b/services/core/java/com/android/server/am/ActivityStartInterceptor.java
@@ -119,7 +119,13 @@
if (!mUserManager.isQuietModeEnabled(UserHandle.of(mUserId))) {
return false;
}
- mIntent = UnlaunchableAppActivity.createInQuietModeDialogIntent(mUserId);
+ IIntentSender target = mService.getIntentSenderLocked(
+ INTENT_SENDER_ACTIVITY, mCallingPackage, mCallingUid, mUserId, null, null, 0,
+ new Intent[] {mIntent}, new String[] {mResolvedType},
+ FLAG_CANCEL_CURRENT | FLAG_ONE_SHOT, null);
+
+ mIntent = UnlaunchableAppActivity.createInQuietModeDialogIntent(mUserId,
+ new IntentSender(target));
mCallingPid = mRealCallingPid;
mCallingUid = mRealCallingUid;
mResolvedType = null;
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index 3bbc452..771d5b2 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -986,7 +986,7 @@
}
top.deliverNewIntentLocked(
mCallingUid, mStartActivity.intent, mStartActivity.launchedFromPackage);
- mSupervisor.showNonResizeableDockToastIfNeeded(mStartActivity.task,
+ mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.task,
preferredLaunchStackId, topStack.mStackId);
return START_DELIVERED_TO_TOP;
}
@@ -1074,7 +1074,7 @@
}
mSupervisor.updateUserStackLocked(mStartActivity.userId, mTargetStack);
- mSupervisor.showNonResizeableDockToastIfNeeded(
+ mSupervisor.handleNonResizableTaskIfNeeded(
mStartActivity.task, preferredLaunchStackId, mTargetStack.mStackId);
return START_SUCCESS;
@@ -1382,6 +1382,9 @@
mTargetStack.moveToFront("intentActivityFound");
}
+ mSupervisor.handleNonResizableTaskIfNeeded(intentActivity.task, INVALID_STACK_ID,
+ mTargetStack.mStackId);
+
// If the caller has requested that the target task be reset, then do so.
if ((mLaunchFlags & FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) != 0) {
return mTargetStack.resetTaskIfNeededLocked(intentActivity, mStartActivity);
diff --git a/services/core/java/com/android/server/job/controllers/ConnectivityController.java b/services/core/java/com/android/server/job/controllers/ConnectivityController.java
index 5ad8189..be9d800 100644
--- a/services/core/java/com/android/server/job/controllers/ConnectivityController.java
+++ b/services/core/java/com/android/server/job/controllers/ConnectivityController.java
@@ -77,8 +77,10 @@
if (cs != null) {
if (cs.getActiveNetworkInfo() != null) {
mNetworkConnected = cs.getActiveNetworkInfo().isConnected();
+ mNetworkUnmetered = mNetworkConnected && !cs.isActiveNetworkMetered();
+ } else {
+ mNetworkConnected = mNetworkUnmetered = false;
}
- mNetworkUnmetered = mNetworkConnected && !cs.isActiveNetworkMetered();
}
}
diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java
index e08fad4..6b916be 100644
--- a/services/core/java/com/android/server/location/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/GnssLocationProvider.java
@@ -39,7 +39,7 @@
import android.location.IGnssStatusListener;
import android.location.IGnssStatusProvider;
import android.location.GnssMeasurementsEvent;
-import android.location.GnssNavigationMessageEvent;
+import android.location.GnssNavigationMessage;
import android.location.IGpsGeofenceHardware;
import android.location.ILocationManager;
import android.location.INetInitiatedListener;
@@ -1662,7 +1662,7 @@
/**
* called from native code - GPS navigation message callback
*/
- private void reportNavigationMessage(GnssNavigationMessageEvent event) {
+ private void reportNavigationMessage(GnssNavigationMessage event) {
mGnssNavigationMessageProvider.onNavigationMessageAvailable(event);
}
diff --git a/services/core/java/com/android/server/location/GnssMeasurementsProvider.java b/services/core/java/com/android/server/location/GnssMeasurementsProvider.java
index 734a8d4..caf1d6c 100644
--- a/services/core/java/com/android/server/location/GnssMeasurementsProvider.java
+++ b/services/core/java/com/android/server/location/GnssMeasurementsProvider.java
@@ -64,15 +64,15 @@
int status;
switch (result) {
case RESULT_SUCCESS:
- status = GnssMeasurementsEvent.STATUS_READY;
+ status = GnssMeasurementsEvent.Callback.STATUS_READY;
break;
case RESULT_NOT_AVAILABLE:
case RESULT_NOT_SUPPORTED:
case RESULT_INTERNAL_ERROR:
- status = GnssMeasurementsEvent.STATUS_NOT_SUPPORTED;
+ status = GnssMeasurementsEvent.Callback.STATUS_NOT_SUPPORTED;
break;
case RESULT_GPS_LOCATION_DISABLED:
- status = GnssMeasurementsEvent.STATUS_GNSS_LOCATION_DISABLED;
+ status = GnssMeasurementsEvent.Callback.STATUS_LOCATION_DISABLED;
break;
case RESULT_UNKNOWN:
return null;
diff --git a/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java b/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java
index fdef31f..8d21928 100644
--- a/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java
+++ b/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java
@@ -16,7 +16,7 @@
package com.android.server.location;
-import android.location.GnssNavigationMessageEvent;
+import android.location.GnssNavigationMessage;
import android.location.IGnssNavigationMessageListener;
import android.os.Handler;
import android.os.RemoteException;
@@ -37,7 +37,7 @@
super(handler, TAG);
}
- public void onNavigationMessageAvailable(final GnssNavigationMessageEvent event) {
+ public void onNavigationMessageAvailable(final GnssNavigationMessage event) {
ListenerOperation<IGnssNavigationMessageListener> operation =
new ListenerOperation<IGnssNavigationMessageListener>() {
@Override
@@ -65,16 +65,15 @@
int status;
switch (result) {
case RESULT_SUCCESS:
- status = GnssNavigationMessageEvent.STATUS_READY;
+ status = GnssNavigationMessage.Callback.STATUS_READY;
break;
case RESULT_NOT_AVAILABLE:
case RESULT_NOT_SUPPORTED:
case RESULT_INTERNAL_ERROR:
- status = GnssNavigationMessageEvent.STATUS_NOT_SUPPORTED;
+ status = GnssNavigationMessage.Callback.STATUS_NOT_SUPPORTED;
break;
case RESULT_GPS_LOCATION_DISABLED:
- status = GnssNavigationMessageEvent
- .STATUS_GNSS_LOCATION_DISABLED;
+ status = GnssNavigationMessage.Callback.STATUS_LOCATION_DISABLED;
break;
case RESULT_UNKNOWN:
return null;
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index e3c540a..a4d2cd2 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -962,6 +962,7 @@
mKeyEventReceiver.aquireWakeLockLocked();
}
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
+ mediaButtonIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
mediaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
try {
if (user.mLastMediaButtonReceiver != null) {
@@ -986,6 +987,7 @@
}
// Fallback to legacy behavior
Intent keyIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null);
+ keyIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
keyIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
if (needWakeLock) {
keyIntent.putExtra(EXTRA_WAKELOCK_ACQUIRED,
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 99c41ea..f20d0a1 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -30,8 +30,11 @@
import static android.service.notification.NotificationRankerService.REASON_PACKAGE_CHANGED;
import static android.service.notification.NotificationRankerService.REASON_PACKAGE_SUSPENDED;
import static android.service.notification.NotificationRankerService.REASON_PROFILE_TURNED_OFF;
+import static android.service.notification.NotificationRankerService.REASON_UNAUTOBUNDLED;
import static android.service.notification.NotificationRankerService.REASON_USER_STOPPED;
import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_EFFECTS;
+import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS;
+import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS;
import static android.service.notification.NotificationListenerService.SUPPRESSED_EFFECT_SCREEN_OFF;
import static android.service.notification.NotificationListenerService.SUPPRESSED_EFFECT_SCREEN_ON;
import static android.service.notification.NotificationListenerService.TRIM_FULL;
@@ -39,8 +42,6 @@
import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_DEFAULT;
import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_NONE;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
-import static org.xmlpull.v1.XmlPullParser.END_TAG;
-import static org.xmlpull.v1.XmlPullParser.START_TAG;
import android.Manifest;
import android.annotation.Nullable;
@@ -97,6 +98,7 @@
import android.os.UserManager;
import android.os.Vibrator;
import android.provider.Settings;
+import android.service.notification.Adjustment;
import android.service.notification.Condition;
import android.service.notification.IConditionProvider;
import android.service.notification.INotificationListener;
@@ -114,6 +116,7 @@
import android.util.AtomicFile;
import android.util.Log;
import android.util.Slog;
+import android.util.SparseArray;
import android.util.Xml;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -136,7 +139,6 @@
import libcore.io.IoUtils;
-import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.xmlpull.v1.XmlPullParser;
@@ -158,7 +160,6 @@
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -248,8 +249,9 @@
private String mSoundNotificationKey;
private String mVibrateNotificationKey;
- private final ArraySet<ManagedServiceInfo> mListenersDisablingEffects = new ArraySet<>();
- private ComponentName mEffectsSuppressor;
+ private final SparseArray<ArraySet<ManagedServiceInfo>> mListenersDisablingEffects =
+ new SparseArray<ArraySet<ManagedServiceInfo>>();
+ private List<ComponentName> mEffectsSuppressors = new ArrayList<ComponentName>();
private int mListenerHints; // right now, all hints are global
private int mInterruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_UNKNOWN;
@@ -263,6 +265,7 @@
new ArrayList<NotificationRecord>();
final ArrayMap<String, NotificationRecord> mNotificationsByKey =
new ArrayMap<String, NotificationRecord>();
+ final ArrayMap<String, String> mAutobundledSummaries = new ArrayMap<>();
final ArrayList<ToastRecord> mToastQueue = new ArrayList<ToastRecord>();
final ArrayMap<String, NotificationRecord> mSummaryByGroupKey = new ArrayMap<>();
final PolicyAccess mPolicyAccess = new PolicyAccess();
@@ -283,11 +286,6 @@
private static final String TAG_NOTIFICATION_POLICY = "notification-policy";
private static final String ATTR_VERSION = "version";
- // Obsolete: converted if present, but not resaved to disk.
- private static final String TAG_BLOCKED_PKGS = "blocked-packages";
- private static final String TAG_PACKAGE = "package";
- private static final String ATTR_NAME = "name";
-
private RankingHelper mRankingHelper;
private final UserProfiles mUserProfiles = new UserProfiles();
@@ -1118,23 +1116,112 @@
}
private void updateListenerHintsLocked() {
- final int hints = mListenersDisablingEffects.isEmpty() ? 0 : HINT_HOST_DISABLE_EFFECTS;
+ final int hints = calculateHints();
if (hints == mListenerHints) return;
- ZenLog.traceListenerHintsChanged(mListenerHints, hints, mListenersDisablingEffects.size());
+ ZenLog.traceListenerHintsChanged(mListenerHints, hints, mEffectsSuppressors.size());
mListenerHints = hints;
scheduleListenerHintsChanged(hints);
}
private void updateEffectsSuppressorLocked() {
- final ComponentName suppressor = !mListenersDisablingEffects.isEmpty()
- ? mListenersDisablingEffects.valueAt(0).component : null;
- if (Objects.equals(suppressor, mEffectsSuppressor)) return;
- ZenLog.traceEffectsSuppressorChanged(mEffectsSuppressor, suppressor);
- mEffectsSuppressor = suppressor;
- mZenModeHelper.setEffectsSuppressed(suppressor != null);
+ final long updatedSuppressedEffects = calculateSuppressedEffects();
+ if (updatedSuppressedEffects == mZenModeHelper.getSuppressedEffects()) return;
+ final List<ComponentName> suppressors = getSuppressors();
+ ZenLog.traceEffectsSuppressorChanged(mEffectsSuppressors, suppressors, updatedSuppressedEffects);
+ mEffectsSuppressors = suppressors;
+ mZenModeHelper.setSuppressedEffects(updatedSuppressedEffects);
sendRegisteredOnlyBroadcast(NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED);
}
+ private ArrayList<ComponentName> getSuppressors() {
+ ArrayList<ComponentName> names = new ArrayList<ComponentName>();
+ for (int i = mListenersDisablingEffects.size() - 1; i >= 0; --i) {
+ ArraySet<ManagedServiceInfo> serviceInfoList = mListenersDisablingEffects.valueAt(i);
+
+ for (ManagedServiceInfo info : serviceInfoList) {
+ names.add(info.component);
+ }
+ }
+
+ return names;
+ }
+
+ private boolean removeDisabledHints(ManagedServiceInfo info) {
+ return removeDisabledHints(info, 0);
+ }
+
+ private boolean removeDisabledHints(ManagedServiceInfo info, int hints) {
+ boolean removed = false;
+
+ for (int i = mListenersDisablingEffects.size() - 1; i >= 0; --i) {
+ final int hint = mListenersDisablingEffects.keyAt(i);
+ final ArraySet<ManagedServiceInfo> listeners =
+ mListenersDisablingEffects.valueAt(i);
+
+ if (hints == 0 || (hint & hints) == hint) {
+ removed = removed || listeners.remove(info);
+ }
+ }
+
+ return removed;
+ }
+
+ private void addDisabledHints(ManagedServiceInfo info, int hints) {
+ if ((hints & HINT_HOST_DISABLE_EFFECTS) != 0) {
+ addDisabledHint(info, HINT_HOST_DISABLE_EFFECTS);
+ }
+
+ if ((hints & HINT_HOST_DISABLE_NOTIFICATION_EFFECTS) != 0) {
+ addDisabledHint(info, HINT_HOST_DISABLE_NOTIFICATION_EFFECTS);
+ }
+
+ if ((hints & HINT_HOST_DISABLE_CALL_EFFECTS) != 0) {
+ addDisabledHint(info, HINT_HOST_DISABLE_CALL_EFFECTS);
+ }
+ }
+
+ private void addDisabledHint(ManagedServiceInfo info, int hint) {
+ if (mListenersDisablingEffects.indexOfKey(hint) < 0) {
+ mListenersDisablingEffects.put(hint, new ArraySet<ManagedServiceInfo>());
+ }
+
+ ArraySet<ManagedServiceInfo> hintListeners = mListenersDisablingEffects.get(hint);
+ hintListeners.add(info);
+ }
+
+ private int calculateHints() {
+ int hints = 0;
+ for (int i = mListenersDisablingEffects.size() - 1; i >= 0; --i) {
+ int hint = mListenersDisablingEffects.keyAt(i);
+ ArraySet<ManagedServiceInfo> serviceInfoList = mListenersDisablingEffects.valueAt(i);
+
+ if (!serviceInfoList.isEmpty()) {
+ hints |= hint;
+ }
+ }
+
+ return hints;
+ }
+
+ private long calculateSuppressedEffects() {
+ int hints = calculateHints();
+ long suppressedEffects = 0;
+
+ if ((hints & HINT_HOST_DISABLE_EFFECTS) != 0) {
+ suppressedEffects |= ZenModeHelper.SUPPRESSED_EFFECT_ALL;
+ }
+
+ if ((hints & HINT_HOST_DISABLE_NOTIFICATION_EFFECTS) != 0) {
+ suppressedEffects |= ZenModeHelper.SUPPRESSED_EFFECT_NOTIFICATIONS;
+ }
+
+ if ((hints & HINT_HOST_DISABLE_CALL_EFFECTS) != 0) {
+ suppressedEffects |= ZenModeHelper.SUPPRESSED_EFFECT_CALLS;
+ }
+
+ return suppressedEffects;
+ }
+
private void updateInterruptionFilterLocked() {
int interruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter();
if (interruptionFilter == mInterruptionFilter) return;
@@ -1259,10 +1346,13 @@
checkCallerIsSystemOrSameApp(pkg);
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userId, true, false, "cancelNotificationWithTag", pkg);
- // Don't allow client applications to cancel foreground service notis.
+ // Don't allow client applications to cancel foreground service notis or autobundled
+ // summaries.
cancelNotification(Binder.getCallingUid(), Binder.getCallingPid(), pkg, tag, id, 0,
- Binder.getCallingUid() == Process.SYSTEM_UID
- ? 0 : Notification.FLAG_FOREGROUND_SERVICE, false, userId,
+ (Binder.getCallingUid() == Process.SYSTEM_UID
+ ? 0 : Notification.FLAG_FOREGROUND_SERVICE)
+ | (Binder.getCallingUid() == Process.SYSTEM_UID
+ ? 0 : Notification.FLAG_AUTOGROUP_SUMMARY), false, userId,
REASON_APP_CANCEL, null);
}
@@ -1404,7 +1494,9 @@
final int N = mNotificationList.size();
for (int i = 0; i < N; i++) {
final StatusBarNotification sbn = mNotificationList.get(i).sbn;
- if (sbn.getPackageName().equals(pkg) && sbn.getUserId() == userId) {
+ if (sbn.getPackageName().equals(pkg) && sbn.getUserId() == userId
+ && (sbn.getNotification().flags
+ & Notification.FLAG_AUTOGROUP_SUMMARY) != 0) {
// We could pass back a cloneLight() but clients might get confused and
// try to send this thing back to notify() again, which would not work
// very well.
@@ -1519,7 +1611,8 @@
checkCallerIsSystemOrSameApp(component.getPackageName());
long identity = Binder.clearCallingIdentity();
try {
- ManagedServices manager = mRankerServices.isComponentEnabledForCurrentProfiles(component)
+ ManagedServices manager =
+ mRankerServices.isComponentEnabledForCurrentProfiles(component)
? mRankerServices
: mListeners;
manager.setComponentState(component, true);
@@ -1651,11 +1744,14 @@
try {
synchronized (mNotificationList) {
final ManagedServiceInfo info = mListeners.checkServiceTokenLocked(token);
- final boolean disableEffects = (hints & HINT_HOST_DISABLE_EFFECTS) != 0;
+ final int disableEffectsMask = HINT_HOST_DISABLE_EFFECTS
+ | HINT_HOST_DISABLE_NOTIFICATION_EFFECTS
+ | HINT_HOST_DISABLE_CALL_EFFECTS;
+ final boolean disableEffects = (hints & disableEffectsMask) != 0;
if (disableEffects) {
- mListenersDisablingEffects.add(info);
+ addDisabledHints(info, hints);
} else {
- mListenersDisablingEffects.remove(info);
+ removeDisabledHints(info, hints);
}
updateListenerHintsLocked();
updateEffectsSuppressorLocked();
@@ -1913,7 +2009,7 @@
@Override
public ComponentName getEffectsSuppressor() {
enforceSystemOrSystemUIOrVolume("INotificationManager.getEffectsSuppressor");
- return mEffectsSuppressor;
+ return mEffectsSuppressors.get(0);
}
@Override
@@ -2035,25 +2131,123 @@
}
@Override
- public void setImportanceFromRankerService(INotificationListener token, String key,
- int importance, CharSequence explanation) throws RemoteException {
- if (importance == IMPORTANCE_NONE) {
- throw new IllegalArgumentException("blocking not allowed: key=" + key);
- }
+ public void applyAdjustmentFromRankerService(INotificationListener token,
+ Adjustment adjustment) throws RemoteException {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mNotificationList) {
mRankerServices.checkServiceTokenLocked(token);
- NotificationRecord n = mNotificationsByKey.get(key);
- n.setImportance(importance, explanation);
- mRankingHandler.requestSort();
+ applyAdjustmentLocked(adjustment);
}
+ maybeAddAutobundleSummary(adjustment);
+ mRankingHandler.requestSort();
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void applyAdjustmentsFromRankerService(INotificationListener token,
+ List<Adjustment> adjustments) throws RemoteException {
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mNotificationList) {
+ mRankerServices.checkServiceTokenLocked(token);
+ for (Adjustment adjustment : adjustments) {
+ applyAdjustmentLocked(adjustment);
+ }
+ }
+ for (Adjustment adjustment : adjustments) {
+ maybeAddAutobundleSummary(adjustment);
+ }
+ mRankingHandler.requestSort();
} finally {
Binder.restoreCallingIdentity(identity);
}
}
};
+ private void applyAdjustmentLocked(Adjustment adjustment) {
+ maybeClearAutobundleSummaryLocked(adjustment);
+ NotificationRecord n = mNotificationsByKey.get(adjustment.getKey());
+ if (n == null) {
+ return;
+ }
+ if (adjustment.getImportance() != IMPORTANCE_NONE) {
+ n.setImportance(adjustment.getImportance(), adjustment.getExplanation());
+ }
+ if (adjustment.getSignals() != null) {
+ Bundle.setDefusable(adjustment.getSignals(), true);
+ n.sbn.setOverrideGroupKey(adjustment.getSignals().getString(
+ Adjustment.GROUP_KEY_OVERRIDE_KEY, null));
+ }
+ }
+
+ // Clears the 'fake' auto-bunding summary.
+ private void maybeClearAutobundleSummaryLocked(Adjustment adjustment) {
+ if (adjustment.getSignals() != null
+ && adjustment.getSignals().containsKey(Adjustment.NEEDS_AUTOGROUPING_KEY)
+ && !adjustment.getSignals().getBoolean(Adjustment.NEEDS_AUTOGROUPING_KEY, false)) {
+ if (mAutobundledSummaries.containsKey(adjustment.getPackage())) {
+ // Clear summary.
+ final NotificationRecord removed = mNotificationsByKey.get(
+ mAutobundledSummaries.remove(adjustment.getPackage()));
+ if (removed != null) {
+ mNotificationList.remove(removed);
+ cancelNotificationLocked(removed, false, REASON_UNAUTOBUNDLED);
+ }
+ }
+ }
+ }
+
+ // Posts a 'fake' summary for a package that has exceeded the solo-notification limit.
+ private void maybeAddAutobundleSummary(Adjustment adjustment) {
+ if (adjustment.getSignals() != null
+ && adjustment.getSignals().getBoolean(Adjustment.NEEDS_AUTOGROUPING_KEY, false)) {
+ final String newAutoBundleKey =
+ adjustment.getSignals().getString(Adjustment.GROUP_KEY_OVERRIDE_KEY, null);
+ int userId = -1;
+ NotificationRecord summaryRecord = null;
+ synchronized (mNotificationList) {
+ if (!mAutobundledSummaries.containsKey(adjustment.getPackage())
+ && newAutoBundleKey != null) {
+ // Add summary
+ final StatusBarNotification adjustedSbn
+ = mNotificationsByKey.get(adjustment.getKey()).sbn;
+
+ final ApplicationInfo appInfo =
+ adjustedSbn.getNotification().extras.getParcelable(
+ Notification.EXTRA_BUILDER_APPLICATION_INFO);
+ final Bundle extras = new Bundle();
+ extras.putParcelable(Notification.EXTRA_BUILDER_APPLICATION_INFO, appInfo);
+ final Notification summaryNotification =
+ new Notification.Builder(getContext()).setSmallIcon(
+ adjustedSbn.getNotification().getSmallIcon())
+ .setGroupSummary(true)
+ .setGroup(newAutoBundleKey)
+ .setFlag(Notification.FLAG_AUTOGROUP_SUMMARY, true)
+ .setFlag(Notification.FLAG_GROUP_SUMMARY, true)
+ .build();
+ summaryNotification.extras.putAll(extras);
+ final StatusBarNotification summarySbn =
+ new StatusBarNotification(adjustedSbn.getPackageName(),
+ adjustedSbn.getOpPkg(),
+ Integer.MAX_VALUE, Adjustment.GROUP_KEY_OVERRIDE_KEY,
+ adjustedSbn.getUid(), adjustedSbn.getInitialPid(),
+ summaryNotification, adjustedSbn.getUser(), newAutoBundleKey,
+ System.currentTimeMillis());
+ summaryRecord = new NotificationRecord(getContext(), summarySbn);
+ mAutobundledSummaries.put(adjustment.getPackage(), summarySbn.getKey());
+ userId = adjustedSbn.getUser().getIdentifier();
+ }
+ }
+ if (summaryRecord != null) {
+ mHandler.post(new EnqueueNotificationRunnable(userId, summaryRecord));
+ }
+ }
+ }
+
private String disableNotificationEffects(NotificationRecord record) {
if (mDisableNotificationEffects) {
return "booleanState";
@@ -2175,9 +2369,19 @@
pw.print(" mListenersDisablingEffects: (");
N = mListenersDisablingEffects.size();
for (int i = 0; i < N; i++) {
- final ManagedServiceInfo listener = mListenersDisablingEffects.valueAt(i);
- if (i > 0) pw.print(',');
- pw.print(listener.component);
+ final int hint = mListenersDisablingEffects.keyAt(i);
+ if (i > 0) pw.print(';');
+ pw.print("hint[" + hint + "]:");
+
+ final ArraySet<ManagedServiceInfo> listeners =
+ mListenersDisablingEffects.valueAt(i);
+ final int listenerSize = listeners.size();
+
+ for (int j = 0; j < listenerSize; j++) {
+ if (i > 0) pw.print(',');
+ final ManagedServiceInfo listener = listeners.valueAt(i);
+ pw.print(listener.component);
+ }
}
pw.println(')');
pw.println("\n mRankerServicePackageName: " + mRankerServicePackageName);
@@ -2253,6 +2457,17 @@
callingUid, incomingUserId, true, false, "enqueueNotification", pkg);
final UserHandle user = new UserHandle(userId);
+ // Fix the notification as best we can.
+ try {
+ Notification.addFieldsFromContext(getContext().createApplicationContext(
+ getContext().getPackageManager().getApplicationInfoAsUser(
+ pkg, PackageManager.MATCH_UNINSTALLED_PACKAGES, userId),
+ Context.CONTEXT_RESTRICTED), notification);
+ } catch (NameNotFoundException e) {
+ Slog.e(TAG, "Cannot create a context for sending app", e);
+ return;
+ }
+
// Limit the number of notifications that any given package except the android
// package or a registered listener can enqueue. Prevents DOS attacks and deals with leaks.
if (!isSystemNotification && !isNotificationFromListener) {
@@ -2492,7 +2707,7 @@
StatusBarNotification sbn = r.sbn;
String group = sbn.getGroupKey();
boolean isSummary = sbn.getNotification().isGroupSummary();
- boolean isChild = sbn.getNotification().isGroupChild();
+ boolean isChild = !isSummary && sbn.isGroup();
NotificationRecord summary = mSummaryByGroupKey.get(group);
if (isChild && summary != null) {
@@ -2857,11 +3072,13 @@
synchronized (mNotificationList) {
final int N = mNotificationList.size();
ArrayList<String> orderBefore = new ArrayList<String>(N);
+ ArrayList<String> groupOverrideBefore = new ArrayList<>(N);
int[] visibilities = new int[N];
- int [] importances = new int[N];
+ int[] importances = new int[N];
for (int i = 0; i < N; i++) {
final NotificationRecord r = mNotificationList.get(i);
orderBefore.add(r.getKey());
+ groupOverrideBefore.add(r.sbn.getGroupKey());
visibilities[i] = r.getPackageVisibilityOverride();
importances[i] = r.getImportance();
mRankingHelper.extractSignals(r);
@@ -2871,7 +3088,8 @@
final NotificationRecord r = mNotificationList.get(i);
if (!orderBefore.get(i).equals(r.getKey())
|| visibilities[i] != r.getPackageVisibilityOverride()
- || importances[i] != r.getImportance()) {
+ || importances[i] != r.getImportance()
+ || !groupOverrideBefore.get(i).equals(r.sbn.getGroupKey())) {
scheduleSendRankingUpdate();
return;
}
@@ -3070,6 +3288,7 @@
mLights.remove(canceledKey);
// Record usage stats
+ // TODO: add unbundling stats?
switch (reason) {
case REASON_DELEGATE_CANCEL:
case REASON_DELEGATE_CANCEL_ALL:
@@ -3089,6 +3308,9 @@
if (groupSummary != null && groupSummary.getKey().equals(r.getKey())) {
mSummaryByGroupKey.remove(groupKey);
}
+ if (r.sbn.getKey().equals(mAutobundledSummaries.get(r.sbn.getPackageName()))) {
+ mAutobundledSummaries.remove(r.sbn.getPackageName());
+ }
// Save it for users of getHistoricalNotifications()
mArchive.record(r.sbn);
@@ -3287,7 +3509,7 @@
for (int i = N - 1; i >= 0; i--) {
NotificationRecord childR = mNotificationList.get(i);
StatusBarNotification childSbn = childR.sbn;
- if (childR.getNotification().isGroupChild() &&
+ if ((childSbn.isGroup() && !childSbn.getNotification().isGroupSummary()) &&
childR.getGroupKey().equals(r.getGroupKey())) {
EventLogTags.writeNotificationCancel(callingUid, callingPid, pkg, childSbn.getId(),
childSbn.getTag(), userId, 0, 0, reason, listenerName);
@@ -3438,6 +3660,7 @@
ArrayList<String> keys = new ArrayList<String>(N);
ArrayList<String> interceptedKeys = new ArrayList<String>(N);
ArrayList<Integer> importance = new ArrayList<>(N);
+ Bundle overrideGroupKeys = new Bundle();
Bundle visibilityOverrides = new Bundle();
Bundle suppressedVisualEffects = new Bundle();
Bundle explanation = new Bundle();
@@ -3461,6 +3684,7 @@
!= NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE) {
visibilityOverrides.putInt(key, record.getPackageVisibilityOverride());
}
+ overrideGroupKeys.putString(key, record.sbn.getOverrideGroupKey());
}
final int M = keys.size();
String[] keysAr = keys.toArray(new String[M]);
@@ -3470,7 +3694,7 @@
importanceAr[i] = importance.get(i);
}
return new NotificationRankingUpdate(keysAr, interceptedKeysAr, visibilityOverrides,
- suppressedVisualEffects, importanceAr, explanation);
+ suppressedVisualEffects, importanceAr, explanation, overrideGroupKeys);
}
private boolean isVisibleToListener(StatusBarNotification sbn, ManagedServiceInfo listener) {
@@ -3690,7 +3914,7 @@
@Override
protected void onServiceRemovedLocked(ManagedServiceInfo removed) {
- if (mListenersDisablingEffects.remove(removed)) {
+ if (removeDisabledHints(removed)) {
updateListenerHintsLocked();
updateEffectsSuppressorLocked();
}
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index fd893fa..a89a422 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -24,18 +24,15 @@
import android.app.Notification;
import android.content.Context;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
import android.media.AudioAttributes;
-import android.os.Build;
import android.os.UserHandle;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.util.Log;
-import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.EventLogTags;
diff --git a/services/core/java/com/android/server/notification/ZenLog.java b/services/core/java/com/android/server/notification/ZenLog.java
index c45071b..207bdba 100644
--- a/services/core/java/com/android/server/notification/ZenLog.java
+++ b/services/core/java/com/android/server/notification/ZenLog.java
@@ -31,6 +31,7 @@
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.List;
public class ZenLog {
private static final String TAG = "ZenLog";
@@ -126,10 +127,11 @@
append(TYPE_DISABLE_EFFECTS, record.getKey() + "," + reason);
}
- public static void traceEffectsSuppressorChanged(ComponentName oldSuppressor,
- ComponentName newSuppressor) {
- append(TYPE_SUPPRESSOR_CHANGED, componentToString(oldSuppressor) + "->"
- + componentToString(newSuppressor));
+ public static void traceEffectsSuppressorChanged(List<ComponentName> oldSuppressors,
+ List<ComponentName> newSuppressors, long suppressedEffects) {
+ append(TYPE_SUPPRESSOR_CHANGED, "suppressed effects:" + suppressedEffects + ","
+ + componentListToString(oldSuppressors) + "->"
+ + componentListToString(newSuppressors));
}
public static void traceListenerHintsChanged(int oldHints, int newHints, int listenerCount) {
@@ -193,6 +195,19 @@
return component != null ? component.toShortString() : null;
}
+ private static String componentListToString(List<ComponentName> components) {
+ StringBuilder stringBuilder = new StringBuilder();
+
+ for (int i = 0; i < components.size(); ++i) {
+ if (i > 0) {
+ stringBuilder.append(", ");
+ }
+ stringBuilder.append(componentToString(components.get(i)));
+ }
+
+ return stringBuilder.toString();
+ }
+
private static void append(int type, String msg) {
synchronized(MSGS) {
TIMES[sNext] = System.currentTimeMillis();
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 5c5c8f8..eb49e9f 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -102,7 +102,12 @@
private ZenModeConfig mConfig;
private AudioManagerInternal mAudioManager;
private PackageManager mPm;
- private boolean mEffectsSuppressed;
+ private long mSuppressedEffects;
+
+ public static final long SUPPRESSED_EFFECT_NOTIFICATIONS = 1;
+ public static final long SUPPRESSED_EFFECT_CALLS = 1 << 1;
+ public static final long SUPPRESSED_EFFECT_ALL = SUPPRESSED_EFFECT_CALLS
+ | SUPPRESSED_EFFECT_NOTIFICATIONS;
public ZenModeHelper(Context context, Looper looper, ConditionProviders conditionProviders) {
mContext = context;
@@ -228,12 +233,16 @@
}
}
- public void setEffectsSuppressed(boolean effectsSuppressed) {
- if (mEffectsSuppressed == effectsSuppressed) return;
- mEffectsSuppressed = effectsSuppressed;
+ public void setSuppressedEffects(long suppressedEffects) {
+ if (mSuppressedEffects == suppressedEffects) return;
+ mSuppressedEffects = suppressedEffects;
applyRestrictions();
}
+ public long getSuppressedEffects() {
+ return mSuppressedEffects;
+ }
+
public int getZenMode() {
return mZenMode;
}
@@ -484,7 +493,8 @@
synchronized (mConfig) {
dump(pw, prefix, "mConfig", mConfig);
}
- pw.print(prefix); pw.print("mEffectsSuppressed="); pw.println(mEffectsSuppressed);
+
+ pw.print(prefix); pw.print("mSuppressedEffects="); pw.println(mSuppressedEffects);
mFiltering.dump(pw, prefix);
mConditions.dump(pw, prefix);
}
@@ -708,9 +718,11 @@
final boolean zen = mZenMode != Global.ZEN_MODE_OFF;
// notification restrictions
- final boolean muteNotifications = mEffectsSuppressed;
+ final boolean muteNotifications =
+ (mSuppressedEffects & SUPPRESSED_EFFECT_NOTIFICATIONS) != 0;
// call restrictions
- final boolean muteCalls = zen && !mConfig.allowCalls && !mConfig.allowRepeatCallers;
+ final boolean muteCalls = zen && !mConfig.allowCalls && !mConfig.allowRepeatCallers
+ || (mSuppressedEffects & SUPPRESSED_EFFECT_CALLS) != 0;
// total silence restrictions
final boolean muteEverything = mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS;
diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java
index 928c19f..8368185 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -862,8 +862,12 @@
IntentSender statusReceiver, int userId) {
final int callingUid = Binder.getCallingUid();
mPm.enforceCrossUserPermission(callingUid, userId, true, true, "uninstall");
+ boolean allowSilentUninstall = true;
if ((callingUid != Process.SHELL_UID) && (callingUid != Process.ROOT_UID)) {
mAppOps.checkPackage(callingUid, callerPackageName);
+ final String installerPackageName = mPm.getInstallerPackageName(packageName);
+ allowSilentUninstall = installerPackageName != null
+ && installerPackageName.equals(callerPackageName);
}
// Check whether the caller is device owner, in which case we do it silently.
@@ -874,8 +878,8 @@
final PackageDeleteObserverAdapter adapter = new PackageDeleteObserverAdapter(mContext,
statusReceiver, packageName, isDeviceOwner, userId);
- if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DELETE_PACKAGES)
- == PackageManager.PERMISSION_GRANTED) {
+ if (allowSilentUninstall && mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.DELETE_PACKAGES) == PackageManager.PERMISSION_GRANTED) {
// Sweet, call straight through!
mPm.deletePackage(packageName, adapter.getBinder(), userId, flags);
} else if (isDeviceOwner) {
@@ -901,7 +905,10 @@
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.INSTALL_PACKAGES, TAG);
synchronized (mSessions) {
- mSessions.get(sessionId).setPermissionsResult(accepted);
+ PackageInstallerSession session = mSessions.get(sessionId);
+ if (session != null) {
+ session.setPermissionsResult(accepted);
+ }
}
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index a6fce51..e62450c 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -76,7 +76,6 @@
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.PackageParser.PARSE_IS_PRIVILEGED;
import static android.content.pm.PackageParser.isApkFile;
-import static android.os.Process.FIRST_APPLICATION_UID;
import static android.os.Process.PACKAGE_INFO_GID;
import static android.os.Process.SYSTEM_UID;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
@@ -117,7 +116,6 @@
import android.content.IIntentReceiver;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.IntentFilter.AuthorityEntry;
import android.content.IntentSender;
import android.content.IntentSender.SendIntentException;
import android.content.ServiceConnection;
@@ -150,7 +148,6 @@
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser.ActivityIntentInfo;
-import android.content.pm.PackageParser.IntentInfo;
import android.content.pm.PackageParser.PackageLite;
import android.content.pm.PackageParser.PackageParserException;
import android.content.pm.PackageStats;
@@ -1066,8 +1063,9 @@
| FLAG_PERMISSION_REVOKE_ON_UPGRADE;
final @Nullable String mRequiredVerifierPackage;
- final @Nullable String mRequiredInstallerPackage;
+ final @NonNull String mRequiredInstallerPackage;
final @Nullable String mSetupWizardPackage;
+ final @NonNull String mServicesSystemSharedLibraryPackageName;
private final PackageUsage mPackageUsage = new PackageUsage();
@@ -2585,11 +2583,16 @@
mIntentFilterVerifierComponent = getIntentFilterVerifierComponentNameLPr();
mIntentFilterVerifier = new IntentVerifierProxy(mContext,
mIntentFilterVerifierComponent);
+ mServicesSystemSharedLibraryPackageName = getRequiredSharedLibraryLPr(
+ PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES);
+ getRequiredSharedLibraryLPr(
+ PackageManager.SYSTEM_SHARED_LIBRARY_SHARED);
} else {
mRequiredVerifierPackage = null;
mRequiredInstallerPackage = null;
mIntentFilterVerifierComponent = null;
mIntentFilterVerifier = null;
+ mServicesSystemSharedLibraryPackageName = null;
}
mInstallerService = new PackageInstallerService(context, this);
@@ -2669,6 +2672,16 @@
}
}
+ private @NonNull String getRequiredSharedLibraryLPr(String libraryName) {
+ synchronized (mPackages) {
+ SharedLibraryEntry libraryEntry = mSharedLibraries.get(libraryName);
+ if (libraryEntry == null) {
+ throw new IllegalStateException("Missing required shared library:" + libraryName);
+ }
+ return libraryEntry.apk;
+ }
+ }
+
private @NonNull String getRequiredInstallerLPr() {
final Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
@@ -2678,6 +2691,10 @@
MATCH_SYSTEM_ONLY | MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE,
UserHandle.USER_SYSTEM);
if (matches.size() == 1) {
+ ResolveInfo resolveInfo = matches.get(0);
+ if (!resolveInfo.activityInfo.applicationInfo.isPrivilegedApp()) {
+ throw new RuntimeException("The installer must be a privileged app");
+ }
return matches.get(0).getComponentInfo().packageName;
} else {
throw new RuntimeException("There must be exactly one installer; found " + matches);
@@ -3038,7 +3055,7 @@
}
if (p == null) {
p = mPackages.get(packageName);
- if (matchFactoryOnly && !isSystemApp(p)) {
+ if (matchFactoryOnly && p != null && !isSystemApp(p)) {
return null;
}
}
@@ -3560,15 +3577,10 @@
}
@Override
- public @Nullable String getServicesSystemSharedLibraryPackageName() {
+ public @NonNull String getServicesSystemSharedLibraryPackageName() {
synchronized (mPackages) {
- SharedLibraryEntry libraryEntry = mSharedLibraries.get(
- PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES);
- if (libraryEntry != null) {
- return libraryEntry.apk;
- }
+ return mServicesSystemSharedLibraryPackageName;
}
- return null;
}
@Override
@@ -8593,7 +8605,7 @@
if (abi32 >= 0) {
final String abi = Build.SUPPORTED_32_BIT_ABIS[abi32];
if (abi64 >= 0) {
- if (cpuAbiOverride == null && pkg.use32bitAbi) {
+ if (pkg.use32bitAbi) {
pkg.applicationInfo.secondaryCpuAbi = pkg.applicationInfo.primaryCpuAbi;
pkg.applicationInfo.primaryCpuAbi = abi;
} else {
@@ -11742,6 +11754,9 @@
// Okay!
targetPackageSetting.installerPackageName = installerPackageName;
+ if (installerPackageName != null) {
+ mSettings.mInstallerPackages.add(installerPackageName);
+ }
scheduleWriteSettingsLocked();
}
}
@@ -14883,7 +14898,7 @@
* This method is an internal method that could be get invoked either
* to delete an installed package or to clean up a failed installation.
* After deleting an installed package, a broadcast is sent to notify any
- * listeners that the package has been installed. For cleaning up a failed
+ * listeners that the package has been removed. For cleaning up a failed
* installation, the broadcast is not necessary since the package's
* installation wouldn't have sent the initial broadcast either
* The key steps in deleting a package are
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 3c3c576..83cd978 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -247,6 +247,9 @@
/** Map from package name to settings */
final ArrayMap<String, PackageSetting> mPackages = new ArrayMap<>();
+ /** List of packages that installed other packages */
+ final ArraySet<String> mInstallerPackages = new ArraySet<>();
+
/** Map from package name to appId */
private final ArrayMap<String, Integer> mKernelMapping = new ArrayMap<>();
@@ -360,7 +363,7 @@
// Packages that have been uninstalled and still need their external
// storage data deleted.
final ArrayList<PackageCleanItem> mPackagesToBeCleaned = new ArrayList<PackageCleanItem>();
-
+
// Packages that have been renamed since they were first installed.
// Keys are the new names of the packages, values are the original
// names. The packages appear everwhere else under their original
@@ -506,6 +509,9 @@
PackageSetting p = mPackages.get(pkgName);
if (p != null) {
p.setInstallerPackageName(installerPkgName);
+ if (installerPkgName != null) {
+ mInstallerPackages.add(installerPkgName);
+ }
}
}
@@ -572,7 +578,7 @@
}
PackageSetting ret = addPackageLPw(name, p.realName, p.codePath, p.resourcePath,
p.legacyNativeLibraryPathString, p.primaryCpuAbiString,
- p.secondaryCpuAbiString, p.secondaryCpuAbiString,
+ p.secondaryCpuAbiString, p.cpuAbiOverrideString,
p.appId, p.versionCode, p.pkgFlags, p.pkgPrivateFlags,
p.parentPackageName, p.childPackageNames);
mDisabledSysPackages.remove(name);
@@ -1062,6 +1068,7 @@
final PackageSetting p = mPackages.get(name);
if (p != null) {
mPackages.remove(name);
+ removeInstallerPackageStatus(name);
if (p.sharedUser != null) {
p.sharedUser.removePackage(p);
if (p.sharedUser.packages.size() == 0) {
@@ -1077,6 +1084,26 @@
return -1;
}
+ /**
+ * Checks if {@param packageName} is an installer package and if so, clear the installer
+ * package name of the packages that are installed by this.
+ */
+ private void removeInstallerPackageStatus(String packageName) {
+ // Check if the package to be removed is an installer package.
+ if (!mInstallerPackages.contains(packageName)) {
+ return;
+ }
+ for (int i = 0; i < mPackages.size(); i++) {
+ final PackageSetting ps = mPackages.valueAt(i);
+ final String installerPackageName = ps.getInstallerPackageName();
+ if (installerPackageName != null
+ && installerPackageName.equals(packageName)) {
+ ps.setInstallerPackageName(null);
+ }
+ }
+ mInstallerPackages.remove(packageName);
+ }
+
private void replacePackageLPw(String name, PackageSetting newp) {
final PackageSetting p = mPackages.get(name);
if (p != null) {
@@ -2742,6 +2769,7 @@
mPendingPackages.clear();
mPastSignatures.clear();
mKeySetRefs.clear();
+ mInstallerPackages.clear();
try {
if (str == null) {
@@ -3706,6 +3734,10 @@
packageSetting.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT, 0, null);
}
+ if (installerPackageName != null) {
+ mInstallerPackages.add(installerPackageName);
+ }
+
final String installStatusStr = parser.getAttributeValue(null, "installStatus");
if (installStatusStr != null) {
if (installStatusStr.equalsIgnoreCase("false")) {
@@ -3724,7 +3756,7 @@
}
String tagName = parser.getName();
- // Legacy
+ // Legacy
if (tagName.equals(TAG_DISABLED_COMPONENTS)) {
readDisabledComponentsLPw(packageSetting, parser, 0);
} else if (tagName.equals(TAG_ENABLED_COMPONENTS)) {
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index bcafddc..5b9d139 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -93,6 +93,7 @@
// Indicates whether we are rebooting into safe mode
public static final String REBOOT_SAFEMODE_PROPERTY = "persist.sys.safemode";
+ public static final String RO_SAFEMODE_PROPERTY = "ro.sys.safemode";
// Indicates whether we should stay in safe mode until ro.build.date.utc is newer than this
public static final String AUDIT_SAFEMODE_PROPERTY = "persist.sys.audit_safemode";
diff --git a/services/core/java/com/android/server/vr/VrManagerService.java b/services/core/java/com/android/server/vr/VrManagerService.java
index e6e5a2d..f004b45 100644
--- a/services/core/java/com/android/server/vr/VrManagerService.java
+++ b/services/core/java/com/android/server/vr/VrManagerService.java
@@ -490,8 +490,15 @@
private void revokeNotificationPolicyAccess(String pkg) {
NotificationManager nm = mContext.getSystemService(NotificationManager.class);
if (mPreviousNotificationPolicyAccessPackage != null) {
- nm.setNotificationPolicyAccessGranted(mPreviousNotificationPolicyAccessPackage, false);
- mPreviousNotificationPolicyAccessPackage = null;
+ if (mPreviousNotificationPolicyAccessPackage.equals(pkg)) {
+ // Remove any DND zen rules possibly created by the package.
+ nm.removeAutomaticZenRules(mPreviousNotificationPolicyAccessPackage);
+ // Remove Notification Policy Access.
+ nm.setNotificationPolicyAccessGranted(mPreviousNotificationPolicyAccessPackage, false);
+ mPreviousNotificationPolicyAccessPackage = null;
+ } else {
+ Slog.e(TAG, "Couldn't remove Notification Policy Access for package: " + pkg);
+ }
}
}
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateService.java b/services/core/java/com/android/server/webkit/WebViewUpdateService.java
index ebec445..1f6fb2a 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdateService.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdateService.java
@@ -20,17 +20,12 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.Signature;
import android.os.Binder;
import android.os.PatternMatcher;
import android.os.Process;
import android.os.ResultReceiver;
import android.os.UserHandle;
-import android.util.Base64;
import android.util.Slog;
import android.webkit.IWebViewUpdateService;
import android.webkit.WebViewFactory;
@@ -40,9 +35,7 @@
import com.android.server.SystemService;
import java.io.FileDescriptor;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
/**
* Private service to wait for the updatable WebView to be ready for use.
@@ -53,19 +46,16 @@
private static final String TAG = "WebViewUpdateService";
private BroadcastReceiver mWebViewUpdatedReceiver;
- private SystemInterface mSystemInterface;
+ private WebViewUpdateServiceImpl mImpl;
static final int PACKAGE_CHANGED = 0;
static final int PACKAGE_ADDED = 1;
static final int PACKAGE_ADDED_REPLACED = 2;
static final int PACKAGE_REMOVED = 3;
- private WebViewUpdater mWebViewUpdater;
-
public WebViewUpdateService(Context context) {
super(context);
- mSystemInterface = new SystemImpl();
- mWebViewUpdater = new WebViewUpdater(getContext(), mSystemInterface);
+ mImpl = new WebViewUpdateServiceImpl(context, new SystemImpl());
}
@Override
@@ -82,24 +72,26 @@
// the package that is being replaced we early-out here so that we don't
// run the update-logic twice.
if (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)) return;
- packageStateChanged(packageNameFromIntent(intent), PACKAGE_REMOVED);
+ mImpl.packageStateChanged(packageNameFromIntent(intent),
+ PACKAGE_REMOVED);
break;
case Intent.ACTION_PACKAGE_CHANGED:
// Ensure that we only heed PACKAGE_CHANGED intents if they change an
// entire package, not just a component
if (entirePackageChanged(intent)) {
- packageStateChanged(packageNameFromIntent(intent), PACKAGE_CHANGED);
+ mImpl.packageStateChanged(packageNameFromIntent(intent),
+ PACKAGE_CHANGED);
}
break;
case Intent.ACTION_PACKAGE_ADDED:
- packageStateChanged(packageNameFromIntent(intent),
+ mImpl.packageStateChanged(packageNameFromIntent(intent),
(intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)
? PACKAGE_ADDED_REPLACED : PACKAGE_ADDED));
break;
case Intent.ACTION_USER_ADDED:
int userId =
intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
- handleNewUser(userId);
+ mImpl.handleNewUser(userId);
break;
}
}
@@ -110,7 +102,7 @@
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
// Make sure we only receive intents for WebView packages from our config file.
- for (WebViewProviderInfo provider : mSystemInterface.getWebViewPackages()) {
+ for (WebViewProviderInfo provider : mImpl.getWebViewPackages()) {
filter.addDataSchemeSpecificPart(provider.packageName, PatternMatcher.PATTERN_LITERAL);
}
getContext().registerReceiver(mWebViewUpdatedReceiver, filter);
@@ -122,518 +114,14 @@
publishBinderService("webviewupdate", new BinderService(), true /*allowIsolated*/);
}
- private void packageStateChanged(String packageName, int changedState) {
- updateFallbackState(packageName, changedState);
- mWebViewUpdater.packageStateChanged(packageName, changedState);
- }
-
public void prepareWebViewInSystemServer() {
- updateFallbackStateOnBoot();
- mWebViewUpdater.prepareWebViewInSystemServer();
+ mImpl.prepareWebViewInSystemServer();
}
private static String packageNameFromIntent(Intent intent) {
return intent.getDataString().substring("package:".length());
}
- private boolean existsValidNonFallbackProvider(WebViewProviderInfo[] providers) {
- for (WebViewProviderInfo provider : providers) {
- if (provider.availableByDefault && !provider.isFallback) {
- try {
- PackageInfo packageInfo = mSystemInterface.getPackageInfoForProvider(provider);
- if (isEnabledPackage(packageInfo)
- && mWebViewUpdater.isValidProvider(provider, packageInfo)) {
- return true;
- }
- } catch (NameNotFoundException e) {
- // A non-existent provider is neither valid nor enabled
- }
- }
- }
- return false;
- }
-
- /**
- * Called when a new user has been added to update the state of its fallback package.
- */
- void handleNewUser(int userId) {
- if (!mSystemInterface.isFallbackLogicEnabled()) return;
-
- WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
- WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewProviders);
- if (fallbackProvider == null) return;
-
- mSystemInterface.enablePackageForUser(fallbackProvider.packageName,
- !existsValidNonFallbackProvider(webviewProviders), userId);
- }
-
- public void updateFallbackStateOnBoot() {
- WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
- updateFallbackState(webviewProviders, true);
- }
-
- /**
- * Handle the enabled-state of our fallback package, i.e. if there exists some non-fallback
- * package that is valid (and available by default) then disable the fallback package,
- * otherwise, enable the fallback package.
- */
- public void updateFallbackState(String changedPackage, int changedState) {
- if (!mSystemInterface.isFallbackLogicEnabled()) return;
-
- WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
-
- // A package was changed / updated / downgraded, early out if it is not one of the
- // webview packages that are available by default.
- boolean changedPackageAvailableByDefault = false;
- for (WebViewProviderInfo provider : webviewProviders) {
- if (provider.packageName.equals(changedPackage)) {
- if (provider.availableByDefault) {
- changedPackageAvailableByDefault = true;
- }
- break;
- }
- }
- if (!changedPackageAvailableByDefault) return;
- updateFallbackState(webviewProviders, false);
- }
-
- private void updateFallbackState(WebViewProviderInfo[] webviewProviders, boolean isBoot) {
- // If there exists a valid and enabled non-fallback package - disable the fallback
- // package, otherwise, enable it.
- WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewProviders);
- if (fallbackProvider == null) return;
- boolean existsValidNonFallbackProvider = existsValidNonFallbackProvider(webviewProviders);
-
- boolean isFallbackEnabled = false;
- try {
- isFallbackEnabled = isEnabledPackage(
- mSystemInterface.getPackageInfoForProvider(fallbackProvider));
- } catch (NameNotFoundException e) {
- }
-
- if (existsValidNonFallbackProvider
- // During an OTA the primary user's WebView state might differ from other users', so
- // ignore the state of that user during boot.
- && (isFallbackEnabled || isBoot)) {
- mSystemInterface.uninstallAndDisablePackageForAllUsers(getContext(),
- fallbackProvider.packageName);
- } else if (!existsValidNonFallbackProvider
- // During an OTA the primary user's WebView state might differ from other users', so
- // ignore the state of that user during boot.
- && (!isFallbackEnabled || isBoot)) {
- // Enable the fallback package for all users.
- mSystemInterface.enablePackageForAllUsers(getContext(),
- fallbackProvider.packageName, true);
- }
- }
-
- /**
- * Returns the only fallback provider in the set of given packages, or null if there is none.
- */
- private static WebViewProviderInfo getFallbackProvider(WebViewProviderInfo[] webviewPackages) {
- for (WebViewProviderInfo provider : webviewPackages) {
- if (provider.isFallback) {
- return provider;
- }
- }
- return null;
- }
-
- private boolean isFallbackPackage(String packageName) {
- if (packageName == null || !mSystemInterface.isFallbackLogicEnabled()) return false;
-
- WebViewProviderInfo[] webviewPackages = mSystemInterface.getWebViewPackages();
- WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewPackages);
- return (fallbackProvider != null
- && packageName.equals(fallbackProvider.packageName));
- }
-
- /**
- * Class that decides what WebView implementation to use and prepares that implementation for
- * use.
- */
- private static class WebViewUpdater {
- private Context mContext;
- private SystemInterface mSystemInterface;
- private int mMinimumVersionCode = -1;
-
- public WebViewUpdater(Context context, SystemInterface systemInterface) {
- mContext = context;
- mSystemInterface = systemInterface;
- }
-
- private static final int WAIT_TIMEOUT_MS = 4500; // KEY_DISPATCHING_TIMEOUT is 5000.
-
- // Keeps track of the number of running relro creations
- private int mNumRelroCreationsStarted = 0;
- private int mNumRelroCreationsFinished = 0;
- // Implies that we need to rerun relro creation because we are using an out-of-date package
- private boolean mWebViewPackageDirty = false;
- private boolean mAnyWebViewInstalled = false;
-
- private int NUMBER_OF_RELROS_UNKNOWN = Integer.MAX_VALUE;
-
- // The WebView package currently in use (or the one we are preparing).
- private PackageInfo mCurrentWebViewPackage = null;
-
- private Object mLock = new Object();
-
- public void packageStateChanged(String packageName, int changedState) {
- for (WebViewProviderInfo provider : mSystemInterface.getWebViewPackages()) {
- String webviewPackage = provider.packageName;
-
- if (webviewPackage.equals(packageName)) {
- boolean updateWebView = false;
- boolean removedOrChangedOldPackage = false;
- String oldProviderName = null;
- PackageInfo newPackage = null;
- synchronized(mLock) {
- try {
- newPackage = findPreferredWebViewPackage();
- if (mCurrentWebViewPackage != null)
- oldProviderName = mCurrentWebViewPackage.packageName;
- // Only trigger update actions if the updated package is the one
- // that will be used, or the one that was in use before the
- // update, or if we haven't seen a valid WebView package before.
- updateWebView =
- provider.packageName.equals(newPackage.packageName)
- || provider.packageName.equals(oldProviderName)
- || mCurrentWebViewPackage == null;
- // We removed the old package if we received an intent to remove
- // or replace the old package.
- removedOrChangedOldPackage =
- provider.packageName.equals(oldProviderName);
- if (updateWebView) {
- onWebViewProviderChanged(newPackage);
- }
- } catch (WebViewFactory.MissingWebViewPackageException e) {
- Slog.e(TAG, "Could not find valid WebView package to create " +
- "relro with " + e);
- }
- }
- if(updateWebView && !removedOrChangedOldPackage
- && oldProviderName != null) {
- // If the provider change is the result of adding or replacing a
- // package that was not the previous provider then we must kill
- // packages dependent on the old package ourselves. The framework
- // only kills dependents of packages that are being removed.
- mSystemInterface.killPackageDependents(oldProviderName);
- }
- return;
- }
- }
- }
-
- public void prepareWebViewInSystemServer() {
- try {
- synchronized(mLock) {
- mCurrentWebViewPackage = findPreferredWebViewPackage();
- onWebViewProviderChanged(mCurrentWebViewPackage);
- }
- } catch (Throwable t) {
- // Log and discard errors at this stage as we must not crash the system server.
- Slog.e(TAG, "error preparing webview provider from system server", t);
- }
- }
-
- /**
- * Change WebView provider and provider setting and kill packages using the old provider.
- * Return the new provider (in case we are in the middle of creating relro files this new
- * provider will not be in use directly, but will when the relros are done).
- */
- public String changeProviderAndSetting(String newProviderName) {
- PackageInfo oldPackage = null;
- PackageInfo newPackage = null;
- synchronized(mLock) {
- oldPackage = mCurrentWebViewPackage;
- mSystemInterface.updateUserSetting(mContext, newProviderName);
-
- try {
- newPackage = findPreferredWebViewPackage();
- if (oldPackage != null
- && newPackage.packageName.equals(oldPackage.packageName)) {
- // If we don't perform the user change, revert the settings change.
- mSystemInterface.updateUserSetting(mContext, newPackage.packageName);
- return newPackage.packageName;
- }
- } catch (WebViewFactory.MissingWebViewPackageException e) {
- Slog.e(TAG, "Tried to change WebView provider but failed to fetch WebView " +
- "package " + e);
- // If we don't perform the user change but don't have an installed WebView
- // package, we will have changed the setting and it will be used when a package
- // is available.
- return newProviderName;
- }
- onWebViewProviderChanged(newPackage);
- }
- // Kill apps using the old provider
- if (oldPackage != null) {
- mSystemInterface.killPackageDependents(oldPackage.packageName);
- }
- return newPackage.packageName;
- }
-
- /**
- * This is called when we change WebView provider, either when the current provider is
- * updated or a new provider is chosen / takes precedence.
- */
- private void onWebViewProviderChanged(PackageInfo newPackage) {
- synchronized(mLock) {
- mAnyWebViewInstalled = true;
- if (mNumRelroCreationsStarted == mNumRelroCreationsFinished) {
- mCurrentWebViewPackage = newPackage;
- mSystemInterface.updateUserSetting(mContext, newPackage.packageName);
-
- // The relro creations might 'finish' (not start at all) before
- // WebViewFactory.onWebViewProviderChanged which means we might not know the
- // number of started creations before they finish.
- mNumRelroCreationsStarted = NUMBER_OF_RELROS_UNKNOWN;
- mNumRelroCreationsFinished = 0;
- mNumRelroCreationsStarted =
- mSystemInterface.onWebViewProviderChanged(newPackage);
- // If the relro creations finish before we know the number of started creations
- // we will have to do any cleanup/notifying here.
- checkIfRelrosDoneLocked();
- } else {
- mWebViewPackageDirty = true;
- }
- }
- }
-
- private ProviderAndPackageInfo[] getValidWebViewPackagesAndInfos() {
- WebViewProviderInfo[] allProviders = mSystemInterface.getWebViewPackages();
- List<ProviderAndPackageInfo> providers = new ArrayList<>();
- for(int n = 0; n < allProviders.length; n++) {
- try {
- PackageInfo packageInfo =
- mSystemInterface.getPackageInfoForProvider(allProviders[n]);
- if (isValidProvider(allProviders[n], packageInfo)) {
- providers.add(new ProviderAndPackageInfo(allProviders[n], packageInfo));
- }
- } catch (NameNotFoundException e) {
- // Don't add non-existent packages
- }
- }
- return providers.toArray(new ProviderAndPackageInfo[providers.size()]);
- }
-
- /**
- * Fetch only the currently valid WebView packages.
- **/
- public WebViewProviderInfo[] getValidWebViewPackages() {
- ProviderAndPackageInfo[] providersAndPackageInfos = getValidWebViewPackagesAndInfos();
- WebViewProviderInfo[] providers =
- new WebViewProviderInfo[providersAndPackageInfos.length];
- for(int n = 0; n < providersAndPackageInfos.length; n++) {
- providers[n] = providersAndPackageInfos[n].provider;
- }
- return providers;
- }
-
-
- private class ProviderAndPackageInfo {
- public final WebViewProviderInfo provider;
- public final PackageInfo packageInfo;
-
- public ProviderAndPackageInfo(WebViewProviderInfo provider, PackageInfo packageInfo) {
- this.provider = provider;
- this.packageInfo = packageInfo;
- }
- }
-
- /**
- * Returns either the package info of the WebView provider determined in the following way:
- * If the user has chosen a provider then use that if it is valid,
- * otherwise use the first package in the webview priority list that is valid.
- *
- */
- private PackageInfo findPreferredWebViewPackage() {
- ProviderAndPackageInfo[] providers = getValidWebViewPackagesAndInfos();
-
- String userChosenProvider = mSystemInterface.getUserChosenWebViewProvider(mContext);
-
- // If the user has chosen provider, use that
- for (ProviderAndPackageInfo providerAndPackage : providers) {
- if (providerAndPackage.provider.packageName.equals(userChosenProvider)
- && isEnabledPackage(providerAndPackage.packageInfo)) {
- return providerAndPackage.packageInfo;
- }
- }
-
- // User did not choose, or the choice failed; use the most stable provider that is
- // enabled and available by default (not through user choice).
- for (ProviderAndPackageInfo providerAndPackage : providers) {
- if (providerAndPackage.provider.availableByDefault
- && isEnabledPackage(providerAndPackage.packageInfo)) {
- return providerAndPackage.packageInfo;
- }
- }
-
- // Could not find any enabled package either, use the most stable provider.
- for (ProviderAndPackageInfo providerAndPackage : providers) {
- return providerAndPackage.packageInfo;
- }
-
- mAnyWebViewInstalled = false;
- throw new WebViewFactory.MissingWebViewPackageException(
- "Could not find a loadable WebView package");
- }
-
- public void notifyRelroCreationCompleted() {
- synchronized (mLock) {
- mNumRelroCreationsFinished++;
- checkIfRelrosDoneLocked();
- }
- }
-
- public WebViewProviderResponse waitForAndGetProvider() {
- PackageInfo webViewPackage = null;
- final long NS_PER_MS = 1000000;
- final long timeoutTimeMs = System.nanoTime() / NS_PER_MS + WAIT_TIMEOUT_MS;
- boolean webViewReady = false;
- int webViewStatus = WebViewFactory.LIBLOAD_SUCCESS;
- synchronized (mLock) {
- webViewReady = webViewIsReadyLocked();
- while (!webViewReady) {
- final long timeNowMs = System.nanoTime() / NS_PER_MS;
- if (timeNowMs >= timeoutTimeMs) break;
- try {
- mLock.wait(timeoutTimeMs - timeNowMs);
- } catch (InterruptedException e) {}
- webViewReady = webViewIsReadyLocked();
- }
- // Make sure we return the provider that was used to create the relro file
- webViewPackage = mCurrentWebViewPackage;
- if (webViewReady) {
- } else if (!mAnyWebViewInstalled) {
- webViewStatus = WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES;
- } else {
- // Either the current relro creation isn't done yet, or the new relro creatioin
- // hasn't kicked off yet (the last relro creation used an out-of-date WebView).
- webViewStatus = WebViewFactory.LIBLOAD_FAILED_WAITING_FOR_RELRO;
- }
- }
- if (!webViewReady) Slog.w(TAG, "creating relro file timed out");
- return new WebViewProviderResponse(webViewPackage, webViewStatus);
- }
-
- public String getCurrentWebViewPackageName() {
- synchronized(mLock) {
- if (mCurrentWebViewPackage == null)
- return null;
- return mCurrentWebViewPackage.packageName;
- }
- }
-
- /**
- * Returns whether WebView is ready and is not going to go through its preparation phase
- * again directly.
- */
- private boolean webViewIsReadyLocked() {
- return !mWebViewPackageDirty
- && (mNumRelroCreationsStarted == mNumRelroCreationsFinished)
- // The current package might be replaced though we haven't received an intent
- // declaring this yet, the following flag makes anyone loading WebView to wait in
- // this case.
- && mAnyWebViewInstalled;
- }
-
- private void checkIfRelrosDoneLocked() {
- if (mNumRelroCreationsStarted == mNumRelroCreationsFinished) {
- if (mWebViewPackageDirty) {
- mWebViewPackageDirty = false;
- // If we have changed provider since we started the relro creation we need to
- // redo the whole process using the new package instead.
- PackageInfo newPackage = findPreferredWebViewPackage();
- onWebViewProviderChanged(newPackage);
- } else {
- mLock.notifyAll();
- }
- }
- }
-
- /**
- * Returns whether this provider is valid for use as a WebView provider.
- */
- public boolean isValidProvider(WebViewProviderInfo configInfo,
- PackageInfo packageInfo) {
- if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0
- && packageInfo.versionCode < getMinimumVersionCode()
- && !mSystemInterface.systemIsDebuggable()) {
- // Non-system package webview providers may be downgraded arbitrarily low, prevent
- // that by enforcing minimum version code. This check is only enforced for user
- // builds.
- return false;
- }
- if (providerHasValidSignature(configInfo, packageInfo, mSystemInterface) &&
- WebViewFactory.getWebViewLibrary(packageInfo.applicationInfo) != null) {
- return true;
- }
- return false;
- }
-
- /**
- * Gets the minimum version code allowed for a valid provider. It is the minimum versionCode
- * of all available-by-default and non-fallback WebView provider packages. If there is no
- * such WebView provider package on the system, then return -1, which means all positive
- * versionCode WebView packages are accepted.
- */
- private int getMinimumVersionCode() {
- if (mMinimumVersionCode > 0) {
- return mMinimumVersionCode;
- }
-
- for (WebViewProviderInfo provider : mSystemInterface.getWebViewPackages()) {
- if (provider.availableByDefault && !provider.isFallback) {
- try {
- int versionCode =
- mSystemInterface.getFactoryPackageVersion(provider.packageName);
- if (mMinimumVersionCode < 0 || versionCode < mMinimumVersionCode) {
- mMinimumVersionCode = versionCode;
- }
- } catch (PackageManager.NameNotFoundException e) {
- // Safe to ignore.
- }
- }
- }
-
- return mMinimumVersionCode;
- }
- }
-
- private static boolean providerHasValidSignature(WebViewProviderInfo provider,
- PackageInfo packageInfo, SystemInterface systemInterface) {
- if (systemInterface.systemIsDebuggable()) {
- return true;
- }
- Signature[] packageSignatures;
- // If no signature is declared, instead check whether the package is included in the
- // system.
- if (provider.signatures == null || provider.signatures.length == 0) {
- return packageInfo.applicationInfo.isSystemApp();
- }
- packageSignatures = packageInfo.signatures;
- if (packageSignatures.length != 1)
- return false;
-
- final byte[] packageSignature = packageSignatures[0].toByteArray();
- // Return whether the package signature matches any of the valid signatures
- for (String signature : provider.signatures) {
- final byte[] validSignature = Base64.decode(signature, Base64.DEFAULT);
- if (Arrays.equals(packageSignature, validSignature))
- return true;
- }
- return false;
- }
-
- /**
- * Returns whether the given package is enabled.
- * This state can be changed by the user from Settings->Apps
- */
- private static boolean isEnabledPackage(PackageInfo packageInfo) {
- return packageInfo.applicationInfo.enabled;
- }
-
/**
* Returns whether the entire package from an ACTION_PACKAGE_CHANGED intent was changed (rather
* than just one of its components).
@@ -673,7 +161,7 @@
long callingId = Binder.clearCallingIdentity();
try {
- WebViewUpdateService.this.mWebViewUpdater.notifyRelroCreationCompleted();
+ WebViewUpdateService.this.mImpl.notifyRelroCreationCompleted();
} finally {
Binder.restoreCallingIdentity(callingId);
}
@@ -693,7 +181,7 @@
throw new IllegalStateException("Cannot create a WebView from the SystemServer");
}
- return WebViewUpdateService.this.mWebViewUpdater.waitForAndGetProvider();
+ return WebViewUpdateService.this.mImpl.waitForAndGetProvider();
}
/**
@@ -714,7 +202,7 @@
long callingId = Binder.clearCallingIdentity();
try {
- return WebViewUpdateService.this.mWebViewUpdater.changeProviderAndSetting(
+ return WebViewUpdateService.this.mImpl.changeProviderAndSetting(
newProvider);
} finally {
Binder.restoreCallingIdentity(callingId);
@@ -723,22 +211,22 @@
@Override // Binder call
public WebViewProviderInfo[] getValidWebViewPackages() {
- return WebViewUpdateService.this.mWebViewUpdater.getValidWebViewPackages();
+ return WebViewUpdateService.this.mImpl.getValidWebViewPackages();
}
@Override // Binder call
public WebViewProviderInfo[] getAllWebViewPackages() {
- return WebViewUpdateService.this.mSystemInterface.getWebViewPackages();
+ return WebViewUpdateService.this.mImpl.getWebViewPackages();
}
@Override // Binder call
public String getCurrentWebViewPackageName() {
- return WebViewUpdateService.this.mWebViewUpdater.getCurrentWebViewPackageName();
+ return WebViewUpdateService.this.mImpl.getCurrentWebViewPackageName();
}
@Override // Binder call
public boolean isFallbackPackage(String packageName) {
- return WebViewUpdateService.this.isFallbackPackage(packageName);
+ return WebViewUpdateService.this.mImpl.isFallbackPackage(packageName);
}
@Override // Binder call
@@ -754,7 +242,7 @@
throw new SecurityException(msg);
}
- WebViewUpdateService.this.mSystemInterface.enableFallbackLogic(enable);
+ WebViewUpdateService.this.mImpl.enableFallbackLogic(enable);
}
}
}
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java b/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java
new file mode 100644
index 0000000..32b195b
--- /dev/null
+++ b/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java
@@ -0,0 +1,588 @@
+/*
+ * Copyright (C) 2016 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.webkit;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.Signature;
+import android.util.Base64;
+import android.util.Slog;
+import android.webkit.WebViewFactory;
+import android.webkit.WebViewProviderInfo;
+import android.webkit.WebViewProviderResponse;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Implementation of the WebViewUpdateService.
+ * This class doesn't depend on the android system like the actual Service does and can be used
+ * directly by tests (as long as they implement a SystemInterface).
+ * @hide
+ */
+public class WebViewUpdateServiceImpl {
+ private static final String TAG = WebViewUpdateServiceImpl.class.getSimpleName();
+
+ private SystemInterface mSystemInterface;
+ private WebViewUpdater mWebViewUpdater;
+ private Context mContext;
+
+ public WebViewUpdateServiceImpl(Context context, SystemInterface systemInterface) {
+ mContext = context;
+ mSystemInterface = systemInterface;
+ mWebViewUpdater = new WebViewUpdater(mContext, mSystemInterface);
+ }
+
+ void packageStateChanged(String packageName, int changedState) {
+ updateFallbackStateOnPackageChange(packageName, changedState);
+ mWebViewUpdater.packageStateChanged(packageName, changedState);
+ }
+
+ void prepareWebViewInSystemServer() {
+ updateFallbackStateOnBoot();
+ mWebViewUpdater.prepareWebViewInSystemServer();
+ }
+
+ private boolean existsValidNonFallbackProvider(WebViewProviderInfo[] providers) {
+ for (WebViewProviderInfo provider : providers) {
+ if (provider.availableByDefault && !provider.isFallback) {
+ try {
+ PackageInfo packageInfo = mSystemInterface.getPackageInfoForProvider(provider);
+ if (isEnabledPackage(packageInfo)
+ && mWebViewUpdater.isValidProvider(provider, packageInfo)) {
+ return true;
+ }
+ } catch (NameNotFoundException e) {
+ // A non-existent provider is neither valid nor enabled
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Called when a new user has been added to update the state of its fallback package.
+ */
+ void handleNewUser(int userId) {
+ if (!mSystemInterface.isFallbackLogicEnabled()) return;
+
+ WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
+ WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewProviders);
+ if (fallbackProvider == null) return;
+
+ mSystemInterface.enablePackageForUser(fallbackProvider.packageName,
+ !existsValidNonFallbackProvider(webviewProviders), userId);
+ }
+
+ void notifyRelroCreationCompleted() {
+ mWebViewUpdater.notifyRelroCreationCompleted();
+ }
+
+ WebViewProviderResponse waitForAndGetProvider() {
+ return mWebViewUpdater.waitForAndGetProvider();
+ }
+
+ String changeProviderAndSetting(String newProvider) {
+ return mWebViewUpdater.changeProviderAndSetting(newProvider);
+ }
+
+ WebViewProviderInfo[] getValidWebViewPackages() {
+ return mWebViewUpdater.getValidWebViewPackages();
+ }
+
+ WebViewProviderInfo[] getWebViewPackages() {
+ return mSystemInterface.getWebViewPackages();
+ }
+
+ String getCurrentWebViewPackageName() {
+ return mWebViewUpdater.getCurrentWebViewPackageName();
+ }
+
+ void enableFallbackLogic(boolean enable) {
+ mSystemInterface.enableFallbackLogic(enable);
+ }
+
+ private void updateFallbackStateOnBoot() {
+ WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
+ updateFallbackState(webviewProviders, true);
+ }
+
+ /**
+ * Handle the enabled-state of our fallback package, i.e. if there exists some non-fallback
+ * package that is valid (and available by default) then disable the fallback package,
+ * otherwise, enable the fallback package.
+ */
+ private void updateFallbackStateOnPackageChange(String changedPackage, int changedState) {
+ if (!mSystemInterface.isFallbackLogicEnabled()) return;
+
+ WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
+
+ // A package was changed / updated / downgraded, early out if it is not one of the
+ // webview packages that are available by default.
+ boolean changedPackageAvailableByDefault = false;
+ for (WebViewProviderInfo provider : webviewProviders) {
+ if (provider.packageName.equals(changedPackage)) {
+ if (provider.availableByDefault) {
+ changedPackageAvailableByDefault = true;
+ }
+ break;
+ }
+ }
+ if (!changedPackageAvailableByDefault) return;
+ updateFallbackState(webviewProviders, false);
+ }
+
+ private void updateFallbackState(WebViewProviderInfo[] webviewProviders, boolean isBoot) {
+ // If there exists a valid and enabled non-fallback package - disable the fallback
+ // package, otherwise, enable it.
+ WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewProviders);
+ if (fallbackProvider == null) return;
+ boolean existsValidNonFallbackProvider = existsValidNonFallbackProvider(webviewProviders);
+
+ boolean isFallbackEnabled = false;
+ try {
+ isFallbackEnabled = isEnabledPackage(
+ mSystemInterface.getPackageInfoForProvider(fallbackProvider));
+ } catch (NameNotFoundException e) {
+ }
+
+ if (existsValidNonFallbackProvider
+ // During an OTA the primary user's WebView state might differ from other users', so
+ // ignore the state of that user during boot.
+ && (isFallbackEnabled || isBoot)) {
+ mSystemInterface.uninstallAndDisablePackageForAllUsers(mContext,
+ fallbackProvider.packageName);
+ } else if (!existsValidNonFallbackProvider
+ // During an OTA the primary user's WebView state might differ from other users', so
+ // ignore the state of that user during boot.
+ && (!isFallbackEnabled || isBoot)) {
+ // Enable the fallback package for all users.
+ mSystemInterface.enablePackageForAllUsers(mContext,
+ fallbackProvider.packageName, true);
+ }
+ }
+
+ /**
+ * Returns the only fallback provider in the set of given packages, or null if there is none.
+ */
+ private static WebViewProviderInfo getFallbackProvider(WebViewProviderInfo[] webviewPackages) {
+ for (WebViewProviderInfo provider : webviewPackages) {
+ if (provider.isFallback) {
+ return provider;
+ }
+ }
+ return null;
+ }
+
+ boolean isFallbackPackage(String packageName) {
+ if (packageName == null || !mSystemInterface.isFallbackLogicEnabled()) return false;
+
+ WebViewProviderInfo[] webviewPackages = mSystemInterface.getWebViewPackages();
+ WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewPackages);
+ return (fallbackProvider != null
+ && packageName.equals(fallbackProvider.packageName));
+ }
+
+ /**
+ * Class that decides what WebView implementation to use and prepares that implementation for
+ * use.
+ */
+ private static class WebViewUpdater {
+ private Context mContext;
+ private SystemInterface mSystemInterface;
+ private int mMinimumVersionCode = -1;
+
+ public WebViewUpdater(Context context, SystemInterface systemInterface) {
+ mContext = context;
+ mSystemInterface = systemInterface;
+ }
+
+ private static final int WAIT_TIMEOUT_MS = 4500; // KEY_DISPATCHING_TIMEOUT is 5000.
+
+ // Keeps track of the number of running relro creations
+ private int mNumRelroCreationsStarted = 0;
+ private int mNumRelroCreationsFinished = 0;
+ // Implies that we need to rerun relro creation because we are using an out-of-date package
+ private boolean mWebViewPackageDirty = false;
+ private boolean mAnyWebViewInstalled = false;
+
+ private int NUMBER_OF_RELROS_UNKNOWN = Integer.MAX_VALUE;
+
+ // The WebView package currently in use (or the one we are preparing).
+ private PackageInfo mCurrentWebViewPackage = null;
+
+ private Object mLock = new Object();
+
+ public void packageStateChanged(String packageName, int changedState) {
+ for (WebViewProviderInfo provider : mSystemInterface.getWebViewPackages()) {
+ String webviewPackage = provider.packageName;
+
+ if (webviewPackage.equals(packageName)) {
+ boolean updateWebView = false;
+ boolean removedOrChangedOldPackage = false;
+ String oldProviderName = null;
+ PackageInfo newPackage = null;
+ synchronized(mLock) {
+ try {
+ newPackage = findPreferredWebViewPackage();
+ if (mCurrentWebViewPackage != null)
+ oldProviderName = mCurrentWebViewPackage.packageName;
+ // Only trigger update actions if the updated package is the one
+ // that will be used, or the one that was in use before the
+ // update, or if we haven't seen a valid WebView package before.
+ updateWebView =
+ provider.packageName.equals(newPackage.packageName)
+ || provider.packageName.equals(oldProviderName)
+ || mCurrentWebViewPackage == null;
+ // We removed the old package if we received an intent to remove
+ // or replace the old package.
+ removedOrChangedOldPackage =
+ provider.packageName.equals(oldProviderName);
+ if (updateWebView) {
+ onWebViewProviderChanged(newPackage);
+ }
+ } catch (WebViewFactory.MissingWebViewPackageException e) {
+ Slog.e(TAG, "Could not find valid WebView package to create " +
+ "relro with " + e);
+ }
+ }
+ if(updateWebView && !removedOrChangedOldPackage
+ && oldProviderName != null) {
+ // If the provider change is the result of adding or replacing a
+ // package that was not the previous provider then we must kill
+ // packages dependent on the old package ourselves. The framework
+ // only kills dependents of packages that are being removed.
+ mSystemInterface.killPackageDependents(oldProviderName);
+ }
+ return;
+ }
+ }
+ }
+
+ public void prepareWebViewInSystemServer() {
+ try {
+ synchronized(mLock) {
+ mCurrentWebViewPackage = findPreferredWebViewPackage();
+ onWebViewProviderChanged(mCurrentWebViewPackage);
+ }
+ } catch (Throwable t) {
+ // Log and discard errors at this stage as we must not crash the system server.
+ Slog.e(TAG, "error preparing webview provider from system server", t);
+ }
+ }
+
+ /**
+ * Change WebView provider and provider setting and kill packages using the old provider.
+ * Return the new provider (in case we are in the middle of creating relro files this new
+ * provider will not be in use directly, but will when the relros are done).
+ */
+ public String changeProviderAndSetting(String newProviderName) {
+ PackageInfo oldPackage = null;
+ PackageInfo newPackage = null;
+ synchronized(mLock) {
+ oldPackage = mCurrentWebViewPackage;
+ mSystemInterface.updateUserSetting(mContext, newProviderName);
+
+ try {
+ newPackage = findPreferredWebViewPackage();
+ if (oldPackage != null
+ && newPackage.packageName.equals(oldPackage.packageName)) {
+ // If we don't perform the user change, revert the settings change.
+ mSystemInterface.updateUserSetting(mContext, newPackage.packageName);
+ return newPackage.packageName;
+ }
+ } catch (WebViewFactory.MissingWebViewPackageException e) {
+ Slog.e(TAG, "Tried to change WebView provider but failed to fetch WebView " +
+ "package " + e);
+ // If we don't perform the user change but don't have an installed WebView
+ // package, we will have changed the setting and it will be used when a package
+ // is available.
+ return newProviderName;
+ }
+ onWebViewProviderChanged(newPackage);
+ }
+ // Kill apps using the old provider
+ if (oldPackage != null) {
+ mSystemInterface.killPackageDependents(oldPackage.packageName);
+ }
+ return newPackage.packageName;
+ }
+
+ /**
+ * This is called when we change WebView provider, either when the current provider is
+ * updated or a new provider is chosen / takes precedence.
+ */
+ private void onWebViewProviderChanged(PackageInfo newPackage) {
+ synchronized(mLock) {
+ mAnyWebViewInstalled = true;
+ if (mNumRelroCreationsStarted == mNumRelroCreationsFinished) {
+ mCurrentWebViewPackage = newPackage;
+ mSystemInterface.updateUserSetting(mContext, newPackage.packageName);
+
+ // The relro creations might 'finish' (not start at all) before
+ // WebViewFactory.onWebViewProviderChanged which means we might not know the
+ // number of started creations before they finish.
+ mNumRelroCreationsStarted = NUMBER_OF_RELROS_UNKNOWN;
+ mNumRelroCreationsFinished = 0;
+ mNumRelroCreationsStarted =
+ mSystemInterface.onWebViewProviderChanged(newPackage);
+ // If the relro creations finish before we know the number of started creations
+ // we will have to do any cleanup/notifying here.
+ checkIfRelrosDoneLocked();
+ } else {
+ mWebViewPackageDirty = true;
+ }
+ }
+ }
+
+ private ProviderAndPackageInfo[] getValidWebViewPackagesAndInfos() {
+ WebViewProviderInfo[] allProviders = mSystemInterface.getWebViewPackages();
+ List<ProviderAndPackageInfo> providers = new ArrayList<>();
+ for(int n = 0; n < allProviders.length; n++) {
+ try {
+ PackageInfo packageInfo =
+ mSystemInterface.getPackageInfoForProvider(allProviders[n]);
+ if (isValidProvider(allProviders[n], packageInfo)) {
+ providers.add(new ProviderAndPackageInfo(allProviders[n], packageInfo));
+ }
+ } catch (NameNotFoundException e) {
+ // Don't add non-existent packages
+ }
+ }
+ return providers.toArray(new ProviderAndPackageInfo[providers.size()]);
+ }
+
+ /**
+ * Fetch only the currently valid WebView packages.
+ **/
+ public WebViewProviderInfo[] getValidWebViewPackages() {
+ ProviderAndPackageInfo[] providersAndPackageInfos = getValidWebViewPackagesAndInfos();
+ WebViewProviderInfo[] providers =
+ new WebViewProviderInfo[providersAndPackageInfos.length];
+ for(int n = 0; n < providersAndPackageInfos.length; n++) {
+ providers[n] = providersAndPackageInfos[n].provider;
+ }
+ return providers;
+ }
+
+
+ private class ProviderAndPackageInfo {
+ public final WebViewProviderInfo provider;
+ public final PackageInfo packageInfo;
+
+ public ProviderAndPackageInfo(WebViewProviderInfo provider, PackageInfo packageInfo) {
+ this.provider = provider;
+ this.packageInfo = packageInfo;
+ }
+ }
+
+ /**
+ * Returns either the package info of the WebView provider determined in the following way:
+ * If the user has chosen a provider then use that if it is valid,
+ * otherwise use the first package in the webview priority list that is valid.
+ *
+ */
+ private PackageInfo findPreferredWebViewPackage() {
+ ProviderAndPackageInfo[] providers = getValidWebViewPackagesAndInfos();
+
+ String userChosenProvider = mSystemInterface.getUserChosenWebViewProvider(mContext);
+
+ // If the user has chosen provider, use that
+ for (ProviderAndPackageInfo providerAndPackage : providers) {
+ if (providerAndPackage.provider.packageName.equals(userChosenProvider)
+ && isEnabledPackage(providerAndPackage.packageInfo)) {
+ return providerAndPackage.packageInfo;
+ }
+ }
+
+ // User did not choose, or the choice failed; use the most stable provider that is
+ // enabled and available by default (not through user choice).
+ for (ProviderAndPackageInfo providerAndPackage : providers) {
+ if (providerAndPackage.provider.availableByDefault
+ && isEnabledPackage(providerAndPackage.packageInfo)) {
+ return providerAndPackage.packageInfo;
+ }
+ }
+
+ // Could not find any enabled package either, use the most stable provider.
+ for (ProviderAndPackageInfo providerAndPackage : providers) {
+ return providerAndPackage.packageInfo;
+ }
+
+ mAnyWebViewInstalled = false;
+ throw new WebViewFactory.MissingWebViewPackageException(
+ "Could not find a loadable WebView package");
+ }
+
+ public void notifyRelroCreationCompleted() {
+ synchronized (mLock) {
+ mNumRelroCreationsFinished++;
+ checkIfRelrosDoneLocked();
+ }
+ }
+
+ public WebViewProviderResponse waitForAndGetProvider() {
+ PackageInfo webViewPackage = null;
+ final long NS_PER_MS = 1000000;
+ final long timeoutTimeMs = System.nanoTime() / NS_PER_MS + WAIT_TIMEOUT_MS;
+ boolean webViewReady = false;
+ int webViewStatus = WebViewFactory.LIBLOAD_SUCCESS;
+ synchronized (mLock) {
+ webViewReady = webViewIsReadyLocked();
+ while (!webViewReady) {
+ final long timeNowMs = System.nanoTime() / NS_PER_MS;
+ if (timeNowMs >= timeoutTimeMs) break;
+ try {
+ mLock.wait(timeoutTimeMs - timeNowMs);
+ } catch (InterruptedException e) {}
+ webViewReady = webViewIsReadyLocked();
+ }
+ // Make sure we return the provider that was used to create the relro file
+ webViewPackage = mCurrentWebViewPackage;
+ if (webViewReady) {
+ } else if (!mAnyWebViewInstalled) {
+ webViewStatus = WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES;
+ } else {
+ // Either the current relro creation isn't done yet, or the new relro creatioin
+ // hasn't kicked off yet (the last relro creation used an out-of-date WebView).
+ webViewStatus = WebViewFactory.LIBLOAD_FAILED_WAITING_FOR_RELRO;
+ }
+ }
+ if (!webViewReady) Slog.w(TAG, "creating relro file timed out");
+ return new WebViewProviderResponse(webViewPackage, webViewStatus);
+ }
+
+ public String getCurrentWebViewPackageName() {
+ synchronized(mLock) {
+ if (mCurrentWebViewPackage == null)
+ return null;
+ return mCurrentWebViewPackage.packageName;
+ }
+ }
+
+ /**
+ * Returns whether WebView is ready and is not going to go through its preparation phase
+ * again directly.
+ */
+ private boolean webViewIsReadyLocked() {
+ return !mWebViewPackageDirty
+ && (mNumRelroCreationsStarted == mNumRelroCreationsFinished)
+ // The current package might be replaced though we haven't received an intent
+ // declaring this yet, the following flag makes anyone loading WebView to wait in
+ // this case.
+ && mAnyWebViewInstalled;
+ }
+
+ private void checkIfRelrosDoneLocked() {
+ if (mNumRelroCreationsStarted == mNumRelroCreationsFinished) {
+ if (mWebViewPackageDirty) {
+ mWebViewPackageDirty = false;
+ // If we have changed provider since we started the relro creation we need to
+ // redo the whole process using the new package instead.
+ PackageInfo newPackage = findPreferredWebViewPackage();
+ onWebViewProviderChanged(newPackage);
+ } else {
+ mLock.notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Returns whether this provider is valid for use as a WebView provider.
+ */
+ public boolean isValidProvider(WebViewProviderInfo configInfo,
+ PackageInfo packageInfo) {
+ if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0
+ && packageInfo.versionCode < getMinimumVersionCode()
+ && !mSystemInterface.systemIsDebuggable()) {
+ // Non-system package webview providers may be downgraded arbitrarily low, prevent
+ // that by enforcing minimum version code. This check is only enforced for user
+ // builds.
+ return false;
+ }
+ if (providerHasValidSignature(configInfo, packageInfo, mSystemInterface) &&
+ WebViewFactory.getWebViewLibrary(packageInfo.applicationInfo) != null) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Gets the minimum version code allowed for a valid provider. It is the minimum versionCode
+ * of all available-by-default and non-fallback WebView provider packages. If there is no
+ * such WebView provider package on the system, then return -1, which means all positive
+ * versionCode WebView packages are accepted.
+ */
+ private int getMinimumVersionCode() {
+ if (mMinimumVersionCode > 0) {
+ return mMinimumVersionCode;
+ }
+
+ for (WebViewProviderInfo provider : mSystemInterface.getWebViewPackages()) {
+ if (provider.availableByDefault && !provider.isFallback) {
+ try {
+ int versionCode =
+ mSystemInterface.getFactoryPackageVersion(provider.packageName);
+ if (mMinimumVersionCode < 0 || versionCode < mMinimumVersionCode) {
+ mMinimumVersionCode = versionCode;
+ }
+ } catch (NameNotFoundException e) {
+ // Safe to ignore.
+ }
+ }
+ }
+
+ return mMinimumVersionCode;
+ }
+ }
+
+ private static boolean providerHasValidSignature(WebViewProviderInfo provider,
+ PackageInfo packageInfo, SystemInterface systemInterface) {
+ if (systemInterface.systemIsDebuggable()) {
+ return true;
+ }
+ Signature[] packageSignatures;
+ // If no signature is declared, instead check whether the package is included in the
+ // system.
+ if (provider.signatures == null || provider.signatures.length == 0) {
+ return packageInfo.applicationInfo.isSystemApp();
+ }
+ packageSignatures = packageInfo.signatures;
+ if (packageSignatures.length != 1)
+ return false;
+
+ final byte[] packageSignature = packageSignatures[0].toByteArray();
+ // Return whether the package signature matches any of the valid signatures
+ for (String signature : provider.signatures) {
+ final byte[] validSignature = Base64.decode(signature, Base64.DEFAULT);
+ if (Arrays.equals(packageSignature, validSignature))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns whether the given package is enabled.
+ * This state can be changed by the user from Settings->Apps
+ */
+ private static boolean isEnabledPackage(PackageInfo packageInfo) {
+ return packageInfo.applicationInfo.enabled;
+ }
+
+}
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index bae628a..3ef077b 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -1214,7 +1214,10 @@
window.type = windowState.mAttrs.type;
window.layer = windowState.mLayer;
window.token = windowState.mClient.asBinder();
- window.title = windowState.mAttrs.getTitle();
+ window.title = windowState.mAttrs.accessibilityTitle;
+ if (window.title == null) {
+ window.title = windowState.mAttrs.getTitle();
+ }
window.accessibilityIdOfAnchor = windowState.mAttrs.accessibilityIdOfAnchor;
WindowState attachedWindow = windowState.mAttachedWindow;
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 8a9ace7..7b16dbe 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -16,24 +16,17 @@
package com.android.server.wm;
+import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
-import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE;
-import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
-import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
-import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
-import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
-import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
+import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_RESIZE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK;
+import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.H.RESIZE_TASK;
-import static com.android.server.wm.WindowManagerService.H.SHOW_NON_RESIZEABLE_DOCK_TOAST;
-import static android.view.WindowManager.DOCKED_INVALID;
-import static android.view.WindowManager.DOCKED_LEFT;
-import static android.view.WindowManager.DOCKED_RIGHT;
-import static android.view.WindowManager.DOCKED_TOP;
import android.app.ActivityManager.StackId;
import android.content.pm.ActivityInfo;
@@ -44,7 +37,6 @@
import android.view.DisplayInfo;
import android.view.Surface;
-import com.android.internal.R;
import com.android.server.EventLogTags;
import java.io.PrintWriter;
@@ -94,11 +86,6 @@
// Resize mode of the task. See {@link ActivityInfo#resizeMode}
private int mResizeMode;
- // Whether we need to show toast about the app being non-resizeable when it becomes visible.
- // This flag is set when a non-resizeable task is docked (or side-by-side). It's cleared
- // after we show the toast.
- private boolean mShowNonResizeableDockToast;
-
// Whether the task is currently being drag-resized
private boolean mDragResizing;
private int mDragResizeMode;
@@ -118,30 +105,6 @@
return mStack.getDisplayContent();
}
- void setShowNonResizeableDockToast() {
- mShowNonResizeableDockToast = true;
- }
-
- void scheduleShowNonResizeableDockToastIfNeeded() {
- if (!mShowNonResizeableDockToast) {
- return;
- }
- final DisplayContent displayContent = mStack.getDisplayContent();
- // If docked stack is not yet visible, we don't want to show the toast yet,
- // since we need the visible rect of the docked task to position the toast.
- if (displayContent == null || displayContent.getDockedStackLocked() == null) {
- return;
- }
-
- mShowNonResizeableDockToast = false;
-
- if (mResizeMode == RESIZE_MODE_UNRESIZEABLE) {
- final String text =
- mService.mContext.getString(R.string.dock_non_resizeble_failed_to_dock_text);
- mService.mH.obtainMessage(SHOW_NON_RESIZEABLE_DOCK_TOAST, 0, 0, text).sendToTarget();
- }
- }
-
void addAppToken(int addPos, AppWindowToken wtoken, int resizeMode, boolean homeTask) {
final int lastPos = mAppTokens.size();
if (addPos >= lastPos) {
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 3430ac9..446b74b 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -720,9 +720,9 @@
}
} else {
if (splitHorizontally) {
- outBounds.left = position - dockDividerWidth;
+ outBounds.left = position + dockDividerWidth;
} else {
- outBounds.top = position - dockDividerWidth;
+ outBounds.top = position + dockDividerWidth;
}
}
return;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 2af324d..27126e6 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -4940,17 +4940,6 @@
}
}
- public void scheduleShowNonResizeableDockToast(int taskId) {
- synchronized (mWindowMap) {
- Task task = mTaskIdToTask.get(taskId);
- if (task == null) {
- if (DEBUG_STACK) Slog.i(TAG_WM, "scheduleShowToast: could not find taskId=" + taskId);
- return;
- }
- task.setShowNonResizeableDockToast();
- }
- }
-
@Override
public void getStackBounds(int stackId, Rect bounds) {
synchronized (mWindowMap) {
@@ -7635,7 +7624,8 @@
mSafeMode = menuState > 0 || sState > 0 || dpadState > 0 || trackballState > 0
|| volumeDownState > 0;
try {
- if (SystemProperties.getInt(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, 0) != 0) {
+ if (SystemProperties.getInt(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, 0) != 0
+ || SystemProperties.getInt(ShutdownThread.RO_SAFEMODE_PROPERTY, 0) != 0) {
int auditSafeMode = SystemProperties.getInt(ShutdownThread.AUDIT_SAFEMODE_PROPERTY, 0);
if (auditSafeMode == 0) {
@@ -7659,6 +7649,7 @@
if (mSafeMode) {
Log.i(TAG_WM, "SAFE MODE ENABLED (menu=" + menuState + " s=" + sState
+ " dpad=" + dpadState + " trackball=" + trackballState + ")");
+ SystemProperties.set(ShutdownThread.RO_SAFEMODE_PROPERTY, "1");
} else {
Log.i(TAG_WM, "SAFE MODE not enabled");
}
@@ -7770,7 +7761,6 @@
public static final int RESIZE_TASK = 43;
public static final int TWO_FINGER_SCROLL_START = 44;
- public static final int SHOW_NON_RESIZEABLE_DOCK_TOAST = 45;
public static final int WINDOW_REPLACEMENT_TIMEOUT = 46;
@@ -8338,16 +8328,6 @@
}
}
break;
- case SHOW_NON_RESIZEABLE_DOCK_TOAST: {
- final Toast toast = Toast.makeText(
- mContext, (String) msg.obj, Toast.LENGTH_SHORT);
- final int gravity = toast.getGravity();
- final int xOffset = toast.getXOffset() + msg.arg1;
- final int yOffset = toast.getYOffset() + msg.arg2;
- toast.setGravity(gravity, xOffset, yOffset);
- toast.show();
- }
- break;
case WINDOW_REPLACEMENT_TIMEOUT: {
final AppWindowToken token = (AppWindowToken) msg.obj;
synchronized (mWindowMap) {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index ddfc022..7f40079 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -734,8 +734,10 @@
layoutYDiff = !mInsetFrame.isEmpty() ? mInsetFrame.top - mContainingFrame.top : 0;
layoutContainingFrame = !mInsetFrame.isEmpty() ? mInsetFrame : mContainingFrame;
subtractInsets(mDisplayFrame, layoutContainingFrame, df);
- subtractInsets(mContainingFrame, layoutContainingFrame, pf);
- subtractInsets(mInsetFrame, layoutContainingFrame, pf);
+ if (!layoutInParentFrame()) {
+ subtractInsets(mContainingFrame, layoutContainingFrame, pf);
+ subtractInsets(mInsetFrame, layoutContainingFrame, pf);
+ }
layoutDisplayFrame = df;
layoutDisplayFrame.intersect(layoutContainingFrame);
}
@@ -2353,6 +2355,10 @@
return mDragResizing;
}
+ boolean isDockedResizing() {
+ return mDragResizing && getResizeMode() == DRAG_RESIZE_MODE_DOCKED_DIVIDER;
+ }
+
void dump(PrintWriter pw, String prefix, boolean dumpAll) {
final TaskStack stack = getStack();
pw.print(prefix); pw.print("mDisplayId="); pw.print(getDisplayId());
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 34452ee..9c25f63 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1125,13 +1125,21 @@
final int top = w.mYOffset + w.mFrame.top;
// Initialize the decor rect to the entire frame.
- if (w.isDragResizing() && w.getResizeMode() == DRAG_RESIZE_MODE_DOCKED_DIVIDER) {
+ if (w.isDockedResizing() ||
+ (w.isChildWindow() && w.mAttachedWindow.isDockedResizing())) {
// If we are resizing with the divider, the task bounds might be smaller than the
// stack bounds. The system decor is used to clip to the task bounds, which we don't
// want in this case in order to avoid holes.
+ //
+ // We take care to not shrink the width, for surfaces which are larger than
+ // the display region. Of course this area will not eventually be visible
+ // but if we truncate the width now, we will calculate incorrectly
+ // when adjusting to the stack bounds.
final DisplayInfo displayInfo = w.getDisplayContent().getDisplayInfo();
- mSystemDecorRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
+ mSystemDecorRect.set(0, 0,
+ Math.max(width, displayInfo.logicalWidth),
+ Math.max(height, displayInfo.logicalHeight));
} else {
mSystemDecorRect.set(0, 0, width, height);
}
@@ -1483,11 +1491,6 @@
}
}
w.mToken.hasVisible = true;
-
- final Task task = w.getTask();
- if (task != null) {
- task.scheduleShowNonResizeableDockToastIfNeeded();
- }
}
}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index fdea84b..72eebb5 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -8078,7 +8078,8 @@
}
}
}
- return null;
+ // We're not specifying the device admin because there isn't one.
+ return intent;
}
}
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
index 0da1bb1..6c8be39 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
@@ -86,6 +86,155 @@
}
private Test[] mTests = new Test[] {
+ new Test("Post a group") {
+ public void run()
+ {
+ Notification n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("Min priority group 1")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_MIN)
+ .setGroup("group1")
+ .build();
+ mNM.notify(6000, n);
+ n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("low priority group 1")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_LOW)
+ .setGroup("group1")
+ .build();
+ mNM.notify(6001, n);
+ n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("default priority group 1")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_DEFAULT)
+ .setGroup("group1")
+ .build();
+ mNM.notify(6002, n);
+ n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("summary group 1")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_MIN)
+ .setGroup("group1")
+ .setGroupSummary(true)
+ .build();
+ mNM.notify(6003, n);
+ }
+ },
+ new Test("Post a group (2) w/o summary") {
+ public void run()
+ {
+ Notification n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("Min priority group 2")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_MIN)
+ .setGroup("group2")
+ .build();
+ mNM.notify(6100, n);
+ n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("low priority group 2")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_LOW)
+ .setGroup("group2")
+ .build();
+ mNM.notify(6101, n);
+ n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("default priority group 2")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_DEFAULT)
+ .setGroup("group2")
+ .build();
+ mNM.notify(6102, n);
+ }
+ },
+ new Test("Summary for group 2") {
+ public void run()
+ {
+ Notification n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("summary group 2")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_MIN)
+ .setGroup("group2")
+ .setGroupSummary(true)
+ .build();
+ mNM.notify(6103, n);
+ }
+ },
+ new Test("Group up public-secret") {
+ public void run()
+ {
+ Notification n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("public notification")
+ .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
+ .setPriority(Notification.PRIORITY_DEFAULT)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
+ .setGroup("public-secret")
+ .build();
+ mNM.notify("public", 7009, n);
+ n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("private only notification")
+ .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
+ .setPriority(Notification.PRIORITY_DEFAULT)
+ .setVisibility(Notification.VISIBILITY_PRIVATE)
+ .setGroup("public-secret")
+ .build();
+ mNM.notify("no public", 7010, n);
+ n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("private version of notification")
+ .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
+ .setPriority(Notification.PRIORITY_DEFAULT)
+ .setVisibility(Notification.VISIBILITY_PRIVATE)
+ .setGroup("public-secret")
+ .setPublicVersion(new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("public notification of private notification")
+ .setPriority(Notification.PRIORITY_DEFAULT)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
+ .build())
+ .build();
+ mNM.notify("priv with pub", 7011, n);
+ n = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("secret notification")
+ .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
+ .setPriority(Notification.PRIORITY_DEFAULT)
+ .setVisibility(Notification.VISIBILITY_SECRET)
+ .setGroup("public-secret")
+ .build();
+ mNM.notify("secret", 7012, n);
+
+ Notification s = new Notification.Builder(NotificationTestList.this)
+ .setSmallIcon(R.drawable.icon2)
+ .setContentTitle("summary group public-secret")
+ .setLights(0xff0000ff, 1, 0)
+ .setPriority(Notification.PRIORITY_MIN)
+ .setGroup("public-secret")
+ .setGroupSummary(true)
+ .build();
+ mNM.notify(7113, s);
+ }
+ },
+ new Test("Cancel priority autogroup") {
+ public void run()
+ {
+ try {
+ mNM.cancel(Integer.MAX_VALUE);
+ } catch (Exception e) {
+ Toast.makeText(NotificationTestList.this, "cancel failed (yay)",
+ Toast.LENGTH_LONG).show();
+ }
+ }
+ },
new Test("Min priority") {
public void run()
{
@@ -95,7 +244,7 @@
.setLights(0xff0000ff, 1, 0)
.setPriority(Notification.PRIORITY_MIN)
.build();
- mNM.notify(7000, n);
+ mNM.notify("min", 7000, n);
}
},
new Test("Min priority, high pri flag") {
@@ -123,7 +272,7 @@
.setLights(0xff0000ff, 1, 0)
.setPriority(Notification.PRIORITY_LOW)
.build();
- mNM.notify(7002, n);
+ mNM.notify("low", 7002, n);
}
},
new Test("Default priority") {
@@ -135,7 +284,7 @@
.setLights(0xff0000ff, 1, 0)
.setPriority(Notification.PRIORITY_DEFAULT)
.build();
- mNM.notify(7004, n);
+ mNM.notify("default", 7004, n);
}
},
new Test("High priority") {
@@ -150,7 +299,7 @@
getPackageName() + "/raw/ringer"))
.setPriority(Notification.PRIORITY_HIGH)
.build();
- mNM.notify(7006, n);
+ mNM.notify("high", 7006, n);
}
},
new Test("Max priority") {
@@ -166,7 +315,7 @@
.setPriority(Notification.PRIORITY_MAX)
.setFullScreenIntent(makeIntent2(), false)
.build();
- mNM.notify(7007, n);
+ mNM.notify("max", 7007, n);
}
},
new Test("Max priority with delay") {
@@ -199,7 +348,7 @@
.setPriority(Notification.PRIORITY_DEFAULT)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.build();
- mNM.notify(7009, n);
+ mNM.notify("public", 7009, n);
}
},
new Test("private notification, no public") {
@@ -212,7 +361,7 @@
.setPriority(Notification.PRIORITY_DEFAULT)
.setVisibility(Notification.VISIBILITY_PRIVATE)
.build();
- mNM.notify(7010, n);
+ mNM.notify("no public", 7010, n);
}
},
new Test("private notification, has public") {
@@ -231,7 +380,7 @@
.setVisibility(Notification.VISIBILITY_PUBLIC)
.build())
.build();
- mNM.notify(7011, n);
+ mNM.notify("priv with pub", 7011, n);
}
},
new Test("secret notification") {
@@ -244,7 +393,7 @@
.setPriority(Notification.PRIORITY_DEFAULT)
.setVisibility(Notification.VISIBILITY_SECRET)
.build();
- mNM.notify(7012, n);
+ mNM.notify("secret", 7012, n);
}
},
new Test("Off") {
diff --git a/tools/aapt2/java/AnnotationProcessor.cpp b/tools/aapt2/java/AnnotationProcessor.cpp
index ba74439..b7e7f90 100644
--- a/tools/aapt2/java/AnnotationProcessor.cpp
+++ b/tools/aapt2/java/AnnotationProcessor.cpp
@@ -21,7 +21,7 @@
namespace aapt {
-void AnnotationProcessor::appendCommentLine(const std::string& comment) {
+void AnnotationProcessor::appendCommentLine(std::string& comment) {
static const std::string sDeprecated = "@deprecated";
static const std::string sSystemApi = "@SystemApi";
@@ -29,8 +29,14 @@
mAnnotationBitMask |= kDeprecated;
}
- if (comment.find(sSystemApi) != std::string::npos) {
+ std::string::size_type idx = comment.find(sSystemApi);
+ if (idx != std::string::npos) {
mAnnotationBitMask |= kSystemApi;
+ comment.erase(comment.begin() + idx, comment.begin() + idx + sSystemApi.size());
+ }
+
+ if (util::trimWhitespace(comment).empty()) {
+ return;
}
if (!mHasComments) {
@@ -46,7 +52,8 @@
for (StringPiece16 line : util::tokenize(comment, u'\n')) {
line = util::trimWhitespace(line);
if (!line.empty()) {
- appendCommentLine(util::utf16ToUtf8(line));
+ std::string utf8Line = util::utf16ToUtf8(line);
+ appendCommentLine(utf8Line);
}
}
}
@@ -55,7 +62,8 @@
for (StringPiece line : util::tokenize(comment, '\n')) {
line = util::trimWhitespace(line);
if (!line.empty()) {
- appendCommentLine(line.toString());
+ std::string utf8Line = line.toString();
+ appendCommentLine(utf8Line);
}
}
}
diff --git a/tools/aapt2/java/AnnotationProcessor.h b/tools/aapt2/java/AnnotationProcessor.h
index 0fc5b08..8309dd9 100644
--- a/tools/aapt2/java/AnnotationProcessor.h
+++ b/tools/aapt2/java/AnnotationProcessor.h
@@ -43,7 +43,6 @@
* /\*
* * This is meant to be hidden because
* * It is system api. Also it is @deprecated
- * * @SystemApi
* *\/
*
* Output Annotations:
@@ -79,7 +78,7 @@
bool mHasComments = false;
uint32_t mAnnotationBitMask = 0;
- void appendCommentLine(const std::string& line);
+ void appendCommentLine(std::string& line);
};
} // namespace aapt
diff --git a/tools/aapt2/java/AnnotationProcessor_test.cpp b/tools/aapt2/java/AnnotationProcessor_test.cpp
index d3860a5..5a39add 100644
--- a/tools/aapt2/java/AnnotationProcessor_test.cpp
+++ b/tools/aapt2/java/AnnotationProcessor_test.cpp
@@ -14,59 +14,18 @@
* limitations under the License.
*/
-#include "ResourceParser.h"
-#include "ResourceTable.h"
-#include "ResourceValues.h"
#include "java/AnnotationProcessor.h"
-#include "test/Builders.h"
-#include "test/Context.h"
-#include "xml/XmlPullParser.h"
-
-#include <gtest/gtest.h>
+#include "test/Test.h"
namespace aapt {
-struct AnnotationProcessorTest : public ::testing::Test {
- std::unique_ptr<IAaptContext> mContext;
- ResourceTable mTable;
-
- void SetUp() override {
- mContext = test::ContextBuilder().build();
- }
-
- ::testing::AssertionResult parse(const StringPiece& str) {
- ResourceParserOptions options;
- ResourceParser parser(mContext->getDiagnostics(), &mTable, Source{}, ConfigDescription{},
- options);
- std::stringstream in;
- in << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" << str;
- xml::XmlPullParser xmlParser(in);
- if (parser.parse(&xmlParser)) {
- return ::testing::AssertionSuccess();
- }
- return ::testing::AssertionFailure();
- }
-};
-
-TEST_F(AnnotationProcessorTest, EmitsDeprecated) {
- const char* xmlInput = R"EOF(
- <resources>
- <declare-styleable name="foo">
- <!-- Some comment, and it should contain
- a marker word, something that marks
- this resource as nor needed.
- {@deprecated That's the marker! } -->
- <attr name="autoText" format="boolean" />
- </declare-styleable>
- </resources>)EOF";
-
- ASSERT_TRUE(parse(xmlInput));
-
- Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/autoText");
- ASSERT_NE(nullptr, attr);
+TEST(AnnotationProcessorTest, EmitsDeprecated) {
+ const char* comment = "Some comment, and it should contain a marker word, "
+ "something that marks this resource as nor needed. "
+ "{@deprecated That's the marker! }";
AnnotationProcessor processor;
- processor.appendComment(attr->getComment());
+ processor.appendComment(comment);
std::stringstream result;
processor.writeToStream(&result, "");
@@ -75,6 +34,19 @@
EXPECT_NE(std::string::npos, annotations.find("@Deprecated"));
}
+TEST(AnnotationProcessorTest, EmitsSystemApiAnnotationAndRemovesFromComment) {
+ AnnotationProcessor processor;
+ processor.appendComment("@SystemApi This is a system API");
+
+ std::stringstream result;
+ processor.writeToStream(&result, "");
+ std::string annotations = result.str();
+
+ EXPECT_NE(std::string::npos, annotations.find("@android.annotation.SystemApi"));
+ EXPECT_EQ(std::string::npos, annotations.find("@SystemApi"));
+ EXPECT_NE(std::string::npos, annotations.find("This is a system API"));
+}
+
} // namespace aapt
diff --git a/tools/aapt2/java/ClassDefinition.h b/tools/aapt2/java/ClassDefinition.h
index 53e0f6f..d45328f 100644
--- a/tools/aapt2/java/ClassDefinition.h
+++ b/tools/aapt2/java/ClassDefinition.h
@@ -125,7 +125,7 @@
void writeToStream(const StringPiece& prefix, bool final, std::ostream* out) const override {
ClassMember::writeToStream(prefix, final, out);
- *out << "public static final int[] " << mName << "={";
+ *out << prefix << "public static final int[] " << mName << "={";
const auto begin = mElements.begin();
const auto end = mElements.end();
diff --git a/tools/aapt2/java/JavaClassGenerator.cpp b/tools/aapt2/java/JavaClassGenerator.cpp
index 32b8600..24347a1 100644
--- a/tools/aapt2/java/JavaClassGenerator.cpp
+++ b/tools/aapt2/java/JavaClassGenerator.cpp
@@ -188,8 +188,8 @@
struct StyleableAttr {
const Reference* attrRef;
- std::shared_ptr<Attribute> attribute;
std::string fieldName;
+ std::unique_ptr<SymbolTable::Symbol> symbol;
};
static bool lessStyleableAttr(const StyleableAttr& lhs, const StyleableAttr& rhs) {
@@ -245,8 +245,9 @@
// legal values for this attribute.
const SymbolTable::Symbol* symbol = mContext->getExternalSymbols()->findByReference(
mangledReference);
- if (symbol) {
- styleableAttr.attribute = symbol->attribute;
+ if (symbol && symbol->attribute) {
+ // Copy the symbol data structure because the returned instance can be destroyed.
+ styleableAttr.symbol = util::make_unique<SymbolTable::Symbol>(*symbol);
}
sortedAttributes.push_back(std::move(styleableAttr));
}
@@ -273,6 +274,16 @@
"<tr><th>Attribute</th><th>Description</th></tr>\n";
for (const StyleableAttr& entry : sortedAttributes) {
+ if (!entry.symbol) {
+ continue;
+ }
+
+ if (mOptions.types == JavaClassGeneratorOptions::SymbolTypes::kPublic &&
+ !entry.symbol->isPublic) {
+ // Don't write entries for non-public attributes.
+ continue;
+ }
+
const ResourceName& attrName = entry.attrRef->name.value();
styleableComment << "<tr><td>";
styleableComment << "<code>{@link #"
@@ -284,14 +295,30 @@
styleableComment << "</td>";
styleableComment << "<td>";
- if (entry.attribute) {
- styleableComment << entry.attribute->getComment();
+
+ // Only use the comment up until the first '.'. This is to stay compatible with
+ // the way old AAPT did it (presumably to keep it short and to avoid including
+ // annotations like @hide which would affect this Styleable).
+ StringPiece16 attrCommentLine = entry.symbol->attribute->getComment();
+ auto iter = std::find(attrCommentLine.begin(), attrCommentLine.end(), u'.');
+ if (iter != attrCommentLine.end()) {
+ attrCommentLine = attrCommentLine.substr(
+ 0, (iter - attrCommentLine.begin()) + 1);
}
- styleableComment << "</td></tr>\n";
+ styleableComment << attrCommentLine << "</td></tr>\n";
}
styleableComment << "</table>\n";
for (const StyleableAttr& entry : sortedAttributes) {
+ if (!entry.symbol) {
+ continue;
+ }
+
+ if (mOptions.types == JavaClassGeneratorOptions::SymbolTypes::kPublic &&
+ !entry.symbol->isPublic) {
+ // Don't write entries for non-public attributes.
+ continue;
+ }
styleableComment << "@see #" << entry.fieldName << "\n";
}
@@ -310,6 +337,17 @@
// Now we emit the indices into the array.
for (size_t i = 0; i < attrCount; i++) {
const StyleableAttr& styleableAttr = sortedAttributes[i];
+
+ if (!styleableAttr.symbol) {
+ continue;
+ }
+
+ if (mOptions.types == JavaClassGeneratorOptions::SymbolTypes::kPublic &&
+ !styleableAttr.symbol->isPublic) {
+ // Don't write entries for non-public attributes.
+ continue;
+ }
+
const ResourceName& attrName = styleableAttr.attrRef->name.value();
StringPiece16 packageName = attrName.package;
@@ -323,8 +361,8 @@
AnnotationProcessor* attrProcessor = indexMember->getCommentBuilder();
StringPiece16 comment = styleableAttr.attrRef->getComment();
- if (styleableAttr.attribute && comment.empty()) {
- comment = styleableAttr.attribute->getComment();
+ if (styleableAttr.symbol->attribute && comment.empty()) {
+ comment = styleableAttr.symbol->attribute->getComment();
}
if (!comment.empty()) {
@@ -342,10 +380,8 @@
attrProcessor->appendNewLine();
- if (styleableAttr.attribute) {
- addAttributeFormatDoc(attrProcessor, styleableAttr.attribute.get());
- attrProcessor->appendNewLine();
- }
+ addAttributeFormatDoc(attrProcessor, styleableAttr.symbol->attribute.get());
+ attrProcessor->appendNewLine();
std::stringstream doclavaName;
doclavaName << "@attr name " << packageName << ":" << attrName.entry;;
diff --git a/tools/aapt2/java/JavaClassGenerator_test.cpp b/tools/aapt2/java/JavaClassGenerator_test.cpp
index 370e78a..7d0aa83 100644
--- a/tools/aapt2/java/JavaClassGenerator_test.cpp
+++ b/tools/aapt2/java/JavaClassGenerator_test.cpp
@@ -43,7 +43,8 @@
std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder()
.setPackageId(u"android", 0x01)
.addSimple(u"@android:id/hey-man", ResourceId(0x01020000))
- .addSimple(u"@android:attr/cool.attr", ResourceId(0x01010000))
+ .addValue(u"@android:attr/cool.attr", ResourceId(0x01010000),
+ test::AttributeBuilder(false).build())
.addValue(u"@android:styleable/hey.dude", ResourceId(0x01030000),
test::StyleableBuilder()
.addItem(u"@android:attr/cool.attr", ResourceId(0x01010000))
@@ -199,8 +200,10 @@
std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder()
.setPackageId(u"android", 0x01)
.setPackageId(u"com.lib", 0x02)
- .addSimple(u"@android:attr/bar", ResourceId(0x01010000))
- .addSimple(u"@com.lib:attr/bar", ResourceId(0x02010000))
+ .addValue(u"@android:attr/bar", ResourceId(0x01010000),
+ test::AttributeBuilder(false).build())
+ .addValue(u"@com.lib:attr/bar", ResourceId(0x02010000),
+ test::AttributeBuilder(false).build())
.addValue(u"@android:styleable/foo", ResourceId(0x01030000),
test::StyleableBuilder()
.addItem(u"@android:attr/bar", ResourceId(0x01010000))
diff --git a/tools/aapt2/java/ManifestClassGenerator_test.cpp b/tools/aapt2/java/ManifestClassGenerator_test.cpp
index e7210db..d3bca70 100644
--- a/tools/aapt2/java/ManifestClassGenerator_test.cpp
+++ b/tools/aapt2/java/ManifestClassGenerator_test.cpp
@@ -126,7 +126,6 @@
R"EOF( /**
* This is a private permission for system only!
* @hide
- * @SystemApi
*/
@android.annotation.SystemApi
public static final String SECRET="android.permission.SECRET";)EOF";
diff --git a/tools/aapt2/process/SymbolTable.h b/tools/aapt2/process/SymbolTable.h
index 0a6a4a5..e684bb0 100644
--- a/tools/aapt2/process/SymbolTable.h
+++ b/tools/aapt2/process/SymbolTable.h
@@ -51,9 +51,28 @@
class SymbolTable {
public:
struct Symbol {
+ Symbol() : Symbol(Maybe<ResourceId>{}) {
+ }
+
+ Symbol(const Maybe<ResourceId>& i) : Symbol(i, nullptr) {
+ }
+
+ Symbol(const Maybe<ResourceId>& i, const std::shared_ptr<Attribute>& attr) :
+ Symbol(i, attr, false) {
+ }
+
+ Symbol(const Maybe<ResourceId>& i, const std::shared_ptr<Attribute>& attr, bool pub) :
+ id(i), attribute(attr), isPublic(pub) {
+ }
+
+ Symbol(const Symbol&) = default;
+ Symbol(Symbol&&) = default;
+ Symbol& operator=(const Symbol&) = default;
+ Symbol& operator=(Symbol&&) = default;
+
Maybe<ResourceId> id;
std::shared_ptr<Attribute> attribute;
- bool isPublic;
+ bool isPublic = false;
};
SymbolTable() : mCache(200), mIdCache(200) {
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java
index 73ddbbc..f8c1ea3 100644
--- a/wifi/java/android/net/wifi/WifiScanner.java
+++ b/wifi/java/android/net/wifi/WifiScanner.java
@@ -810,19 +810,17 @@
}
/**
* Stop an ongoing wifi PNO scan
- * @param pnoSettings specifies various parameters for PNO; for more information look at
- * {@link PnoSettings}
* @param listener specifies which scan to cancel; must be same object as passed in {@link
* #startPnoScan}
* TODO(rpius): Check if we can remove pnoSettings param in stop.
* {@hide}
*/
- public void stopPnoScan(PnoSettings pnoSettings, ScanListener listener) {
+ public void stopPnoScan(ScanListener listener) {
Preconditions.checkNotNull(listener, "listener cannot be null");
int key = removeListener(listener);
if (key == INVALID_KEY) return;
validateChannel();
- sAsyncChannel.sendMessage(CMD_STOP_PNO_SCAN, 0, key, pnoSettings);
+ sAsyncChannel.sendMessage(CMD_STOP_PNO_SCAN, 0, key);
}
/** specifies information about an access point of interest */