Merge "Add scaffolds for performance tests of DocumentsUI" into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index 7f6ca37..014ae35 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -2668,6 +2668,8 @@
field public static final int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN = 7; // 0x7
field public static final java.lang.String SERVICE_INTERFACE = "android.accessibilityservice.AccessibilityService";
field public static final java.lang.String SERVICE_META_DATA = "android.accessibilityservice";
+ field public static final int SHOW_MODE_AUTO = 0; // 0x0
+ field public static final int SHOW_MODE_HIDDEN = 1; // 0x1
}
public static abstract class AccessibilityService.GestureResultCallback {
@@ -4132,7 +4134,6 @@
method public int describeContents();
method public android.net.Uri getConditionId();
method public long getCreationTime();
- method public java.lang.String getId();
method public int getInterruptionFilter();
method public java.lang.String getName();
method public android.content.ComponentName getOwner();
@@ -5228,14 +5229,14 @@
}
public class NotificationManager {
- method public android.app.AutomaticZenRule addAutomaticZenRule(android.app.AutomaticZenRule);
+ method public java.lang.String addAutomaticZenRule(android.app.AutomaticZenRule);
method public boolean areNotificationsEnabled();
method public void cancel(int);
method public void cancel(java.lang.String, int);
method public void cancelAll();
method public android.service.notification.StatusBarNotification[] getActiveNotifications();
method public android.app.AutomaticZenRule getAutomaticZenRule(java.lang.String);
- method public java.util.List<android.app.AutomaticZenRule> getAutomaticZenRules();
+ method public java.util.Map<java.lang.String, android.app.AutomaticZenRule> getAutomaticZenRules();
method public final int getCurrentInterruptionFilter();
method public int getImportance();
method public android.app.NotificationManager.Policy getNotificationPolicy();
@@ -5245,7 +5246,7 @@
method public boolean removeAutomaticZenRule(java.lang.String);
method public final void setInterruptionFilter(int);
method public void setNotificationPolicy(android.app.NotificationManager.Policy);
- method public boolean updateAutomaticZenRule(android.app.AutomaticZenRule);
+ method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED";
@@ -7335,15 +7336,6 @@
field public static final int TYPE_SCO = 2; // 0x2
}
- public final class OobData implements android.os.Parcelable {
- ctor public OobData();
- method public int describeContents();
- method public byte[] getSecurityManagerTk();
- method public void setSecurityManagerTk(byte[]);
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.bluetooth.OobData> CREATOR;
- }
-
}
package android.bluetooth.le {
@@ -20660,6 +20652,7 @@
field public static final int HEVCMainTierLevel62 = 16777216; // 0x1000000
field public static final int HEVCProfileMain = 1; // 0x1
field public static final int HEVCProfileMain10 = 2; // 0x2
+ field public static final int HEVCProfileMain10HDR10 = 4096; // 0x1000
field public static final int MPEG2LevelH14 = 2; // 0x2
field public static final int MPEG2LevelHL = 3; // 0x3
field public static final int MPEG2LevelLL = 0; // 0x0
@@ -22976,7 +22969,7 @@
}
public static final class TvInputInfo.Builder {
- ctor public TvInputInfo.Builder(android.content.Context, java.lang.Class<?>);
+ ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
method public android.media.tv.TvInputInfo.Builder setTunerCount(int);
@@ -23044,7 +23037,7 @@
ctor public TvInputService.RecordingSession(android.content.Context);
method public void notifyError(int);
method public void notifyRecordingStopped(android.net.Uri);
- method public void notifyTuned();
+ method public void notifyTuned(android.net.Uri);
method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
@@ -23103,7 +23096,7 @@
method public void onDisconnected(java.lang.String);
method public void onError(int);
method public void onRecordingStopped(android.net.Uri);
- method public void onTuned();
+ method public void onTuned(android.net.Uri);
}
public final class TvTrackInfo implements android.os.Parcelable {
@@ -34542,7 +34535,7 @@
method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
method public final void requestInterruptionFilter(int);
method public final void requestListenerHints(int);
- method public static final void requestRebind(android.content.ComponentName) throws android.os.RemoteException;
+ 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 java.lang.String CATEGORY_VR_NOTIFICATIONS = "android.intent.category.vr.notifications";
@@ -36422,7 +36415,7 @@
method public boolean handleMmi(java.lang.String, android.telecom.PhoneAccountHandle);
method public boolean isInCall();
method public boolean isVoiceMailNumber(android.telecom.PhoneAccountHandle, java.lang.String);
- method public void launchManageBlockedNumbersActivity();
+ method public deprecated void launchManageBlockedNumbersActivity();
method public void placeCall(android.net.Uri, android.os.Bundle);
method public void registerPhoneAccount(android.telecom.PhoneAccount);
method public void showInCallScreen(boolean);
@@ -50674,6 +50667,7 @@
}
public abstract interface Iterable {
+ method public default void forEach(java.util.function.Consumer<? super T>);
method public abstract java.util.Iterator<T> iterator();
}
@@ -54149,6 +54143,7 @@
public abstract class Provider extends java.util.Properties {
ctor protected Provider(java.lang.String, double, java.lang.String);
+ method public synchronized void forEach(java.util.function.BiConsumer<? super java.lang.Object, ? super java.lang.Object>);
method public java.lang.String getInfo();
method public java.lang.String getName();
method public synchronized java.security.Provider.Service getService(java.lang.String, java.lang.String);
@@ -57098,6 +57093,7 @@
ctor public ArrayList(java.util.Collection<? extends E>);
method public java.lang.Object clone();
method public void ensureCapacity(int);
+ method public void forEach(java.util.function.Consumer<? super E>);
method public E get(int);
method public int size();
method public void trimToSize();
@@ -57661,6 +57657,7 @@
ctor public HashMap(java.util.Map<? extends K, ? extends V>);
method public java.lang.Object clone();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
public class HashSet extends java.util.AbstractSet implements java.lang.Cloneable java.io.Serializable java.util.Set {
@@ -57685,6 +57682,7 @@
method public boolean containsValue(java.lang.Object);
method public synchronized java.util.Enumeration<V> elements();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public synchronized void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public synchronized V get(java.lang.Object);
method public synchronized boolean isEmpty();
method public java.util.Set<K> keySet();
@@ -57703,6 +57701,7 @@
ctor public IdentityHashMap(java.util.Map<? extends K, ? extends V>);
method public java.lang.Object clone();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
public class IllegalFormatCodePointException extends java.util.IllegalFormatException {
@@ -57942,6 +57941,7 @@
method public abstract boolean containsValue(java.lang.Object);
method public abstract java.util.Set<java.util.Map.Entry<K, V>> entrySet();
method public abstract boolean equals(java.lang.Object);
+ method public default void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public abstract V get(java.lang.Object);
method public abstract int hashCode();
method public abstract boolean isEmpty();
@@ -58403,6 +58403,7 @@
method public K firstKey();
method public java.util.Map.Entry<K, V> floorEntry(K);
method public K floorKey(K);
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public java.util.NavigableMap<K, V> headMap(K, boolean);
method public java.util.SortedMap<K, V> headMap(K);
method public java.util.Map.Entry<K, V> higherEntry(K);
@@ -58485,6 +58486,7 @@
method public java.util.Enumeration<E> elements();
method public synchronized void ensureCapacity(int);
method public synchronized E firstElement();
+ method public synchronized void forEach(java.util.function.Consumer<? super E>);
method public synchronized E get(int);
method public synchronized int indexOf(java.lang.Object, int);
method public synchronized void insertElementAt(E, int);
@@ -58508,6 +58510,7 @@
ctor public WeakHashMap();
ctor public WeakHashMap(java.util.Map<? extends K, ? extends V>);
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 759876f..fc252ce 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -2770,6 +2770,8 @@
field public static final int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN = 7; // 0x7
field public static final java.lang.String SERVICE_INTERFACE = "android.accessibilityservice.AccessibilityService";
field public static final java.lang.String SERVICE_META_DATA = "android.accessibilityservice";
+ field public static final int SHOW_MODE_AUTO = 0; // 0x0
+ field public static final int SHOW_MODE_HIDDEN = 1; // 0x1
}
public static abstract class AccessibilityService.GestureResultCallback {
@@ -4258,7 +4260,6 @@
method public int describeContents();
method public android.net.Uri getConditionId();
method public long getCreationTime();
- method public java.lang.String getId();
method public int getInterruptionFilter();
method public java.lang.String getName();
method public android.content.ComponentName getOwner();
@@ -5360,14 +5361,14 @@
}
public class NotificationManager {
- method public android.app.AutomaticZenRule addAutomaticZenRule(android.app.AutomaticZenRule);
+ method public java.lang.String addAutomaticZenRule(android.app.AutomaticZenRule);
method public boolean areNotificationsEnabled();
method public void cancel(int);
method public void cancel(java.lang.String, int);
method public void cancelAll();
method public android.service.notification.StatusBarNotification[] getActiveNotifications();
method public android.app.AutomaticZenRule getAutomaticZenRule(java.lang.String);
- method public java.util.List<android.app.AutomaticZenRule> getAutomaticZenRules();
+ method public java.util.Map<java.lang.String, android.app.AutomaticZenRule> getAutomaticZenRules();
method public final int getCurrentInterruptionFilter();
method public int getImportance();
method public android.app.NotificationManager.Policy getNotificationPolicy();
@@ -5377,7 +5378,7 @@
method public boolean removeAutomaticZenRule(java.lang.String);
method public final void setInterruptionFilter(int);
method public void setNotificationPolicy(android.app.NotificationManager.Policy);
- method public boolean updateAutomaticZenRule(android.app.AutomaticZenRule);
+ method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED";
@@ -7610,15 +7611,6 @@
field public static final int TYPE_SCO = 2; // 0x2
}
- public final class OobData implements android.os.Parcelable {
- ctor public OobData();
- method public int describeContents();
- method public byte[] getSecurityManagerTk();
- method public void setSecurityManagerTk(byte[]);
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.bluetooth.OobData> CREATOR;
- }
-
}
package android.bluetooth.le {
@@ -9707,25 +9699,6 @@
field public int reqTouchScreen;
}
- public deprecated class ContainerEncryptionParams implements android.os.Parcelable {
- ctor public ContainerEncryptionParams(java.lang.String, java.security.spec.AlgorithmParameterSpec, javax.crypto.SecretKey) throws java.security.InvalidAlgorithmParameterException;
- ctor public ContainerEncryptionParams(java.lang.String, java.security.spec.AlgorithmParameterSpec, javax.crypto.SecretKey, java.lang.String, java.security.spec.AlgorithmParameterSpec, javax.crypto.SecretKey, byte[], long, long, long) throws java.security.InvalidAlgorithmParameterException;
- method public int describeContents();
- method public long getAuthenticatedDataStart();
- method public long getDataEnd();
- method public long getEncryptedDataStart();
- method public java.lang.String getEncryptionAlgorithm();
- method public javax.crypto.SecretKey getEncryptionKey();
- method public java.security.spec.AlgorithmParameterSpec getEncryptionSpec();
- method public java.lang.String getMacAlgorithm();
- method public javax.crypto.SecretKey getMacKey();
- method public java.security.spec.AlgorithmParameterSpec getMacSpec();
- method public byte[] getMacTag();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.content.pm.ContainerEncryptionParams> CREATOR;
- field protected static final java.lang.String TAG = "ContainerEncryptionParams";
- }
-
public final class EphemeralResolveInfo implements android.os.Parcelable {
ctor public EphemeralResolveInfo(android.net.Uri, java.lang.String, java.util.List<android.content.IntentFilter>);
method public int describeContents();
@@ -9955,6 +9928,7 @@
method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);
method public android.graphics.drawable.Drawable loadLogo(android.content.pm.PackageManager);
+ method public java.lang.CharSequence loadSafeLabel(android.content.pm.PackageManager);
method public android.graphics.drawable.Drawable loadUnbadgedIcon(android.content.pm.PackageManager);
method public android.content.res.XmlResourceParser loadXmlMetaData(android.content.pm.PackageManager, java.lang.String);
method public void writeToParcel(android.os.Parcel, int);
@@ -22168,6 +22142,7 @@
field public static final int HEVCMainTierLevel62 = 16777216; // 0x1000000
field public static final int HEVCProfileMain = 1; // 0x1
field public static final int HEVCProfileMain10 = 2; // 0x2
+ field public static final int HEVCProfileMain10HDR10 = 4096; // 0x1000
field public static final int MPEG2LevelH14 = 2; // 0x2
field public static final int MPEG2LevelHL = 3; // 0x3
field public static final int MPEG2LevelLL = 0; // 0x0
@@ -24663,7 +24638,7 @@
}
public static final class TvInputInfo.Builder {
- ctor public TvInputInfo.Builder(android.content.Context, java.lang.Class<?>);
+ ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
method public android.media.tv.TvInputInfo.Builder setHdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo);
@@ -24808,7 +24783,7 @@
method public void notifyError(int);
method public void notifyRecordingStopped(android.net.Uri);
method public void notifySessionEvent(java.lang.String, android.os.Bundle);
- method public void notifyTuned();
+ method public void notifyTuned(android.net.Uri);
method public void onAppPrivateCommand(java.lang.String, android.os.Bundle);
method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
@@ -24876,7 +24851,7 @@
method public void onError(int);
method public void onEvent(java.lang.String, java.lang.String, android.os.Bundle);
method public void onRecordingStopped(android.net.Uri);
- method public void onTuned();
+ method public void onTuned(android.net.Uri);
}
public class TvStreamConfig implements android.os.Parcelable {
@@ -37031,6 +37006,7 @@
public abstract class NotificationAssistantService extends android.service.notification.NotificationListenerService {
ctor public NotificationAssistantService();
method public final void adjustImportance(java.lang.String, android.service.notification.NotificationAssistantService.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.NotificationAssistantService.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification, int, boolean);
@@ -37083,7 +37059,7 @@
method public void registerAsSystemService(android.content.Context, android.content.ComponentName, int) throws android.os.RemoteException;
method public final void requestInterruptionFilter(int);
method public final void requestListenerHints(int);
- method public static final void requestRebind(android.content.ComponentName) throws android.os.RemoteException;
+ 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[]);
method public final void setOnNotificationPostedTrim(int);
@@ -39134,7 +39110,7 @@
method public boolean isRinging();
method public boolean isTtySupported();
method public boolean isVoiceMailNumber(android.telecom.PhoneAccountHandle, java.lang.String);
- method public void launchManageBlockedNumbersActivity();
+ method public deprecated void launchManageBlockedNumbersActivity();
method public void placeCall(android.net.Uri, android.os.Bundle);
method public void registerPhoneAccount(android.telecom.PhoneAccount);
method public void showInCallScreen(boolean);
@@ -53794,6 +53770,7 @@
}
public abstract interface Iterable {
+ method public default void forEach(java.util.function.Consumer<? super T>);
method public abstract java.util.Iterator<T> iterator();
}
@@ -57269,6 +57246,7 @@
public abstract class Provider extends java.util.Properties {
ctor protected Provider(java.lang.String, double, java.lang.String);
+ method public synchronized void forEach(java.util.function.BiConsumer<? super java.lang.Object, ? super java.lang.Object>);
method public java.lang.String getInfo();
method public java.lang.String getName();
method public synchronized java.security.Provider.Service getService(java.lang.String, java.lang.String);
@@ -60218,6 +60196,7 @@
ctor public ArrayList(java.util.Collection<? extends E>);
method public java.lang.Object clone();
method public void ensureCapacity(int);
+ method public void forEach(java.util.function.Consumer<? super E>);
method public E get(int);
method public int size();
method public void trimToSize();
@@ -60781,6 +60760,7 @@
ctor public HashMap(java.util.Map<? extends K, ? extends V>);
method public java.lang.Object clone();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
public class HashSet extends java.util.AbstractSet implements java.lang.Cloneable java.io.Serializable java.util.Set {
@@ -60805,6 +60785,7 @@
method public boolean containsValue(java.lang.Object);
method public synchronized java.util.Enumeration<V> elements();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public synchronized void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public synchronized V get(java.lang.Object);
method public synchronized boolean isEmpty();
method public java.util.Set<K> keySet();
@@ -60823,6 +60804,7 @@
ctor public IdentityHashMap(java.util.Map<? extends K, ? extends V>);
method public java.lang.Object clone();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
public class IllegalFormatCodePointException extends java.util.IllegalFormatException {
@@ -61062,6 +61044,7 @@
method public abstract boolean containsValue(java.lang.Object);
method public abstract java.util.Set<java.util.Map.Entry<K, V>> entrySet();
method public abstract boolean equals(java.lang.Object);
+ method public default void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public abstract V get(java.lang.Object);
method public abstract int hashCode();
method public abstract boolean isEmpty();
@@ -61523,6 +61506,7 @@
method public K firstKey();
method public java.util.Map.Entry<K, V> floorEntry(K);
method public K floorKey(K);
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public java.util.NavigableMap<K, V> headMap(K, boolean);
method public java.util.SortedMap<K, V> headMap(K);
method public java.util.Map.Entry<K, V> higherEntry(K);
@@ -61605,6 +61589,7 @@
method public java.util.Enumeration<E> elements();
method public synchronized void ensureCapacity(int);
method public synchronized E firstElement();
+ method public synchronized void forEach(java.util.function.Consumer<? super E>);
method public synchronized E get(int);
method public synchronized int indexOf(java.lang.Object, int);
method public synchronized void insertElementAt(E, int);
@@ -61628,6 +61613,7 @@
ctor public WeakHashMap();
ctor public WeakHashMap(java.util.Map<? extends K, ? extends V>);
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
}
diff --git a/api/test-current.txt b/api/test-current.txt
index 372ca3e..580af72 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -2668,6 +2668,8 @@
field public static final int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN = 7; // 0x7
field public static final java.lang.String SERVICE_INTERFACE = "android.accessibilityservice.AccessibilityService";
field public static final java.lang.String SERVICE_META_DATA = "android.accessibilityservice";
+ field public static final int SHOW_MODE_AUTO = 0; // 0x0
+ field public static final int SHOW_MODE_HIDDEN = 1; // 0x1
}
public static abstract class AccessibilityService.GestureResultCallback {
@@ -4132,7 +4134,6 @@
method public int describeContents();
method public android.net.Uri getConditionId();
method public long getCreationTime();
- method public java.lang.String getId();
method public int getInterruptionFilter();
method public java.lang.String getName();
method public android.content.ComponentName getOwner();
@@ -5228,14 +5229,14 @@
}
public class NotificationManager {
- method public android.app.AutomaticZenRule addAutomaticZenRule(android.app.AutomaticZenRule);
+ method public java.lang.String addAutomaticZenRule(android.app.AutomaticZenRule);
method public boolean areNotificationsEnabled();
method public void cancel(int);
method public void cancel(java.lang.String, int);
method public void cancelAll();
method public android.service.notification.StatusBarNotification[] getActiveNotifications();
method public android.app.AutomaticZenRule getAutomaticZenRule(java.lang.String);
- method public java.util.List<android.app.AutomaticZenRule> getAutomaticZenRules();
+ method public java.util.Map<java.lang.String, android.app.AutomaticZenRule> getAutomaticZenRules();
method public final int getCurrentInterruptionFilter();
method public int getImportance();
method public android.app.NotificationManager.Policy getNotificationPolicy();
@@ -5245,7 +5246,7 @@
method public boolean removeAutomaticZenRule(java.lang.String);
method public final void setInterruptionFilter(int);
method public void setNotificationPolicy(android.app.NotificationManager.Policy);
- method public boolean updateAutomaticZenRule(android.app.AutomaticZenRule);
+ method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED";
@@ -7337,15 +7338,6 @@
field public static final int TYPE_SCO = 2; // 0x2
}
- public final class OobData implements android.os.Parcelable {
- ctor public OobData();
- method public int describeContents();
- method public byte[] getSecurityManagerTk();
- method public void setSecurityManagerTk(byte[]);
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.bluetooth.OobData> CREATOR;
- }
-
}
package android.bluetooth.le {
@@ -20669,6 +20661,7 @@
field public static final int HEVCMainTierLevel62 = 16777216; // 0x1000000
field public static final int HEVCProfileMain = 1; // 0x1
field public static final int HEVCProfileMain10 = 2; // 0x2
+ field public static final int HEVCProfileMain10HDR10 = 4096; // 0x1000
field public static final int MPEG2LevelH14 = 2; // 0x2
field public static final int MPEG2LevelHL = 3; // 0x3
field public static final int MPEG2LevelLL = 0; // 0x0
@@ -22985,7 +22978,7 @@
}
public static final class TvInputInfo.Builder {
- ctor public TvInputInfo.Builder(android.content.Context, java.lang.Class<?>);
+ ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
method public android.media.tv.TvInputInfo.Builder setTunerCount(int);
@@ -23053,7 +23046,7 @@
ctor public TvInputService.RecordingSession(android.content.Context);
method public void notifyError(int);
method public void notifyRecordingStopped(android.net.Uri);
- method public void notifyTuned();
+ method public void notifyTuned(android.net.Uri);
method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
@@ -23112,7 +23105,7 @@
method public void onDisconnected(java.lang.String);
method public void onError(int);
method public void onRecordingStopped(android.net.Uri);
- method public void onTuned();
+ method public void onTuned(android.net.Uri);
}
public final class TvTrackInfo implements android.os.Parcelable {
@@ -34557,7 +34550,7 @@
method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
method public final void requestInterruptionFilter(int);
method public final void requestListenerHints(int);
- method public static final void requestRebind(android.content.ComponentName) throws android.os.RemoteException;
+ 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 java.lang.String CATEGORY_VR_NOTIFICATIONS = "android.intent.category.vr.notifications";
@@ -36437,7 +36430,7 @@
method public boolean handleMmi(java.lang.String, android.telecom.PhoneAccountHandle);
method public boolean isInCall();
method public boolean isVoiceMailNumber(android.telecom.PhoneAccountHandle, java.lang.String);
- method public void launchManageBlockedNumbersActivity();
+ method public deprecated void launchManageBlockedNumbersActivity();
method public void placeCall(android.net.Uri, android.os.Bundle);
method public void registerPhoneAccount(android.telecom.PhoneAccount);
method public void showInCallScreen(boolean);
@@ -50691,6 +50684,7 @@
}
public abstract interface Iterable {
+ method public default void forEach(java.util.function.Consumer<? super T>);
method public abstract java.util.Iterator<T> iterator();
}
@@ -54166,6 +54160,7 @@
public abstract class Provider extends java.util.Properties {
ctor protected Provider(java.lang.String, double, java.lang.String);
+ method public synchronized void forEach(java.util.function.BiConsumer<? super java.lang.Object, ? super java.lang.Object>);
method public java.lang.String getInfo();
method public java.lang.String getName();
method public synchronized java.security.Provider.Service getService(java.lang.String, java.lang.String);
@@ -57115,6 +57110,7 @@
ctor public ArrayList(java.util.Collection<? extends E>);
method public java.lang.Object clone();
method public void ensureCapacity(int);
+ method public void forEach(java.util.function.Consumer<? super E>);
method public E get(int);
method public int size();
method public void trimToSize();
@@ -57678,6 +57674,7 @@
ctor public HashMap(java.util.Map<? extends K, ? extends V>);
method public java.lang.Object clone();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
public class HashSet extends java.util.AbstractSet implements java.lang.Cloneable java.io.Serializable java.util.Set {
@@ -57702,6 +57699,7 @@
method public boolean containsValue(java.lang.Object);
method public synchronized java.util.Enumeration<V> elements();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public synchronized void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public synchronized V get(java.lang.Object);
method public synchronized boolean isEmpty();
method public java.util.Set<K> keySet();
@@ -57720,6 +57718,7 @@
ctor public IdentityHashMap(java.util.Map<? extends K, ? extends V>);
method public java.lang.Object clone();
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
public class IllegalFormatCodePointException extends java.util.IllegalFormatException {
@@ -57959,6 +57958,7 @@
method public abstract boolean containsValue(java.lang.Object);
method public abstract java.util.Set<java.util.Map.Entry<K, V>> entrySet();
method public abstract boolean equals(java.lang.Object);
+ method public default void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public abstract V get(java.lang.Object);
method public abstract int hashCode();
method public abstract boolean isEmpty();
@@ -58420,6 +58420,7 @@
method public K firstKey();
method public java.util.Map.Entry<K, V> floorEntry(K);
method public K floorKey(K);
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
method public java.util.NavigableMap<K, V> headMap(K, boolean);
method public java.util.SortedMap<K, V> headMap(K);
method public java.util.Map.Entry<K, V> higherEntry(K);
@@ -58502,6 +58503,7 @@
method public java.util.Enumeration<E> elements();
method public synchronized void ensureCapacity(int);
method public synchronized E firstElement();
+ method public synchronized void forEach(java.util.function.Consumer<? super E>);
method public synchronized E get(int);
method public synchronized int indexOf(java.lang.Object, int);
method public synchronized void insertElementAt(E, int);
@@ -58525,6 +58527,7 @@
ctor public WeakHashMap();
ctor public WeakHashMap(java.util.Map<? extends K, ? extends V>);
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
+ method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
}
}
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java
index fb5f5b9..ac3b8e3 100644
--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -383,13 +383,7 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef({SHOW_MODE_AUTO, SHOW_MODE_HIDDEN})
public @interface SoftKeyboardShowMode {};
- /**
- * @hide
- */
public static final int SHOW_MODE_AUTO = 0;
- /**
- * @hide
- */
public static final int SHOW_MODE_HIDDEN = 1;
private int mConnectionId;
@@ -1137,7 +1131,7 @@
}
/**
- * Removes all instances of the specified change listener from teh list of magnification
+ * Removes all instances of the specified change listener from the list of magnification
* change listeners.
*
* @param listener the listener to remove, must be non-null
@@ -1216,14 +1210,11 @@
/**
* Returns the show mode of the soft keyboard. The default show mode is
- * {@code Settings.Secure.SHOW_MODE_AUTO}, where the soft keyboard is shown when a text
- * input field is focused. An AccessibilityService can also request the show mode
- * {@code Settings.Secure.SHOW_MODE_HIDDEN}, where the soft keyboard is never shown.
+ * {@code SHOW_MODE_AUTO}, where the soft keyboard is shown when a text input field is
+ * focused. An AccessibilityService can also request the show mode
+ * {@code SHOW_MODE_HIDDEN}, where the soft keyboard is never shown.
*
* @return the current soft keyboard show mode
- *
- * @see Settings#Secure#SHOW_MODE_AUTO
- * @see Settings#Secure#SHOW_MODE_HIDDEN
*/
@SoftKeyboardShowMode
public int getShowMode() {
@@ -1239,9 +1230,9 @@
/**
* Sets the soft keyboard show mode. The default show mode is
- * {@code Settings.Secure.SHOW_MODE_AUTO}, where the soft keyboard is shown when a text
- * input field is focused. An AccessibilityService can also request the show mode
- * {@code Settings.Secure.SHOW_MODE_HIDDEN}, where the soft keyboard is never shown. The
+ * {@code SHOW_MODE_AUTO}, where the soft keyboard is shown when a text input field is
+ * focused. An AccessibilityService can also request the show mode
+ * {@code SHOW_MODE_HIDDEN}, where the soft keyboard is never shown. The
* The lastto this method will be honored, regardless of any previous calls (including those
* made by other AccessibilityServices).
* <p>
@@ -1251,9 +1242,6 @@
*
* @param showMode the new show mode for the soft keyboard
* @return {@code true} on success
- *
- * @see Settings#Secure#SHOW_MODE_AUTO
- * @see Settings#Secure#SHOW_MODE_HIDDEN
*/
public boolean setShowMode(@SoftKeyboardShowMode int showMode) {
final IAccessibilityServiceConnection connection =
@@ -1263,9 +1251,13 @@
try {
return connection.setSoftKeyboardShowMode(showMode);
} catch (RemoteException re) {
- Log.w(LOG_TAG, "Falied to set soft keyboard behavior", re);
+ Log.w(LOG_TAG, "Failed to set soft keyboard behavior", re);
+ re.rethrowFromSystemServer();
}
+ } else {
+ throw new RuntimeException("AccessibilityServiceConnection is null");
}
+
return false;
}
@@ -1275,9 +1267,9 @@
public interface OnShowModeChangedListener {
/**
* Called when the soft keyboard behavior changes. The default show mode is
- * {@code Settings.Secure.SHOW_MODE_AUTO}, where the soft keyboard is shown when a text
- * input field is focused. An AccessibilityService can also request the show mode
- * {@code Settings.Secure.SHOW_MODE_HIDDEN}, where the soft keyboard is never shown.
+ * {@code SHOW_MODE_AUTO}, where the soft keyboard is shown when a text input field is
+ * focused. An AccessibilityService can also request the show mode
+ * {@code SHOW_MODE_HIDDEN}, where the soft keyboard is never shown.
*
* @param controller the soft keyboard controller
* @param showMode the current soft keyboard show mode
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 32751b2..be89b20 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -41,6 +41,7 @@
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
@@ -68,6 +69,7 @@
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.StrictMode;
+import android.os.SystemProperties;
import android.os.UserHandle;
import android.text.Selection;
import android.text.SpannableStringBuilder;
@@ -110,6 +112,7 @@
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
+import android.widget.Toast;
import android.widget.Toolbar;
import com.android.internal.app.IVoiceInteractor;
@@ -832,6 +835,8 @@
private boolean mHasCurrentPermissionsRequest;
private boolean mEatKeyUpEvent;
+ private static native String getDlWarning();
+
/** Return the intent that started this activity. */
public Intent getIntent() {
return mIntent;
@@ -1119,34 +1124,6 @@
}
/**
- * Attempts to extract the color from a given drawable.
- *
- * @return the extracted color or 0 if no color could be extracted.
- */
- private int tryExtractColorFromDrawable(Drawable drawable) {
- if (drawable instanceof ColorDrawable) {
- return ((ColorDrawable) drawable).getColor();
- } else if (drawable instanceof InsetDrawable) {
- return tryExtractColorFromDrawable(((InsetDrawable) drawable).getDrawable());
- } else if (drawable instanceof ShapeDrawable) {
- Paint p = ((ShapeDrawable) drawable).getPaint();
- if (p != null) {
- return p.getColor();
- }
- } else if (drawable instanceof LayerDrawable) {
- LayerDrawable ld = (LayerDrawable) drawable;
- int numLayers = ld.getNumberOfLayers();
- for (int i = 0; i < numLayers; i++) {
- int color = tryExtractColorFromDrawable(ld.getDrawable(i));
- if (color != 0) {
- return color;
- }
- }
- }
- return 0;
- }
-
- /**
* Called when activity start-up is complete (after {@link #onStart}
* and {@link #onRestoreInstanceState} have been called). Applications will
* generally not implement this method; it is intended for system
@@ -1168,35 +1145,6 @@
onTitleChanged(getTitle(), getTitleColor());
}
- Resources.Theme theme = getTheme();
- if (theme != null) {
- // Get the primary color and update the TaskDescription for this activity
- TypedArray a = theme.obtainStyledAttributes(
- com.android.internal.R.styleable.ActivityTaskDescription);
- if (mTaskDescription.getPrimaryColor() == 0) {
- int colorPrimary = a.getColor(
- com.android.internal.R.styleable.ActivityTaskDescription_colorPrimary, 0);
- if (colorPrimary != 0 && Color.alpha(colorPrimary) == 0xFF) {
- mTaskDescription.setPrimaryColor(colorPrimary);
- }
- }
- if (mTaskDescription.getBackgroundColor() == 0) {
- int windowBgResourceId = a.getResourceId(
- com.android.internal.R.styleable.ActivityTaskDescription_windowBackground,
- 0);
- int windowBgFallbackResourceId = a.getResourceId(
- com.android.internal.R.styleable.ActivityTaskDescription_windowBackgroundFallback,
- 0);
- int colorBg = tryExtractColorFromDrawable(DecorView.getResizingBackgroundDrawable(
- this, windowBgResourceId, windowBgFallbackResourceId));
- if (colorBg != 0 && Color.alpha(colorBg) == 0xFF) {
- mTaskDescription.setBackgroundColor(colorBg);
- }
- }
- a.recycle();
- setTaskDescription(mTaskDescription);
- }
-
mCalled = true;
}
@@ -4036,6 +3984,27 @@
}
theme.applyStyle(resid, false);
}
+
+ // Get the primary color and update the TaskDescription for this activity
+ TypedArray a = theme.obtainStyledAttributes(
+ com.android.internal.R.styleable.ActivityTaskDescription);
+ if (mTaskDescription.getPrimaryColor() == 0) {
+ int colorPrimary = a.getColor(
+ com.android.internal.R.styleable.ActivityTaskDescription_colorPrimary, 0);
+ if (colorPrimary != 0 && Color.alpha(colorPrimary) == 0xFF) {
+ mTaskDescription.setPrimaryColor(colorPrimary);
+ }
+ }
+ // For dev-preview only.
+ if (mTaskDescription.getBackgroundColor() == 0) {
+ int colorBackground = a.getColor(
+ com.android.internal.R.styleable.ActivityTaskDescription_colorBackground, 0);
+ if (colorBackground != 0 && Color.alpha(colorBackground) == 0xFF) {
+ mTaskDescription.setBackgroundColor(colorBackground);
+ }
+ }
+ a.recycle();
+ setTaskDescription(mTaskDescription);
}
/**
@@ -6621,6 +6590,31 @@
}
mFragments.dispatchStart();
mFragments.reportLoaderStart();
+
+ // This property is set for all builds except final release
+ boolean isDlwarningEnabled = SystemProperties.getInt("ro.bionic.ld.warning", 0) == 1;
+ boolean isAppDebuggable =
+ (mApplication.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
+
+ if (isAppDebuggable || isDlwarningEnabled) {
+ String dlwarning = getDlWarning();
+ if (dlwarning != null) {
+ String appName = getString(mApplication.getApplicationInfo().labelRes);
+ String warning = "Detected problems with app native libraries\n" +
+ "(please consult log for detail):\n" + dlwarning;
+ if (isAppDebuggable) {
+ new AlertDialog.Builder(this).
+ setTitle(appName).
+ setMessage(warning).
+ setPositiveButton(android.R.string.ok, null).
+ setCancelable(false).
+ show();
+ } else {
+ Toast.makeText(this, appName + "\n" + warning, Toast.LENGTH_LONG).show();
+ }
+ }
+ }
+
mActivityTransitionState.enterReady(this);
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index f2a8ea5..177234c 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -175,6 +175,7 @@
private static final int SQLITE_MEM_RELEASED_EVENT_LOG_TAG = 75003;
private static final int LOG_AM_ON_PAUSE_CALLED = 30021;
private static final int LOG_AM_ON_RESUME_CALLED = 30022;
+ private static final int LOG_AM_ON_STOP_CALLED = 30049;
/** Type for IActivityManager.serviceDoneExecuting: anonymous operation */
public static final int SERVICE_DONE_EXECUTING_ANON = 0;
@@ -1407,7 +1408,7 @@
r.packageInfo = getPackageInfoNoCheck(
r.activityInfo.applicationInfo, r.compatInfo);
- handleLaunchActivity(r, null);
+ handleLaunchActivity(r, null, "LAUNCH_ACTIVITY");
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
} break;
case RELAUNCH_ACTIVITY: {
@@ -1458,7 +1459,7 @@
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityResume");
SomeArgs args = (SomeArgs) msg.obj;
handleResumeActivity((IBinder) args.arg1, true, args.argi1 != 0, true,
- args.argi3);
+ args.argi3, "RESUME_ACTIVITY");
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
case SEND_RESULT:
@@ -2631,7 +2632,7 @@
return baseContext;
}
- private void handleLaunchActivity(ActivityClientRecord r, Intent customIntent) {
+ private void handleLaunchActivity(ActivityClientRecord r, Intent customIntent, String reason) {
// If we are getting ready to gc after going to the background, well
// we are back active so skip it.
unscheduleGcIdler();
@@ -2658,7 +2659,7 @@
reportSizeConfigurations(r);
Bundle oldState = r.state;
handleResumeActivity(r.token, false, r.isForward,
- !r.activity.mFinished && !r.startsNotResumed, r.lastProcessedSeq);
+ !r.activity.mFinished && !r.startsNotResumed, r.lastProcessedSeq, reason);
if (!r.activity.mFinished && r.startsNotResumed) {
// The activity manager actually wants this one to start out
@@ -2673,6 +2674,8 @@
try {
r.activity.mCalled = false;
mInstrumentation.callActivityOnPause(r.activity);
+ EventLog.writeEvent(LOG_AM_ON_PAUSE_CALLED, UserHandle.myUserId(),
+ r.activity.getComponentName().getClassName(), reason);
// We need to keep around the original state, in case
// we need to be created again. But we only do this
// for pre-Honeycomb apps, which always save their state
@@ -3320,7 +3323,7 @@
}
public final ActivityClientRecord performResumeActivity(IBinder token,
- boolean clearHide) {
+ boolean clearHide, String reason) {
ActivityClientRecord r = mActivities.get(token);
if (localLOGV) Slog.v(TAG, "Performing resume of " + r
+ " finished=" + r.activity.mFinished);
@@ -3342,8 +3345,20 @@
}
r.activity.performResume();
- EventLog.writeEvent(LOG_AM_ON_RESUME_CALLED,
- UserHandle.myUserId(), r.activity.getComponentName().getClassName());
+ // If there is a pending local relaunch that was requested when the activity was
+ // paused, it will put the activity into paused state when it finally happens.
+ // Since the activity resumed before being relaunched, we don't want that to happen,
+ // so we need to clear the request to relaunch paused.
+ for (int i = mRelaunchingActivities.size() - 1; i >= 0; i--) {
+ final ActivityClientRecord relaunching = mRelaunchingActivities.get(i);
+ if (relaunching.token == r.token
+ && relaunching.onlyLocalRequest && relaunching.startsNotResumed) {
+ relaunching.startsNotResumed = false;
+ }
+ }
+
+ EventLog.writeEvent(LOG_AM_ON_RESUME_CALLED, UserHandle.myUserId(),
+ r.activity.getComponentName().getClassName(), reason);
r.paused = false;
r.stopped = false;
@@ -3379,7 +3394,7 @@
}
final void handleResumeActivity(IBinder token,
- boolean clearHide, boolean isForward, boolean reallyResume, int seq) {
+ boolean clearHide, boolean isForward, boolean reallyResume, int seq, String reason) {
ActivityClientRecord r = mActivities.get(token);
if (!checkAndUpdateLifecycleSeq(seq, r, "resumeActivity")) {
return;
@@ -3391,7 +3406,7 @@
mSomeActivitiesChanged = true;
// TODO Push resumeArgs into the activity for consideration
- r = performResumeActivity(token, clearHide);
+ r = performResumeActivity(token, clearHide, reason);
if (r != null) {
final Activity a = r.activity;
@@ -3573,6 +3588,7 @@
private void handlePauseActivity(IBinder token, boolean finished,
boolean userLeaving, int configChanges, boolean dontReport, int seq) {
ActivityClientRecord r = mActivities.get(token);
+ if (DEBUG_ORDER) Slog.d(TAG, "handlePauseActivity " + r + ", seq: " + seq);
if (!checkAndUpdateLifecycleSeq(seq, r, "pauseActivity")) {
return;
}
@@ -3583,7 +3599,7 @@
}
r.activity.mConfigChangeFlags |= configChanges;
- performPauseActivity(token, finished, r.isPreHoneycomb());
+ performPauseActivity(token, finished, r.isPreHoneycomb(), "handlePauseActivity");
// Make sure any pending writes are now committed.
if (r.isPreHoneycomb()) {
@@ -3607,13 +3623,13 @@
}
final Bundle performPauseActivity(IBinder token, boolean finished,
- boolean saveState) {
+ boolean saveState, String reason) {
ActivityClientRecord r = mActivities.get(token);
- return r != null ? performPauseActivity(r, finished, saveState) : null;
+ return r != null ? performPauseActivity(r, finished, saveState, reason) : null;
}
final Bundle performPauseActivity(ActivityClientRecord r, boolean finished,
- boolean saveState) {
+ boolean saveState, String reason) {
if (r.paused) {
if (r.activity.mFinished) {
// If we are finishing, we won't call onResume() in certain cases.
@@ -3638,7 +3654,7 @@
r.activity.mCalled = false;
mInstrumentation.callActivityOnPause(r.activity);
EventLog.writeEvent(LOG_AM_ON_PAUSE_CALLED, UserHandle.myUserId(),
- r.activity.getComponentName().getClassName());
+ r.activity.getComponentName().getClassName(), reason);
if (!r.activity.mCalled) {
throw new SuperNotCalledException(
"Activity " + r.intent.getComponent().toShortString() +
@@ -3671,9 +3687,9 @@
return !r.activity.mFinished && saveState ? r.state : null;
}
- final void performStopActivity(IBinder token, boolean saveState) {
+ final void performStopActivity(IBinder token, boolean saveState, String reason) {
ActivityClientRecord r = mActivities.get(token);
- performStopActivityInner(r, null, false, saveState);
+ performStopActivityInner(r, null, false, saveState, reason);
}
private static class StopInfo implements Runnable {
@@ -3690,8 +3706,8 @@
activity.token, state, persistentState, description);
} catch (RemoteException ex) {
if (ex instanceof TransactionTooLargeException
- && "com.google.android.gms".equals(activity.packageInfo.getPackageName())) {
- Log.d(TAG, "STAHP SENDING SO MUCH DATA KTHX: " + ex);
+ && activity.packageInfo.getTargetSdkVersion() < Build.VERSION_CODES.N) {
+ Log.e(TAG, "App tried sending too much data in instance state", ex);
return;
}
@@ -3731,7 +3747,7 @@
* the activity's UI visibillity changes.
*/
private void performStopActivityInner(ActivityClientRecord r,
- StopInfo info, boolean keepShown, boolean saveState) {
+ StopInfo info, boolean keepShown, boolean saveState, String reason) {
if (localLOGV) Slog.v(TAG, "Performing stop of " + r);
if (r != null) {
if (!keepShown && r.stopped) {
@@ -3783,6 +3799,8 @@
}
}
r.stopped = true;
+ EventLog.writeEvent(LOG_AM_ON_STOP_CALLED, UserHandle.myUserId(),
+ r.activity.getComponentName().getClassName(), reason);
}
r.paused = true;
@@ -3829,7 +3847,7 @@
r.activity.mConfigChangeFlags |= configChanges;
StopInfo info = new StopInfo();
- performStopActivityInner(r, info, show, true);
+ performStopActivityInner(r, info, show, true, "handleStopActivity");
if (localLOGV) Slog.v(
TAG, "Finishing stop of " + r + ": show=" + show
@@ -3885,7 +3903,7 @@
}
if (!show && !r.stopped) {
- performStopActivityInner(r, null, show, false);
+ performStopActivityInner(r, null, show, false, "handleWindowVisibility");
} else if (show && r.stopped) {
// If we are getting ready to gc after going to the background, well
// we are back active so skip it.
@@ -3924,6 +3942,8 @@
}
}
r.stopped = true;
+ EventLog.writeEvent(LOG_AM_ON_STOP_CALLED, UserHandle.myUserId(),
+ r.activity.getComponentName().getClassName(), "sleeping");
}
// Make sure any pending writes are now committed.
@@ -4065,7 +4085,7 @@
r.activity.mCalled = false;
mInstrumentation.callActivityOnPause(r.activity);
EventLog.writeEvent(LOG_AM_ON_PAUSE_CALLED, UserHandle.myUserId(),
- r.activity.getComponentName().getClassName());
+ r.activity.getComponentName().getClassName(), "destroy");
if (!r.activity.mCalled) {
throw new SuperNotCalledException(
"Activity " + safeToComponentShortString(r.intent)
@@ -4097,6 +4117,8 @@
}
}
r.stopped = true;
+ EventLog.writeEvent(LOG_AM_ON_STOP_CALLED, UserHandle.myUserId(),
+ r.activity.getComponentName().getClassName(), "destroy");
}
if (getNonConfigInstance) {
try {
@@ -4221,6 +4243,7 @@
synchronized (mResourcesManager) {
for (int i=0; i<mRelaunchingActivities.size(); i++) {
ActivityClientRecord r = mRelaunchingActivities.get(i);
+ if (DEBUG_ORDER) Slog.d(TAG, "requestRelaunchActivity: " + this + ", trying: " + r);
if (r.token == token) {
target = r;
if (pendingResults != null) {
@@ -4251,14 +4274,19 @@
}
if (target == null) {
+ if (DEBUG_ORDER) Slog.d(TAG, "requestRelaunchActivity: target is null, fromServer:"
+ + fromServer);
target = new ActivityClientRecord();
target.token = token;
target.pendingResults = pendingResults;
target.pendingIntents = pendingNewIntents;
target.mPreserveWindow = preserveWindow;
if (!fromServer) {
- ActivityClientRecord existing = mActivities.get(token);
+ final ActivityClientRecord existing = mActivities.get(token);
+ if (DEBUG_ORDER) Slog.d(TAG, "requestRelaunchActivity: " + existing);
if (existing != null) {
+ if (DEBUG_ORDER) Slog.d(TAG, "requestRelaunchActivity: paused= "
+ + existing.paused);;
target.startsNotResumed = existing.paused;
target.overrideConfig = existing.overrideConfig;
}
@@ -4281,8 +4309,8 @@
target.pendingConfigChanges |= configChanges;
target.relaunchSeq = getLifecycleSeq();
}
- if (DEBUG_ORDER) Slog.d(TAG, "relaunchActivity " + ActivityThread.this
- + " operation received seq: " + target.relaunchSeq);
+ if (DEBUG_ORDER) Slog.d(TAG, "relaunchActivity " + ActivityThread.this + ", target "
+ + target + " operation received seq: " + target.relaunchSeq);
}
private void handleRelaunchActivity(ActivityClientRecord tmp) {
@@ -4396,7 +4424,7 @@
// Need to ensure state is saved.
if (!r.paused) {
- performPauseActivity(r.token, false, r.isPreHoneycomb());
+ performPauseActivity(r.token, false, r.isPreHoneycomb(), "handleRelaunchActivity");
}
if (r.state == null && !r.stopped && !r.isPreHoneycomb()) {
callCallActivityOnSaveInstanceState(r);
@@ -4426,7 +4454,7 @@
r.startsNotResumed = tmp.startsNotResumed;
r.overrideConfig = tmp.overrideConfig;
- handleLaunchActivity(r, currentIntent);
+ handleLaunchActivity(r, currentIntent, "handleRelaunchActivity");
if (!tmp.onlyLocalRequest) {
try {
@@ -4804,8 +4832,9 @@
// Keep in sync with installd (frameworks/native/cmds/installd/commands.cpp).
private static File getPrimaryProfileFile(String packageName) {
- return new File("/data/misc/profiles/cur/" + UserHandle.myUserId() +
- "/" + packageName + "/primary.prof");
+ File profileDir = Environment.getDataProfilesDePackageDirectory(
+ UserHandle.myUserId(), packageName);
+ return new File(profileDir, "primary.prof");
}
private static void setupJitProfileSupport(LoadedApk loadedApk, File cacheDir) {
@@ -4848,8 +4877,17 @@
}
}
+ final File foreignDexProfilesFile =
+ Environment.getDataProfilesDeForeignDexDirectory(UserHandle.myUserId());
+ String foreignDexProfilesPath = null;
+ if (!foreignDexProfilesFile.exists()) {
+ Log.v(TAG, "ForeignDexProfilesPath does not exists:" +
+ foreignDexProfilesFile.getPath());
+ } else {
+ foreignDexProfilesPath = foreignDexProfilesFile.getAbsolutePath();
+ }
VMRuntime.registerAppInfo(profileFile.getAbsolutePath(), appInfo.dataDir,
- codePaths.toArray(new String[codePaths.size()]));
+ codePaths.toArray(new String[codePaths.size()]), foreignDexProfilesPath);
}
private void updateDefaultDensity() {
diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java
index b569416..455f869 100644
--- a/core/java/android/app/AlarmManager.java
+++ b/core/java/android/app/AlarmManager.java
@@ -201,6 +201,7 @@
try {
mService.remove(null, this);
} catch (RemoteException ex) {
+ throw ex.rethrowFromSystemServer();
}
synchronized (AlarmManager.class) {
@@ -656,6 +657,7 @@
mService.set(mPackageName, type, triggerAtMillis, windowMillis, intervalMillis, flags,
operation, recipientWrapper, listenerTag, workSource, alarmClock);
} catch (RemoteException ex) {
+ throw ex.rethrowFromSystemServer();
}
}
@@ -886,6 +888,7 @@
try {
mService.remove(operation, null);
} catch (RemoteException ex) {
+ throw ex.rethrowFromSystemServer();
}
}
@@ -926,6 +929,7 @@
try {
mService.setTime(millis);
} catch (RemoteException ex) {
+ throw ex.rethrowFromSystemServer();
}
}
@@ -965,6 +969,7 @@
try {
mService.setTimeZone(timeZone);
} catch (RemoteException ex) {
+ throw ex.rethrowFromSystemServer();
}
}
@@ -973,7 +978,7 @@
try {
return mService.getNextWakeFromIdleTime();
} catch (RemoteException ex) {
- return Long.MAX_VALUE;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -1005,7 +1010,7 @@
try {
return mService.getNextAlarmClock(userId);
} catch (RemoteException ex) {
- return null;
+ throw ex.rethrowFromSystemServer();
}
}
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 4d466d3..53cc9ca 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -30,7 +30,6 @@
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
-import android.content.pm.ContainerEncryptionParams;
import android.content.pm.EphemeralApplicationInfo;
import android.content.pm.FeatureInfo;
import android.content.pm.IOnPermissionsChangeListener;
@@ -54,7 +53,6 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.UserInfo;
-import android.content.pm.VerificationParams;
import android.content.pm.VerifierDeviceIdentity;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
@@ -1469,80 +1467,27 @@
@Override
public void installPackage(Uri packageURI, IPackageInstallObserver observer, int flags,
String installerPackageName) {
- final VerificationParams verificationParams = new VerificationParams(null, null,
- null, VerificationParams.NO_UID);
installCommon(packageURI, new LegacyPackageInstallObserver(observer), flags,
- installerPackageName, verificationParams, null, mContext.getUserId());
- }
-
- @Override
- public void installPackageWithVerification(Uri packageURI, IPackageInstallObserver observer,
- int flags, String installerPackageName, Uri verificationURI,
- ContainerEncryptionParams encryptionParams) {
- final VerificationParams verificationParams = new VerificationParams(verificationURI, null,
- null, VerificationParams.NO_UID);
- installCommon(packageURI, new LegacyPackageInstallObserver(observer), flags,
- installerPackageName, verificationParams, encryptionParams, mContext.getUserId());
- }
-
- @Override
- public void installPackageWithVerificationAndEncryption(Uri packageURI,
- IPackageInstallObserver observer, int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
- installCommon(packageURI, new LegacyPackageInstallObserver(observer), flags,
- installerPackageName, verificationParams, encryptionParams, mContext.getUserId());
+ installerPackageName, mContext.getUserId());
}
@Override
public void installPackage(Uri packageURI, PackageInstallObserver observer,
int flags, String installerPackageName) {
- installPackageAsUser(packageURI, observer, flags, installerPackageName,
- mContext.getUserId());
- }
-
- @Override
- public void installPackageAsUser(Uri packageURI, PackageInstallObserver observer, int flags,
- String installerPackageName, int userId) {
- final VerificationParams verificationParams = new VerificationParams(null, null,
- null, VerificationParams.NO_UID);
- installCommon(packageURI, observer, flags, installerPackageName, verificationParams, null,
- userId);
- }
-
- @Override
- public void installPackageWithVerification(Uri packageURI,
- PackageInstallObserver observer, int flags, String installerPackageName,
- Uri verificationURI,
- ContainerEncryptionParams encryptionParams) {
- final VerificationParams verificationParams = new VerificationParams(verificationURI, null,
- null, VerificationParams.NO_UID);
- installCommon(packageURI, observer, flags, installerPackageName, verificationParams,
- encryptionParams, mContext.getUserId());
- }
-
- @Override
- public void installPackageWithVerificationAndEncryption(Uri packageURI,
- PackageInstallObserver observer, int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
- installCommon(packageURI, observer, flags, installerPackageName, verificationParams,
- encryptionParams, mContext.getUserId());
+ installCommon(packageURI, observer, flags, installerPackageName, mContext.getUserId());
}
private void installCommon(Uri packageURI,
PackageInstallObserver observer, int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams,
int userId) {
if (!"file".equals(packageURI.getScheme())) {
throw new UnsupportedOperationException("Only file:// URIs are supported");
}
- if (encryptionParams != null) {
- throw new UnsupportedOperationException("ContainerEncryptionParams not supported");
- }
final String originPath = packageURI.getPath();
try {
mPM.installPackageAsUser(originPath, observer.getBinder(), flags, installerPackageName,
- verificationParams, null, userId);
+ userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/AutomaticZenRule.java b/core/java/android/app/AutomaticZenRule.java
index ceec62f..1f1f318 100644
--- a/core/java/android/app/AutomaticZenRule.java
+++ b/core/java/android/app/AutomaticZenRule.java
@@ -34,7 +34,6 @@
private @InterruptionFilter int interruptionFilter;
private Uri conditionId;
private ComponentName owner;
- private String id;
private long creationTime;
/**
@@ -63,9 +62,8 @@
* @hide
*/
public AutomaticZenRule(String name, ComponentName owner, Uri conditionId,
- int interruptionFilter, boolean enabled, String id, long creationTime) {
+ int interruptionFilter, boolean enabled, long creationTime) {
this(name, owner, conditionId, interruptionFilter, enabled);
- this.id = id;
this.creationTime = creationTime;
}
@@ -77,9 +75,6 @@
interruptionFilter = source.readInt();
conditionId = source.readParcelable(null);
owner = source.readParcelable(null);
- if (source.readInt() == 1) {
- id = source.readString();
- }
creationTime = source.readLong();
}
@@ -119,20 +114,13 @@
}
/**
- * Returns the wall time in milliseconds when this rule was created, if known.
+ * Returns the time this rule was created, represented as milliseconds since the epoch.
*/
public long getCreationTime() {
return creationTime;
}
/**
- * Returns the unique identifier for this rule.
- */
- public String getId() {
- return id;
- }
-
- /**
* Sets the representation of the state that causes this rule to become active.
*/
public void setConditionId(Uri conditionId) {
@@ -178,12 +166,6 @@
dest.writeInt(interruptionFilter);
dest.writeParcelable(conditionId, 0);
dest.writeParcelable(owner, 0);
- if (id != null) {
- dest.writeInt(1);
- dest.writeString(id);
- } else {
- dest.writeInt(0);
- }
dest.writeLong(creationTime);
}
@@ -195,7 +177,6 @@
.append(",interruptionFilter=").append(interruptionFilter)
.append(",conditionId=").append(conditionId)
.append(",owner=").append(owner)
- .append(",id=").append(id)
.append(",creationTime=").append(creationTime)
.append(']').toString();
}
@@ -210,13 +191,12 @@
&& other.interruptionFilter == interruptionFilter
&& Objects.equals(other.conditionId, conditionId)
&& Objects.equals(other.owner, owner)
- && Objects.equals(other.id, id)
&& other.creationTime == creationTime;
}
@Override
public int hashCode() {
- return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, id, creationTime);
+ return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, creationTime);
}
public static final Parcelable.Creator<AutomaticZenRule> CREATOR
diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java
index 4b0dfc7..3a51aff 100644
--- a/core/java/android/app/BackStackRecord.java
+++ b/core/java/android/app/BackStackRecord.java
@@ -16,8 +16,6 @@
package android.app;
-import com.android.internal.util.FastPrintWriter;
-
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcelable;
@@ -33,6 +31,8 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
+import com.android.internal.util.FastPrintWriter;
+
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -717,10 +717,12 @@
bumpBackStackNesting(1);
- SparseArray<Fragment> firstOutFragments = new SparseArray<Fragment>();
- SparseArray<Fragment> lastInFragments = new SparseArray<Fragment>();
- calculateFragments(firstOutFragments, lastInFragments);
- beginTransition(firstOutFragments, lastInFragments, false);
+ if (mManager.mCurState >= Fragment.CREATED) {
+ SparseArray<Fragment> firstOutFragments = new SparseArray<Fragment>();
+ SparseArray<Fragment> lastInFragments = new SparseArray<Fragment>();
+ calculateFragments(firstOutFragments, lastInFragments);
+ beginTransition(firstOutFragments, lastInFragments, false);
+ }
Op op = mHead;
while (op != null) {
@@ -842,6 +844,14 @@
firstOutFragments.remove(containerId);
}
}
+ /**
+ * Ensure that fragments that are entering are at least at the CREATED state
+ * so that they may load Transitions using TransitionInflater.
+ */
+ if (fragment.mState < Fragment.CREATED && mManager.mCurState >= Fragment.CREATED) {
+ mManager.makeActive(fragment);
+ mManager.moveToState(fragment, Fragment.CREATED, 0, 0, false);
+ }
}
}
@@ -986,7 +996,6 @@
*/
private TransitionState beginTransition(SparseArray<Fragment> firstOutFragments,
SparseArray<Fragment> lastInFragments, boolean isBack) {
- ensureFragmentsAreInitialized(lastInFragments);
TransitionState state = new TransitionState();
// Adding a non-existent target view makes sure that the transitions don't target
@@ -1012,21 +1021,6 @@
return state;
}
- /**
- * Ensure that fragments that are entering are at least at the CREATED state
- * so that they may load Transitions using TransitionInflater.
- */
- private void ensureFragmentsAreInitialized(SparseArray<Fragment> lastInFragments) {
- final int count = lastInFragments.size();
- for (int i = 0; i < count; i++) {
- final Fragment fragment = lastInFragments.valueAt(i);
- if (fragment.mState < Fragment.CREATED) {
- mManager.makeActive(fragment);
- mManager.moveToState(fragment, Fragment.CREATED, 0, 0, false);
- }
- }
- }
-
private static Transition cloneTransition(Transition transition) {
if (transition != null) {
transition = transition.clone();
@@ -1663,12 +1657,14 @@
pw.flush();
}
- if (state == null) {
- if (firstOutFragments.size() != 0 || lastInFragments.size() != 0) {
- state = beginTransition(firstOutFragments, lastInFragments, true);
+ if (mManager.mCurState >= Fragment.CREATED) {
+ if (state == null) {
+ if (firstOutFragments.size() != 0 || lastInFragments.size() != 0) {
+ state = beginTransition(firstOutFragments, lastInFragments, true);
+ }
+ } else if (!doStateMove) {
+ setNameOverrides(state, mSharedElementTargetNames, mSharedElementSourceNames);
}
- } else if (!doStateMove) {
- setNameOverrides(state, mSharedElementTargetNames, mSharedElementSourceNames);
}
bumpBackStackNesting(-1);
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 47eec8b..e76f991 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -396,9 +396,11 @@
/**
* Try our best to migrate all files from source to target that match
- * requested prefix. Return false if we have any trouble migrating.
+ * requested prefix.
+ *
+ * @return the number of files moved, or -1 if there was trouble.
*/
- private static boolean migrateFiles(File sourceDir, File targetDir, final String prefix) {
+ private static int migrateFiles(File sourceDir, File targetDir, final String prefix) {
final File[] sourceFiles = FileUtils.listFilesOrEmpty(sourceDir, new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
@@ -406,7 +408,7 @@
}
});
- boolean res = true;
+ int res = 0;
for (File sourceFile : sourceFiles) {
final File targetFile = new File(targetDir, sourceFile.getName());
Log.d(TAG, "Migrating " + sourceFile + " to " + targetFile);
@@ -416,9 +418,12 @@
if (!sourceFile.delete()) {
throw new IOException("Failed to clean up " + sourceFile);
}
+ if (res != -1) {
+ res++;
+ }
} catch (IOException e) {
Log.w(TAG, "Failed to migrate " + sourceFile + ": " + e);
- res = false;
+ res = -1;
}
}
return res;
@@ -430,12 +435,17 @@
final File source = sourceContext.getSharedPreferencesPath(name);
final File target = getSharedPreferencesPath(name);
- // Evict any in-memory caches for either location
- final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
- cache.remove(source);
- cache.remove(target);
-
- return migrateFiles(source.getParentFile(), target.getParentFile(), source.getName());
+ final int res = migrateFiles(source.getParentFile(), target.getParentFile(),
+ source.getName());
+ if (res > 0) {
+ // We moved at least one file, so evict any in-memory caches for
+ // either location
+ final ArrayMap<File, SharedPreferencesImpl> cache =
+ getSharedPreferencesCacheLocked();
+ cache.remove(source);
+ cache.remove(target);
+ }
+ return res != -1;
}
}
@@ -675,7 +685,8 @@
synchronized (ContextImpl.class) {
final File source = sourceContext.getDatabasePath(name);
final File target = getDatabasePath(name);
- return migrateFiles(source.getParentFile(), target.getParentFile(), source.getName());
+ return migrateFiles(source.getParentFile(), target.getParentFile(),
+ source.getName()) != -1;
}
}
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index aafb3c6..6870bbf 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -2509,6 +2509,7 @@
throw new SuperNotCalledException("Fragment " + this
+ " did not call through to super.onDestroy()");
}
+ mChildFragmentManager = null;
}
private static Transition loadTransition(Context context, TypedArray typedArray,
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 78a054b..0631943 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -1525,7 +1525,7 @@
throw new IllegalStateException("Must be called from main thread of fragment host");
}
- if (allowStateLoss) {
+ if (!allowStateLoss) {
checkStateLoss();
}
@@ -1625,7 +1625,9 @@
final BackStackRecord bss = mBackStack.remove(last);
SparseArray<Fragment> firstOutFragments = new SparseArray<Fragment>();
SparseArray<Fragment> lastInFragments = new SparseArray<Fragment>();
- bss.calculateBackFragments(firstOutFragments, lastInFragments);
+ if (mCurState >= Fragment.CREATED) {
+ bss.calculateBackFragments(firstOutFragments, lastInFragments);
+ }
bss.popFromBackStack(true, null, firstOutFragments, lastInFragments);
reportBackStackChanged();
} else {
@@ -1672,8 +1674,10 @@
final int LAST = states.size()-1;
SparseArray<Fragment> firstOutFragments = new SparseArray<Fragment>();
SparseArray<Fragment> lastInFragments = new SparseArray<Fragment>();
- for (int i=0; i<=LAST; i++) {
- states.get(i).calculateBackFragments(firstOutFragments, lastInFragments);
+ if (mCurState >= Fragment.CREATED) {
+ for (int i = 0; i <= LAST; i++) {
+ states.get(i).calculateBackFragments(firstOutFragments, lastInFragments);
+ }
}
BackStackRecord.TransitionState state = null;
for (int i=0; i<=LAST; i++) {
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 8be00aa..5697924 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -97,9 +97,9 @@
boolean isNotificationPolicyAccessGrantedForPackage(String pkg);
void setNotificationPolicyAccessGranted(String pkg, boolean granted);
AutomaticZenRule getAutomaticZenRule(String id);
- List<AutomaticZenRule> getAutomaticZenRules();
- AutomaticZenRule addAutomaticZenRule(in AutomaticZenRule automaticZenRule);
- boolean updateAutomaticZenRule(in AutomaticZenRule automaticZenRule);
+ List<ZenModeConfig.ZenRule> getZenRules();
+ String addAutomaticZenRule(in AutomaticZenRule automaticZenRule);
+ boolean updateAutomaticZenRule(String id, in AutomaticZenRule automaticZenRule);
boolean removeAutomaticZenRule(String id);
boolean removeAutomaticZenRules(String packageName);
int getRuleInstanceCount(in ComponentName owner);
diff --git a/core/java/android/app/LocalActivityManager.java b/core/java/android/app/LocalActivityManager.java
index 873e337..2a1e3c2 100644
--- a/core/java/android/app/LocalActivityManager.java
+++ b/core/java/android/app/LocalActivityManager.java
@@ -144,7 +144,7 @@
if (desiredState == RESUMED) {
if (localLOGV) Log.v(TAG, r.id + ": resuming");
- mActivityThread.performResumeActivity(r, true);
+ mActivityThread.performResumeActivity(r, true, "moveToState-INITIALIZING");
r.curState = RESUMED;
}
@@ -167,7 +167,7 @@
if (desiredState == RESUMED) {
if (localLOGV) Log.v(TAG, r.id + ": restarting and resuming");
mActivityThread.performRestartActivity(r);
- mActivityThread.performResumeActivity(r, true);
+ mActivityThread.performResumeActivity(r, true, "moveToState-CREATED");
r.curState = RESUMED;
}
return;
@@ -176,13 +176,13 @@
if (desiredState == RESUMED) {
// Need to resume it...
if (localLOGV) Log.v(TAG, r.id + ": resuming");
- mActivityThread.performResumeActivity(r, true);
+ mActivityThread.performResumeActivity(r, true, "moveToState-STARTED");
r.instanceState = null;
r.curState = RESUMED;
}
if (desiredState == CREATED) {
if (localLOGV) Log.v(TAG, r.id + ": stopping");
- mActivityThread.performStopActivity(r, false);
+ mActivityThread.performStopActivity(r, false, "moveToState-STARTED");
r.curState = CREATED;
}
return;
@@ -197,7 +197,7 @@
if (localLOGV) Log.v(TAG, r.id + ": pausing");
performPause(r, mFinishing);
if (localLOGV) Log.v(TAG, r.id + ": stopping");
- mActivityThread.performStopActivity(r, false);
+ mActivityThread.performStopActivity(r, false, "moveToState-RESUMED");
r.curState = CREATED;
}
return;
@@ -205,9 +205,9 @@
}
private void performPause(LocalActivityRecord r, boolean finishing) {
- boolean needState = r.instanceState == null;
- Bundle instanceState = mActivityThread.performPauseActivity(r,
- finishing, needState);
+ final boolean needState = r.instanceState == null;
+ final Bundle instanceState = mActivityThread.performPauseActivity(
+ r, finishing, needState, "performPause");
if (needState) {
r.instanceState = instanceState;
}
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index 344315d..057a4e9 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -48,8 +48,12 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Objects;
import java.util.List;
+import java.util.Set;
/**
* Class to notify the user of events that happen. This is how you tell
@@ -413,13 +417,20 @@
* Returns AutomaticZenRules owned by the caller.
*
* <p>
- * Only available if policy access is granted to this package.
+ * Throws a SecurityException if policy access is granted to this package.
* See {@link #isNotificationPolicyAccessGranted}.
*/
- public List<AutomaticZenRule> getAutomaticZenRules() {
+ public Map<String, AutomaticZenRule> getAutomaticZenRules() {
INotificationManager service = getService();
try {
- return service.getAutomaticZenRules();
+ List<ZenModeConfig.ZenRule> rules = service.getZenRules();
+ Map<String, AutomaticZenRule> ruleMap = new HashMap<>();
+ for (ZenModeConfig.ZenRule rule : rules) {
+ ruleMap.put(rule.id, new AutomaticZenRule(rule.name, rule.component,
+ rule.conditionId, zenModeToInterruptionFilter(rule.zenMode), rule.enabled,
+ rule.creationTime));
+ }
+ return ruleMap;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -429,7 +440,7 @@
* Returns the AutomaticZenRule with the given id, if it exists and the caller has access.
*
* <p>
- * Only available if policy access is granted to this package.
+ * Throws a SecurityException if policy access is granted to this package.
* See {@link #isNotificationPolicyAccessGranted}.
*
* <p>
@@ -449,14 +460,13 @@
* Creates the given zen rule.
*
* <p>
- * Only available if policy access is granted to this package.
+ * Throws a SecurityException if policy access is granted to this package.
* See {@link #isNotificationPolicyAccessGranted}.
*
* @param automaticZenRule the rule to create.
- * @return A fully populated {@link AutomaticZenRule} if the rule was persisted successfully,
- * null otherwise.
+ * @return The id of the newly created rule; null if the rule could not be created.
*/
- public AutomaticZenRule addAutomaticZenRule(AutomaticZenRule automaticZenRule) {
+ public String addAutomaticZenRule(AutomaticZenRule automaticZenRule) {
INotificationManager service = getService();
try {
return service.addAutomaticZenRule(automaticZenRule);
@@ -469,18 +479,19 @@
* Updates the given zen rule.
*
* <p>
- * Only available if policy access is granted to this package.
+ * Throws a SecurityException if policy access is granted to this package.
* See {@link #isNotificationPolicyAccessGranted}.
*
* <p>
* Callers can only update rules that they own. See {@link AutomaticZenRule#getOwner}.
+ * @param id The id of the rule to update
* @param automaticZenRule the rule to update.
* @return Whether the rule was successfully updated.
*/
- public boolean updateAutomaticZenRule(AutomaticZenRule automaticZenRule) {
+ public boolean updateAutomaticZenRule(String id, AutomaticZenRule automaticZenRule) {
INotificationManager service = getService();
try {
- return service.updateAutomaticZenRule(automaticZenRule);
+ return service.updateAutomaticZenRule(id, automaticZenRule);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -490,7 +501,7 @@
* Deletes the automatic zen rule with the given id.
*
* <p>
- * Only available if policy access is granted to this package.
+ * Throws a SecurityException if policy access is granted to this package.
* See {@link #isNotificationPolicyAccessGranted}.
*
* <p>
@@ -879,9 +890,8 @@
final List<StatusBarNotification> list = parceledList.getList();
return list.toArray(new StatusBarNotification[list.size()]);
} catch (RemoteException e) {
- Log.e(TAG, "Unable to talk to notification manager. Woe!", e);
+ throw e.rethrowFromSystemServer();
}
- return new StatusBarNotification[0];
}
/**
@@ -902,9 +912,8 @@
try {
return zenModeToInterruptionFilter(service.getZenMode());
} catch (RemoteException e) {
- Log.e(TAG, "Unable to talk to notification manager. Woe!", e);
+ throw e.rethrowFromSystemServer();
}
- return INTERRUPTION_FILTER_UNKNOWN;
}
/**
@@ -925,7 +934,7 @@
try {
service.setInterruptionFilter(mContext.getOpPackageName(), interruptionFilter);
} catch (RemoteException e) {
- Log.e(TAG, "Unable to talk to notification manager. Woe!", e);
+ throw e.rethrowFromSystemServer();
}
}
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index 9e32164..ac4abf5 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -686,8 +686,7 @@
try {
return mService.getGlobalSearchActivities();
} catch (RemoteException ex) {
- Log.e(TAG, "getGlobalSearchActivities() failed: " + ex);
- return null;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -698,8 +697,7 @@
try {
return mService.getGlobalSearchActivity();
} catch (RemoteException ex) {
- Log.e(TAG, "getGlobalSearchActivity() failed: " + ex);
- return null;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -716,8 +714,7 @@
try {
return mService.getWebSearchActivity();
} catch (RemoteException ex) {
- Log.e(TAG, "getWebSearchActivity() failed: " + ex);
- return null;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -850,8 +847,7 @@
try {
return mService.getSearchableInfo(componentName);
} catch (RemoteException ex) {
- Log.e(TAG, "getSearchableInfo() failed: " + ex);
- return null;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -935,8 +931,7 @@
try {
return mService.getSearchablesInGlobalSearch();
} catch (RemoteException e) {
- Log.e(TAG, "getSearchablesInGlobalSearch() failed: " + e);
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -958,8 +953,7 @@
}
return intent;
} catch (RemoteException re) {
- Log.e(TAG, "getAssistIntent() failed: " + re);
- return null;
+ throw re.rethrowFromSystemServer();
}
}
@@ -977,7 +971,7 @@
}
mService.launchAssist(args);
} catch (RemoteException re) {
- Log.e(TAG, "launchAssist() failed: " + re);
+ throw re.rethrowFromSystemServer();
}
}
@@ -995,8 +989,7 @@
}
return mService.launchLegacyAssist(hint, userHandle, args);
} catch (RemoteException re) {
- Log.e(TAG, "launchAssist() failed: " + re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java
index b899116..e57a9b5 100644
--- a/core/java/android/app/StatusBarManager.java
+++ b/core/java/android/app/StatusBarManager.java
@@ -123,8 +123,7 @@
svc.disable(what, mToken, mContext.getPackageName());
}
} catch (RemoteException ex) {
- // system process is dead anyway.
- throw new RuntimeException(ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -141,8 +140,7 @@
svc.disable2(what, mToken, mContext.getPackageName());
}
} catch (RemoteException ex) {
- // system process is dead anyway.
- throw new RuntimeException(ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -156,8 +154,7 @@
svc.expandNotificationsPanel();
}
} catch (RemoteException ex) {
- // system process is dead anyway.
- throw new RuntimeException(ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -171,8 +168,7 @@
svc.collapsePanels();
}
} catch (RemoteException ex) {
- // system process is dead anyway.
- throw new RuntimeException(ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -193,8 +189,7 @@
svc.expandSettingsPanel(subPanel);
}
} catch (RemoteException ex) {
- // system process is dead anyway.
- throw new RuntimeException(ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -206,8 +201,7 @@
contentDescription);
}
} catch (RemoteException ex) {
- // system process is dead anyway.
- throw new RuntimeException(ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -218,8 +212,7 @@
svc.removeIcon(slot);
}
} catch (RemoteException ex) {
- // system process is dead anyway.
- throw new RuntimeException(ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -230,8 +223,7 @@
svc.setIconVisibility(slot, visible);
}
} catch (RemoteException ex) {
- // system process is dead anyway.
- throw new RuntimeException(ex);
+ throw ex.rethrowFromSystemServer();
}
}
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 307c3eb..b1c5fd8 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -226,7 +226,7 @@
SYSTEM_SERVICE_NAMES.put(android.text.ClipboardManager.class, Context.CLIPBOARD_SERVICE);
registerService(Context.CONNECTIVITY_SERVICE, ConnectivityManager.class,
- new StaticOuterContextServiceFetcher<ConnectivityManager>() {
+ new StaticApplicationContextServiceFetcher<ConnectivityManager>() {
@Override
public ConnectivityManager createService(Context context) {
IBinder b = ServiceManager.getService(Context.CONNECTIVITY_SERVICE);
@@ -840,22 +840,21 @@
}
/**
- * Like StaticServiceFetcher, creates only one instance of the service per process, but when
- * creating the service for the first time, passes it the outer context of the creating
- * component.
+ * Like StaticServiceFetcher, creates only one instance of the service per application, but when
+ * creating the service for the first time, passes it the application context of the creating
+ * application.
*
- * TODO: Is this safe in the case where multiple applications share the same process?
* TODO: Delete this once its only user (ConnectivityManager) is known to work well in the
* case where multiple application components each have their own ConnectivityManager object.
*/
- static abstract class StaticOuterContextServiceFetcher<T> implements ServiceFetcher<T> {
+ static abstract class StaticApplicationContextServiceFetcher<T> implements ServiceFetcher<T> {
private T mCachedInstance;
@Override
public final T getService(ContextImpl ctx) {
- synchronized (StaticOuterContextServiceFetcher.this) {
+ synchronized (StaticApplicationContextServiceFetcher.this) {
if (mCachedInstance == null) {
- mCachedInstance = createService(ctx.getOuterContext());
+ mCachedInstance = createService(ctx.getApplicationContext());
}
return mCachedInstance;
}
diff --git a/core/java/android/app/UiModeManager.java b/core/java/android/app/UiModeManager.java
index 56b4249..73fb55f 100644
--- a/core/java/android/app/UiModeManager.java
+++ b/core/java/android/app/UiModeManager.java
@@ -158,7 +158,7 @@
try {
mService.enableCarMode(flags);
} catch (RemoteException e) {
- Log.e(TAG, "disableCarMode: RemoteException", e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -181,7 +181,7 @@
try {
mService.disableCarMode(flags);
} catch (RemoteException e) {
- Log.e(TAG, "disableCarMode: RemoteException", e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -200,7 +200,7 @@
try {
return mService.getCurrentModeType();
} catch (RemoteException e) {
- Log.e(TAG, "getCurrentModeType: RemoteException", e);
+ throw e.rethrowFromSystemServer();
}
}
return Configuration.UI_MODE_TYPE_NORMAL;
@@ -233,7 +233,7 @@
try {
mService.setNightMode(mode);
} catch (RemoteException e) {
- Log.e(TAG, "setNightMode: RemoteException", e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -257,7 +257,7 @@
try {
return mService.getNightMode();
} catch (RemoteException e) {
- Log.e(TAG, "getNightMode: RemoteException", e);
+ throw e.rethrowFromSystemServer();
}
}
return -1;
@@ -272,7 +272,7 @@
try {
return mService.isUiModeLocked();
} catch (RemoteException e) {
- Log.e(TAG, "isUiModeLocked: RemoteException", e);
+ throw e.rethrowFromSystemServer();
}
}
return true;
@@ -292,7 +292,7 @@
try {
return mService.isNightModeLocked();
} catch (RemoteException e) {
- Log.e(TAG, "isNightModeLocked: RemoteException", e);
+ throw e.rethrowFromSystemServer();
}
}
return true;
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index b7e31ab..4d8d96b0 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -293,7 +293,7 @@
return null;
}
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
}
if (mWallpaper != null) {
@@ -349,7 +349,7 @@
}
}
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
return null;
}
@@ -691,7 +691,7 @@
Bundle outParams = new Bundle();
return sGlobals.mService.getWallpaper(null, which, outParams, userId);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -720,7 +720,7 @@
return sGlobals.mService.getWallpaperInfo();
}
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -844,7 +844,7 @@
}
}
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
return result.getInt(EXTRA_NEW_WALLPAPER_ID, 0);
}
@@ -950,7 +950,7 @@
}
}
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
return result.getInt(EXTRA_NEW_WALLPAPER_ID, 0);
}
@@ -1067,7 +1067,7 @@
}
}
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
return result.getInt(EXTRA_NEW_WALLPAPER_ID, 0);
@@ -1088,7 +1088,7 @@
String name = "res:" + resources.getResourceName(resid);
return sGlobals.mService.hasNamedWallpaper(name);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1114,8 +1114,7 @@
try {
return sGlobals.mService.getWidthHint();
} catch (RemoteException e) {
- // Shouldn't happen!
- return 0;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1141,8 +1140,7 @@
try {
return sGlobals.mService.getHeightHint();
} catch (RemoteException e) {
- // Shouldn't happen!
- return 0;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1203,7 +1201,7 @@
mContext.getOpPackageName());
}
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
}
@@ -1224,7 +1222,7 @@
sGlobals.mService.setDisplayPadding(padding, mContext.getOpPackageName());
}
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
}
@@ -1245,7 +1243,7 @@
windowToken, x, y);
//Log.v(TAG, "...app returning after sending display offset!");
} catch (RemoteException e) {
- // Ignore.
+ throw e.rethrowFromSystemServer();
}
}
@@ -1274,7 +1272,7 @@
try {
sGlobals.mService.clearWallpaper(mContext.getOpPackageName(), which, userId);
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
}
@@ -1296,9 +1294,8 @@
sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName());
return true;
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
- return false;
}
/**
@@ -1321,7 +1318,7 @@
windowToken, xOffset, yOffset, mWallpaperXStep, mWallpaperYStep);
//Log.v(TAG, "...app returning after sending offsets!");
} catch (RemoteException e) {
- // Ignore.
+ throw e.rethrowFromSystemServer();
}
}
@@ -1359,7 +1356,7 @@
windowToken, action, x, y, z, extras, false);
//Log.v(TAG, "...app returning after sending offsets!");
} catch (RemoteException e) {
- // Ignore.
+ throw e.rethrowFromSystemServer();
}
}
@@ -1375,7 +1372,7 @@
try {
return sGlobals.mService.isWallpaperSupported(mContext.getOpPackageName());
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1395,7 +1392,7 @@
try {
return sGlobals.mService.isWallpaperSettingAllowed(mContext.getOpPackageName());
} catch (RemoteException e) {
- // Ignore
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1416,7 +1413,7 @@
WindowManagerGlobal.getWindowSession().setWallpaperPosition(
windowToken, -1, -1, -1, -1);
} catch (RemoteException e) {
- // Ignore.
+ throw e.rethrowFromSystemServer();
}
}
@@ -1497,9 +1494,8 @@
try {
return sGlobals.mService.setLockWallpaperCallback(callback);
} catch (RemoteException e) {
- Log.e(TAG, "Unable to contact wallpaper service");
+ throw e.rethrowFromSystemServer();
}
- return false;
}
// Private completion callback for setWallpaper() synchronization
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 74fe13a..5285d52 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -100,9 +100,6 @@
private final IDevicePolicyManager mService;
private final boolean mParentInstance;
- private static final String REMOTE_EXCEPTION_MESSAGE =
- "Failed to talk with device policy manager service";
-
private DevicePolicyManager(Context context, boolean parentInstance) {
this(context,
IDevicePolicyManager.Stub.asInterface(
@@ -989,7 +986,7 @@
try {
return mService.isAdminActive(admin, userId);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1004,7 +1001,7 @@
try {
return mService.isRemovingAdmin(admin, userId);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1029,7 +1026,7 @@
try {
return mService.getActiveAdmins(userId);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -1054,7 +1051,7 @@
try {
return mService.packageHasActiveAdmins(packageName, userId);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1074,7 +1071,7 @@
try {
mService.removeActiveAdmin(admin, myUserId());
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1093,7 +1090,7 @@
try {
return mService.hasGrantedPolicy(admin, usesPolicy, myUserId());
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1109,7 +1106,7 @@
try {
return mService.isSeparateProfileChallengeAllowed(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1227,7 +1224,7 @@
try {
mService.setPasswordQuality(admin, quality, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1254,7 +1251,7 @@
try {
return mService.getPasswordQuality(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return PASSWORD_QUALITY_UNSPECIFIED;
@@ -1291,7 +1288,7 @@
try {
mService.setPasswordMinimumLength(admin, length, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1319,7 +1316,7 @@
try {
return mService.getPasswordMinimumLength(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1357,7 +1354,7 @@
try {
mService.setPasswordMinimumUpperCase(admin, length, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1391,7 +1388,7 @@
try {
return mService.getPasswordMinimumUpperCase(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1429,7 +1426,7 @@
try {
mService.setPasswordMinimumLowerCase(admin, length, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1463,7 +1460,7 @@
try {
return mService.getPasswordMinimumLowerCase(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1500,7 +1497,7 @@
try {
mService.setPasswordMinimumLetters(admin, length, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1533,7 +1530,7 @@
try {
return mService.getPasswordMinimumLetters(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1570,7 +1567,7 @@
try {
mService.setPasswordMinimumNumeric(admin, length, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1603,7 +1600,7 @@
try {
return mService.getPasswordMinimumNumeric(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1640,7 +1637,7 @@
try {
mService.setPasswordMinimumSymbols(admin, length, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1672,7 +1669,7 @@
try {
return mService.getPasswordMinimumSymbols(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1709,7 +1706,7 @@
try {
mService.setPasswordMinimumNonLetter(admin, length, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1742,7 +1739,7 @@
try {
return mService.getPasswordMinimumNonLetter(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1780,7 +1777,7 @@
try {
mService.setPasswordHistoryLength(admin, length, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1816,7 +1813,7 @@
try {
mService.setPasswordExpirationTimeout(admin, timeout, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1840,7 +1837,7 @@
try {
return mService.getPasswordExpirationTimeout(admin, myUserId(), mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1864,7 +1861,7 @@
try {
return mService.getPasswordExpiration(admin, myUserId(), mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1893,7 +1890,7 @@
try {
return mService.getPasswordHistoryLength(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -1931,7 +1928,7 @@
try {
return mService.isActivePasswordSufficient(myUserId(), mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1951,7 +1948,7 @@
try {
return mService.isProfileActivePasswordSufficientForParent(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -1988,7 +1985,7 @@
try {
return mService.getCurrentFailedPasswordAttempts(userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return -1;
@@ -2005,7 +2002,7 @@
try {
return mService.getDoNotAskCredentialsOnBoot();
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -2039,7 +2036,7 @@
try {
mService.setMaximumFailedPasswordsForWipe(admin, num, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2068,7 +2065,7 @@
return mService.getMaximumFailedPasswordsForWipe(
admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -2087,7 +2084,7 @@
return mService.getProfileWithMinimumFailedPasswordsForWipe(
userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return UserHandle.USER_NULL;
@@ -2155,7 +2152,7 @@
try {
return mService.resetPassword(password, flags);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -2183,7 +2180,7 @@
try {
mService.setMaximumTimeToLock(admin, timeMs, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2212,7 +2209,7 @@
try {
return mService.getMaximumTimeToLock(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -2235,7 +2232,7 @@
try {
mService.lockNow(mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2272,7 +2269,7 @@
try {
mService.wipeData(flags);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2342,7 +2339,7 @@
}
return mService.setGlobalProxy(admin, hostSpec, exclSpec);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -2370,7 +2367,7 @@
try {
mService.setRecommendedGlobalProxy(admin, proxyInfo);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2386,7 +2383,7 @@
try {
return mService.getGlobalProxyAdmin(myUserId());
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -2515,7 +2512,7 @@
try {
return mService.setStorageEncryption(admin, encrypt);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return ENCRYPTION_STATUS_UNSUPPORTED;
@@ -2535,7 +2532,7 @@
try {
return mService.getStorageEncryption(admin, myUserId());
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -2570,7 +2567,7 @@
try {
return mService.getStorageEncryptionStatus(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return ENCRYPTION_STATUS_UNSUPPORTED;
@@ -2591,7 +2588,7 @@
try {
return mService.installCaCert(admin, certBuffer);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -2612,7 +2609,7 @@
} catch (CertificateException e) {
Log.w(TAG, "Unable to parse certificate", e);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2640,7 +2637,7 @@
}
}
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return certs;
@@ -2659,7 +2656,7 @@
mService.uninstallCaCerts(admin, new TrustedCertificateStore().userAliases()
.toArray(new String[0]));
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
@@ -2677,7 +2674,7 @@
mService.enforceCanManageCaCerts(admin);
return getCaCertAlias(certBuffer) != null;
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
} catch (CertificateException ce) {
Log.w(TAG, "Could not parse certificate", ce);
}
@@ -2737,7 +2734,7 @@
.getKeySpec(privKey, PKCS8EncodedKeySpec.class).getEncoded();
return mService.installKeyPair(admin, pkcs8Key, pemCert, alias, requestAccess);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
Log.w(TAG, "Failed to obtain private key material", e);
} catch (CertificateException | IOException e) {
@@ -2759,9 +2756,8 @@
try {
return mService.removeKeyPair(admin, alias);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
- return false;
}
/**
@@ -2800,7 +2796,7 @@
try {
mService.setCertInstallerPackage(admin, installerPackage);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2818,7 +2814,7 @@
try {
return mService.getCertInstallerPackage(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -2845,7 +2841,7 @@
try {
return mService.setAlwaysOnVpnPackage(admin, vpnPackage);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -2865,7 +2861,7 @@
try {
return mService.getAlwaysOnVpnPackage(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -2890,7 +2886,7 @@
try {
mService.setCameraDisabled(admin, disabled);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2911,7 +2907,7 @@
try {
return mService.getCameraDisabled(admin, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -2921,7 +2917,7 @@
* Called by a device owner to request a bugreport.
*
* <p>There must be only one user on the device, managed by the device owner.
- * Otherwise a security exception will be thrown.
+ * Otherwise a {@link SecurityException} will be thrown.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @return {@code true} if the bugreport collection started successfully, or {@code false}
@@ -2933,7 +2929,7 @@
try {
return mService.requestBugreport(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -2970,7 +2966,7 @@
try {
mService.setScreenCaptureDisabled(admin, disabled);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2991,7 +2987,7 @@
try {
return mService.getScreenCaptureDisabled(admin, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -3014,7 +3010,7 @@
try {
mService.setAutoTimeRequired(admin, required);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3027,7 +3023,7 @@
try {
return mService.getAutoTimeRequired();
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -3052,7 +3048,7 @@
try {
mService.setForceEphemeralUsers(admin, forceEphemeralUsers);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3066,7 +3062,7 @@
try {
return mService.getForceEphemeralUsers(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -3115,7 +3111,7 @@
try {
mService.setKeyguardDisabledFeatures(admin, which, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3144,7 +3140,7 @@
try {
return mService.getKeyguardDisabledFeatures(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return KEYGUARD_DISABLE_FEATURES_NONE;
@@ -3159,7 +3155,7 @@
try {
mService.setActiveAdmin(policyReceiver, refreshing, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3179,7 +3175,7 @@
try {
mService.getRemoveWarning(admin, result, myUserId());
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3194,7 +3190,7 @@
mService.setActivePasswordState(quality, length, letters, uppercase, lowercase,
numbers, symbols, nonletter, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3207,7 +3203,7 @@
try {
mService.reportFailedPasswordAttempt(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3220,7 +3216,7 @@
try {
mService.reportSuccessfulPasswordAttempt(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3233,7 +3229,7 @@
try {
mService.reportFailedFingerprintAttempt(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3246,7 +3242,7 @@
try {
mService.reportSuccessfulFingerprintAttempt(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3260,7 +3256,7 @@
try {
mService.reportKeyguardDismissed(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3274,7 +3270,7 @@
try {
mService.reportKeyguardSecured(userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3327,7 +3323,7 @@
try {
return mService.setDeviceOwner(who, ownerName, userId);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -3409,7 +3405,7 @@
try {
return mService.getDeviceOwnerComponent(callingUserOnly);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return null;
@@ -3428,7 +3424,7 @@
try {
return mService.getDeviceOwnerUserId();
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return UserHandle.USER_NULL;
@@ -3448,7 +3444,7 @@
try {
mService.clearDeviceOwner(packageName);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
@@ -3491,7 +3487,7 @@
try {
return mService.getDeviceOwnerName();
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return null;
@@ -3544,7 +3540,7 @@
mService.setActiveAdmin(admin, false, myUserId);
return mService.setProfileOwner(admin, ownerName, myUserId);
} catch (RemoteException re) {
- throw new IllegalArgumentException("Couldn't set profile owner.", re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -3564,7 +3560,7 @@
try {
mService.clearProfileOwner(admin);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
@@ -3578,7 +3574,7 @@
try {
return mService.hasUserSetupCompleted();
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return true;
@@ -3609,8 +3605,7 @@
}
return mService.setProfileOwner(admin, ownerName, userHandle);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- throw new IllegalArgumentException("Couldn't set profile owner.", re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -3638,7 +3633,7 @@
try {
return mService.setDeviceOwnerLockScreenInfo(admin, info);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -3652,7 +3647,7 @@
try {
return mService.getDeviceOwnerLockScreenInfo();
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return null;
@@ -3680,7 +3675,7 @@
try {
return mService.setPackagesSuspended(admin, packageNames, suspended);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return packageNames;
@@ -3699,7 +3694,7 @@
try {
return mService.getPackageSuspended(admin, packageName);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -3718,7 +3713,7 @@
try {
mService.setProfileEnabled(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3739,7 +3734,7 @@
try {
mService.setProfileName(admin, profileName);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3759,7 +3754,7 @@
return profileOwner != null
&& profileOwner.getPackageName().equals(packageName);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -3785,9 +3780,7 @@
try {
return mService.getProfileOwner(userId);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- throw new IllegalArgumentException(
- "Requested profile owner for invalid userId", re);
+ throw re.rethrowFromSystemServer();
}
}
return null;
@@ -3804,9 +3797,7 @@
try {
return mService.getProfileOwnerName(Process.myUserHandle().getIdentifier());
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- throw new IllegalArgumentException(
- "Requested profile owner for invalid userId", re);
+ throw re.rethrowFromSystemServer();
}
}
return null;
@@ -3825,9 +3816,7 @@
try {
return mService.getProfileOwnerName(userId);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- throw new IllegalArgumentException(
- "Requested profile owner for invalid userId", re);
+ throw re.rethrowFromSystemServer();
}
}
return null;
@@ -3856,7 +3845,7 @@
try {
mService.addPersistentPreferredActivity(admin, filter, activity);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3877,7 +3866,7 @@
try {
mService.clearPackagePersistentPreferredActivities(admin, packageName);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3903,7 +3892,7 @@
try {
mService.setApplicationRestrictionsManagingPackage(admin, packageName);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -3921,7 +3910,7 @@
try {
return mService.getApplicationRestrictionsManagingPackage(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -3937,7 +3926,7 @@
try {
return mService.isCallerApplicationRestrictionsManagingPackage();
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -3982,7 +3971,7 @@
try {
mService.setApplicationRestrictions(admin, packageName, settings);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4012,7 +4001,7 @@
try {
mService.setTrustAgentConfiguration(admin, target, configuration);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4043,7 +4032,7 @@
try {
return mService.getTrustAgentConfiguration(admin, agent, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return new ArrayList<PersistableBundle>(); // empty list
@@ -4064,7 +4053,7 @@
try {
mService.setCrossProfileCallerIdDisabled(admin, disabled);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4083,7 +4072,7 @@
try {
return mService.getCrossProfileCallerIdDisabled(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4100,7 +4089,7 @@
try {
return mService.getCrossProfileCallerIdDisabledForUser(userHandle.getIdentifier());
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4122,7 +4111,7 @@
try {
mService.setCrossProfileContactsSearchDisabled(admin, disabled);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4141,7 +4130,7 @@
try {
return mService.getCrossProfileContactsSearchDisabled(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4160,7 +4149,7 @@
return mService
.getCrossProfileContactsSearchDisabledForUser(userHandle.getIdentifier());
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4178,7 +4167,7 @@
mService.startManagedQuickContact(actualLookupKey, actualContactId,
isContactIdIgnored, directoryId, originalIntent);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4212,7 +4201,7 @@
try {
mService.setBluetoothContactSharingDisabled(admin, disabled);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4234,7 +4223,7 @@
try {
return mService.getBluetoothContactSharingDisabled(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return true;
@@ -4254,7 +4243,7 @@
return mService.getBluetoothContactSharingDisabledForUser(userHandle
.getIdentifier());
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return true;
@@ -4276,7 +4265,7 @@
try {
mService.addCrossProfileIntentFilter(admin, filter, flags);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4292,7 +4281,7 @@
try {
mService.clearCrossProfileIntentFilters(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4324,7 +4313,7 @@
try {
return mService.setPermittedAccessibilityServices(admin, packageNames);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4344,7 +4333,7 @@
try {
return mService.getPermittedAccessibilityServices(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -4367,7 +4356,7 @@
return mService.isAccessibilityServicePermittedByAdmin(admin, packageName,
userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4391,7 +4380,7 @@
try {
return mService.getPermittedAccessibilityServicesForUser(userId);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -4425,7 +4414,7 @@
try {
return mService.setPermittedInputMethods(admin, packageNames);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4446,7 +4435,7 @@
try {
return mService.getPermittedInputMethods(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -4468,7 +4457,7 @@
try {
return mService.isInputMethodPermittedByAdmin(admin, packageName, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4491,7 +4480,7 @@
try {
return mService.getPermittedInputMethodsForCurrentUser();
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -4511,7 +4500,7 @@
try {
return mService.getKeepUninstalledPackages(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -4534,7 +4523,7 @@
try {
mService.setKeepUninstalledPackages(admin, packageNames);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4639,9 +4628,8 @@
try {
return mService.createAndManageUser(admin, name, profileOwner, adminExtras, flags);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
- return null;
}
/**
@@ -4656,8 +4644,7 @@
try {
return mService.removeUser(admin, userHandle);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -4674,8 +4661,7 @@
try {
return mService.switchUser(admin, userHandle);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -4701,7 +4687,7 @@
try {
return mService.getApplicationRestrictions(admin, packageName);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -4723,7 +4709,7 @@
try {
mService.setUserRestriction(admin, key, true);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4744,7 +4730,7 @@
try {
mService.setUserRestriction(admin, key, false);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4771,7 +4757,7 @@
try {
ret = mService.getUserRestrictions(admin, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return ret == null ? new Bundle() : ret;
@@ -4793,7 +4779,7 @@
try {
return mService.setApplicationHidden(admin, packageName, hidden);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4811,7 +4797,7 @@
try {
return mService.isApplicationHidden(admin, packageName);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -4829,7 +4815,7 @@
try {
mService.enableSystemApp(admin, packageName);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4848,7 +4834,7 @@
try {
return mService.enableSystemAppWithIntent(admin, intent);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return 0;
@@ -4879,7 +4865,7 @@
try {
mService.setAccountManagementDisabled(admin, accountType, disabled);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4907,7 +4893,7 @@
try {
return mService.getAccountTypesWithManagementDisabledAsUser(userId);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -4938,7 +4924,7 @@
try {
mService.setLockTaskPackages(admin, packages);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -4954,7 +4940,7 @@
try {
return mService.getLockTaskPackages(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -4970,7 +4956,7 @@
try {
return mService.isLockTaskPermitted(pkg);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return false;
@@ -5017,7 +5003,7 @@
try {
mService.setGlobalSetting(admin, setting, value);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -5045,7 +5031,7 @@
try {
mService.setSecureSetting(admin, setting, value);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -5066,7 +5052,7 @@
try {
mService.setRestrictionsProvider(admin, provider);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
@@ -5082,7 +5068,7 @@
try {
mService.setMasterVolumeMuted(admin, on);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
@@ -5098,7 +5084,7 @@
try {
return mService.isMasterVolumeMuted(admin);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -5118,7 +5104,7 @@
try {
mService.setUninstallBlocked(admin, packageName, uninstallBlocked);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
@@ -5142,7 +5128,7 @@
try {
return mService.isUninstallBlocked(admin, packageName);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -5170,7 +5156,7 @@
try {
return mService.addCrossProfileWidgetProvider(admin, packageName);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -5198,7 +5184,7 @@
try {
return mService.removeCrossProfileWidgetProvider(admin, packageName);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return false;
@@ -5222,7 +5208,7 @@
return providers;
}
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return Collections.emptyList();
@@ -5238,7 +5224,7 @@
try {
mService.setUserIcon(admin, icon);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
@@ -5258,7 +5244,7 @@
try {
mService.setSystemUpdatePolicy(admin, policy);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
@@ -5273,7 +5259,7 @@
try {
return mService.getSystemUpdatePolicy();
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
return null;
@@ -5297,8 +5283,7 @@
try {
return mService.setKeyguardDisabled(admin, disabled);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5317,8 +5302,7 @@
try {
return mService.setStatusBarDisabled(admin, disabled);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5337,7 +5321,7 @@
try {
mService.notifyPendingSystemUpdate(updateReceivedTime);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
@@ -5363,7 +5347,7 @@
try {
mService.setPermissionPolicy(admin, policy);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
@@ -5377,7 +5361,7 @@
try {
return mService.getPermissionPolicy(admin);
} catch (RemoteException re) {
- return PERMISSION_POLICY_PROMPT;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5414,8 +5398,7 @@
try {
return mService.setPermissionGrantState(admin, packageName, permission, grantState);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5441,8 +5424,7 @@
try {
return mService.getPermissionGrantState(admin, packageName, permission);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return PERMISSION_GRANT_STATE_DEFAULT;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5460,8 +5442,7 @@
try {
return mService.isProvisioningAllowed(action);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5477,8 +5458,7 @@
try {
return mService.isManagedProfile(admin);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5493,8 +5473,7 @@
try {
return mService.isSystemOnlyUser(admin);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5510,8 +5489,7 @@
try {
return mService.getWifiMacAddress();
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return null;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5522,7 +5500,7 @@
try {
mService.reboot(admin);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
@@ -5552,7 +5530,7 @@
try {
mService.setShortSupportMessage(admin, message);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -5569,7 +5547,7 @@
try {
return mService.getShortSupportMessage(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -5595,7 +5573,7 @@
try {
mService.setLongSupportMessage(admin, message);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -5612,7 +5590,7 @@
try {
return mService.getLongSupportMessage(admin);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -5632,7 +5610,7 @@
try {
return mService.getShortSupportMessageForUser(admin, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -5653,7 +5631,7 @@
try {
return mService.getLongSupportMessageForUser(admin, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return null;
@@ -5674,8 +5652,7 @@
}
return new DevicePolicyManager(mContext, true);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -5686,6 +5663,9 @@
* <p> Device logs contain various information intended for security auditing purposes.
* See {@link SecurityEvent} for details.
*
+ * <p>There must be only one user on the device, managed by the device owner.
+ * Otherwise a {@link SecurityException} will be thrown.
+ *
* @param admin Which device owner this request is associated with.
* @param enabled whether device logging should be enabled or not.
* @see #retrieveDeviceLogs
@@ -5694,13 +5674,16 @@
try {
mService.setDeviceLoggingEnabled(admin, enabled);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
/**
* Return whether device logging is enabled or not by the device owner.
*
+ * <p>Can only be called by the device owner, otherwise a {@link SecurityException} will be
+ * thrown.
+ *
* @param admin Which device owner this request is associated with.
* @return {@code true} if device logging is enabled by device owner, {@code false} otherwise.
*/
@@ -5708,8 +5691,7 @@
try {
return mService.getDeviceLoggingEnabled(admin);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5720,6 +5702,9 @@
* <p> Access to the logs is rate limited and it will only return new logs after the device
* owner has been notified via {@link DeviceAdminReceiver#onSecurityLogsAvailable}.
*
+ * <p>There must be only one user on the device, managed by the device owner.
+ * Otherwise a {@link SecurityException} will be thrown.
+ *
* @param admin Which device owner this request is associated with.
* @return the new batch of device logs which is a list of {@link SecurityEvent},
* or {@code null} if rate limitation is exceeded or if logging is currently disabled.
@@ -5734,8 +5719,7 @@
return null;
}
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return null;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5764,6 +5748,9 @@
* result, this API is provided as best-effort and the returned logs may contain corrupted data.
* </strong>
*
+ * <p>There must be only one user on the device, managed by the device owner.
+ * Otherwise a {@link SecurityException} will be thrown.
+ *
* @param admin Which device owner this request is associated with.
* @return Device logs from before the latest reboot of the system.
*/
@@ -5772,8 +5759,7 @@
ParceledListSlice<SecurityEvent> list = mService.retrievePreviousDeviceLogs(admin);
return list.getList();
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return Collections.<SecurityEvent>emptyList();
+ throw re.rethrowFromSystemServer();
}
}
@@ -5792,7 +5778,7 @@
try {
mService.setOrganizationColor(admin, color);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
@@ -5811,7 +5797,7 @@
try {
mService.setOrganizationColorForUser(color, userId);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
@@ -5826,8 +5812,7 @@
try {
return mService.getOrganizationColor(admin);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return 0;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5842,8 +5827,7 @@
try {
return mService.getOrganizationColorForUser(userHandle);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return 0;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5862,7 +5846,7 @@
try {
mService.setOrganizationName(admin, title);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE);
+ throw re.rethrowFromSystemServer();
}
}
@@ -5877,8 +5861,7 @@
try {
return mService.getOrganizationName(admin);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE);
- return null;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5894,8 +5877,7 @@
try {
return mService.getOrganizationNameForUser(userHandle);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE);
- return null;
+ throw re.rethrowFromSystemServer();
}
}
@@ -5911,7 +5893,7 @@
try {
return mService.getUserProvisioningState();
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
return STATE_USER_UNMANAGED;
@@ -5929,7 +5911,7 @@
try {
mService.setUserProvisioningState(state, userHandle);
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -5956,7 +5938,7 @@
try {
mService.setAffiliationIds(admin, new ArrayList<String>(ids));
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -5971,8 +5953,7 @@
try {
return mService != null && mService.isAffiliatedUser();
} catch (RemoteException e) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -5987,8 +5968,7 @@
try {
return mService.isUninstallInQueue(packageName);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
- return false;
+ throw re.rethrowFromSystemServer();
}
}
@@ -6000,7 +5980,7 @@
try {
mService.uninstallPackageWithActiveAdmins(packageName);
} catch (RemoteException re) {
- Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ throw re.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/bluetooth/OobData.java b/core/java/android/bluetooth/OobData.java
index 2822df7..70d47ee 100644
--- a/core/java/android/bluetooth/OobData.java
+++ b/core/java/android/bluetooth/OobData.java
@@ -23,8 +23,9 @@
/**
* Out Of Band Data for Bluetooth device.
+ * @hide
*/
-public final class OobData implements Parcelable {
+public class OobData implements Parcelable {
private byte[] securityManagerTk;
public byte[] getSecurityManagerTk() {
diff --git a/core/java/android/content/pm/ContainerEncryptionParams.java b/core/java/android/content/pm/ContainerEncryptionParams.java
deleted file mode 100644
index ab3aa27..0000000
--- a/core/java/android/content/pm/ContainerEncryptionParams.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * 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 android.content.pm;
-
-import android.annotation.SystemApi;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.TextUtils;
-import android.util.Slog;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.spec.AlgorithmParameterSpec;
-import java.util.Arrays;
-
-import javax.crypto.SecretKey;
-import javax.crypto.spec.IvParameterSpec;
-
-/**
- * Represents encryption parameters used to read a container.
- *
- * @deprecated encrypted containers are legacy.
- * @hide
- */
-@SystemApi
-@Deprecated
-public class ContainerEncryptionParams implements Parcelable {
- protected static final String TAG = "ContainerEncryptionParams";
-
- /** What we print out first when toString() is called. */
- private static final String TO_STRING_PREFIX = "ContainerEncryptionParams{";
-
- /**
- * Parameter type for parceling that indicates the next parameters are
- * IvParameters.
- */
- private static final int ENC_PARAMS_IV_PARAMETERS = 1;
-
- /** Parameter type for paceling that indicates there are no MAC parameters. */
- private static final int MAC_PARAMS_NONE = 1;
-
- /** The encryption algorithm used. */
- private final String mEncryptionAlgorithm;
-
- /** The parameter spec to be used for encryption. */
- private final IvParameterSpec mEncryptionSpec;
-
- /** Secret key to be used for decryption. */
- private final SecretKey mEncryptionKey;
-
- /** Algorithm name for the MAC to be used. */
- private final String mMacAlgorithm;
-
- /** The parameter spec to be used for the MAC tag authentication. */
- private final AlgorithmParameterSpec mMacSpec;
-
- /** Secret key to be used for MAC tag authentication. */
- private final SecretKey mMacKey;
-
- /** MAC tag authenticating the data in the container. */
- private final byte[] mMacTag;
-
- /** Offset into file where authenticated (e.g., MAC protected) data begins. */
- private final long mAuthenticatedDataStart;
-
- /** Offset into file where encrypted data begins. */
- private final long mEncryptedDataStart;
-
- /**
- * Offset into file for the end of encrypted data (and, by extension,
- * authenticated data) in file.
- */
- private final long mDataEnd;
-
- public ContainerEncryptionParams(String encryptionAlgorithm,
- AlgorithmParameterSpec encryptionSpec, SecretKey encryptionKey)
- throws InvalidAlgorithmParameterException {
- this(encryptionAlgorithm, encryptionSpec, encryptionKey, null, null, null, null, -1, -1,
- -1);
- }
-
- /**
- * Creates container encryption specifications for installing from encrypted
- * containers.
- *
- * @param encryptionAlgorithm encryption algorithm to use; format matches
- * JCE
- * @param encryptionSpec algorithm parameter specification
- * @param encryptionKey key used for decryption
- * @param macAlgorithm MAC algorithm to use; format matches JCE
- * @param macSpec algorithm parameters specification, may be {@code null}
- * @param macKey key used for authentication (i.e., for the MAC tag)
- * @param macTag message authentication code (MAC) tag for the authenticated
- * data
- * @param authenticatedDataStart offset of start of authenticated data in
- * stream
- * @param encryptedDataStart offset of start of encrypted data in stream
- * @param dataEnd offset of the end of both the authenticated and encrypted
- * data
- * @throws InvalidAlgorithmParameterException
- */
- public ContainerEncryptionParams(String encryptionAlgorithm,
- AlgorithmParameterSpec encryptionSpec, SecretKey encryptionKey, String macAlgorithm,
- AlgorithmParameterSpec macSpec, SecretKey macKey, byte[] macTag,
- long authenticatedDataStart, long encryptedDataStart, long dataEnd)
- throws InvalidAlgorithmParameterException {
- if (TextUtils.isEmpty(encryptionAlgorithm)) {
- throw new NullPointerException("algorithm == null");
- } else if (encryptionSpec == null) {
- throw new NullPointerException("encryptionSpec == null");
- } else if (encryptionKey == null) {
- throw new NullPointerException("encryptionKey == null");
- }
-
- if (!TextUtils.isEmpty(macAlgorithm)) {
- if (macKey == null) {
- throw new NullPointerException("macKey == null");
- }
- }
-
- if (!(encryptionSpec instanceof IvParameterSpec)) {
- throw new InvalidAlgorithmParameterException(
- "Unknown parameter spec class; must be IvParameters");
- }
-
- mEncryptionAlgorithm = encryptionAlgorithm;
- mEncryptionSpec = (IvParameterSpec) encryptionSpec;
- mEncryptionKey = encryptionKey;
-
- mMacAlgorithm = macAlgorithm;
- mMacSpec = macSpec;
- mMacKey = macKey;
- mMacTag = macTag;
-
- mAuthenticatedDataStart = authenticatedDataStart;
- mEncryptedDataStart = encryptedDataStart;
- mDataEnd = dataEnd;
- }
-
- public String getEncryptionAlgorithm() {
- return mEncryptionAlgorithm;
- }
-
- public AlgorithmParameterSpec getEncryptionSpec() {
- return mEncryptionSpec;
- }
-
- public SecretKey getEncryptionKey() {
- return mEncryptionKey;
- }
-
- public String getMacAlgorithm() {
- return mMacAlgorithm;
- }
-
- public AlgorithmParameterSpec getMacSpec() {
- return mMacSpec;
- }
-
- public SecretKey getMacKey() {
- return mMacKey;
- }
-
- public byte[] getMacTag() {
- return mMacTag;
- }
-
- public long getAuthenticatedDataStart() {
- return mAuthenticatedDataStart;
- }
-
- public long getEncryptedDataStart() {
- return mEncryptedDataStart;
- }
-
- public long getDataEnd() {
- return mDataEnd;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (!(o instanceof ContainerEncryptionParams)) {
- return false;
- }
-
- final ContainerEncryptionParams other = (ContainerEncryptionParams) o;
-
- // Primitive comparison
- if ((mAuthenticatedDataStart != other.mAuthenticatedDataStart)
- || (mEncryptedDataStart != other.mEncryptedDataStart)
- || (mDataEnd != other.mDataEnd)) {
- return false;
- }
-
- // String comparison
- if (!mEncryptionAlgorithm.equals(other.mEncryptionAlgorithm)
- || !mMacAlgorithm.equals(other.mMacAlgorithm)) {
- return false;
- }
-
- // Object comparison
- if (!isSecretKeyEqual(mEncryptionKey, other.mEncryptionKey)
- || !isSecretKeyEqual(mMacKey, other.mMacKey)) {
- return false;
- }
-
- if (!Arrays.equals(mEncryptionSpec.getIV(), other.mEncryptionSpec.getIV())
- || !Arrays.equals(mMacTag, other.mMacTag) || (mMacSpec != other.mMacSpec)) {
- return false;
- }
-
- return true;
- }
-
- private static final boolean isSecretKeyEqual(SecretKey key1, SecretKey key2) {
- final String keyFormat = key1.getFormat();
- final String otherKeyFormat = key2.getFormat();
-
- if (keyFormat == null) {
- if (keyFormat != otherKeyFormat) {
- return false;
- }
-
- if (key1.getEncoded() != key2.getEncoded()) {
- return false;
- }
- } else {
- if (!keyFormat.equals(key2.getFormat())) {
- return false;
- }
-
- if (!Arrays.equals(key1.getEncoded(), key2.getEncoded())) {
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int hash = 3;
-
- hash += 5 * mEncryptionAlgorithm.hashCode();
- hash += 7 * Arrays.hashCode(mEncryptionSpec.getIV());
- hash += 11 * mEncryptionKey.hashCode();
- hash += 13 * mMacAlgorithm.hashCode();
- hash += 17 * mMacKey.hashCode();
- hash += 19 * Arrays.hashCode(mMacTag);
- hash += 23 * mAuthenticatedDataStart;
- hash += 29 * mEncryptedDataStart;
- hash += 31 * mDataEnd;
-
- return hash;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder(TO_STRING_PREFIX);
-
- sb.append("mEncryptionAlgorithm=\"");
- sb.append(mEncryptionAlgorithm);
- sb.append("\",");
- sb.append("mEncryptionSpec=");
- sb.append(mEncryptionSpec.toString());
- sb.append("mEncryptionKey=");
- sb.append(mEncryptionKey.toString());
-
- sb.append("mMacAlgorithm=\"");
- sb.append(mMacAlgorithm);
- sb.append("\",");
- sb.append("mMacSpec=");
- sb.append(mMacSpec.toString());
- sb.append("mMacKey=");
- sb.append(mMacKey.toString());
-
- sb.append(",mAuthenticatedDataStart=");
- sb.append(mAuthenticatedDataStart);
- sb.append(",mEncryptedDataStart=");
- sb.append(mEncryptedDataStart);
- sb.append(",mDataEnd=");
- sb.append(mDataEnd);
- sb.append('}');
-
- return sb.toString();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(mEncryptionAlgorithm);
- dest.writeInt(ENC_PARAMS_IV_PARAMETERS);
- dest.writeByteArray(mEncryptionSpec.getIV());
- dest.writeSerializable(mEncryptionKey);
-
- dest.writeString(mMacAlgorithm);
- dest.writeInt(MAC_PARAMS_NONE);
- dest.writeByteArray(new byte[0]);
- dest.writeSerializable(mMacKey);
-
- dest.writeByteArray(mMacTag);
-
- dest.writeLong(mAuthenticatedDataStart);
- dest.writeLong(mEncryptedDataStart);
- dest.writeLong(mDataEnd);
- }
-
- private ContainerEncryptionParams(Parcel source) throws InvalidAlgorithmParameterException {
- mEncryptionAlgorithm = source.readString();
- final int encParamType = source.readInt();
- final byte[] encParamsEncoded = source.createByteArray();
- mEncryptionKey = (SecretKey) source.readSerializable();
-
- mMacAlgorithm = source.readString();
- final int macParamType = source.readInt();
- source.createByteArray(); // byte[] macParamsEncoded
- mMacKey = (SecretKey) source.readSerializable();
-
- mMacTag = source.createByteArray();
-
- mAuthenticatedDataStart = source.readLong();
- mEncryptedDataStart = source.readLong();
- mDataEnd = source.readLong();
-
- switch (encParamType) {
- case ENC_PARAMS_IV_PARAMETERS:
- mEncryptionSpec = new IvParameterSpec(encParamsEncoded);
- break;
- default:
- throw new InvalidAlgorithmParameterException("Unknown parameter type "
- + encParamType);
- }
-
- switch (macParamType) {
- case MAC_PARAMS_NONE:
- mMacSpec = null;
- break;
- default:
- throw new InvalidAlgorithmParameterException("Unknown parameter type "
- + macParamType);
- }
-
- if (mEncryptionKey == null) {
- throw new NullPointerException("encryptionKey == null");
- }
- }
-
- public static final Parcelable.Creator<ContainerEncryptionParams> CREATOR =
- new Parcelable.Creator<ContainerEncryptionParams>() {
- public ContainerEncryptionParams createFromParcel(Parcel source) {
- try {
- return new ContainerEncryptionParams(source);
- } catch (InvalidAlgorithmParameterException e) {
- Slog.e(TAG, "Invalid algorithm parameters specified", e);
- return null;
- }
- }
-
- public ContainerEncryptionParams[] newArray(int size) {
- return new ContainerEncryptionParams[size];
- }
- };
-}
\ No newline at end of file
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index d6b674c..9959f27 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -46,7 +46,6 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.UserInfo;
-import android.content.pm.VerificationParams;
import android.content.pm.VerifierDeviceIdentity;
import android.graphics.Bitmap;
import android.net.Uri;
@@ -214,19 +213,11 @@
List<InstrumentationInfo> queryInstrumentation(
String targetPackage, int flags);
- void installPackage(in String originPath,
- in IPackageInstallObserver2 observer,
- int flags,
- in String installerPackageName,
- in VerificationParams verificationParams,
- in String packageAbiOverride);
-
+ /** @deprecated Use PackageInstaller instead */
void installPackageAsUser(in String originPath,
in IPackageInstallObserver2 observer,
int flags,
in String installerPackageName,
- in VerificationParams verificationParams,
- in String packageAbiOverride,
int userId);
void finishPackageInstall(int token);
diff --git a/core/java/android/content/pm/PackageItemInfo.java b/core/java/android/content/pm/PackageItemInfo.java
index 4df83036..edd888b 100644
--- a/core/java/android/content/pm/PackageItemInfo.java
+++ b/core/java/android/content/pm/PackageItemInfo.java
@@ -16,12 +16,16 @@
package android.content.pm;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcel;
import android.os.UserHandle;
+import android.text.BidiFormatter;
+import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Printer;
@@ -38,6 +42,8 @@
* in the implementation of Parcelable in subclasses.
*/
public class PackageItemInfo {
+ private static final float MAX_LABEL_SIZE_PX = 500f;
+
/**
* Public name of this item. From the "android:name" attribute.
*/
@@ -140,6 +146,56 @@
}
/**
+ * Same as {@link #loadLabel(PackageManager)} with the addition that
+ * the returned label is safe for being presented in the UI since it
+ * will not contain new lines and the length will be limited to a
+ * reasonable amount. This prevents a malicious party to influence UI
+ * layout via the app label misleading the user into performing a
+ * detrimental for them action. If the label is too long it will be
+ * truncated and ellipsized at the end.
+ *
+ * @param pm A PackageManager from which the label can be loaded; usually
+ * the PackageManager from which you originally retrieved this item
+ * @return Returns a CharSequence containing the item's label. If the
+ * item does not have a label, its name is returned.
+ *
+ * @hide
+ */
+ @SystemApi
+ public @NonNull CharSequence loadSafeLabel(@NonNull PackageManager pm) {
+ // loadLabel() always returns non-null
+ CharSequence label = loadLabel(pm);
+
+ // If the label contains new line characters it may push the UI
+ // down to hide a part of it. Labels shouldn't have new line
+ // characters, so just truncate at the first time one is seen.
+ String labelStr = label.toString();
+ final int labelLength = labelStr.length();
+ int offset = 0;
+ while (offset < labelLength) {
+ final int codePoint = labelStr.codePointAt(offset);
+ final int type = Character.getType(codePoint);
+ if (type == Character.LINE_SEPARATOR
+ || type == Character.CONTROL
+ || type == Character.PARAGRAPH_SEPARATOR) {
+ labelStr = labelStr.substring(0, offset);
+ break;
+ }
+ offset += Character.charCount(codePoint);
+ }
+
+ if (labelStr.isEmpty()) {
+ return labelStr;
+ }
+
+ TextPaint paint = new TextPaint();
+ paint.setTextSize(42);
+
+ return TextUtils.ellipsize(labelStr, paint, MAX_LABEL_SIZE_PX,
+ TextUtils.TruncateAt.END);
+ }
+
+ /**
* Retrieve the current graphical icon associated with this item. This
* will call back on the given PackageManager to load the icon from
* the application.
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 4dd8155..c2d1bdd 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -4598,60 +4598,20 @@
*/
@Deprecated
public abstract void installPackage(
- Uri packageURI, IPackageInstallObserver observer, @InstallFlags int flags,
+ Uri packageURI,
+ IPackageInstallObserver observer,
+ @InstallFlags int flags,
String installerPackageName);
-
/**
* @deprecated replaced by {@link PackageInstaller}
* @hide
*/
@Deprecated
- public abstract void installPackageWithVerification(Uri packageURI,
- IPackageInstallObserver observer, @InstallFlags int flags, String installerPackageName,
- Uri verificationURI, ContainerEncryptionParams encryptionParams);
-
- /**
- * @deprecated replaced by {@link PackageInstaller}
- * @hide
- */
- @Deprecated
- public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
- IPackageInstallObserver observer, @InstallFlags int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
-
- /**
- * @deprecated replaced by {@link PackageInstaller}
- * @hide
- */
- @Deprecated
- public abstract void installPackage(Uri packageURI, PackageInstallObserver observer,
- @InstallFlags int flags, String installerPackageName);
-
- /**
- * @deprecated replaced by {@link PackageInstaller}
- * @hide
- */
- @Deprecated
- public abstract void installPackageAsUser(Uri packageURI, PackageInstallObserver observer,
- @InstallFlags int flags, String installerPackageName, @UserIdInt int userId);
-
- /**
- * @deprecated replaced by {@link PackageInstaller}
- * @hide
- */
- @Deprecated
- public abstract void installPackageWithVerification(Uri packageURI,
- PackageInstallObserver observer, @InstallFlags int flags, String installerPackageName,
- Uri verificationURI, ContainerEncryptionParams encryptionParams);
-
- /**
- * @deprecated replaced by {@link PackageInstaller}
- * @hide
- */
- @Deprecated
- public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
- PackageInstallObserver observer, @InstallFlags int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
+ public abstract void installPackage(
+ Uri packageURI,
+ PackageInstallObserver observer,
+ @InstallFlags int flags,
+ String installerPackageName);
/**
* If there is already an application with the given package name installed
diff --git a/core/java/android/content/pm/VerificationParams.aidl b/core/java/android/content/pm/VerificationParams.aidl
deleted file mode 100644
index 5bb7f6962..0000000
--- a/core/java/android/content/pm/VerificationParams.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 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 android.content.pm;
-
-parcelable VerificationParams;
diff --git a/core/java/android/hardware/ConsumerIrManager.java b/core/java/android/hardware/ConsumerIrManager.java
index 6d29212..9fa1c3f 100644
--- a/core/java/android/hardware/ConsumerIrManager.java
+++ b/core/java/android/hardware/ConsumerIrManager.java
@@ -60,8 +60,8 @@
try {
return mService.hasIrEmitter();
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
- return false;
}
/**
@@ -84,7 +84,7 @@
try {
mService.transmit(mPackageName, carrierFrequency, pattern);
} catch (RemoteException e) {
- Log.w(TAG, "failed to transmit.", e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -149,8 +149,7 @@
}
return range;
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
- return null;
}
-
}
diff --git a/core/java/android/hardware/SerialManager.java b/core/java/android/hardware/SerialManager.java
index e0680bf22..83f7649 100644
--- a/core/java/android/hardware/SerialManager.java
+++ b/core/java/android/hardware/SerialManager.java
@@ -14,13 +14,11 @@
* limitations under the License.
*/
-
package android.hardware;
import android.content.Context;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
-import android.util.Log;
import java.io.IOException;
@@ -50,8 +48,7 @@
try {
return mService.getSerialPorts();
} catch (RemoteException e) {
- Log.e(TAG, "RemoteException in getSerialPorts", e);
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -77,8 +74,7 @@
throw new IOException("Could not open serial port " + name);
}
} catch (RemoteException e) {
- Log.e(TAG, "exception in UsbManager.openDevice", e);
+ throw e.rethrowFromSystemServer();
}
- return null;
}
}
diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java
index abd02f0..b8088f3 100644
--- a/core/java/android/hardware/fingerprint/FingerprintManager.java
+++ b/core/java/android/hardware/fingerprint/FingerprintManager.java
@@ -540,7 +540,7 @@
if (mService != null) try {
result = mService.preEnroll(mToken);
} catch (RemoteException e) {
- Log.w(TAG, "Remote exception in enroll: ", e);
+ throw e.rethrowFromSystemServer();
}
return result;
}
@@ -555,7 +555,7 @@
if (mService != null) try {
result = mService.postEnroll(mToken);
} catch (RemoteException e) {
- Log.w(TAG, "Remote exception in post enroll: ", e);
+ throw e.rethrowFromSystemServer();
}
return result;
}
@@ -571,7 +571,7 @@
if (mService != null) try {
mService.setActiveUser(userId);
} catch (RemoteException e) {
- Log.w(TAG, "Remote exception in setActiveUser: ", e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -614,7 +614,7 @@
try {
mService.rename(fpId, userId, newName);
} catch (RemoteException e) {
- Log.v(TAG, "Remote exception in rename(): ", e);
+ throw e.rethrowFromSystemServer();
}
} else {
Log.w(TAG, "rename(): Service not connected!");
@@ -632,7 +632,7 @@
if (mService != null) try {
return mService.getEnrolledFingerprints(userId, mContext.getOpPackageName());
} catch (RemoteException e) {
- Log.v(TAG, "Remote exception in getEnrolledFingerprints: ", e);
+ throw e.rethrowFromSystemServer();
}
return null;
}
@@ -659,7 +659,7 @@
return mService.hasEnrolledFingerprints(
UserHandle.myUserId(), mContext.getOpPackageName());
} catch (RemoteException e) {
- Log.v(TAG, "Remote exception in getEnrolledFingerprints: ", e);
+ throw e.rethrowFromSystemServer();
}
return false;
}
@@ -674,7 +674,7 @@
if (mService != null) try {
return mService.hasEnrolledFingerprints(userId, mContext.getOpPackageName());
} catch (RemoteException e) {
- Log.v(TAG, "Remote exception in getEnrolledFingerprints: ", e);
+ throw e.rethrowFromSystemServer();
}
return false;
}
@@ -691,7 +691,7 @@
long deviceId = 0; /* TODO: plumb hardware id to FPMS */
return mService.isHardwareDetected(deviceId, mContext.getOpPackageName());
} catch (RemoteException e) {
- Log.v(TAG, "Remote exception in isFingerprintHardwareDetected(): ", e);
+ throw e.rethrowFromSystemServer();
}
} else {
Log.w(TAG, "isFingerprintHardwareDetected(): Service not connected!");
@@ -710,7 +710,7 @@
try {
return mService.getAuthenticatorId(mContext.getOpPackageName());
} catch (RemoteException e) {
- Log.v(TAG, "Remote exception in getAuthenticatorId(): ", e);
+ throw e.rethrowFromSystemServer();
}
} else {
Log.w(TAG, "getAuthenticatorId(): Service not connected!");
@@ -730,7 +730,7 @@
try {
mService.resetTimeout(token);
} catch (RemoteException e) {
- Log.v(TAG, "Remote exception in resetTimeout(): ", e);
+ throw e.rethrowFromSystemServer();
}
} else {
Log.w(TAG, "resetTimeout(): Service not connected!");
@@ -765,7 +765,7 @@
}
});
} catch (RemoteException e) {
- Log.v(TAG, "Remote exception in addLockoutResetCallback(): ", e);
+ throw e.rethrowFromSystemServer();
}
} else {
Log.w(TAG, "addLockoutResetCallback(): Service not connected!");
@@ -881,8 +881,7 @@
try {
return ActivityManagerNative.getDefault().getCurrentUser().id;
} catch (RemoteException e) {
- Log.w(TAG, "Failed to get current user id\n");
- return UserHandle.USER_NULL;
+ throw e.rethrowFromSystemServer();
}
}
@@ -890,7 +889,7 @@
if (mService != null) try {
mService.cancelEnrollment(mToken);
} catch (RemoteException e) {
- if (DEBUG) Log.w(TAG, "Remote exception while canceling enrollment");
+ throw e.rethrowFromSystemServer();
}
}
@@ -898,7 +897,7 @@
if (mService != null) try {
mService.cancelAuthentication(mToken, mContext.getOpPackageName());
} catch (RemoteException e) {
- if (DEBUG) Log.w(TAG, "Remote exception while canceling enrollment");
+ throw e.rethrowFromSystemServer();
}
}
diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java
index 6effc0d..ff87b67 100644
--- a/core/java/android/hardware/hdmi/HdmiControlManager.java
+++ b/core/java/android/hardware/hdmi/HdmiControlManager.java
@@ -267,7 +267,7 @@
try {
types = mService.getSupportedTypes();
} catch (RemoteException e) {
- // Do nothing.
+ throw e.rethrowFromSystemServer();
}
}
mHasTvDevice = hasDeviceType(types, HdmiDeviceInfo.DEVICE_TV);
@@ -403,7 +403,7 @@
try {
mService.addHotplugEventListener(wrappedListener);
} catch (RemoteException e) {
- Log.e(TAG, "failed to add hotplug event listener: ", e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -425,7 +425,7 @@
try {
mService.removeHotplugEventListener(wrappedListener);
} catch (RemoteException e) {
- Log.e(TAG, "failed to remove hotplug event listener: ", e);
+ throw e.rethrowFromSystemServer();
}
}
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index cbe3412..fbac58c 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -252,7 +252,7 @@
try {
inputDevice = mIm.getInputDevice(id);
} catch (RemoteException ex) {
- throw new RuntimeException("Could not get input device information.", ex);
+ throw ex.rethrowFromSystemServer();
}
if (inputDevice != null) {
mInputDevices.setValueAt(index, inputDevice);
@@ -284,7 +284,7 @@
try {
inputDevice = mIm.getInputDevice(id);
} catch (RemoteException ex) {
- // Ignore the problem for the purposes of this method.
+ throw ex.rethrowFromSystemServer();
}
if (inputDevice == null) {
continue;
@@ -384,8 +384,7 @@
try {
return mIm.isInTabletMode();
} catch (RemoteException ex) {
- Log.w(TAG, "Could not get tablet mode state", ex);
- return SWITCH_STATE_UNKNOWN;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -439,7 +438,7 @@
try {
mIm.registerTabletModeChangedListener(listener);
} catch (RemoteException ex) {
- throw new RuntimeException("Could not register tablet mode changed listener", ex);
+ throw ex.rethrowFromSystemServer();
}
mTabletModeChangedListener = listener;
mOnTabletModeChangedListeners = new ArrayList<>();
@@ -471,8 +470,7 @@
try {
return mIm.getKeyboardLayouts();
} catch (RemoteException ex) {
- Log.w(TAG, "Could not get list of keyboard layout informations.", ex);
- return new KeyboardLayout[0];
+ throw ex.rethrowFromSystemServer();
}
}
@@ -494,8 +492,7 @@
try {
return mIm.getKeyboardLayoutsForInputDevice(identifier);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not get list of keyboard layouts for input device.", ex);
- return new KeyboardLayout[0];
+ throw ex.rethrowFromSystemServer();
}
}
@@ -516,8 +513,7 @@
try {
return mIm.getKeyboardLayout(keyboardLayoutDescriptor);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not get keyboard layout information.", ex);
- return null;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -534,8 +530,7 @@
try {
return mIm.getCurrentKeyboardLayoutForInputDevice(identifier);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not get current keyboard layout for input device.", ex);
- return null;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -565,7 +560,7 @@
mIm.setCurrentKeyboardLayoutForInputDevice(identifier,
keyboardLayoutDescriptor);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not set current keyboard layout for input device.", ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -585,8 +580,7 @@
try {
return mIm.getEnabledKeyboardLayoutsForInputDevice(identifier);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not get keyboard layouts for input device.", ex);
- return ArrayUtils.emptyArray(String.class);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -614,7 +608,7 @@
try {
mIm.addKeyboardLayoutForInputDevice(identifier, keyboardLayoutDescriptor);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not add keyboard layout for input device.", ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -642,7 +636,7 @@
try {
mIm.removeKeyboardLayoutForInputDevice(identifier, keyboardLayoutDescriptor);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not remove keyboard layout for input device.", ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -664,8 +658,7 @@
return mIm.getKeyboardLayoutForInputDevice(
identifier, inputMethodInfo, inputMethodSubtype);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not set keyboard layout.", ex);
- return null;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -687,7 +680,7 @@
mIm.setKeyboardLayoutForInputDevice(identifier, inputMethodInfo,
inputMethodSubtype, keyboardLayoutDescriptor);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not set keyboard layout.", ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -704,8 +697,7 @@
try {
return mIm.getTouchCalibrationForInputDevice(inputDeviceDescriptor, surfaceRotation);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not get calibration matrix for input device.", ex);
- return TouchCalibration.IDENTITY;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -726,7 +718,7 @@
try {
mIm.setTouchCalibrationForInputDevice(inputDeviceDescriptor, surfaceRotation, calibration);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not set calibration matrix for input device.", ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -793,7 +785,7 @@
try {
mIm.tryPointerSpeed(speed);
} catch (RemoteException ex) {
- Log.w(TAG, "Could not set temporary pointer speed.", ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -831,7 +823,7 @@
try {
mIm.hasKeys(id, InputDevice.SOURCE_ANY, keyCodes, ret);
} catch (RemoteException e) {
- // no fallback; just return the empty array
+ throw e.rethrowFromSystemServer();
}
return ret;
}
@@ -871,7 +863,7 @@
try {
return mIm.injectInputEvent(event, mode);
} catch (RemoteException ex) {
- return false;
+ throw ex.rethrowFromSystemServer();
}
}
@@ -887,7 +879,7 @@
try {
mIm.setPointerIconShape(iconId);
} catch (RemoteException ex) {
- // Do nothing.
+ throw ex.rethrowFromSystemServer();
}
}
@@ -896,7 +888,7 @@
try {
mIm.setCustomPointerIcon(icon);
} catch (RemoteException ex) {
- // Do nothing.
+ throw ex.rethrowFromSystemServer();
}
}
@@ -914,7 +906,7 @@
try {
mIm.setPointerIconDetached(detached);
} catch (RemoteException ex) {
- // Do nothing.
+ throw ex.rethrowFromSystemServer();
}
}
@@ -924,8 +916,7 @@
try {
mIm.registerInputDevicesChangedListener(listener);
} catch (RemoteException ex) {
- throw new RuntimeException(
- "Could not get register input device changed listener", ex);
+ throw ex.rethrowFromSystemServer();
}
mInputDevicesChangedListener = listener;
}
@@ -935,7 +926,7 @@
try {
ids = mIm.getInputDeviceIds();
} catch (RemoteException ex) {
- throw new RuntimeException("Could not get input device ids.", ex);
+ throw ex.rethrowFromSystemServer();
}
mInputDevices = new SparseArray<InputDevice>();
@@ -1175,7 +1166,7 @@
try {
mIm.vibrate(mDeviceId, pattern, repeat, mToken);
} catch (RemoteException ex) {
- Log.w(TAG, "Failed to vibrate.", ex);
+ throw ex.rethrowFromSystemServer();
}
}
@@ -1184,7 +1175,7 @@
try {
mIm.cancelVibrate(mDeviceId, mToken);
} catch (RemoteException ex) {
- Log.w(TAG, "Failed to cancel vibration.", ex);
+ throw ex.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 7004e97..5f1043b 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -45,10 +45,12 @@
import android.telephony.SubscriptionManager;
import android.util.ArrayMap;
import android.util.Log;
+import android.util.SparseArray;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.Protocol;
+import com.android.internal.util.MessageUtils;
import libcore.net.event.NetworkEventDispatcher;
@@ -79,6 +81,13 @@
public class ConnectivityManager {
private static final String TAG = "ConnectivityManager";
+ private static final SparseArray<String> sMagicDecoderRing = MessageUtils.findMessageNames(
+ new Class[]{ConnectivityManager.class}, new String[]{"CALLBACK_"});
+
+ private static final String whatToString(int what) {
+ return sMagicDecoderRing.get(what, Integer.toString(what));
+ }
+
/**
* A change in network connectivity has occurred. A default connection has either
* been established or lost. The NetworkInfo for the affected network is
@@ -733,7 +742,7 @@
try {
return mService.getActiveNetworkInfo();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -753,7 +762,7 @@
try {
return mService.getActiveNetwork();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -777,7 +786,7 @@
try {
return mService.setAlwaysOnVpnPackage(userId, vpnPackage);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -794,7 +803,7 @@
try {
return mService.getAlwaysOnVpnPackage(userId);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -815,7 +824,7 @@
try {
return mService.getActiveNetworkInfoForUid(uid);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -839,7 +848,7 @@
try {
return mService.getNetworkInfo(networkType);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -859,7 +868,7 @@
try {
return mService.getNetworkInfoForNetwork(network);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -880,7 +889,7 @@
try {
return mService.getAllNetworkInfo();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -900,7 +909,7 @@
try {
return mService.getNetworkForType(networkType);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -916,7 +925,7 @@
try {
return mService.getAllNetworks();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -929,7 +938,7 @@
try {
return mService.getDefaultNetworkCapabilitiesForUser(userId);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -948,7 +957,7 @@
try {
return mService.getActiveLinkProperties();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -972,7 +981,7 @@
try {
return mService.getLinkPropertiesForType(networkType);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -989,7 +998,7 @@
try {
return mService.getLinkProperties(network);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1006,7 +1015,7 @@
try {
return mService.getNetworkCapabilities(network);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1024,7 +1033,7 @@
try {
return mService.getCaptivePortalServerUrl();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1324,7 +1333,9 @@
int type = legacyTypeForNetworkCapabilities(netCap);
try {
delay = mService.getRestoreDefaultNetworkDelay(type);
- } catch (RemoteException e) {}
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
LegacyRequest l = new LegacyRequest();
l.networkCapabilities = netCap;
l.delay = delay;
@@ -1542,7 +1553,7 @@
try {
return mService.requestRouteToHostAddress(networkType, hostAddress.getAddress());
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1598,7 +1609,7 @@
try {
return mService.getActiveNetworkQuotaInfo();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1617,7 +1628,9 @@
Log.d("ConnectivityManager", "getMobileDataEnabled()- subId=" + subId
+ " retVal=" + retVal);
return retVal;
- } catch (RemoteException e) { }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
Log.d("ConnectivityManager", "getMobileDataEnabled()- remote exception retVal=false");
return false;
@@ -1678,6 +1691,7 @@
getNetworkManagementService().registerNetworkActivityListener(rl);
mNetworkActivityListeners.put(l, rl);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -1695,6 +1709,7 @@
try {
getNetworkManagementService().unregisterNetworkActivityListener(rl);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -1710,8 +1725,8 @@
try {
return getNetworkManagementService().isNetworkActive();
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
- return false;
}
/**
@@ -1785,7 +1800,7 @@
try {
return mService.getTetherableIfaces();
} catch (RemoteException e) {
- return new String[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -1802,7 +1817,7 @@
try {
return mService.getTetheredIfaces();
} catch (RemoteException e) {
- return new String[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -1825,7 +1840,7 @@
try {
return mService.getTetheringErroredIfaces();
} catch (RemoteException e) {
- return new String[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -1839,7 +1854,7 @@
try {
return mService.getTetheredDhcpRanges();
} catch (RemoteException e) {
- return new String[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -1871,7 +1886,7 @@
try {
return mService.tether(iface);
} catch (RemoteException e) {
- return TETHER_ERROR_SERVICE_UNAVAIL;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1897,7 +1912,7 @@
try {
return mService.untether(iface);
} catch (RemoteException e) {
- return TETHER_ERROR_SERVICE_UNAVAIL;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1917,7 +1932,7 @@
try {
return mService.isTetheringSupported();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2005,7 +2020,7 @@
try {
mService.stopTethering(type);
} catch (RemoteException e) {
- Log.e(TAG, "Exception trying to stop tethering.", e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2025,7 +2040,7 @@
try {
return mService.getTetherableUsbRegexs();
} catch (RemoteException e) {
- return new String[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -2045,7 +2060,7 @@
try {
return mService.getTetherableWifiRegexs();
} catch (RemoteException e) {
- return new String[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -2065,7 +2080,7 @@
try {
return mService.getTetherableBluetoothRegexs();
} catch (RemoteException e) {
- return new String[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -2090,7 +2105,7 @@
try {
return mService.setUsbTethering(enable);
} catch (RemoteException e) {
- return TETHER_ERROR_SERVICE_UNAVAIL;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2135,7 +2150,7 @@
try {
return mService.getLastTetherError(iface);
} catch (RemoteException e) {
- return TETHER_ERROR_SERVICE_UNAVAIL;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2153,6 +2168,7 @@
try {
mService.reportInetCondition(networkType, percentage);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -2174,6 +2190,7 @@
mService.reportNetworkConnectivity(network, true);
mService.reportNetworkConnectivity(network, false);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -2192,6 +2209,7 @@
try {
mService.reportNetworkConnectivity(network, hasConnectivity);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -2211,6 +2229,7 @@
try {
mService.setGlobalProxy(p);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -2225,7 +2244,7 @@
try {
return mService.getGlobalProxy();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2247,7 +2266,7 @@
try {
return mService.getProxyForNetwork(network);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2282,8 +2301,9 @@
public boolean isNetworkSupported(int networkType) {
try {
return mService.isNetworkSupported(networkType);
- } catch (RemoteException e) {}
- return false;
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -2303,7 +2323,7 @@
try {
return mService.isActiveNetworkMetered();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2320,7 +2340,7 @@
try {
return mService.updateLockdownVpn();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2339,6 +2359,7 @@
try {
timeOutMs = mService.checkMobileProvisioning(suggestedTimeOutMs);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
return timeOutMs;
}
@@ -2351,8 +2372,8 @@
try {
return mService.getMobileProvisioningUrl();
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
- return null;
}
/**
@@ -2369,6 +2390,7 @@
try {
mService.setProvisioningNotificationVisible(visible, networkType, action);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -2385,6 +2407,7 @@
try {
mService.setAirplaneMode(enable);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -2392,14 +2415,18 @@
public void registerNetworkFactory(Messenger messenger, String name) {
try {
mService.registerNetworkFactory(messenger, name);
- } catch (RemoteException e) { }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/** {@hide} */
public void unregisterNetworkFactory(Messenger messenger) {
try {
mService.unregisterNetworkFactory(messenger);
- } catch (RemoteException e) { }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -2412,7 +2439,7 @@
try {
return mService.registerNetworkAgent(messenger, ni, lp, nc, score, misc);
} catch (RemoteException e) {
- return NETID_UNSET;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2563,9 +2590,11 @@
@Override
public void handleMessage(Message message) {
- if (DBG) Log.d(TAG, "CM callback handler got msg " + message.what);
NetworkRequest request = (NetworkRequest) getObject(message, NetworkRequest.class);
Network network = (Network) getObject(message, Network.class);
+ if (DBG) {
+ Log.d(TAG, whatToString(message.what) + " for network " + network);
+ }
switch (message.what) {
case CALLBACK_PRECHECK: {
NetworkCallback callback = getCallback(request, "PRECHECK");
@@ -2730,7 +2759,9 @@
sNetworkCallback.put(networkCallback.networkRequest, networkCallback);
}
}
- } catch (RemoteException e) {}
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
if (networkCallback.networkRequest == null) decCallbackHandlerRefCount();
return networkCallback.networkRequest;
}
@@ -2893,7 +2924,9 @@
checkPendingIntent(operation);
try {
mService.pendingRequestForNetwork(request.networkCapabilities, operation);
- } catch (RemoteException e) {}
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -2911,7 +2944,9 @@
checkPendingIntent(operation);
try {
mService.releasePendingNetworkRequest(operation);
- } catch (RemoteException e) {}
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
private void checkPendingIntent(PendingIntent intent) {
@@ -2970,7 +3005,9 @@
checkPendingIntent(operation);
try {
mService.pendingListenForNetwork(request.networkCapabilities, operation);
- } catch (RemoteException e) {}
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -2988,7 +3025,7 @@
try {
return mService.requestBandwidthUpdate(network);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -3008,7 +3045,9 @@
}
try {
mService.releaseNetworkRequest(networkCallback.networkRequest);
- } catch (RemoteException e) {}
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -3044,7 +3083,9 @@
public void setAcceptUnvalidated(Network network, boolean accept, boolean always) {
try {
mService.setAcceptUnvalidated(network, accept, always);
- } catch (RemoteException e) {}
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -3055,6 +3096,7 @@
try {
mService.factoryReset();
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -3262,7 +3304,7 @@
try {
return getNetworkPolicyManager().getRestrictBackgroundByCaller();
} catch (RemoteException e) {
- return RESTRICT_BACKGROUND_STATUS_DISABLED;
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/net/EthernetManager.java b/core/java/android/net/EthernetManager.java
index f45737a..664b7b4 100644
--- a/core/java/android/net/EthernetManager.java
+++ b/core/java/android/net/EthernetManager.java
@@ -87,8 +87,8 @@
public IpConfiguration getConfiguration() {
try {
return mService.getConfiguration();
- } catch (NullPointerException | RemoteException e) {
- return new IpConfiguration();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -98,7 +98,8 @@
public void setConfiguration(IpConfiguration config) {
try {
mService.setConfiguration(config);
- } catch (NullPointerException | RemoteException e) {
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -109,8 +110,8 @@
public boolean isAvailable() {
try {
return mService.isAvailable();
- } catch (NullPointerException | RemoteException e) {
- return false;
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -127,7 +128,8 @@
if (mListeners.size() == 1) {
try {
mService.addListener(mServiceListener);
- } catch (NullPointerException | RemoteException e) {
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -145,7 +147,8 @@
if (mListeners.isEmpty()) {
try {
mService.removeListener(mServiceListener);
- } catch (NullPointerException | RemoteException e) {
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/net/NetworkScoreManager.java b/core/java/android/net/NetworkScoreManager.java
index b6fe68a..01c160f 100644
--- a/core/java/android/net/NetworkScoreManager.java
+++ b/core/java/android/net/NetworkScoreManager.java
@@ -166,7 +166,7 @@
try {
return mService.updateScores(networks);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -186,7 +186,7 @@
try {
return mService.clearScores();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -206,7 +206,7 @@
try {
return mService.setActiveScorer(packageName);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -221,6 +221,7 @@
try {
mService.disableScoring();
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -265,6 +266,7 @@
try {
mService.registerNetworkScoreCache(networkType, scoreCache);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/net/nsd/NsdManager.java b/core/java/android/net/nsd/NsdManager.java
index 377ed88..86bd502 100644
--- a/core/java/android/net/nsd/NsdManager.java
+++ b/core/java/android/net/nsd/NsdManager.java
@@ -619,7 +619,9 @@
public void setEnabled(boolean enabled) {
try {
mService.setEnabled(enabled);
- } catch (RemoteException e) { }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -632,7 +634,7 @@
try {
return mService.getMessenger();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java
index 56cb250..e40ebf7 100644
--- a/core/java/android/os/BatteryManager.java
+++ b/core/java/android/os/BatteryManager.java
@@ -221,7 +221,7 @@
try {
return mBatteryStats.isCharging();
} catch (RemoteException e) {
- return true;
+ throw e.rethrowFromSystemServer();
}
}
@@ -246,7 +246,7 @@
else
ret = Long.MIN_VALUE;
} catch (RemoteException e) {
- ret = Long.MIN_VALUE;
+ throw e.rethrowFromSystemServer();
}
return ret;
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index 1085b1e..307bd2d 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -258,6 +258,20 @@
return buildPath(getDataDirectory(), "misc_de", String.valueOf(userId));
}
+ private static File getDataProfilesDeDirectory(int userId) {
+ return buildPath(getDataDirectory(), "misc", "profiles", "cur", String.valueOf(userId));
+ }
+
+ /** {@hide} */
+ public static File getDataProfilesDePackageDirectory(int userId, String packageName) {
+ return buildPath(getDataProfilesDeDirectory(userId), packageName);
+ }
+
+ /** {@hide} */
+ public static File getDataProfilesDeForeignDexDirectory(int userId) {
+ return buildPath(getDataProfilesDeDirectory(userId), "foreign-dex");
+ }
+
/** {@hide} */
public static File getDataAppDirectory(String volumeUuid) {
return new File(getDataDirectory(volumeUuid), "app");
@@ -493,7 +507,7 @@
* </ul>
* @hide
*/
- private static final String[] STANDARD_DIRECTORIES = {
+ public static final String[] STANDARD_DIRECTORIES = {
DIRECTORY_MUSIC,
DIRECTORY_PODCASTS,
DIRECTORY_RINGTONES,
diff --git a/core/java/android/os/HardwarePropertiesManager.java b/core/java/android/os/HardwarePropertiesManager.java
index f48306a..9ca1dcd 100644
--- a/core/java/android/os/HardwarePropertiesManager.java
+++ b/core/java/android/os/HardwarePropertiesManager.java
@@ -79,8 +79,7 @@
try {
return mService.getDeviceTemperatures(mContext.getOpPackageName(), type);
} catch (RemoteException e) {
- Log.w(TAG, "Could not get device temperatures", e);
- return new float[0];
+ throw e.rethrowFromSystemServer();
}
default:
Log.w(TAG, "Unknown device temperature type.");
@@ -100,8 +99,7 @@
try {
return mService.getCpuUsages(mContext.getOpPackageName());
} catch (RemoteException e) {
- Log.w(TAG, "Could not get CPU usages", e);
- return new CpuUsageInfo[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -117,8 +115,7 @@
try {
return mService.getFanSpeeds(mContext.getOpPackageName());
} catch (RemoteException e) {
- Log.w(TAG, "Could not get fan speeds", e);
- return new float[0];
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 369ec15..2a4507c 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -620,6 +620,7 @@
try {
mService.userActivity(when, event, flags);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -671,6 +672,7 @@
try {
mService.goToSleep(time, reason, flags);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -697,6 +699,7 @@
try {
mService.wakeUp(time, "wakeUp", mContext.getOpPackageName());
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -707,6 +710,7 @@
try {
mService.wakeUp(time, reason, mContext.getOpPackageName());
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -735,6 +739,7 @@
try {
mService.nap(time);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -757,6 +762,7 @@
try {
mService.boostScreenBrightness(time);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -772,7 +778,7 @@
try {
return mService.isScreenBrightnessBoosted();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -790,6 +796,7 @@
try {
mService.setTemporaryScreenBrightnessSettingOverride(brightness);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -803,7 +810,7 @@
try {
return mService.isWakeLockLevelSupported(level);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -867,7 +874,7 @@
try {
return mService.isInteractive();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -884,6 +891,7 @@
try {
mService.reboot(false, reason, true);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -899,7 +907,7 @@
try {
return mService.isPowerSaveMode();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -916,7 +924,7 @@
try {
return mService.setPowerSaveMode(mode);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -936,7 +944,7 @@
try {
return mService.isDeviceIdleMode();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -956,7 +964,7 @@
try {
return mService.isLightDeviceIdleMode();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -975,7 +983,7 @@
try {
return mIDeviceIdleController.isPowerSaveWhitelistApp(packageName);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -992,6 +1000,7 @@
try {
mService.shutdown(confirm, reason, wait);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -1118,6 +1127,7 @@
try {
mService.releaseWakeLock(mToken, 0);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1186,6 +1196,7 @@
mService.acquireWakeLock(mToken, mFlags, mTag, mPackageName, mWorkSource,
mHistoryTag);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
mHeld = true;
}
@@ -1224,6 +1235,7 @@
try {
mService.releaseWakeLock(mToken, flags);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
mHeld = false;
}
@@ -1280,6 +1292,7 @@
try {
mService.updateWakeLockWorkSource(mToken, mWorkSource, mHistoryTag);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 20b3798..6e9e456 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -36,6 +36,7 @@
import android.graphics.drawable.Drawable;
import android.os.storage.StorageManager;
import android.provider.Settings;
+import android.telephony.TelephonyManager;
import android.view.WindowManager.LayoutParams;
import com.android.internal.R;
@@ -680,6 +681,22 @@
}
/**
+ * Returns whether switching users is currently allowed.
+ * <p>For instance switching users is not allowed if the current user is in a phone call,
+ * or system user hasn't been unlocked yet
+ * @hide
+ */
+ public boolean canSwitchUsers() {
+ boolean allowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt(
+ mContext.getContentResolver(),
+ Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED, 0) != 0;
+ boolean isSystemUserUnlocked = isUserUnlocked(UserHandle.SYSTEM);
+ boolean inCall = TelephonyManager.getDefault().getCallState()
+ != TelephonyManager.CALL_STATE_IDLE;
+ return (allowUserSwitchingWhenSystemUserLocked || isSystemUserUnlocked) && !inCall;
+ }
+
+ /**
* Returns the user handle for the user that this process is running under.
*
* @return the user handle of this process.
diff --git a/core/java/android/service/notification/ZenModeConfig.aidl b/core/java/android/service/notification/ZenModeConfig.aidl
index c73b75e..4644103 100644
--- a/core/java/android/service/notification/ZenModeConfig.aidl
+++ b/core/java/android/service/notification/ZenModeConfig.aidl
@@ -17,4 +17,5 @@
package android.service.notification;
parcelable ZenModeConfig;
+parcelable ZenModeConfig.ZenRule;
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 97939a9..27315ee 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -1017,7 +1017,7 @@
public static class ZenRule implements Parcelable {
public boolean enabled;
public boolean snoozing; // user manually disabled this instance
- public String name; // required for automatic (unique)
+ public String name; // required for automatic
public int zenMode;
public Uri conditionId; // required for automatic
public Condition condition; // optional
diff --git a/core/java/android/util/ArrayMap.java b/core/java/android/util/ArrayMap.java
index bdb1fdc..92a5803 100644
--- a/core/java/android/util/ArrayMap.java
+++ b/core/java/android/util/ArrayMap.java
@@ -67,7 +67,7 @@
/**
* @hide Special immutable empty ArrayMap.
*/
- public static final ArrayMap EMPTY = new ArrayMap(true);
+ public static final ArrayMap EMPTY = new ArrayMap<>(-1);
/**
* Caches of small array objects to avoid spamming garbage. The cache
@@ -80,6 +80,7 @@
static Object[] mTwiceBaseCache;
static int mTwiceBaseCacheSize;
+ final boolean mIdentityHashCode;
int[] mHashes;
Object[] mArray;
int mSize;
@@ -236,16 +237,27 @@
* will grow once items are added to it.
*/
public ArrayMap() {
- mHashes = EmptyArray.INT;
- mArray = EmptyArray.OBJECT;
- mSize = 0;
+ this(0, false);
}
/**
* Create a new ArrayMap with a given initial capacity.
*/
public ArrayMap(int capacity) {
- if (capacity == 0) {
+ this(capacity, false);
+ }
+
+ /** {@hide} */
+ public ArrayMap(int capacity, boolean identityHashCode) {
+ mIdentityHashCode = identityHashCode;
+
+ // If this is immutable, use the sentinal EMPTY_IMMUTABLE_INTS
+ // instance instead of the usual EmptyArray.INT. The reference
+ // is checked later to see if the array is allowed to grow.
+ if (capacity < 0) {
+ mHashes = EMPTY_IMMUTABLE_INTS;
+ mArray = EmptyArray.OBJECT;
+ } else if (capacity == 0) {
mHashes = EmptyArray.INT;
mArray = EmptyArray.OBJECT;
} else {
@@ -254,15 +266,6 @@
mSize = 0;
}
- private ArrayMap(boolean immutable) {
- // If this is immutable, use the sentinal EMPTY_IMMUTABLE_INTS
- // instance instead of the usual EmptyArray.INT. The reference
- // is checked later to see if the array is allowed to grow.
- mHashes = immutable ? EMPTY_IMMUTABLE_INTS : EmptyArray.INT;
- mArray = EmptyArray.OBJECT;
- mSize = 0;
- }
-
/**
* Create a new ArrayMap with the mappings from the given ArrayMap.
*/
@@ -336,7 +339,8 @@
* @return Returns the index of the key if it exists, else a negative integer.
*/
public int indexOfKey(Object key) {
- return key == null ? indexOfNull() : indexOf(key, key.hashCode());
+ return key == null ? indexOfNull()
+ : indexOf(key, mIdentityHashCode ? System.identityHashCode(key) : key.hashCode());
}
int indexOfValue(Object value) {
@@ -437,7 +441,7 @@
hash = 0;
index = indexOfNull();
} else {
- hash = key.hashCode();
+ hash = mIdentityHashCode ? System.identityHashCode(key) : key.hashCode();
index = indexOf(key, hash);
}
if (index >= 0) {
@@ -488,7 +492,8 @@
*/
public void append(K key, V value) {
int index = mSize;
- final int hash = key == null ? 0 : key.hashCode();
+ final int hash = key == null ? 0
+ : (mIdentityHashCode ? System.identityHashCode(key) : key.hashCode());
if (index >= mHashes.length) {
throw new IllegalStateException("Array is full");
}
diff --git a/core/java/android/util/ArraySet.java b/core/java/android/util/ArraySet.java
index b7a3c42..9e9314f 100644
--- a/core/java/android/util/ArraySet.java
+++ b/core/java/android/util/ArraySet.java
@@ -69,6 +69,7 @@
static Object[] mTwiceBaseCache;
static int mTwiceBaseCacheSize;
+ final boolean mIdentityHashCode;
int[] mHashes;
Object[] mArray;
int mSize;
@@ -222,15 +223,19 @@
* will grow once items are added to it.
*/
public ArraySet() {
- mHashes = EmptyArray.INT;
- mArray = EmptyArray.OBJECT;
- mSize = 0;
+ this(0, false);
}
/**
* Create a new ArraySet with a given initial capacity.
*/
public ArraySet(int capacity) {
+ this(capacity, false);
+ }
+
+ /** {@hide} */
+ public ArraySet(int capacity, boolean identityHashCode) {
+ mIdentityHashCode = identityHashCode;
if (capacity == 0) {
mHashes = EmptyArray.INT;
mArray = EmptyArray.OBJECT;
@@ -306,7 +311,8 @@
* @return Returns the index of the value if it exists, else a negative integer.
*/
public int indexOf(Object key) {
- return key == null ? indexOfNull() : indexOf(key, key.hashCode());
+ return key == null ? indexOfNull()
+ : indexOf(key, mIdentityHashCode ? System.identityHashCode(key) : key.hashCode());
}
/**
@@ -343,7 +349,7 @@
hash = 0;
index = indexOfNull();
} else {
- hash = value.hashCode();
+ hash = mIdentityHashCode ? System.identityHashCode(value) : value.hashCode();
index = indexOf(value, hash);
}
if (index >= 0) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index e7be7af..9bd3df0 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10270,6 +10270,27 @@
}
/**
+ * Like {@link #getWindowVisibleDisplayFrame}, but returns the "full" display frame this window
+ * is currently in without any insets.
+ *
+ * @hide
+ */
+ public void getWindowDisplayFrame(Rect outRect) {
+ if (mAttachInfo != null) {
+ try {
+ mAttachInfo.mSession.getDisplayFrame(mAttachInfo.mWindow, outRect);
+ } catch (RemoteException e) {
+ return;
+ }
+ return;
+ }
+ // The view is not attached to a display so we don't have a context.
+ // Make a best guess about the display size.
+ Display d = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
+ d.getRectSize(outRect);
+ }
+
+ /**
* Dispatch a notification about a resource configuration change down
* the view hierarchy.
* ViewGroups should override to route to their children.
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 4c015ba..859df43 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -664,7 +664,7 @@
try {
return mService.getInputMethodList();
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -672,7 +672,7 @@
try {
return mService.getEnabledInputMethodList();
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -689,7 +689,7 @@
return mService.getEnabledInputMethodSubtypeList(
imi == null ? null : imi.getId(), allowsImplicitlySelectedSubtypes);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -697,7 +697,7 @@
try {
mService.updateStatusIcon(imeToken, packageName, iconId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -705,7 +705,7 @@
try {
mService.updateStatusIcon(imeToken, null, 0);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -714,7 +714,7 @@
try {
mService.setImeWindowStatus(imeToken, vis, backDisposition);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -728,7 +728,7 @@
try {
mService.registerSuggestionSpansForNotification(spans);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -737,7 +737,7 @@
try {
mService.notifySuggestionPicked(span, originalString, index);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -833,6 +833,7 @@
try {
mService.finishInput(mClient);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
notifyInputConnectionFinished();
@@ -996,9 +997,8 @@
try {
return mService.showSoftInput(mClient, flags, resultReceiver);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
-
- return false;
}
}
@@ -1007,6 +1007,7 @@
try {
mService.showSoftInput(mClient, flags, resultReceiver);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -1065,8 +1066,8 @@
try {
return mService.hideSoftInput(mClient, flags, resultReceiver);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
- return false;
}
}
@@ -1421,6 +1422,7 @@
try {
mService.hideSoftInput(mClient, HIDE_NOT_ALWAYS, null);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -1476,6 +1478,7 @@
rootView.getWindowToken(), controlFlags, softInputMode, windowFlags, null,
null);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1716,7 +1719,7 @@
try {
mService.setInputMethod(token, id);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1733,7 +1736,7 @@
try {
mService.setInputMethodAndSubtype(token, id, subtype);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1753,7 +1756,7 @@
try {
mService.hideMySoftInput(token, flags);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1774,7 +1777,7 @@
try {
mService.showMySoftInput(token, flags);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1980,7 +1983,7 @@
SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES;
mService.showInputMethodPickerFromClient(mClient, mode);
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1989,7 +1992,7 @@
try {
mService.showInputMethodPickerFromClient(mClient, SHOW_IM_PICKER_MODE_AUTO);
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2003,7 +2006,7 @@
try {
mService.showInputMethodAndSubtypeEnablerFromClient(mClient, imiId);
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2018,8 +2021,7 @@
try {
return mService.getCurrentInputMethodSubtype();
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
- return null;
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2036,8 +2038,7 @@
try {
return mService.setCurrentInputMethodSubtype(subtype);
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
- return false;
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2071,7 +2072,7 @@
mLastSentUserActionNotificationSequenceNumber =
mNextUserActionNotificationSequenceNumber;
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2104,7 +2105,7 @@
}
}
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
+ throw e.rethrowFromSystemServer();
}
return ret;
}
@@ -2119,8 +2120,7 @@
try {
return mService.getInputMethodWindowVisibleHeight();
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
- return 0;
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2139,8 +2139,7 @@
try {
return mService.switchToLastInputMethod(imeToken);
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
- return false;
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2160,8 +2159,7 @@
try {
return mService.switchToNextInputMethod(imeToken, onlyCurrentIme);
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
- return false;
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2182,8 +2180,7 @@
try {
return mService.shouldOfferSwitchingToNextInputMethod(imeToken);
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
- return false;
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2218,7 +2215,7 @@
try {
mService.setAdditionalInputMethodSubtypes(imiId, subtypes);
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2228,8 +2225,7 @@
try {
return mService.getLastInputMethodSubtype();
} catch (RemoteException e) {
- Log.w(TAG, "IME died: " + mCurId, e);
- return null;
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 496f7ee..d2aef0a 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -3078,7 +3078,8 @@
final int motionPosition = mClickMotionPosition;
if (adapter != null && mItemCount > 0 &&
motionPosition != INVALID_POSITION &&
- motionPosition < adapter.getCount() && sameWindow()) {
+ motionPosition < adapter.getCount() && sameWindow() &&
+ adapter.isEnabled(motionPosition)) {
final View view = getChildAt(motionPosition - mFirstPosition);
// If there is no view, something bad happened (the view scrolled off the
// screen, etc.) and we should cancel the click
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 87bee44..6e3dbd8 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -23,32 +23,17 @@
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
-import android.text.TextUtils;
-import android.text.InputType;
-import android.text.format.DateFormat;
-import android.text.format.DateUtils;
import android.util.AttributeSet;
-import android.util.Log;
import android.util.SparseArray;
-import android.view.LayoutInflater;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.NumberPicker.OnValueChangeListener;
import com.android.internal.R;
-import java.text.DateFormatSymbols;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
-import libcore.icu.ICU;
-
/**
* Provides a widget for selecting a date.
* <p>
@@ -527,6 +512,114 @@
protected void onLocaleChanged(Locale locale) {
// Stub.
}
+
+ /**
+ * Class for managing state storing/restoring.
+ */
+ static class SavedState extends View.BaseSavedState {
+ private final int mSelectedYear;
+ private final int mSelectedMonth;
+ private final int mSelectedDay;
+ private final long mMinDate;
+ private final long mMaxDate;
+ private final int mCurrentView;
+ private final int mListPosition;
+ private final int mListPositionOffset;
+
+ public SavedState(Parcelable superState, int year, int month, int day, long minDate,
+ long maxDate) {
+ this(superState, year, month, day, minDate, maxDate, 0, 0, 0);
+ }
+
+ /**
+ * Constructor called from {@link DatePicker#onSaveInstanceState()}
+ */
+ public SavedState(Parcelable superState, int year, int month, int day, long minDate,
+ long maxDate, int currentView, int listPosition, int listPositionOffset) {
+ super(superState);
+ mSelectedYear = year;
+ mSelectedMonth = month;
+ mSelectedDay = day;
+ mMinDate = minDate;
+ mMaxDate = maxDate;
+ mCurrentView = currentView;
+ mListPosition = listPosition;
+ mListPositionOffset = listPositionOffset;
+ }
+
+ /**
+ * Constructor called from {@link #CREATOR}
+ */
+ private SavedState(Parcel in) {
+ super(in);
+ mSelectedYear = in.readInt();
+ mSelectedMonth = in.readInt();
+ mSelectedDay = in.readInt();
+ mMinDate = in.readLong();
+ mMaxDate = in.readLong();
+ mCurrentView = in.readInt();
+ mListPosition = in.readInt();
+ mListPositionOffset = in.readInt();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeInt(mSelectedYear);
+ dest.writeInt(mSelectedMonth);
+ dest.writeInt(mSelectedDay);
+ dest.writeLong(mMinDate);
+ dest.writeLong(mMaxDate);
+ dest.writeInt(mCurrentView);
+ dest.writeInt(mListPosition);
+ dest.writeInt(mListPositionOffset);
+ }
+
+ public int getSelectedDay() {
+ return mSelectedDay;
+ }
+
+ public int getSelectedMonth() {
+ return mSelectedMonth;
+ }
+
+ public int getSelectedYear() {
+ return mSelectedYear;
+ }
+
+ public long getMinDate() {
+ return mMinDate;
+ }
+
+ public long getMaxDate() {
+ return mMaxDate;
+ }
+
+ public int getCurrentView() {
+ return mCurrentView;
+ }
+
+ public int getListPosition() {
+ return mListPosition;
+ }
+
+ public int getListPositionOffset() {
+ return mListPositionOffset;
+ }
+
+ @SuppressWarnings("all")
+ // suppress unused and hiding
+ public static final Parcelable.Creator<SavedState> CREATOR = new Creator<SavedState>() {
+
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
}
/**
@@ -535,666 +628,7 @@
*
* @hide
*/
- public static interface ValidationCallback {
+ public interface ValidationCallback {
void onValidationChanged(boolean valid);
}
-
- /**
- * A delegate implementing the basic DatePicker
- */
- private static class DatePickerSpinnerDelegate extends AbstractDatePickerDelegate {
-
- private static final String DATE_FORMAT = "MM/dd/yyyy";
-
- private static final int DEFAULT_START_YEAR = 1900;
-
- private static final int DEFAULT_END_YEAR = 2100;
-
- private static final boolean DEFAULT_CALENDAR_VIEW_SHOWN = true;
-
- private static final boolean DEFAULT_SPINNERS_SHOWN = true;
-
- private static final boolean DEFAULT_ENABLED_STATE = true;
-
- private final LinearLayout mSpinners;
-
- private final NumberPicker mDaySpinner;
-
- private final NumberPicker mMonthSpinner;
-
- private final NumberPicker mYearSpinner;
-
- private final EditText mDaySpinnerInput;
-
- private final EditText mMonthSpinnerInput;
-
- private final EditText mYearSpinnerInput;
-
- private final CalendarView mCalendarView;
-
- private String[] mShortMonths;
-
- private final java.text.DateFormat mDateFormat = new SimpleDateFormat(DATE_FORMAT);
-
- private int mNumberOfMonths;
-
- private Calendar mTempDate;
-
- private Calendar mMinDate;
-
- private Calendar mMaxDate;
-
- private Calendar mCurrentDate;
-
- private boolean mIsEnabled = DEFAULT_ENABLED_STATE;
-
- DatePickerSpinnerDelegate(DatePicker delegator, Context context, AttributeSet attrs,
- int defStyleAttr, int defStyleRes) {
- super(delegator, context);
-
- mDelegator = delegator;
- mContext = context;
-
- // initialization based on locale
- setCurrentLocale(Locale.getDefault());
-
- final TypedArray attributesArray = context.obtainStyledAttributes(attrs,
- R.styleable.DatePicker, defStyleAttr, defStyleRes);
- boolean spinnersShown = attributesArray.getBoolean(R.styleable.DatePicker_spinnersShown,
- DEFAULT_SPINNERS_SHOWN);
- boolean calendarViewShown = attributesArray.getBoolean(
- R.styleable.DatePicker_calendarViewShown, DEFAULT_CALENDAR_VIEW_SHOWN);
- int startYear = attributesArray.getInt(R.styleable.DatePicker_startYear,
- DEFAULT_START_YEAR);
- int endYear = attributesArray.getInt(R.styleable.DatePicker_endYear, DEFAULT_END_YEAR);
- String minDate = attributesArray.getString(R.styleable.DatePicker_minDate);
- String maxDate = attributesArray.getString(R.styleable.DatePicker_maxDate);
- int layoutResourceId = attributesArray.getResourceId(
- R.styleable.DatePicker_legacyLayout, R.layout.date_picker_legacy);
- attributesArray.recycle();
-
- LayoutInflater inflater = (LayoutInflater) context
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- inflater.inflate(layoutResourceId, mDelegator, true);
-
- OnValueChangeListener onChangeListener = new OnValueChangeListener() {
- public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
- updateInputState();
- mTempDate.setTimeInMillis(mCurrentDate.getTimeInMillis());
- // take care of wrapping of days and months to update greater fields
- if (picker == mDaySpinner) {
- int maxDayOfMonth = mTempDate.getActualMaximum(Calendar.DAY_OF_MONTH);
- if (oldVal == maxDayOfMonth && newVal == 1) {
- mTempDate.add(Calendar.DAY_OF_MONTH, 1);
- } else if (oldVal == 1 && newVal == maxDayOfMonth) {
- mTempDate.add(Calendar.DAY_OF_MONTH, -1);
- } else {
- mTempDate.add(Calendar.DAY_OF_MONTH, newVal - oldVal);
- }
- } else if (picker == mMonthSpinner) {
- if (oldVal == 11 && newVal == 0) {
- mTempDate.add(Calendar.MONTH, 1);
- } else if (oldVal == 0 && newVal == 11) {
- mTempDate.add(Calendar.MONTH, -1);
- } else {
- mTempDate.add(Calendar.MONTH, newVal - oldVal);
- }
- } else if (picker == mYearSpinner) {
- mTempDate.set(Calendar.YEAR, newVal);
- } else {
- throw new IllegalArgumentException();
- }
- // now set the date to the adjusted one
- setDate(mTempDate.get(Calendar.YEAR), mTempDate.get(Calendar.MONTH),
- mTempDate.get(Calendar.DAY_OF_MONTH));
- updateSpinners();
- updateCalendarView();
- notifyDateChanged();
- }
- };
-
- mSpinners = (LinearLayout) mDelegator.findViewById(R.id.pickers);
-
- // calendar view day-picker
- mCalendarView = (CalendarView) mDelegator.findViewById(R.id.calendar_view);
- mCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
- public void onSelectedDayChange(CalendarView view, int year, int month, int monthDay) {
- setDate(year, month, monthDay);
- updateSpinners();
- notifyDateChanged();
- }
- });
-
- // day
- mDaySpinner = (NumberPicker) mDelegator.findViewById(R.id.day);
- mDaySpinner.setFormatter(NumberPicker.getTwoDigitFormatter());
- mDaySpinner.setOnLongPressUpdateInterval(100);
- mDaySpinner.setOnValueChangedListener(onChangeListener);
- mDaySpinnerInput = (EditText) mDaySpinner.findViewById(R.id.numberpicker_input);
-
- // month
- mMonthSpinner = (NumberPicker) mDelegator.findViewById(R.id.month);
- mMonthSpinner.setMinValue(0);
- mMonthSpinner.setMaxValue(mNumberOfMonths - 1);
- mMonthSpinner.setDisplayedValues(mShortMonths);
- mMonthSpinner.setOnLongPressUpdateInterval(200);
- mMonthSpinner.setOnValueChangedListener(onChangeListener);
- mMonthSpinnerInput = (EditText) mMonthSpinner.findViewById(R.id.numberpicker_input);
-
- // year
- mYearSpinner = (NumberPicker) mDelegator.findViewById(R.id.year);
- mYearSpinner.setOnLongPressUpdateInterval(100);
- mYearSpinner.setOnValueChangedListener(onChangeListener);
- mYearSpinnerInput = (EditText) mYearSpinner.findViewById(R.id.numberpicker_input);
-
- // show only what the user required but make sure we
- // show something and the spinners have higher priority
- if (!spinnersShown && !calendarViewShown) {
- setSpinnersShown(true);
- } else {
- setSpinnersShown(spinnersShown);
- setCalendarViewShown(calendarViewShown);
- }
-
- // set the min date giving priority of the minDate over startYear
- mTempDate.clear();
- if (!TextUtils.isEmpty(minDate)) {
- if (!parseDate(minDate, mTempDate)) {
- mTempDate.set(startYear, 0, 1);
- }
- } else {
- mTempDate.set(startYear, 0, 1);
- }
- setMinDate(mTempDate.getTimeInMillis());
-
- // set the max date giving priority of the maxDate over endYear
- mTempDate.clear();
- if (!TextUtils.isEmpty(maxDate)) {
- if (!parseDate(maxDate, mTempDate)) {
- mTempDate.set(endYear, 11, 31);
- }
- } else {
- mTempDate.set(endYear, 11, 31);
- }
- setMaxDate(mTempDate.getTimeInMillis());
-
- // initialize to current date
- mCurrentDate.setTimeInMillis(System.currentTimeMillis());
- init(mCurrentDate.get(Calendar.YEAR), mCurrentDate.get(Calendar.MONTH), mCurrentDate
- .get(Calendar.DAY_OF_MONTH), null);
-
- // re-order the number spinners to match the current date format
- reorderSpinners();
-
- // accessibility
- setContentDescriptions();
-
- // If not explicitly specified this view is important for accessibility.
- if (mDelegator.getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
- mDelegator.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
- }
- }
-
- @Override
- public void init(int year, int monthOfYear, int dayOfMonth,
- OnDateChangedListener onDateChangedListener) {
- setDate(year, monthOfYear, dayOfMonth);
- updateSpinners();
- updateCalendarView();
- mOnDateChangedListener = onDateChangedListener;
- }
-
- @Override
- public void updateDate(int year, int month, int dayOfMonth) {
- if (!isNewDate(year, month, dayOfMonth)) {
- return;
- }
- setDate(year, month, dayOfMonth);
- updateSpinners();
- updateCalendarView();
- notifyDateChanged();
- }
-
- @Override
- public int getYear() {
- return mCurrentDate.get(Calendar.YEAR);
- }
-
- @Override
- public int getMonth() {
- return mCurrentDate.get(Calendar.MONTH);
- }
-
- @Override
- public int getDayOfMonth() {
- return mCurrentDate.get(Calendar.DAY_OF_MONTH);
- }
-
- @Override
- public void setFirstDayOfWeek(int firstDayOfWeek) {
- mCalendarView.setFirstDayOfWeek(firstDayOfWeek);
- }
-
- @Override
- public int getFirstDayOfWeek() {
- return mCalendarView.getFirstDayOfWeek();
- }
-
- @Override
- public void setMinDate(long minDate) {
- mTempDate.setTimeInMillis(minDate);
- if (mTempDate.get(Calendar.YEAR) == mMinDate.get(Calendar.YEAR)
- && mTempDate.get(Calendar.DAY_OF_YEAR) != mMinDate.get(Calendar.DAY_OF_YEAR)) {
- return;
- }
- mMinDate.setTimeInMillis(minDate);
- mCalendarView.setMinDate(minDate);
- if (mCurrentDate.before(mMinDate)) {
- mCurrentDate.setTimeInMillis(mMinDate.getTimeInMillis());
- updateCalendarView();
- }
- updateSpinners();
- }
-
- @Override
- public Calendar getMinDate() {
- final Calendar minDate = Calendar.getInstance();
- minDate.setTimeInMillis(mCalendarView.getMinDate());
- return minDate;
- }
-
- @Override
- public void setMaxDate(long maxDate) {
- mTempDate.setTimeInMillis(maxDate);
- if (mTempDate.get(Calendar.YEAR) == mMaxDate.get(Calendar.YEAR)
- && mTempDate.get(Calendar.DAY_OF_YEAR) != mMaxDate.get(Calendar.DAY_OF_YEAR)) {
- return;
- }
- mMaxDate.setTimeInMillis(maxDate);
- mCalendarView.setMaxDate(maxDate);
- if (mCurrentDate.after(mMaxDate)) {
- mCurrentDate.setTimeInMillis(mMaxDate.getTimeInMillis());
- updateCalendarView();
- }
- updateSpinners();
- }
-
- @Override
- public Calendar getMaxDate() {
- final Calendar maxDate = Calendar.getInstance();
- maxDate.setTimeInMillis(mCalendarView.getMaxDate());
- return maxDate;
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- mDaySpinner.setEnabled(enabled);
- mMonthSpinner.setEnabled(enabled);
- mYearSpinner.setEnabled(enabled);
- mCalendarView.setEnabled(enabled);
- mIsEnabled = enabled;
- }
-
- @Override
- public boolean isEnabled() {
- return mIsEnabled;
- }
-
- @Override
- public CalendarView getCalendarView() {
- return mCalendarView;
- }
-
- @Override
- public void setCalendarViewShown(boolean shown) {
- mCalendarView.setVisibility(shown ? VISIBLE : GONE);
- }
-
- @Override
- public boolean getCalendarViewShown() {
- return (mCalendarView.getVisibility() == View.VISIBLE);
- }
-
- @Override
- public void setSpinnersShown(boolean shown) {
- mSpinners.setVisibility(shown ? VISIBLE : GONE);
- }
-
- @Override
- public boolean getSpinnersShown() {
- return mSpinners.isShown();
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- setCurrentLocale(newConfig.locale);
- }
-
- @Override
- public Parcelable onSaveInstanceState(Parcelable superState) {
- return new SavedState(superState, getYear(), getMonth(), getDayOfMonth());
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- SavedState ss = (SavedState) state;
- setDate(ss.mYear, ss.mMonth, ss.mDay);
- updateSpinners();
- updateCalendarView();
- }
-
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- onPopulateAccessibilityEvent(event);
- return true;
- }
-
- @Override
- public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
- final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
- String selectedDateUtterance = DateUtils.formatDateTime(mContext,
- mCurrentDate.getTimeInMillis(), flags);
- event.getText().add(selectedDateUtterance);
- }
-
- /**
- * Sets the current locale.
- *
- * @param locale The current locale.
- */
- @Override
- protected void setCurrentLocale(Locale locale) {
- super.setCurrentLocale(locale);
-
- mTempDate = getCalendarForLocale(mTempDate, locale);
- mMinDate = getCalendarForLocale(mMinDate, locale);
- mMaxDate = getCalendarForLocale(mMaxDate, locale);
- mCurrentDate = getCalendarForLocale(mCurrentDate, locale);
-
- mNumberOfMonths = mTempDate.getActualMaximum(Calendar.MONTH) + 1;
- mShortMonths = new DateFormatSymbols().getShortMonths();
-
- if (usingNumericMonths()) {
- // We're in a locale where a date should either be all-numeric, or all-text.
- // All-text would require custom NumberPicker formatters for day and year.
- mShortMonths = new String[mNumberOfMonths];
- for (int i = 0; i < mNumberOfMonths; ++i) {
- mShortMonths[i] = String.format("%d", i + 1);
- }
- }
- }
-
- /**
- * Tests whether the current locale is one where there are no real month names,
- * such as Chinese, Japanese, or Korean locales.
- */
- private boolean usingNumericMonths() {
- return Character.isDigit(mShortMonths[Calendar.JANUARY].charAt(0));
- }
-
- /**
- * Gets a calendar for locale bootstrapped with the value of a given calendar.
- *
- * @param oldCalendar The old calendar.
- * @param locale The locale.
- */
- private Calendar getCalendarForLocale(Calendar oldCalendar, Locale locale) {
- if (oldCalendar == null) {
- return Calendar.getInstance(locale);
- } else {
- final long currentTimeMillis = oldCalendar.getTimeInMillis();
- Calendar newCalendar = Calendar.getInstance(locale);
- newCalendar.setTimeInMillis(currentTimeMillis);
- return newCalendar;
- }
- }
-
- /**
- * Reorders the spinners according to the date format that is
- * explicitly set by the user and if no such is set fall back
- * to the current locale's default format.
- */
- private void reorderSpinners() {
- mSpinners.removeAllViews();
- // We use numeric spinners for year and day, but textual months. Ask icu4c what
- // order the user's locale uses for that combination. http://b/7207103.
- String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), "yyyyMMMdd");
- char[] order = ICU.getDateFormatOrder(pattern);
- final int spinnerCount = order.length;
- for (int i = 0; i < spinnerCount; i++) {
- switch (order[i]) {
- case 'd':
- mSpinners.addView(mDaySpinner);
- setImeOptions(mDaySpinner, spinnerCount, i);
- break;
- case 'M':
- mSpinners.addView(mMonthSpinner);
- setImeOptions(mMonthSpinner, spinnerCount, i);
- break;
- case 'y':
- mSpinners.addView(mYearSpinner);
- setImeOptions(mYearSpinner, spinnerCount, i);
- break;
- default:
- throw new IllegalArgumentException(Arrays.toString(order));
- }
- }
- }
-
- /**
- * Parses the given <code>date</code> and in case of success sets the result
- * to the <code>outDate</code>.
- *
- * @return True if the date was parsed.
- */
- private boolean parseDate(String date, Calendar outDate) {
- try {
- outDate.setTime(mDateFormat.parse(date));
- return true;
- } catch (ParseException e) {
- Log.w(LOG_TAG, "Date: " + date + " not in format: " + DATE_FORMAT);
- return false;
- }
- }
-
- private boolean isNewDate(int year, int month, int dayOfMonth) {
- return (mCurrentDate.get(Calendar.YEAR) != year
- || mCurrentDate.get(Calendar.MONTH) != month
- || mCurrentDate.get(Calendar.DAY_OF_MONTH) != dayOfMonth);
- }
-
- private void setDate(int year, int month, int dayOfMonth) {
- mCurrentDate.set(year, month, dayOfMonth);
- if (mCurrentDate.before(mMinDate)) {
- mCurrentDate.setTimeInMillis(mMinDate.getTimeInMillis());
- } else if (mCurrentDate.after(mMaxDate)) {
- mCurrentDate.setTimeInMillis(mMaxDate.getTimeInMillis());
- }
- }
-
- private void updateSpinners() {
- // set the spinner ranges respecting the min and max dates
- if (mCurrentDate.equals(mMinDate)) {
- mDaySpinner.setMinValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
- mDaySpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.DAY_OF_MONTH));
- mDaySpinner.setWrapSelectorWheel(false);
- mMonthSpinner.setDisplayedValues(null);
- mMonthSpinner.setMinValue(mCurrentDate.get(Calendar.MONTH));
- mMonthSpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.MONTH));
- mMonthSpinner.setWrapSelectorWheel(false);
- } else if (mCurrentDate.equals(mMaxDate)) {
- mDaySpinner.setMinValue(mCurrentDate.getActualMinimum(Calendar.DAY_OF_MONTH));
- mDaySpinner.setMaxValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
- mDaySpinner.setWrapSelectorWheel(false);
- mMonthSpinner.setDisplayedValues(null);
- mMonthSpinner.setMinValue(mCurrentDate.getActualMinimum(Calendar.MONTH));
- mMonthSpinner.setMaxValue(mCurrentDate.get(Calendar.MONTH));
- mMonthSpinner.setWrapSelectorWheel(false);
- } else {
- mDaySpinner.setMinValue(1);
- mDaySpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.DAY_OF_MONTH));
- mDaySpinner.setWrapSelectorWheel(true);
- mMonthSpinner.setDisplayedValues(null);
- mMonthSpinner.setMinValue(0);
- mMonthSpinner.setMaxValue(11);
- mMonthSpinner.setWrapSelectorWheel(true);
- }
-
- // make sure the month names are a zero based array
- // with the months in the month spinner
- String[] displayedValues = Arrays.copyOfRange(mShortMonths,
- mMonthSpinner.getMinValue(), mMonthSpinner.getMaxValue() + 1);
- mMonthSpinner.setDisplayedValues(displayedValues);
-
- // year spinner range does not change based on the current date
- mYearSpinner.setMinValue(mMinDate.get(Calendar.YEAR));
- mYearSpinner.setMaxValue(mMaxDate.get(Calendar.YEAR));
- mYearSpinner.setWrapSelectorWheel(false);
-
- // set the spinner values
- mYearSpinner.setValue(mCurrentDate.get(Calendar.YEAR));
- mMonthSpinner.setValue(mCurrentDate.get(Calendar.MONTH));
- mDaySpinner.setValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
-
- if (usingNumericMonths()) {
- mMonthSpinnerInput.setRawInputType(InputType.TYPE_CLASS_NUMBER);
- }
- }
-
- /**
- * Updates the calendar view with the current date.
- */
- private void updateCalendarView() {
- mCalendarView.setDate(mCurrentDate.getTimeInMillis(), false, false);
- }
-
-
- /**
- * Notifies the listener, if such, for a change in the selected date.
- */
- private void notifyDateChanged() {
- mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
- if (mOnDateChangedListener != null) {
- mOnDateChangedListener.onDateChanged(mDelegator, getYear(), getMonth(),
- getDayOfMonth());
- }
- }
-
- /**
- * Sets the IME options for a spinner based on its ordering.
- *
- * @param spinner The spinner.
- * @param spinnerCount The total spinner count.
- * @param spinnerIndex The index of the given spinner.
- */
- private void setImeOptions(NumberPicker spinner, int spinnerCount, int spinnerIndex) {
- final int imeOptions;
- if (spinnerIndex < spinnerCount - 1) {
- imeOptions = EditorInfo.IME_ACTION_NEXT;
- } else {
- imeOptions = EditorInfo.IME_ACTION_DONE;
- }
- TextView input = (TextView) spinner.findViewById(R.id.numberpicker_input);
- input.setImeOptions(imeOptions);
- }
-
- private void setContentDescriptions() {
- // Day
- trySetContentDescription(mDaySpinner, R.id.increment,
- R.string.date_picker_increment_day_button);
- trySetContentDescription(mDaySpinner, R.id.decrement,
- R.string.date_picker_decrement_day_button);
- // Month
- trySetContentDescription(mMonthSpinner, R.id.increment,
- R.string.date_picker_increment_month_button);
- trySetContentDescription(mMonthSpinner, R.id.decrement,
- R.string.date_picker_decrement_month_button);
- // Year
- trySetContentDescription(mYearSpinner, R.id.increment,
- R.string.date_picker_increment_year_button);
- trySetContentDescription(mYearSpinner, R.id.decrement,
- R.string.date_picker_decrement_year_button);
- }
-
- private void trySetContentDescription(View root, int viewId, int contDescResId) {
- View target = root.findViewById(viewId);
- if (target != null) {
- target.setContentDescription(mContext.getString(contDescResId));
- }
- }
-
- private void updateInputState() {
- // Make sure that if the user changes the value and the IME is active
- // for one of the inputs if this widget, the IME is closed. If the user
- // changed the value via the IME and there is a next input the IME will
- // be shown, otherwise the user chose another means of changing the
- // value and having the IME up makes no sense.
- InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
- if (inputMethodManager != null) {
- if (inputMethodManager.isActive(mYearSpinnerInput)) {
- mYearSpinnerInput.clearFocus();
- inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
- } else if (inputMethodManager.isActive(mMonthSpinnerInput)) {
- mMonthSpinnerInput.clearFocus();
- inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
- } else if (inputMethodManager.isActive(mDaySpinnerInput)) {
- mDaySpinnerInput.clearFocus();
- inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
- }
- }
- }
- }
-
- /**
- * Class for managing state storing/restoring.
- */
- private static class SavedState extends BaseSavedState {
-
- private final int mYear;
-
- private final int mMonth;
-
- private final int mDay;
-
- /**
- * Constructor called from {@link DatePicker#onSaveInstanceState()}
- */
- private SavedState(Parcelable superState, int year, int month, int day) {
- super(superState);
- mYear = year;
- mMonth = month;
- mDay = day;
- }
-
- /**
- * Constructor called from {@link #CREATOR}
- */
- private SavedState(Parcel in) {
- super(in);
- mYear = in.readInt();
- mMonth = in.readInt();
- mDay = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mYear);
- dest.writeInt(mMonth);
- dest.writeInt(mDay);
- }
-
- @SuppressWarnings("all")
- // suppress unused and hiding
- public static final Parcelable.Creator<SavedState> CREATOR = new Creator<SavedState>() {
-
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
}
diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java
index cbb6109..5adac01 100755
--- a/core/java/android/widget/DatePickerCalendarDelegate.java
+++ b/core/java/android/widget/DatePickerCalendarDelegate.java
@@ -16,13 +16,14 @@
package android.widget;
+import com.android.internal.R;
+
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.os.Parcel;
import android.os.Parcelable;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
@@ -37,8 +38,6 @@
import android.widget.DayPickerView.OnDaySelectedListener;
import android.widget.YearPickerView.OnYearSelectedListener;
-import com.android.internal.R;
-
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
@@ -550,25 +549,27 @@
@Override
public void onRestoreInstanceState(Parcelable state) {
- final SavedState ss = (SavedState) state;
+ if (state instanceof SavedState) {
+ final SavedState ss = (SavedState) state;
- // TODO: Move instance state into DayPickerView, YearPickerView.
- mCurrentDate.set(ss.getSelectedYear(), ss.getSelectedMonth(), ss.getSelectedDay());
- mMinDate.setTimeInMillis(ss.getMinDate());
- mMaxDate.setTimeInMillis(ss.getMaxDate());
+ // TODO: Move instance state into DayPickerView, YearPickerView.
+ mCurrentDate.set(ss.getSelectedYear(), ss.getSelectedMonth(), ss.getSelectedDay());
+ mMinDate.setTimeInMillis(ss.getMinDate());
+ mMaxDate.setTimeInMillis(ss.getMaxDate());
- onCurrentDateChanged(false);
+ onCurrentDateChanged(false);
- final int currentView = ss.getCurrentView();
- setCurrentView(currentView);
+ final int currentView = ss.getCurrentView();
+ setCurrentView(currentView);
- final int listPosition = ss.getListPosition();
- if (listPosition != -1) {
- if (currentView == VIEW_MONTH_DAY) {
- mDayPickerView.setPosition(listPosition);
- } else if (currentView == VIEW_YEAR) {
- final int listPositionOffset = ss.getListPositionOffset();
- mYearPickerView.setSelectionFromTop(listPosition, listPositionOffset);
+ final int listPosition = ss.getListPosition();
+ if (listPosition != -1) {
+ if (currentView == VIEW_MONTH_DAY) {
+ mDayPickerView.setPosition(listPosition);
+ } else if (currentView == VIEW_YEAR) {
+ final int listPositionOffset = ss.getListPositionOffset();
+ mYearPickerView.setSelectionFromTop(listPosition, listPositionOffset);
+ }
}
}
}
@@ -613,108 +614,4 @@
private void tryVibrate() {
mDelegator.performHapticFeedback(HapticFeedbackConstants.CALENDAR_DATE);
}
-
- /**
- * Class for managing state storing/restoring.
- */
- private static class SavedState extends View.BaseSavedState {
- private final int mSelectedYear;
- private final int mSelectedMonth;
- private final int mSelectedDay;
- private final long mMinDate;
- private final long mMaxDate;
- private final int mCurrentView;
- private final int mListPosition;
- private final int mListPositionOffset;
-
- /**
- * Constructor called from {@link DatePicker#onSaveInstanceState()}
- */
- private SavedState(Parcelable superState, int year, int month, int day,
- long minDate, long maxDate, int currentView, int listPosition,
- int listPositionOffset) {
- super(superState);
- mSelectedYear = year;
- mSelectedMonth = month;
- mSelectedDay = day;
- mMinDate = minDate;
- mMaxDate = maxDate;
- mCurrentView = currentView;
- mListPosition = listPosition;
- mListPositionOffset = listPositionOffset;
- }
-
- /**
- * Constructor called from {@link #CREATOR}
- */
- private SavedState(Parcel in) {
- super(in);
- mSelectedYear = in.readInt();
- mSelectedMonth = in.readInt();
- mSelectedDay = in.readInt();
- mMinDate = in.readLong();
- mMaxDate = in.readLong();
- mCurrentView = in.readInt();
- mListPosition = in.readInt();
- mListPositionOffset = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mSelectedYear);
- dest.writeInt(mSelectedMonth);
- dest.writeInt(mSelectedDay);
- dest.writeLong(mMinDate);
- dest.writeLong(mMaxDate);
- dest.writeInt(mCurrentView);
- dest.writeInt(mListPosition);
- dest.writeInt(mListPositionOffset);
- }
-
- public int getSelectedDay() {
- return mSelectedDay;
- }
-
- public int getSelectedMonth() {
- return mSelectedMonth;
- }
-
- public int getSelectedYear() {
- return mSelectedYear;
- }
-
- public long getMinDate() {
- return mMinDate;
- }
-
- public long getMaxDate() {
- return mMaxDate;
- }
-
- public int getCurrentView() {
- return mCurrentView;
- }
-
- public int getListPosition() {
- return mListPosition;
- }
-
- public int getListPositionOffset() {
- return mListPositionOffset;
- }
-
- @SuppressWarnings("all")
- // suppress unused and hiding
- public static final Parcelable.Creator<SavedState> CREATOR = new Creator<SavedState>() {
-
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
}
diff --git a/core/java/android/widget/DatePickerSpinnerDelegate.java b/core/java/android/widget/DatePickerSpinnerDelegate.java
new file mode 100644
index 0000000..255de79
--- /dev/null
+++ b/core/java/android/widget/DatePickerSpinnerDelegate.java
@@ -0,0 +1,652 @@
+/*
+ * 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.widget;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
+import android.os.Parcelable;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.text.format.DateFormat;
+import android.text.format.DateUtils;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.DatePicker.AbstractDatePickerDelegate;
+import android.widget.NumberPicker.OnValueChangeListener;
+
+import java.text.DateFormatSymbols;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Locale;
+
+import libcore.icu.ICU;
+
+/**
+ * A delegate implementing the basic DatePicker
+ */
+class DatePickerSpinnerDelegate extends AbstractDatePickerDelegate {
+
+ private static final String DATE_FORMAT = "MM/dd/yyyy";
+
+ private static final int DEFAULT_START_YEAR = 1900;
+
+ private static final int DEFAULT_END_YEAR = 2100;
+
+ private static final boolean DEFAULT_CALENDAR_VIEW_SHOWN = true;
+
+ private static final boolean DEFAULT_SPINNERS_SHOWN = true;
+
+ private static final boolean DEFAULT_ENABLED_STATE = true;
+
+ private final LinearLayout mSpinners;
+
+ private final NumberPicker mDaySpinner;
+
+ private final NumberPicker mMonthSpinner;
+
+ private final NumberPicker mYearSpinner;
+
+ private final EditText mDaySpinnerInput;
+
+ private final EditText mMonthSpinnerInput;
+
+ private final EditText mYearSpinnerInput;
+
+ private final CalendarView mCalendarView;
+
+ private String[] mShortMonths;
+
+ private final java.text.DateFormat mDateFormat = new SimpleDateFormat(DATE_FORMAT);
+
+ private int mNumberOfMonths;
+
+ private Calendar mTempDate;
+
+ private Calendar mMinDate;
+
+ private Calendar mMaxDate;
+
+ private Calendar mCurrentDate;
+
+ private boolean mIsEnabled = DEFAULT_ENABLED_STATE;
+
+ DatePickerSpinnerDelegate(DatePicker delegator, Context context, AttributeSet attrs,
+ int defStyleAttr, int defStyleRes) {
+ super(delegator, context);
+
+ mDelegator = delegator;
+ mContext = context;
+
+ // initialization based on locale
+ setCurrentLocale(Locale.getDefault());
+
+ final TypedArray attributesArray = context.obtainStyledAttributes(attrs,
+ com.android.internal.R.styleable.DatePicker, defStyleAttr, defStyleRes);
+ boolean spinnersShown = attributesArray.getBoolean(com.android.internal.R.styleable.DatePicker_spinnersShown,
+ DEFAULT_SPINNERS_SHOWN);
+ boolean calendarViewShown = attributesArray.getBoolean(
+ com.android.internal.R.styleable.DatePicker_calendarViewShown, DEFAULT_CALENDAR_VIEW_SHOWN);
+ int startYear = attributesArray.getInt(com.android.internal.R.styleable.DatePicker_startYear,
+ DEFAULT_START_YEAR);
+ int endYear = attributesArray.getInt(com.android.internal.R.styleable.DatePicker_endYear, DEFAULT_END_YEAR);
+ String minDate = attributesArray.getString(com.android.internal.R.styleable.DatePicker_minDate);
+ String maxDate = attributesArray.getString(com.android.internal.R.styleable.DatePicker_maxDate);
+ int layoutResourceId = attributesArray.getResourceId(
+ com.android.internal.R.styleable.DatePicker_legacyLayout, com.android.internal.R.layout.date_picker_legacy);
+ attributesArray.recycle();
+
+ LayoutInflater inflater = (LayoutInflater) context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ inflater.inflate(layoutResourceId, mDelegator, true);
+
+ OnValueChangeListener onChangeListener = new OnValueChangeListener() {
+ public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
+ updateInputState();
+ mTempDate.setTimeInMillis(mCurrentDate.getTimeInMillis());
+ // take care of wrapping of days and months to update greater fields
+ if (picker == mDaySpinner) {
+ int maxDayOfMonth = mTempDate.getActualMaximum(Calendar.DAY_OF_MONTH);
+ if (oldVal == maxDayOfMonth && newVal == 1) {
+ mTempDate.add(Calendar.DAY_OF_MONTH, 1);
+ } else if (oldVal == 1 && newVal == maxDayOfMonth) {
+ mTempDate.add(Calendar.DAY_OF_MONTH, -1);
+ } else {
+ mTempDate.add(Calendar.DAY_OF_MONTH, newVal - oldVal);
+ }
+ } else if (picker == mMonthSpinner) {
+ if (oldVal == 11 && newVal == 0) {
+ mTempDate.add(Calendar.MONTH, 1);
+ } else if (oldVal == 0 && newVal == 11) {
+ mTempDate.add(Calendar.MONTH, -1);
+ } else {
+ mTempDate.add(Calendar.MONTH, newVal - oldVal);
+ }
+ } else if (picker == mYearSpinner) {
+ mTempDate.set(Calendar.YEAR, newVal);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ // now set the date to the adjusted one
+ setDate(mTempDate.get(Calendar.YEAR), mTempDate.get(Calendar.MONTH),
+ mTempDate.get(Calendar.DAY_OF_MONTH));
+ updateSpinners();
+ updateCalendarView();
+ notifyDateChanged();
+ }
+ };
+
+ mSpinners = (LinearLayout) mDelegator.findViewById(com.android.internal.R.id.pickers);
+
+ // calendar view day-picker
+ mCalendarView = (CalendarView) mDelegator.findViewById(com.android.internal.R.id.calendar_view);
+ mCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
+ public void onSelectedDayChange(CalendarView view, int year, int month, int monthDay) {
+ setDate(year, month, monthDay);
+ updateSpinners();
+ notifyDateChanged();
+ }
+ });
+
+ // day
+ mDaySpinner = (NumberPicker) mDelegator.findViewById(com.android.internal.R.id.day);
+ mDaySpinner.setFormatter(NumberPicker.getTwoDigitFormatter());
+ mDaySpinner.setOnLongPressUpdateInterval(100);
+ mDaySpinner.setOnValueChangedListener(onChangeListener);
+ mDaySpinnerInput = (EditText) mDaySpinner.findViewById(com.android.internal.R.id.numberpicker_input);
+
+ // month
+ mMonthSpinner = (NumberPicker) mDelegator.findViewById(com.android.internal.R.id.month);
+ mMonthSpinner.setMinValue(0);
+ mMonthSpinner.setMaxValue(mNumberOfMonths - 1);
+ mMonthSpinner.setDisplayedValues(mShortMonths);
+ mMonthSpinner.setOnLongPressUpdateInterval(200);
+ mMonthSpinner.setOnValueChangedListener(onChangeListener);
+ mMonthSpinnerInput = (EditText) mMonthSpinner.findViewById(com.android.internal.R.id.numberpicker_input);
+
+ // year
+ mYearSpinner = (NumberPicker) mDelegator.findViewById(com.android.internal.R.id.year);
+ mYearSpinner.setOnLongPressUpdateInterval(100);
+ mYearSpinner.setOnValueChangedListener(onChangeListener);
+ mYearSpinnerInput = (EditText) mYearSpinner.findViewById(com.android.internal.R.id.numberpicker_input);
+
+ // show only what the user required but make sure we
+ // show something and the spinners have higher priority
+ if (!spinnersShown && !calendarViewShown) {
+ setSpinnersShown(true);
+ } else {
+ setSpinnersShown(spinnersShown);
+ setCalendarViewShown(calendarViewShown);
+ }
+
+ // set the min date giving priority of the minDate over startYear
+ mTempDate.clear();
+ if (!TextUtils.isEmpty(minDate)) {
+ if (!parseDate(minDate, mTempDate)) {
+ mTempDate.set(startYear, 0, 1);
+ }
+ } else {
+ mTempDate.set(startYear, 0, 1);
+ }
+ setMinDate(mTempDate.getTimeInMillis());
+
+ // set the max date giving priority of the maxDate over endYear
+ mTempDate.clear();
+ if (!TextUtils.isEmpty(maxDate)) {
+ if (!parseDate(maxDate, mTempDate)) {
+ mTempDate.set(endYear, 11, 31);
+ }
+ } else {
+ mTempDate.set(endYear, 11, 31);
+ }
+ setMaxDate(mTempDate.getTimeInMillis());
+
+ // initialize to current date
+ mCurrentDate.setTimeInMillis(System.currentTimeMillis());
+ init(mCurrentDate.get(Calendar.YEAR), mCurrentDate.get(Calendar.MONTH), mCurrentDate
+ .get(Calendar.DAY_OF_MONTH), null);
+
+ // re-order the number spinners to match the current date format
+ reorderSpinners();
+
+ // accessibility
+ setContentDescriptions();
+
+ // If not explicitly specified this view is important for accessibility.
+ if (mDelegator.getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
+ mDelegator.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
+ }
+ }
+
+ @Override
+ public void init(int year, int monthOfYear, int dayOfMonth,
+ DatePicker.OnDateChangedListener onDateChangedListener) {
+ setDate(year, monthOfYear, dayOfMonth);
+ updateSpinners();
+ updateCalendarView();
+ mOnDateChangedListener = onDateChangedListener;
+ }
+
+ @Override
+ public void updateDate(int year, int month, int dayOfMonth) {
+ if (!isNewDate(year, month, dayOfMonth)) {
+ return;
+ }
+ setDate(year, month, dayOfMonth);
+ updateSpinners();
+ updateCalendarView();
+ notifyDateChanged();
+ }
+
+ @Override
+ public int getYear() {
+ return mCurrentDate.get(Calendar.YEAR);
+ }
+
+ @Override
+ public int getMonth() {
+ return mCurrentDate.get(Calendar.MONTH);
+ }
+
+ @Override
+ public int getDayOfMonth() {
+ return mCurrentDate.get(Calendar.DAY_OF_MONTH);
+ }
+
+ @Override
+ public void setFirstDayOfWeek(int firstDayOfWeek) {
+ mCalendarView.setFirstDayOfWeek(firstDayOfWeek);
+ }
+
+ @Override
+ public int getFirstDayOfWeek() {
+ return mCalendarView.getFirstDayOfWeek();
+ }
+
+ @Override
+ public void setMinDate(long minDate) {
+ mTempDate.setTimeInMillis(minDate);
+ if (mTempDate.get(Calendar.YEAR) == mMinDate.get(Calendar.YEAR)
+ && mTempDate.get(Calendar.DAY_OF_YEAR) != mMinDate.get(Calendar.DAY_OF_YEAR)) {
+ return;
+ }
+ mMinDate.setTimeInMillis(minDate);
+ mCalendarView.setMinDate(minDate);
+ if (mCurrentDate.before(mMinDate)) {
+ mCurrentDate.setTimeInMillis(mMinDate.getTimeInMillis());
+ updateCalendarView();
+ }
+ updateSpinners();
+ }
+
+ @Override
+ public Calendar getMinDate() {
+ final Calendar minDate = Calendar.getInstance();
+ minDate.setTimeInMillis(mCalendarView.getMinDate());
+ return minDate;
+ }
+
+ @Override
+ public void setMaxDate(long maxDate) {
+ mTempDate.setTimeInMillis(maxDate);
+ if (mTempDate.get(Calendar.YEAR) == mMaxDate.get(Calendar.YEAR)
+ && mTempDate.get(Calendar.DAY_OF_YEAR) != mMaxDate.get(Calendar.DAY_OF_YEAR)) {
+ return;
+ }
+ mMaxDate.setTimeInMillis(maxDate);
+ mCalendarView.setMaxDate(maxDate);
+ if (mCurrentDate.after(mMaxDate)) {
+ mCurrentDate.setTimeInMillis(mMaxDate.getTimeInMillis());
+ updateCalendarView();
+ }
+ updateSpinners();
+ }
+
+ @Override
+ public Calendar getMaxDate() {
+ final Calendar maxDate = Calendar.getInstance();
+ maxDate.setTimeInMillis(mCalendarView.getMaxDate());
+ return maxDate;
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ mDaySpinner.setEnabled(enabled);
+ mMonthSpinner.setEnabled(enabled);
+ mYearSpinner.setEnabled(enabled);
+ mCalendarView.setEnabled(enabled);
+ mIsEnabled = enabled;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return mIsEnabled;
+ }
+
+ @Override
+ public CalendarView getCalendarView() {
+ return mCalendarView;
+ }
+
+ @Override
+ public void setCalendarViewShown(boolean shown) {
+ mCalendarView.setVisibility(shown ? View.VISIBLE : View.GONE);
+ }
+
+ @Override
+ public boolean getCalendarViewShown() {
+ return (mCalendarView.getVisibility() == View.VISIBLE);
+ }
+
+ @Override
+ public void setSpinnersShown(boolean shown) {
+ mSpinners.setVisibility(shown ? View.VISIBLE : View.GONE);
+ }
+
+ @Override
+ public boolean getSpinnersShown() {
+ return mSpinners.isShown();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ setCurrentLocale(newConfig.locale);
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState(Parcelable superState) {
+ return new SavedState(superState, getYear(), getMonth(), getDayOfMonth(),
+ getMinDate().getTimeInMillis(), getMaxDate().getTimeInMillis());
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ if (state instanceof SavedState) {
+ final SavedState ss = (SavedState) state;
+ setDate(ss.getSelectedYear(), ss.getSelectedMonth(), ss.getSelectedDay());
+ updateSpinners();
+ updateCalendarView();
+ }
+ }
+
+ @Override
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ onPopulateAccessibilityEvent(event);
+ return true;
+ }
+
+ @Override
+ public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
+ String selectedDateUtterance = DateUtils.formatDateTime(mContext,
+ mCurrentDate.getTimeInMillis(), flags);
+ event.getText().add(selectedDateUtterance);
+ }
+
+ /**
+ * Sets the current locale.
+ *
+ * @param locale The current locale.
+ */
+ @Override
+ protected void setCurrentLocale(Locale locale) {
+ super.setCurrentLocale(locale);
+
+ mTempDate = getCalendarForLocale(mTempDate, locale);
+ mMinDate = getCalendarForLocale(mMinDate, locale);
+ mMaxDate = getCalendarForLocale(mMaxDate, locale);
+ mCurrentDate = getCalendarForLocale(mCurrentDate, locale);
+
+ mNumberOfMonths = mTempDate.getActualMaximum(Calendar.MONTH) + 1;
+ mShortMonths = new DateFormatSymbols().getShortMonths();
+
+ if (usingNumericMonths()) {
+ // We're in a locale where a date should either be all-numeric, or all-text.
+ // All-text would require custom NumberPicker formatters for day and year.
+ mShortMonths = new String[mNumberOfMonths];
+ for (int i = 0; i < mNumberOfMonths; ++i) {
+ mShortMonths[i] = String.format("%d", i + 1);
+ }
+ }
+ }
+
+ /**
+ * Tests whether the current locale is one where there are no real month names,
+ * such as Chinese, Japanese, or Korean locales.
+ */
+ private boolean usingNumericMonths() {
+ return Character.isDigit(mShortMonths[Calendar.JANUARY].charAt(0));
+ }
+
+ /**
+ * Gets a calendar for locale bootstrapped with the value of a given calendar.
+ *
+ * @param oldCalendar The old calendar.
+ * @param locale The locale.
+ */
+ private Calendar getCalendarForLocale(Calendar oldCalendar, Locale locale) {
+ if (oldCalendar == null) {
+ return Calendar.getInstance(locale);
+ } else {
+ final long currentTimeMillis = oldCalendar.getTimeInMillis();
+ Calendar newCalendar = Calendar.getInstance(locale);
+ newCalendar.setTimeInMillis(currentTimeMillis);
+ return newCalendar;
+ }
+ }
+
+ /**
+ * Reorders the spinners according to the date format that is
+ * explicitly set by the user and if no such is set fall back
+ * to the current locale's default format.
+ */
+ private void reorderSpinners() {
+ mSpinners.removeAllViews();
+ // We use numeric spinners for year and day, but textual months. Ask icu4c what
+ // order the user's locale uses for that combination. http://b/7207103.
+ String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), "yyyyMMMdd");
+ char[] order = ICU.getDateFormatOrder(pattern);
+ final int spinnerCount = order.length;
+ for (int i = 0; i < spinnerCount; i++) {
+ switch (order[i]) {
+ case 'd':
+ mSpinners.addView(mDaySpinner);
+ setImeOptions(mDaySpinner, spinnerCount, i);
+ break;
+ case 'M':
+ mSpinners.addView(mMonthSpinner);
+ setImeOptions(mMonthSpinner, spinnerCount, i);
+ break;
+ case 'y':
+ mSpinners.addView(mYearSpinner);
+ setImeOptions(mYearSpinner, spinnerCount, i);
+ break;
+ default:
+ throw new IllegalArgumentException(Arrays.toString(order));
+ }
+ }
+ }
+
+ /**
+ * Parses the given <code>date</code> and in case of success sets the result
+ * to the <code>outDate</code>.
+ *
+ * @return True if the date was parsed.
+ */
+ private boolean parseDate(String date, Calendar outDate) {
+ try {
+ outDate.setTime(mDateFormat.parse(date));
+ return true;
+ } catch (ParseException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ private boolean isNewDate(int year, int month, int dayOfMonth) {
+ return (mCurrentDate.get(Calendar.YEAR) != year
+ || mCurrentDate.get(Calendar.MONTH) != month
+ || mCurrentDate.get(Calendar.DAY_OF_MONTH) != dayOfMonth);
+ }
+
+ private void setDate(int year, int month, int dayOfMonth) {
+ mCurrentDate.set(year, month, dayOfMonth);
+ if (mCurrentDate.before(mMinDate)) {
+ mCurrentDate.setTimeInMillis(mMinDate.getTimeInMillis());
+ } else if (mCurrentDate.after(mMaxDate)) {
+ mCurrentDate.setTimeInMillis(mMaxDate.getTimeInMillis());
+ }
+ }
+
+ private void updateSpinners() {
+ // set the spinner ranges respecting the min and max dates
+ if (mCurrentDate.equals(mMinDate)) {
+ mDaySpinner.setMinValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
+ mDaySpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.DAY_OF_MONTH));
+ mDaySpinner.setWrapSelectorWheel(false);
+ mMonthSpinner.setDisplayedValues(null);
+ mMonthSpinner.setMinValue(mCurrentDate.get(Calendar.MONTH));
+ mMonthSpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.MONTH));
+ mMonthSpinner.setWrapSelectorWheel(false);
+ } else if (mCurrentDate.equals(mMaxDate)) {
+ mDaySpinner.setMinValue(mCurrentDate.getActualMinimum(Calendar.DAY_OF_MONTH));
+ mDaySpinner.setMaxValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
+ mDaySpinner.setWrapSelectorWheel(false);
+ mMonthSpinner.setDisplayedValues(null);
+ mMonthSpinner.setMinValue(mCurrentDate.getActualMinimum(Calendar.MONTH));
+ mMonthSpinner.setMaxValue(mCurrentDate.get(Calendar.MONTH));
+ mMonthSpinner.setWrapSelectorWheel(false);
+ } else {
+ mDaySpinner.setMinValue(1);
+ mDaySpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.DAY_OF_MONTH));
+ mDaySpinner.setWrapSelectorWheel(true);
+ mMonthSpinner.setDisplayedValues(null);
+ mMonthSpinner.setMinValue(0);
+ mMonthSpinner.setMaxValue(11);
+ mMonthSpinner.setWrapSelectorWheel(true);
+ }
+
+ // make sure the month names are a zero based array
+ // with the months in the month spinner
+ String[] displayedValues = Arrays.copyOfRange(mShortMonths,
+ mMonthSpinner.getMinValue(), mMonthSpinner.getMaxValue() + 1);
+ mMonthSpinner.setDisplayedValues(displayedValues);
+
+ // year spinner range does not change based on the current date
+ mYearSpinner.setMinValue(mMinDate.get(Calendar.YEAR));
+ mYearSpinner.setMaxValue(mMaxDate.get(Calendar.YEAR));
+ mYearSpinner.setWrapSelectorWheel(false);
+
+ // set the spinner values
+ mYearSpinner.setValue(mCurrentDate.get(Calendar.YEAR));
+ mMonthSpinner.setValue(mCurrentDate.get(Calendar.MONTH));
+ mDaySpinner.setValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
+
+ if (usingNumericMonths()) {
+ mMonthSpinnerInput.setRawInputType(InputType.TYPE_CLASS_NUMBER);
+ }
+ }
+
+ /**
+ * Updates the calendar view with the current date.
+ */
+ private void updateCalendarView() {
+ mCalendarView.setDate(mCurrentDate.getTimeInMillis(), false, false);
+ }
+
+
+ /**
+ * Notifies the listener, if such, for a change in the selected date.
+ */
+ private void notifyDateChanged() {
+ mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
+ if (mOnDateChangedListener != null) {
+ mOnDateChangedListener.onDateChanged(mDelegator, getYear(), getMonth(),
+ getDayOfMonth());
+ }
+ }
+
+ /**
+ * Sets the IME options for a spinner based on its ordering.
+ *
+ * @param spinner The spinner.
+ * @param spinnerCount The total spinner count.
+ * @param spinnerIndex The index of the given spinner.
+ */
+ private void setImeOptions(NumberPicker spinner, int spinnerCount, int spinnerIndex) {
+ final int imeOptions;
+ if (spinnerIndex < spinnerCount - 1) {
+ imeOptions = EditorInfo.IME_ACTION_NEXT;
+ } else {
+ imeOptions = EditorInfo.IME_ACTION_DONE;
+ }
+ TextView input = (TextView) spinner.findViewById(com.android.internal.R.id.numberpicker_input);
+ input.setImeOptions(imeOptions);
+ }
+
+ private void setContentDescriptions() {
+ // Day
+ trySetContentDescription(mDaySpinner, com.android.internal.R.id.increment,
+ com.android.internal.R.string.date_picker_increment_day_button);
+ trySetContentDescription(mDaySpinner, com.android.internal.R.id.decrement,
+ com.android.internal.R.string.date_picker_decrement_day_button);
+ // Month
+ trySetContentDescription(mMonthSpinner, com.android.internal.R.id.increment,
+ com.android.internal.R.string.date_picker_increment_month_button);
+ trySetContentDescription(mMonthSpinner, com.android.internal.R.id.decrement,
+ com.android.internal.R.string.date_picker_decrement_month_button);
+ // Year
+ trySetContentDescription(mYearSpinner, com.android.internal.R.id.increment,
+ com.android.internal.R.string.date_picker_increment_year_button);
+ trySetContentDescription(mYearSpinner, com.android.internal.R.id.decrement,
+ com.android.internal.R.string.date_picker_decrement_year_button);
+ }
+
+ private void trySetContentDescription(View root, int viewId, int contDescResId) {
+ View target = root.findViewById(viewId);
+ if (target != null) {
+ target.setContentDescription(mContext.getString(contDescResId));
+ }
+ }
+
+ private void updateInputState() {
+ // Make sure that if the user changes the value and the IME is active
+ // for one of the inputs if this widget, the IME is closed. If the user
+ // changed the value via the IME and there is a next input the IME will
+ // be shown, otherwise the user chose another means of changing the
+ // value and having the IME up makes no sense.
+ InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
+ if (inputMethodManager != null) {
+ if (inputMethodManager.isActive(mYearSpinnerInput)) {
+ mYearSpinnerInput.clearFocus();
+ inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
+ } else if (inputMethodManager.isActive(mMonthSpinnerInput)) {
+ mMonthSpinnerInput.clearFocus();
+ inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
+ } else if (inputMethodManager.isActive(mDaySpinnerInput)) {
+ mDaySpinnerInput.clearFocus();
+ inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
+ }
+ }
+ }
+}
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index 54b3932..df2f575 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -23,7 +23,6 @@
import android.annotation.NonNull;
import android.content.Context;
-import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PixelFormat;
import android.graphics.Rect;
@@ -1587,18 +1586,16 @@
public int getMaxAvailableHeight(
@NonNull View anchor, int yOffset, boolean ignoreBottomDecorations) {
final Rect displayFrame = new Rect();
- anchor.getWindowVisibleDisplayFrame(displayFrame);
+ if (ignoreBottomDecorations) {
+ anchor.getWindowDisplayFrame(displayFrame);
+ } else {
+ anchor.getWindowVisibleDisplayFrame(displayFrame);
+ }
final int[] anchorPos = mDrawingLocation;
anchor.getLocationOnScreen(anchorPos);
- final int bottomEdge;
- if (ignoreBottomDecorations) {
- final Resources res = anchor.getContext().getResources();
- bottomEdge = res.getDisplayMetrics().heightPixels;
- } else {
- bottomEdge = displayFrame.bottom;
- }
+ final int bottomEdge = displayFrame.bottom;
final int distanceToBottom;
if (mOverlapAnchor) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 95fcdc1..f19bf02 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -662,11 +662,12 @@
*/
private int mDeviceProvisionedState = DEVICE_PROVISIONED_UNKNOWN;
- /*
+ /**
* Kick-start the font cache for the zygote process (to pay the cost of
* initializing freetype for our default font only once).
+ * @hide
*/
- static {
+ public static void preloadFontCache() {
Paint p = new Paint();
p.setAntiAlias(true);
// We don't care about the result, just the side-effect of measuring.
diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java
index a24d37f..f2fc617 100644
--- a/core/java/android/widget/TimePicker.java
+++ b/core/java/android/widget/TimePicker.java
@@ -22,8 +22,11 @@
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
+import android.os.Parcel;
import android.os.Parcelable;
+import android.os.Parcelable.Creator;
import android.util.AttributeSet;
+import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import com.android.internal.R;
@@ -301,5 +304,69 @@
mContext = context;
mLocale = context.getResources().getConfiguration().locale;
}
+
+ protected static class SavedState extends View.BaseSavedState {
+ private final int mHour;
+ private final int mMinute;
+ private final boolean mIs24HourMode;
+ private final int mCurrentItemShowing;
+
+ public SavedState(Parcelable superState, int hour, int minute, boolean is24HourMode) {
+ this(superState, hour, minute, is24HourMode, 0);
+ }
+
+ public SavedState(Parcelable superState, int hour, int minute, boolean is24HourMode,
+ int currentItemShowing) {
+ super(superState);
+ mHour = hour;
+ mMinute = minute;
+ mIs24HourMode = is24HourMode;
+ mCurrentItemShowing = currentItemShowing;
+ }
+
+ private SavedState(Parcel in) {
+ super(in);
+ mHour = in.readInt();
+ mMinute = in.readInt();
+ mIs24HourMode = (in.readInt() == 1);
+ mCurrentItemShowing = in.readInt();
+ }
+
+ public int getHour() {
+ return mHour;
+ }
+
+ public int getMinute() {
+ return mMinute;
+ }
+
+ public boolean is24HourMode() {
+ return mIs24HourMode;
+ }
+
+ public int getCurrentItemShowing() {
+ return mCurrentItemShowing;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeInt(mHour);
+ dest.writeInt(mMinute);
+ dest.writeInt(mIs24HourMode ? 1 : 0);
+ dest.writeInt(mCurrentItemShowing);
+ }
+
+ @SuppressWarnings({"unused", "hiding"})
+ public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
}
}
diff --git a/core/java/android/widget/TimePickerClockDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java
index 05fd4c8..4a24e26 100644
--- a/core/java/android/widget/TimePickerClockDelegate.java
+++ b/core/java/android/widget/TimePickerClockDelegate.java
@@ -21,7 +21,6 @@
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.os.Parcel;
import android.os.Parcelable;
import android.text.SpannableStringBuilder;
import android.text.format.DateFormat;
@@ -45,7 +44,6 @@
import com.android.internal.widget.NumericTextView.OnValueChangedListener;
import java.util.Calendar;
-import java.util.Locale;
/**
* A delegate implementing the radial clock-based TimePicker.
@@ -501,9 +499,11 @@
@Override
public void onRestoreInstanceState(Parcelable state) {
- final SavedState ss = (SavedState) state;
- initialize(ss.getHour(), ss.getMinute(), ss.is24HourMode(), ss.getCurrentItemShowing());
- mRadialTimePickerView.invalidate();
+ if (state instanceof SavedState) {
+ final SavedState ss = (SavedState) state;
+ initialize(ss.getHour(), ss.getMinute(), ss.is24HourMode(), ss.getCurrentItemShowing());
+ mRadialTimePickerView.invalidate();
+ }
}
@Override
@@ -544,70 +544,6 @@
}
}
- /**
- * Used to save / restore state of time picker
- */
- private static class SavedState extends View.BaseSavedState {
-
- private final int mHour;
- private final int mMinute;
- private final boolean mIs24HourMode;
- private final int mCurrentItemShowing;
-
- private SavedState(Parcelable superState, int hour, int minute, boolean is24HourMode,
- int currentItemShowing) {
- super(superState);
- mHour = hour;
- mMinute = minute;
- mIs24HourMode = is24HourMode;
- mCurrentItemShowing = currentItemShowing;
- }
-
- private SavedState(Parcel in) {
- super(in);
- mHour = in.readInt();
- mMinute = in.readInt();
- mIs24HourMode = (in.readInt() == 1);
- mCurrentItemShowing = in.readInt();
- }
-
- public int getHour() {
- return mHour;
- }
-
- public int getMinute() {
- return mMinute;
- }
-
- public boolean is24HourMode() {
- return mIs24HourMode;
- }
-
- public int getCurrentItemShowing() {
- return mCurrentItemShowing;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mHour);
- dest.writeInt(mMinute);
- dest.writeInt(mIs24HourMode ? 1 : 0);
- dest.writeInt(mCurrentItemShowing);
- }
-
- @SuppressWarnings({"unused", "hiding"})
- public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
private void tryVibrate() {
mDelegator.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
}
diff --git a/core/java/android/widget/TimePickerSpinnerDelegate.java b/core/java/android/widget/TimePickerSpinnerDelegate.java
index 863d409..b113fd9 100644
--- a/core/java/android/widget/TimePickerSpinnerDelegate.java
+++ b/core/java/android/widget/TimePickerSpinnerDelegate.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.content.res.TypedArray;
-import android.os.Parcel;
import android.os.Parcelable;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
@@ -32,7 +31,6 @@
import com.android.internal.R;
import java.util.Calendar;
-import java.util.Locale;
import libcore.icu.LocaleData;
@@ -387,14 +385,16 @@
@Override
public Parcelable onSaveInstanceState(Parcelable superState) {
- return new SavedState(superState, getHour(), getMinute());
+ return new SavedState(superState, getHour(), getMinute(), is24Hour());
}
@Override
public void onRestoreInstanceState(Parcelable state) {
- SavedState ss = (SavedState) state;
- setHour(ss.getHour());
- setMinute(ss.getMinute());
+ if (state instanceof SavedState) {
+ final SavedState ss = (SavedState) state;
+ setHour(ss.getHour());
+ setMinute(ss.getMinute());
+ }
}
@Override
@@ -525,52 +525,6 @@
}
}
- /**
- * Used to save / restore state of time picker
- */
- private static class SavedState extends View.BaseSavedState {
- private final int mHour;
- private final int mMinute;
-
- private SavedState(Parcelable superState, int hour, int minute) {
- super(superState);
- mHour = hour;
- mMinute = minute;
- }
-
- private SavedState(Parcel in) {
- super(in);
- mHour = in.readInt();
- mMinute = in.readInt();
- }
-
- public int getHour() {
- return mHour;
- }
-
- public int getMinute() {
- return mMinute;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mHour);
- dest.writeInt(mMinute);
- }
-
- @SuppressWarnings({"unused", "hiding"})
- public static final Parcelable.Creator<SavedState> CREATOR = new Creator<SavedState>() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
public static String[] getAmPmStrings(Context context) {
String[] result = new String[2];
LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 6ad9e20..eb509c2 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -36,6 +36,7 @@
import android.util.EventLog;
import android.util.Log;
import android.webkit.WebViewFactory;
+import android.widget.TextView;
import com.android.internal.os.InstallerConnection.InstallerException;
@@ -214,6 +215,7 @@
private static void preloadTextResources() {
Hyphenator.init();
+ TextView.preloadFontCache();
}
/**
diff --git a/core/java/com/android/server/net/NetworkPinner.java b/core/java/com/android/server/net/NetworkPinner.java
new file mode 100644
index 0000000..d922a48
--- /dev/null
+++ b/core/java/com/android/server/net/NetworkPinner.java
@@ -0,0 +1,146 @@
+/*
+ * 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.net;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.ConnectivityManager.NetworkCallback;
+import android.net.Network;
+import android.net.NetworkRequest;
+import android.util.Log;
+
+import com.android.internal.annotations.GuardedBy;
+import com.android.internal.annotations.VisibleForTesting;
+
+/**
+ * A class that pins a process to the first network that satisfies a particular NetworkRequest.
+ *
+ * We use this to maintain compatibility with pre-M apps that call WifiManager.enableNetwork()
+ * to connect to a Wi-Fi network that has no Internet access, and then assume that they will be
+ * able to use that network because it's the system default.
+ *
+ * In order to maintain compatibility with apps that call setProcessDefaultNetwork themselves,
+ * we try not to set the default network unless they have already done so, and we try not to
+ * clear the default network unless we set it ourselves.
+ *
+ * This should maintain behaviour that's compatible with L, which would pin the whole system to
+ * any wifi network that was created via enableNetwork(..., true) until that network
+ * disconnected.
+ *
+ * Note that while this hack allows network traffic to flow, it is quite limited. For example:
+ *
+ * 1. setProcessDefaultNetwork only affects this process, so:
+ * - Any subprocesses spawned by this process will not be pinned to Wi-Fi.
+ * - If this app relies on any other apps on the device also being on Wi-Fi, that won't work
+ * either, because other apps on the device will not be pinned.
+ * 2. The behaviour of other APIs is not modified. For example:
+ * - getActiveNetworkInfo will return the system default network, not Wi-Fi.
+ * - There will be no CONNECTIVITY_ACTION broadcasts about TYPE_WIFI.
+ * - getProcessDefaultNetwork will not return null, so if any apps are relying on that, they
+ * will be surprised as well.
+ *
+ * This class is a per-process singleton because the process default network is a per-process
+ * singleton.
+ *
+ */
+public class NetworkPinner extends NetworkCallback {
+
+ private static final String TAG = NetworkPinner.class.getSimpleName();
+
+ @VisibleForTesting
+ protected static final Object sLock = new Object();
+
+ @GuardedBy("sLock")
+ private static ConnectivityManager sCM;
+ @GuardedBy("sLock")
+ private static Callback sCallback;
+ @VisibleForTesting
+ @GuardedBy("sLock")
+ protected static Network sNetwork;
+
+ private static void maybeInitConnectivityManager(Context context) {
+ // TODO: what happens if an app calls a WifiManager API before ConnectivityManager is
+ // registered? Can we fix this by starting ConnectivityService before WifiService?
+ if (sCM == null) {
+ // Getting a ConnectivityManager does not leak the calling context, because it stores
+ // the application context and not the calling context.
+ sCM = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (sCM == null) {
+ throw new IllegalStateException("Bad luck, ConnectivityService not started.");
+ }
+ }
+ }
+
+ private static class Callback extends NetworkCallback {
+ @Override
+ public void onAvailable(Network network) {
+ synchronized(sLock) {
+ if (this != sCallback) return;
+
+ if (sCM.getBoundNetworkForProcess() == null && sNetwork == null) {
+ sCM.bindProcessToNetwork(network);
+ sNetwork = network;
+ Log.d(TAG, "Wifi alternate reality enabled on network " + network);
+ }
+ sLock.notify();
+ }
+ }
+
+ @Override
+ public void onLost(Network network) {
+ synchronized (sLock) {
+ if (this != sCallback) return;
+
+ if (network.equals(sNetwork) && network.equals(sCM.getBoundNetworkForProcess())) {
+ unpin();
+ Log.d(TAG, "Wifi alternate reality disabled on network " + network);
+ }
+ sLock.notify();
+ }
+ }
+ }
+
+ public static void pin(Context context, NetworkRequest request) {
+ synchronized (sLock) {
+ if (sCallback == null) {
+ maybeInitConnectivityManager(context);
+ sCallback = new Callback();
+ try {
+ sCM.registerNetworkCallback(request, sCallback);
+ } catch (SecurityException e) {
+ Log.d(TAG, "Failed to register network callback", e);
+ sCallback = null;
+ }
+ }
+ }
+ }
+
+ public static void unpin() {
+ synchronized (sLock) {
+ if (sCallback != null) {
+ try {
+ sCM.bindProcessToNetwork(null);
+ sCM.unregisterNetworkCallback(sCallback);
+ } catch (SecurityException e) {
+ Log.d(TAG, "Failed to unregister network callback", e);
+ }
+ sCallback = null;
+ sNetwork = null;
+ }
+ }
+ }
+}
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index d5f080a..ed3fe42 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -33,6 +33,7 @@
com_android_internal_content_NativeLibraryHelper.cpp \
com_google_android_gles_jni_EGLImpl.cpp \
com_google_android_gles_jni_GLImpl.cpp.arm \
+ android_app_Activity.cpp \
android_app_ApplicationLoaders.cpp \
android_app_NativeActivity.cpp \
android_auditing_SecurityLog.cpp \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 6ed07a7..2a04526 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -178,6 +178,7 @@
extern int register_android_backup_BackupHelperDispatcher(JNIEnv *env);
extern int register_android_app_backup_FullBackup(JNIEnv *env);
extern int register_android_app_ApplicationLoaders(JNIEnv* env);
+extern int register_android_app_Activity(JNIEnv *env);
extern int register_android_app_ActivityThread(JNIEnv *env);
extern int register_android_app_NativeActivity(JNIEnv *env);
extern int register_android_media_RemoteDisplay(JNIEnv *env);
@@ -1373,6 +1374,7 @@
REG_JNI(register_android_backup_BackupHelperDispatcher),
REG_JNI(register_android_app_backup_FullBackup),
REG_JNI(register_android_app_ApplicationLoaders),
+ REG_JNI(register_android_app_Activity),
REG_JNI(register_android_app_ActivityThread),
REG_JNI(register_android_app_NativeActivity),
REG_JNI(register_android_util_jar_StrictJarFile),
diff --git a/core/jni/android_app_Activity.cpp b/core/jni/android_app_Activity.cpp
new file mode 100644
index 0000000..b1d7e82
--- /dev/null
+++ b/core/jni/android_app_Activity.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 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 <poll.h>
+#include <android/dlext.h>
+
+#include "core_jni_helpers.h"
+
+namespace android
+{
+
+static jstring getDlWarning_native(JNIEnv* env, jobject) {
+ const char* text = android_dlwarning();
+ return text == nullptr ? nullptr : env->NewStringUTF(text);
+}
+
+static const JNINativeMethod g_methods[] = {
+ { "getDlWarning",
+ "()Ljava/lang/String;",
+ reinterpret_cast<void*>(getDlWarning_native) },
+};
+
+static const char* const kActivityPathName = "android/app/Activity";
+
+int register_android_app_Activity(JNIEnv* env) {
+ return RegisterMethodsOrDie(env, kActivityPathName, g_methods, NELEM(g_methods));
+}
+
+} // namespace android
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 2fb7498..1eb0111 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -320,7 +320,7 @@
static jint
android_media_AudioSystem_newAudioSessionId(JNIEnv *env, jobject thiz)
{
- return AudioSystem::newAudioUniqueId();
+ return AudioSystem::newAudioUniqueId(AUDIO_UNIQUE_ID_USE_SESSION);
}
static jint
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 03d93a1..588e738 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1598,6 +1598,11 @@
<permission android:name="android.permission.GET_PACKAGE_IMPORTANCE"
android:protectionLevel="signature|privileged" />
+ <!-- Allows use of PendingIntent.getIntent().
+ @hide -->
+ <permission android:name="android.permission.GET_INTENT_SENDER_INTENT"
+ android:protectionLevel="signature" />
+
<!-- ================================== -->
<!-- Permissions affecting the display of other applications -->
<!-- ================================== -->
diff --git a/core/res/res/drawable-nodpi/default_wallpaper.jpg b/core/res/res/drawable-nodpi/default_wallpaper.jpg
deleted file mode 100644
index d7475b4c..0000000
--- a/core/res/res/drawable-nodpi/default_wallpaper.jpg
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-nodpi/default_wallpaper.png b/core/res/res/drawable-nodpi/default_wallpaper.png
new file mode 100644
index 0000000..91ad252
--- /dev/null
+++ b/core/res/res/drawable-nodpi/default_wallpaper.png
Binary files differ
diff --git a/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.jpg b/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.jpg
deleted file mode 100644
index 03a14c0..0000000
--- a/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.jpg
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.png b/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.png
new file mode 100644
index 0000000..af8e251
--- /dev/null
+++ b/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.png
Binary files differ
diff --git a/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.jpg b/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.jpg
deleted file mode 100644
index 543d118..0000000
--- a/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.jpg
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.png b/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.png
new file mode 100644
index 0000000..cb00d82
--- /dev/null
+++ b/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.png
Binary files differ
diff --git a/core/res/res/values-h426dp-port/integers.xml b/core/res/res/values-h426dp-port/integers.xml
new file mode 100644
index 0000000..94abbec
--- /dev/null
+++ b/core/res/res/values-h426dp-port/integers.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** 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>
+ <integer name="date_picker_mode">2</integer>
+ <integer name="time_picker_mode">2</integer>
+</resources>
diff --git a/core/res/res/values-w426dp-land/integers.xml b/core/res/res/values-w426dp-land/integers.xml
new file mode 100644
index 0000000..94abbec
--- /dev/null
+++ b/core/res/res/values-w426dp-land/integers.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** 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>
+ <integer name="date_picker_mode">2</integer>
+ <integer name="time_picker_mode">2</integer>
+</resources>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 7c021280..90a573b 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -8189,11 +8189,8 @@
<!-- @hide From Theme.colorPrimary, used for the TaskDescription primary
color. -->
<attr name="colorPrimary" />
- <!-- @hide From Theme.windowBackground, used for calculating the
- TaskDescription background color. -->
- <attr name="windowBackground" />
- <!-- @hide From Theme.windowBackgroundFallback, used for calculating the
- TaskDescription background color. -->
- <attr name="windowBackgroundFallback" />
+ <!-- @hide From Theme.colorBackground, used for the TaskDescription background
+ color. -->
+ <attr name="colorBackground" />
</declare-styleable>
</resources>
diff --git a/core/res/res/values/integers.xml b/core/res/res/values/integers.xml
index 8e27226..8f8d59e 100644
--- a/core/res/res/values/integers.xml
+++ b/core/res/res/values/integers.xml
@@ -23,4 +23,7 @@
<integer name="button_pressed_animation_delay">100</integer>
<integer name="disabled_alpha_animation_duration">100</integer>
<integer name="dock_enter_exit_duration">250</integer>
+
+ <integer name="date_picker_mode">1</integer>
+ <integer name="time_picker_mode">1</integer>
</resources>
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index db418f7..a9c8a06 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -652,7 +652,7 @@
</style>
<style name="Widget.Material.TimePicker">
- <item name="timePickerMode">clock</item>
+ <item name="timePickerMode">@integer/time_picker_mode</item>
<item name="legacyLayout">@layout/time_picker_legacy_material</item>
<!-- Attributes for new-style TimePicker. -->
<item name="internalLayout">@layout/time_picker_material</item>
@@ -666,7 +666,7 @@
</style>
<style name="Widget.Material.DatePicker">
- <item name="datePickerMode">calendar</item>
+ <item name="datePickerMode">@integer/date_picker_mode</item>
<item name="legacyLayout">@layout/date_picker_legacy_holo</item>
<item name="calendarViewShown">true</item>
<!-- Attributes for new-style DatePicker. -->
diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml
index dd8baa7..11bb106 100644
--- a/core/res/res/values/themes_device_defaults.xml
+++ b/core/res/res/values/themes_device_defaults.xml
@@ -544,9 +544,7 @@
<item name="windowNoTitle">true</item>
<item name="windowBackground">@color/transparent</item>
<item name="backgroundDimEnabled">true</item>
- <item name="windowTranslucentStatus">false</item>
- <item name="windowTranslucentNavigation">false</item>
- <item name="windowDrawsSystemBarBackgrounds">false</item>
+ <item name="statusBarColor">@color/transparent</item>
<item name="windowContentOverlay">@null</item>
<item name="colorControlActivated">?attr/colorControlHighlight</item>
<item name="listPreferredItemPaddingStart">?attr/dialogPreferredPadding</item>
diff --git a/core/tests/coretests/src/android/content/pm/ContainerEncryptionParamsTest.java b/core/tests/coretests/src/android/content/pm/ContainerEncryptionParamsTest.java
deleted file mode 100644
index 7deaa9a..0000000
--- a/core/tests/coretests/src/android/content/pm/ContainerEncryptionParamsTest.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * 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 android.content.pm;
-
-import android.os.Parcel;
-import android.test.AndroidTestCase;
-
-import java.util.Arrays;
-
-import javax.crypto.SecretKey;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
-
-public class ContainerEncryptionParamsTest extends AndroidTestCase {
- private static final String ENC_ALGORITHM = "AES/CBC/PKCS7Padding";
-
- private static final byte[] IV_BYTES = "FOOBAR".getBytes();
-
- private static final IvParameterSpec ENC_PARAMS = new IvParameterSpec(IV_BYTES);
-
- private static final byte[] ENC_KEY_BYTES = "abcd1234wxyz7890".getBytes();
-
- private static final SecretKey ENC_KEY = new SecretKeySpec(ENC_KEY_BYTES, "RAW");
-
- private static final String MAC_ALGORITHM = "HMAC-SHA1";
-
- private static final byte[] MAC_KEY_BYTES = "4wxyzabcd1237890".getBytes();
-
- private static final SecretKey MAC_KEY = new SecretKeySpec(MAC_KEY_BYTES, "RAW");
-
- private static final byte[] MAC_TAG = "faketag".getBytes();
-
- private static final int AUTHENTICATED_START = 5;
-
- private static final int ENCRYPTED_START = 11;
-
- private static final int DATA_END = 19;
-
- public void testParcel() throws Exception {
- ContainerEncryptionParams expected = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- Parcel parcel = Parcel.obtain();
- expected.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
-
- ContainerEncryptionParams actual = ContainerEncryptionParams.CREATOR
- .createFromParcel(parcel);
-
- assertEquals(ENC_ALGORITHM, actual.getEncryptionAlgorithm());
-
- if (!(actual.getEncryptionSpec() instanceof IvParameterSpec)) {
- fail("encryption parameters should be IvParameterSpec");
- } else {
- IvParameterSpec actualParams = (IvParameterSpec) actual.getEncryptionSpec();
- assertTrue(Arrays.equals(IV_BYTES, actualParams.getIV()));
- }
-
- assertEquals(ENC_KEY, actual.getEncryptionKey());
-
- assertEquals(MAC_ALGORITHM, actual.getMacAlgorithm());
-
- assertNull(actual.getMacSpec());
-
- assertEquals(MAC_KEY, actual.getMacKey());
-
- assertTrue(Arrays.equals(MAC_TAG, actual.getMacTag()));
-
- assertEquals(AUTHENTICATED_START, actual.getAuthenticatedDataStart());
-
- assertEquals(ENCRYPTED_START, actual.getEncryptedDataStart());
-
- assertEquals(DATA_END, actual.getDataEnd());
- }
-
- public void testEquals_Success() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertEquals(params1, params2);
- }
-
- public void testEquals_EncAlgo_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(new String(
- "AES-256/CBC/PKCS7Padding"), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_EncParams_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec("BLAHBLAH".getBytes()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_EncKey_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec("BLAHBLAH".getBytes(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_MacAlgo_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), "BLAHBLAH", null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_MacKey_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec("FAKE_MAC_KEY".getBytes(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_MacTag_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), "broken".getBytes(),
- AUTHENTICATED_START, ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_AuthenticatedStart_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START - 1,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_EncryptedStart_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START - 1, DATA_END);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_DataEnd_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END + 1);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testHashCode_Success() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertEquals(params1.hashCode(), params2.hashCode());
- }
-
- public void testHashCode_EncAlgo_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(new String(
- "AES-256/CBC/PKCS7Padding"), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_EncParams_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec("BLAHBLAH".getBytes()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_EncKey_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec("BLAHBLAH".getBytes(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_MacAlgo_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), "BLAHBLAH", null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_MacKey_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec("FAKE_MAC_KEY".getBytes(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_MacTag_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), "broken".getBytes(),
- AUTHENTICATED_START, ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_AuthenticatedStart_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START - 1,
- ENCRYPTED_START, DATA_END);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_EncryptedStart_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START - 1, DATA_END);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_DataEnd_Failure() throws Exception {
- ContainerEncryptionParams params1 = new ContainerEncryptionParams(ENC_ALGORITHM,
- ENC_PARAMS, ENC_KEY, MAC_ALGORITHM, null, MAC_KEY, MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END);
-
- ContainerEncryptionParams params2 = new ContainerEncryptionParams(
- new String(ENC_ALGORITHM), new IvParameterSpec(IV_BYTES.clone()),
- new SecretKeySpec(ENC_KEY_BYTES.clone(), "RAW"), new String(MAC_ALGORITHM), null,
- new SecretKeySpec(MAC_KEY_BYTES.clone(), "RAW"), MAC_TAG, AUTHENTICATED_START,
- ENCRYPTED_START, DATA_END + 1);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-}
diff --git a/keystore/java/android/security/Credentials.java b/keystore/java/android/security/Credentials.java
index 302b0bd..6830a74 100644
--- a/keystore/java/android/security/Credentials.java
+++ b/keystore/java/android/security/Credentials.java
@@ -217,42 +217,42 @@
}
/**
- * Delete all types (private key, certificate, CA certificate) for a
+ * Delete all types (private key, user certificate, CA certificate) for a
* particular {@code alias}. All three can exist for any given alias.
- * Returns {@code true} if there was at least one of those types.
+ * Returns {@code true} if the alias no longer contains any types.
*/
public static boolean deleteAllTypesForAlias(KeyStore keystore, String alias) {
return deleteAllTypesForAlias(keystore, alias, KeyStore.UID_SELF);
}
/**
- * Delete all types (private key, certificate, CA certificate) for a
+ * Delete all types (private key, user certificate, CA certificate) for a
* particular {@code alias}. All three can exist for any given alias.
- * Returns {@code true} if there was at least one of those types.
+ * Returns {@code true} if the alias no longer contains any types.
*/
public static boolean deleteAllTypesForAlias(KeyStore keystore, String alias, int uid) {
/*
* Make sure every type is deleted. There can be all three types, so
* don't use a conditional here.
*/
- return keystore.delete(Credentials.USER_PRIVATE_KEY + alias, uid)
- | keystore.delete(Credentials.USER_SECRET_KEY + alias, uid)
- | deleteCertificateTypesForAlias(keystore, alias, uid);
+ return deletePrivateKeyTypeForAlias(keystore, alias, uid)
+ & deleteSecretKeyTypeForAlias(keystore, alias, uid)
+ & deleteCertificateTypesForAlias(keystore, alias, uid);
}
/**
- * Delete all types (private key, certificate, CA certificate) for a
- * particular {@code alias}. All three can exist for any given alias.
- * Returns {@code true} if there was at least one of those types.
+ * Delete certificate types (user certificate, CA certificate) for a
+ * particular {@code alias}. Both can exist for any given alias.
+ * Returns {@code true} if the alias no longer contains either type.
*/
public static boolean deleteCertificateTypesForAlias(KeyStore keystore, String alias) {
return deleteCertificateTypesForAlias(keystore, alias, KeyStore.UID_SELF);
}
/**
- * Delete all types (private key, certificate, CA certificate) for a
- * particular {@code alias}. All three can exist for any given alias.
- * Returns {@code true} if there was at least one of those types.
+ * Delete certificate types (user certificate, CA certificate) for a
+ * particular {@code alias}. Both can exist for any given alias.
+ * Returns {@code true} if the alias no longer contains either type.
*/
public static boolean deleteCertificateTypesForAlias(KeyStore keystore, String alias, int uid) {
/*
@@ -260,12 +260,12 @@
* so don't use a conditional here.
*/
return keystore.delete(Credentials.USER_CERTIFICATE + alias, uid)
- | keystore.delete(Credentials.CA_CERTIFICATE + alias, uid);
+ & keystore.delete(Credentials.CA_CERTIFICATE + alias, uid);
}
/**
* Delete private key for a particular {@code alias}.
- * Returns {@code true} if an entry was was deleted.
+ * Returns {@code true} if the entry no longer exists.
*/
static boolean deletePrivateKeyTypeForAlias(KeyStore keystore, String alias) {
return deletePrivateKeyTypeForAlias(keystore, alias, KeyStore.UID_SELF);
@@ -273,7 +273,7 @@
/**
* Delete private key for a particular {@code alias}.
- * Returns {@code true} if an entry was was deleted.
+ * Returns {@code true} if the entry no longer exists.
*/
static boolean deletePrivateKeyTypeForAlias(KeyStore keystore, String alias, int uid) {
return keystore.delete(Credentials.USER_PRIVATE_KEY + alias, uid);
@@ -281,7 +281,7 @@
/**
* Delete secret key for a particular {@code alias}.
- * Returns {@code true} if an entry was was deleted.
+ * Returns {@code true} if the entry no longer exists.
*/
public static boolean deleteSecretKeyTypeForAlias(KeyStore keystore, String alias) {
return deleteSecretKeyTypeForAlias(keystore, alias, KeyStore.UID_SELF);
@@ -289,7 +289,7 @@
/**
* Delete secret key for a particular {@code alias}.
- * Returns {@code true} if an entry was was deleted.
+ * Returns {@code true} if the entry no longer exists.
*/
public static boolean deleteSecretKeyTypeForAlias(KeyStore keystore, String alias, int uid) {
return keystore.delete(Credentials.USER_SECRET_KEY + alias, uid);
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index 3090ac1..70e4b6f 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -183,7 +183,8 @@
public boolean delete(String key, int uid) {
try {
- return mBinder.del(key, uid) == NO_ERROR;
+ int ret = mBinder.del(key, uid);
+ return (ret == NO_ERROR || ret == KEY_NOT_FOUND);
} catch (RemoteException e) {
Log.w(TAG, "Cannot connect to keystore", e);
return false;
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
index d7d4f1c..fcbb553 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
@@ -765,11 +765,6 @@
@Override
public void engineDeleteEntry(String alias) throws KeyStoreException {
- if (!engineContainsAlias(alias)) {
- return;
- }
- // At least one entry corresponding to this alias exists in keystore
-
if (!Credentials.deleteAllTypesForAlias(mKeyStore, alias, mUid)) {
throw new KeyStoreException("Failed to delete entry: " + alias);
}
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index f02e8375..c48bfc5 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -1214,13 +1214,12 @@
* An underrun occurs if the application does not write audio
* data quickly enough, causing the buffer to underflow
* and a potential audio glitch or pop.
+ * <p>
* Underruns are less likely when buffer sizes are large.
- * <p> Though the "int" type is signed 32-bits, the value should be reinterpreted
- * as if it is unsigned 32-bits.
- * That is, the next position after 0x7FFFFFFF is (int) 0x80000000.
- * This is a continuously advancing counter. It can wrap around to zero
- * if there are too many underruns. If there were, for example, 68 underruns per
- * second then the counter would wrap in 2 years.
+ * It may be possible to eliminate underruns by recreating the AudioTrack with
+ * a larger buffer.
+ * Or by using {@link #setBufferSizeInFrames(int)} to dynamically increase the
+ * effective size of the buffer.
*/
public int getUnderrunCount() {
return native_get_underrun_count();
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index dcca666..4c6f0e6 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -2221,7 +2221,10 @@
public int mode;
/**
- * Metadata describing encryption pattern for the protected bytes in a subsample.
+ * Metadata describing an encryption pattern for the protected bytes in
+ * a subsample. An encryption pattern consists of a repeating sequence
+ * of crypto blocks comprised of a number of encrypted blocks followed
+ * by a number of unencrypted, or skipped, blocks.
*/
public final static class Pattern {
/**
@@ -2273,6 +2276,10 @@
*/
private Pattern pattern;
+ /**
+ * Set the subsample count, clear/encrypted sizes, key, IV and mode fields of
+ * a {@link MediaCodec.CryptoInfo} instance.
+ */
public void set(
int newNumSubSamples,
@NonNull int[] newNumBytesOfClearData,
@@ -2289,6 +2296,10 @@
pattern = new Pattern(0, 0);
}
+ /**
+ * Set the encryption pattern on a {@link MediaCodec.CryptoInfo} instance.
+ * See {@link MediaCodec.CryptoInfo.Pattern}.
+ */
public void setPattern(Pattern newPattern) {
pattern = newPattern;
}
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index d9690f0..b1c1b79 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -2231,6 +2231,7 @@
switch (profileLevel.profile) {
case CodecProfileLevel.HEVCProfileMain:
case CodecProfileLevel.HEVCProfileMain10:
+ case CodecProfileLevel.HEVCProfileMain10HDR10:
break;
default:
Log.w(TAG, "Unrecognized profile "
@@ -2632,8 +2633,9 @@
public static final int VP9Level62 = 0x1000;
// from OMX_VIDEO_HEVCPROFILETYPE
- public static final int HEVCProfileMain = 0x01;
- public static final int HEVCProfileMain10 = 0x02;
+ public static final int HEVCProfileMain = 0x01;
+ public static final int HEVCProfileMain10 = 0x02;
+ public static final int HEVCProfileMain10HDR10 = 0x1000;
// from OMX_VIDEO_HEVCLEVELTYPE
public static final int HEVCMainTierLevel1 = 0x1;
diff --git a/media/java/android/media/MediaMetadata.java b/media/java/android/media/MediaMetadata.java
index 39bcef5..722605f 100644
--- a/media/java/android/media/MediaMetadata.java
+++ b/media/java/android/media/MediaMetadata.java
@@ -16,6 +16,7 @@
package android.media;
import android.annotation.NonNull;
+import android.annotation.StringDef;
import android.content.ContentResolver;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -30,6 +31,8 @@
import android.util.Log;
import android.util.SparseArray;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.Set;
/**
@@ -39,6 +42,40 @@
private static final String TAG = "MediaMetadata";
/**
+ * @hide
+ */
+ @StringDef({METADATA_KEY_TITLE, METADATA_KEY_ARTIST, METADATA_KEY_ALBUM, METADATA_KEY_AUTHOR,
+ METADATA_KEY_WRITER, METADATA_KEY_COMPOSER, METADATA_KEY_COMPILATION,
+ METADATA_KEY_DATE, METADATA_KEY_GENRE, METADATA_KEY_ALBUM_ARTIST, METADATA_KEY_ART_URI,
+ METADATA_KEY_ALBUM_ART_URI, METADATA_KEY_DISPLAY_TITLE, METADATA_KEY_DISPLAY_SUBTITLE,
+ METADATA_KEY_DISPLAY_DESCRIPTION, METADATA_KEY_DISPLAY_ICON_URI,
+ METADATA_KEY_MEDIA_ID})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface TextKey {}
+
+ /**
+ * @hide
+ */
+ @StringDef({METADATA_KEY_DURATION, METADATA_KEY_YEAR, METADATA_KEY_TRACK_NUMBER,
+ METADATA_KEY_NUM_TRACKS, METADATA_KEY_DISC_NUMBER})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface LongKey {}
+
+ /**
+ * @hide
+ */
+ @StringDef({METADATA_KEY_ART, METADATA_KEY_ALBUM_ART, METADATA_KEY_DISPLAY_ICON})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface BitmapKey {}
+
+ /**
+ * @hide
+ */
+ @StringDef({METADATA_KEY_USER_RATING, METADATA_KEY_RATING})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface RatingKey {}
+
+ /**
* The title of the media.
*/
public static final String METADATA_KEY_TITLE = "android.media.metadata.TITLE";
@@ -232,7 +269,7 @@
*/
public static final String METADATA_KEY_MEDIA_ID = "android.media.metadata.MEDIA_ID";
- private static final String[] PREFERRED_DESCRIPTION_ORDER = {
+ private static final @TextKey String[] PREFERRED_DESCRIPTION_ORDER = {
METADATA_KEY_TITLE,
METADATA_KEY_ARTIST,
METADATA_KEY_ALBUM,
@@ -242,13 +279,13 @@
METADATA_KEY_COMPOSER
};
- private static final String[] PREFERRED_BITMAP_ORDER = {
+ private static final @BitmapKey String[] PREFERRED_BITMAP_ORDER = {
METADATA_KEY_DISPLAY_ICON,
METADATA_KEY_ART,
METADATA_KEY_ALBUM_ART
};
- private static final String[] PREFERRED_URI_ORDER = {
+ private static final @TextKey String[] PREFERRED_URI_ORDER = {
METADATA_KEY_DISPLAY_ICON_URI,
METADATA_KEY_ART_URI,
METADATA_KEY_ALBUM_ART_URI
@@ -349,7 +386,7 @@
* @param key The key the value is stored under
* @return a CharSequence value, or null
*/
- public CharSequence getText(String key) {
+ public CharSequence getText(@TextKey String key) {
return mBundle.getCharSequence(key);
}
@@ -362,7 +399,7 @@
* @param key The key the value is stored under
* @return a String value, or null
*/
- public String getString(String key) {
+ public String getString(@TextKey String key) {
CharSequence text = getText(key);
if (text != null) {
return text.toString();
@@ -377,7 +414,7 @@
* @param key The key the value is stored under
* @return a long value
*/
- public long getLong(String key) {
+ public long getLong(@LongKey String key) {
return mBundle.getLong(key, 0);
}
@@ -388,7 +425,7 @@
* @param key The key the value is stored under
* @return A {@link Rating} or null
*/
- public Rating getRating(String key) {
+ public Rating getRating(@RatingKey String key) {
Rating rating = null;
try {
rating = mBundle.getParcelable(key);
@@ -406,7 +443,7 @@
* @param key The key the value is stored under
* @return A {@link Bitmap} or null
*/
- public Bitmap getBitmap(String key) {
+ public Bitmap getBitmap(@BitmapKey String key) {
Bitmap bmp = null;
try {
bmp = mBundle.getParcelable(key);
@@ -612,7 +649,7 @@
* @param value The CharSequence value to store
* @return The Builder to allow chaining
*/
- public Builder putText(String key, CharSequence value) {
+ public Builder putText(@TextKey String key, CharSequence value) {
if (METADATA_KEYS_TYPE.containsKey(key)) {
if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_TEXT) {
throw new IllegalArgumentException("The " + key
@@ -654,7 +691,7 @@
* @param value The String value to store
* @return The Builder to allow chaining
*/
- public Builder putString(String key, String value) {
+ public Builder putString(@TextKey String key, String value) {
if (METADATA_KEYS_TYPE.containsKey(key)) {
if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_TEXT) {
throw new IllegalArgumentException("The " + key
@@ -681,7 +718,7 @@
* @param value The long value to store
* @return The Builder to allow chaining
*/
- public Builder putLong(String key, long value) {
+ public Builder putLong(@LongKey String key, long value) {
if (METADATA_KEYS_TYPE.containsKey(key)) {
if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_LONG) {
throw new IllegalArgumentException("The " + key
@@ -705,7 +742,7 @@
* @param value The Rating value to store
* @return The Builder to allow chaining
*/
- public Builder putRating(String key, Rating value) {
+ public Builder putRating(@RatingKey String key, Rating value) {
if (METADATA_KEYS_TYPE.containsKey(key)) {
if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_RATING) {
throw new IllegalArgumentException("The " + key
@@ -734,7 +771,7 @@
* @param value The Bitmap to store
* @return The Builder to allow chaining
*/
- public Builder putBitmap(String key, Bitmap value) {
+ public Builder putBitmap(@BitmapKey String key, Bitmap value) {
if (METADATA_KEYS_TYPE.containsKey(key)) {
if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_BITMAP) {
throw new IllegalArgumentException("The " + key
diff --git a/media/java/android/media/MediaMuxer.java b/media/java/android/media/MediaMuxer.java
index 8618ec9..ebe509c 100644
--- a/media/java/android/media/MediaMuxer.java
+++ b/media/java/android/media/MediaMuxer.java
@@ -127,7 +127,8 @@
* @param path The path of the output media file.
* @param format The format of the output media file.
* @see android.media.MediaMuxer.OutputFormat
- * @throws IOException if failed to open the file for write
+ * @throws IllegalArgumentException if path is invalid or format is not supported.
+ * @throws IOException if failed to open the file for write.
*/
public MediaMuxer(@NonNull String path, @Format int format) throws IOException {
if (path == null) {
@@ -165,6 +166,8 @@
* By default, the rotation degree is 0.</p>
* @param degrees the angle to be rotated clockwise in degrees.
* The supported angles are 0, 90, 180, and 270 degrees.
+ * @throws IllegalArgumentException if degree is not supported.
+ * @throws IllegalStateException If this method is called after {@link #start}.
*/
public void setOrientationHint(int degrees) {
if (degrees != 0 && degrees != 90 && degrees != 180 && degrees != 270) {
@@ -217,6 +220,8 @@
* Starts the muxer.
* <p>Make sure this is called after {@link #addTrack} and before
* {@link #writeSampleData}.</p>
+ * @throws IllegalStateException If this method is called after {@link #start}
+ * or Muxer is released
*/
public void start() {
if (mNativeObject == 0) {
@@ -233,6 +238,7 @@
/**
* Stops the muxer.
* <p>Once the muxer stops, it can not be restarted.</p>
+ * @throws IllegalStateException if muxer is in the wrong state.
*/
public void stop() {
if (mState == MUXER_STATE_STARTED) {
@@ -264,6 +270,8 @@
* MediaFormat.
* @return The track index for this newly added track, and it should be used
* in the {@link #writeSampleData}.
+ * @throws IllegalArgumentException if format is invalid.
+ * @throws IllegalStateException if muxer is in the wrong state.
*/
public int addTrack(@NonNull MediaFormat format) {
if (format == null) {
@@ -314,6 +322,8 @@
* @param byteBuf The encoded sample.
* @param trackIndex The track index for this sample.
* @param bufferInfo The buffer information related to this sample.
+ * @throws IllegalArgumentException if trackIndex, byteBuf or bufferInfo is invalid.
+ * @throws IllegalStateException if muxer is in wrong state.
* MediaMuxer uses the flags provided in {@link MediaCodec.BufferInfo},
* to signal sync frames.
*/
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index bcc2b406..d8e0d6d 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -1547,18 +1547,30 @@
private Object mTag;
+ /** @hide */
+ @IntDef({PLAYBACK_TYPE_LOCAL, PLAYBACK_TYPE_REMOTE})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface PlaybackType {}
+
/**
* The default playback type, "local", indicating the presentation of the media is happening
* on the same device (e.g. a phone, a tablet) as where it is controlled from.
* @see #getPlaybackType()
*/
public final static int PLAYBACK_TYPE_LOCAL = 0;
+
/**
* A playback type indicating the presentation of the media is happening on
* a different device (i.e. the remote device) than where it is controlled from.
* @see #getPlaybackType()
*/
public final static int PLAYBACK_TYPE_REMOTE = 1;
+
+ /** @hide */
+ @IntDef({PLAYBACK_VOLUME_FIXED,PLAYBACK_VOLUME_VARIABLE})
+ @Retention(RetentionPolicy.SOURCE)
+ private @interface PlaybackVolume {}
+
/**
* Playback information indicating the playback volume is fixed, i.e. it cannot be
* controlled from this object. An example of fixed playback volume is a remote player,
@@ -1783,6 +1795,7 @@
* @return the type of playback associated with this route
* @see UserRouteInfo#setPlaybackType(int)
*/
+ @PlaybackType
public int getPlaybackType() {
return mPlaybackType;
}
@@ -1874,6 +1887,7 @@
* @return how volume is handling on the route
* @see UserRouteInfo#setVolumeHandling(int)
*/
+ @PlaybackVolume
public int getVolumeHandling() {
return mVolumeHandling;
}
@@ -2164,7 +2178,7 @@
* ({@link RouteInfo#PLAYBACK_TYPE_REMOTE}).
* @param type
*/
- public void setPlaybackType(int type) {
+ public void setPlaybackType(@RouteInfo.PlaybackType int type) {
if (mPlaybackType != type) {
mPlaybackType = type;
configureSessionVolume();
@@ -2177,7 +2191,7 @@
* ({@link RouteInfo#PLAYBACK_VOLUME_VARIABLE}).
* @param volumeHandling
*/
- public void setVolumeHandling(int volumeHandling) {
+ public void setVolumeHandling(@RouteInfo.PlaybackVolume int volumeHandling) {
if (mVolumeHandling != volumeHandling) {
mVolumeHandling = volumeHandling;
configureSessionVolume();
@@ -2268,7 +2282,8 @@
return;
}
if (mPlaybackType == RemoteControlClient.PLAYBACK_TYPE_REMOTE) {
- int volumeControl = VolumeProvider.VOLUME_CONTROL_FIXED;
+ @VolumeProvider.ControlType int volumeControl =
+ VolumeProvider.VOLUME_CONTROL_FIXED;
switch (mVolumeHandling) {
case RemoteControlClient.PLAYBACK_VOLUME_VARIABLE:
volumeControl = VolumeProvider.VOLUME_CONTROL_ABSOLUTE;
@@ -2294,7 +2309,8 @@
class SessionVolumeProvider extends VolumeProvider {
- public SessionVolumeProvider(int volumeControl, int maxVolume, int currentVolume) {
+ public SessionVolumeProvider(@VolumeProvider.ControlType int volumeControl,
+ int maxVolume, int currentVolume) {
super(volumeControl, maxVolume, currentVolume);
}
diff --git a/media/java/android/media/Rating.java b/media/java/android/media/Rating.java
index a518bb45..04d5364f 100644
--- a/media/java/android/media/Rating.java
+++ b/media/java/android/media/Rating.java
@@ -16,10 +16,14 @@
package android.media;
+import android.annotation.IntDef;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* A class to encapsulate rating information used as content metadata.
* A rating is defined by its rating style (see {@link #RATING_HEART},
@@ -32,6 +36,21 @@
private final static String TAG = "Rating";
/**
+ * @hide
+ */
+ @IntDef({RATING_NONE, RATING_HEART, RATING_THUMB_UP_DOWN, RATING_3_STARS, RATING_4_STARS,
+ RATING_5_STARS, RATING_PERCENTAGE})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Style {}
+
+ /**
+ * @hide
+ */
+ @IntDef({RATING_3_STARS, RATING_4_STARS, RATING_5_STARS})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface StarStyle {}
+
+ /**
* Indicates a rating style is not supported. A Rating will never have this
* type, but can be used by other classes to indicate they do not support
* Rating.
@@ -75,7 +94,7 @@
private final float mRatingValue;
- private Rating(int ratingStyle, float rating) {
+ private Rating(@Style int ratingStyle, float rating) {
mRatingStyle = ratingStyle;
mRatingValue = rating;
}
@@ -124,7 +143,7 @@
* or {@link #RATING_PERCENTAGE}.
* @return null if an invalid rating style is passed, a new Rating instance otherwise.
*/
- public static Rating newUnratedRating(int ratingStyle) {
+ public static Rating newUnratedRating(@Style int ratingStyle) {
switch(ratingStyle) {
case RATING_HEART:
case RATING_THUMB_UP_DOWN:
@@ -172,7 +191,7 @@
* @return null if the rating style is invalid, or the rating is out of range,
* a new Rating instance otherwise.
*/
- public static Rating newStarRating(int starRatingStyle, float starRating) {
+ public static Rating newStarRating(@StarStyle int starRatingStyle, float starRating) {
float maxRating = -1.0f;
switch(starRatingStyle) {
case RATING_3_STARS:
@@ -225,6 +244,7 @@
* {@link #RATING_3_STARS}, {@link #RATING_4_STARS}, {@link #RATING_5_STARS},
* or {@link #RATING_PERCENTAGE}.
*/
+ @Style
public int getRatingStyle() {
return mRatingStyle;
}
@@ -285,4 +305,4 @@
return mRatingValue;
}
}
-}
\ No newline at end of file
+}
diff --git a/media/java/android/media/VolumeProvider.java b/media/java/android/media/VolumeProvider.java
index 5d1e004..1c017c5 100644
--- a/media/java/android/media/VolumeProvider.java
+++ b/media/java/android/media/VolumeProvider.java
@@ -15,8 +15,12 @@
*/
package android.media;
+import android.annotation.IntDef;
import android.media.session.MediaSession;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* Handles requests to adjust or set the volume on a session. This is also used
* to push volume updates back to the session. The provider must call
@@ -26,6 +30,14 @@
* {@link MediaSession#setPlaybackToRemote}.
*/
public abstract class VolumeProvider {
+
+ /**
+ * @hide
+ */
+ @IntDef({VOLUME_CONTROL_FIXED, VOLUME_CONTROL_RELATIVE, VOLUME_CONTROL_ABSOLUTE})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ControlType {}
+
/**
* The volume is fixed and can not be modified. Requests to change volume
* should be ignored.
@@ -61,7 +73,7 @@
* @param maxVolume The maximum allowed volume.
* @param currentVolume The current volume on the output.
*/
- public VolumeProvider(int volumeControl, int maxVolume, int currentVolume) {
+ public VolumeProvider(@ControlType int volumeControl, int maxVolume, int currentVolume) {
mControlType = volumeControl;
mMaxVolume = maxVolume;
mCurrentVolume = currentVolume;
@@ -72,6 +84,7 @@
*
* @return The volume control type for this volume provider
*/
+ @ControlType
public final int getVolumeControl() {
return mControlType;
}
@@ -145,4 +158,4 @@
public static abstract class Callback {
public abstract void onVolumeChanged(VolumeProvider volumeProvider);
}
-}
\ No newline at end of file
+}
diff --git a/media/java/android/media/midi/MidiManager.java b/media/java/android/media/midi/MidiManager.java
index 266b0d9..07c8ae8 100644
--- a/media/java/android/media/midi/MidiManager.java
+++ b/media/java/android/media/midi/MidiManager.java
@@ -186,8 +186,7 @@
try {
mService.registerListener(mToken, deviceListener);
} catch (RemoteException e) {
- Log.e(TAG, "RemoteException in registerDeviceListener");
- return;
+ throw e.rethrowFromSystemServer();
}
mDeviceListeners.put(callback, deviceListener);
}
@@ -203,7 +202,7 @@
try {
mService.unregisterListener(mToken, deviceListener);
} catch (RemoteException e) {
- Log.e(TAG, "RemoteException in unregisterDeviceListener");
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -217,8 +216,7 @@
try {
return mService.getDevices();
} catch (RemoteException e) {
- Log.e(TAG, "RemoteException in getDevices");
- return new MidiDeviceInfo[0];
+ throw e.rethrowFromSystemServer();
}
}
@@ -267,7 +265,7 @@
try {
mService.openDevice(mToken, deviceInfo, callback);
} catch (RemoteException e) {
- Log.e(TAG, "RemoteException in openDevice");
+ throw e.rethrowFromSystemServer();
}
}
@@ -306,7 +304,7 @@
try {
mService.openBluetoothDevice(mToken, bluetoothDevice, callback);
} catch (RemoteException e) {
- Log.e(TAG, "RemoteException in openDevice");
+ throw e.rethrowFromSystemServer();
}
}
@@ -326,8 +324,7 @@
}
return server;
} catch (RemoteException e) {
- Log.e(TAG, "RemoteException in createVirtualDevice");
- return null;
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java
index 0bd1713..7f9653d 100644
--- a/media/java/android/media/session/MediaSession.java
+++ b/media/java/android/media/session/MediaSession.java
@@ -469,7 +469,7 @@
* <li>{@link Rating#RATING_THUMB_UP_DOWN}</li>
* </ul>
*/
- public void setRatingType(int type) {
+ public void setRatingType(@Rating.Style int type) {
try {
mBinder.setRatingType(type);
} catch (RemoteException e) {
diff --git a/media/java/android/media/session/PlaybackState.java b/media/java/android/media/session/PlaybackState.java
index 1485cd7..8283c8b 100644
--- a/media/java/android/media/session/PlaybackState.java
+++ b/media/java/android/media/session/PlaybackState.java
@@ -16,6 +16,7 @@
package android.media.session;
import android.annotation.DrawableRes;
+import android.annotation.IntDef;
import android.annotation.Nullable;
import android.media.RemoteControlClient;
import android.os.Bundle;
@@ -26,6 +27,9 @@
import java.util.ArrayList;
import java.util.List;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* Playback state for a {@link MediaSession}. This includes a state like
* {@link PlaybackState#STATE_PLAYING}, the current playback position,
@@ -35,6 +39,17 @@
private static final String TAG = "PlaybackState";
/**
+ * @hide
+ */
+ @IntDef(flag=true, value={ACTION_STOP, ACTION_PAUSE, ACTION_PLAY, ACTION_REWIND,
+ ACTION_SKIP_TO_PREVIOUS, ACTION_SKIP_TO_NEXT, ACTION_FAST_FORWARD, ACTION_SET_RATING,
+ ACTION_SEEK_TO, ACTION_PLAY_PAUSE, ACTION_PLAY_FROM_MEDIA_ID, ACTION_PLAY_FROM_SEARCH,
+ ACTION_SKIP_TO_QUEUE_ITEM, ACTION_PLAY_FROM_URI, ACTION_PREPARE,
+ ACTION_PREPARE_FROM_MEDIA_ID, ACTION_PREPARE_FROM_SEARCH, ACTION_PREPARE_FROM_URI})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Actions {}
+
+ /**
* Indicates this session supports the stop command.
*
* @see Builder#setActions(long)
@@ -161,6 +176,15 @@
public static final long ACTION_PREPARE_FROM_URI = 1 << 17;
/**
+ * @hide
+ */
+ @IntDef({STATE_NONE, STATE_STOPPED, STATE_PAUSED, STATE_PLAYING, STATE_FAST_FORWARDING,
+ STATE_REWINDING, STATE_BUFFERING, STATE_ERROR, STATE_CONNECTING,
+ STATE_SKIPPING_TO_PREVIOUS, STATE_SKIPPING_TO_NEXT, STATE_SKIPPING_TO_QUEUE_ITEM})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface State {}
+
+ /**
* This is the default playback state and indicates that no media has been
* added yet, or the performer has been reset and has no content to play.
*
@@ -349,9 +373,11 @@
* <li> {@link PlaybackState#STATE_SKIPPING_TO_QUEUE_ITEM}</li>
* </ul>
*/
+ @State
public int getState() {
return mState;
}
+
/**
* Get the current playback position in ms.
*/
@@ -403,6 +429,7 @@
* <li> {@link PlaybackState#ACTION_PREPARE_FROM_URI}</li>
* </ul>
*/
+ @Actions
public long getActions() {
return mActions;
}
@@ -866,7 +893,8 @@
* timebase that the position was updated at.
* @return this
*/
- public Builder setState(int state, long position, float playbackSpeed, long updateTime) {
+ public Builder setState(@State int state, long position, float playbackSpeed,
+ long updateTime) {
mState = state;
mPosition = position;
mUpdateTime = updateTime;
@@ -907,7 +935,7 @@
* normal playback.
* @return this
*/
- public Builder setState(int state, long position, float playbackSpeed) {
+ public Builder setState(@State int state, long position, float playbackSpeed) {
return setState(state, position, playbackSpeed, SystemClock.elapsedRealtime());
}
@@ -938,7 +966,7 @@
* @param actions The set of actions allowed.
* @return this
*/
- public Builder setActions(long actions) {
+ public Builder setActions(@Actions long actions) {
mActions = actions;
return this;
}
diff --git a/media/java/android/media/soundtrigger/SoundTriggerManager.java b/media/java/android/media/soundtrigger/SoundTriggerManager.java
index 4fd3310..fdd7fc2 100644
--- a/media/java/android/media/soundtrigger/SoundTriggerManager.java
+++ b/media/java/android/media/soundtrigger/SoundTriggerManager.java
@@ -69,6 +69,7 @@
try {
mSoundTriggerService.updateSoundModel(model.getGenericSoundModel());
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -81,7 +82,7 @@
return new Model(mSoundTriggerService.getSoundModel(
new ParcelUuid(soundModelId)));
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -92,6 +93,7 @@
try {
mSoundTriggerService.deleteSoundModel(new ParcelUuid(soundModelId));
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
diff --git a/media/java/android/media/tv/ITvInputClient.aidl b/media/java/android/media/tv/ITvInputClient.aidl
index 5dd4e85..72f8b57 100644
--- a/media/java/android/media/tv/ITvInputClient.aidl
+++ b/media/java/android/media/tv/ITvInputClient.aidl
@@ -45,7 +45,7 @@
void onTimeShiftCurrentPositionChanged(long timeMs, int seq);
// For the recording session
- void onTuned(int seq);
+ void onTuned(int seq, in Uri channelUri);
void onRecordingStopped(in Uri recordedProgramUri, int seq);
void onError(int error, int seq);
}
diff --git a/media/java/android/media/tv/ITvInputSessionCallback.aidl b/media/java/android/media/tv/ITvInputSessionCallback.aidl
index 60d6f0d..af76f90 100644
--- a/media/java/android/media/tv/ITvInputSessionCallback.aidl
+++ b/media/java/android/media/tv/ITvInputSessionCallback.aidl
@@ -42,7 +42,7 @@
void onTimeShiftCurrentPositionChanged(long timeMs);
// For the recording session
- void onTuned();
+ void onTuned(in Uri channelUri);
void onRecordingStopped(in Uri recordedProgramUri);
void onError(int error);
}
diff --git a/media/java/android/media/tv/TvInputInfo.java b/media/java/android/media/tv/TvInputInfo.java
index 6e0f5f2..63e3edc 100644
--- a/media/java/android/media/tv/TvInputInfo.java
+++ b/media/java/android/media/tv/TvInputInfo.java
@@ -677,11 +677,12 @@
* Constructs a new builder for {@link TvInputInfo}.
*
* @param context A Context of the application package implementing this class.
- * @param cls The component class that is to be used for the {@link TvInputService}.
+ * @param component The name of the application component to be used for the
+ * {@link TvInputService}.
*/
- public Builder(Context context, Class<?> cls) {
+ public Builder(Context context, ComponentName component) {
mContext = context;
- Intent intent = new Intent(TvInputService.SERVICE_INTERFACE).setClass(context, cls);
+ Intent intent = new Intent(TvInputService.SERVICE_INTERFACE).setComponent(component);
mResolveInfo = context.getPackageManager().resolveService(intent,
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
}
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java
index 2703b1a..0b0306c 100644
--- a/media/java/android/media/tv/TvInputManager.java
+++ b/media/java/android/media/tv/TvInputManager.java
@@ -478,8 +478,10 @@
/**
* This is called when the recording session has been tuned to the given channel and is
* ready to start recording.
+ *
+ * @param channelUri The URI of a channel.
*/
- void onTuned(Session session) {
+ void onTuned(Session session, Uri channelUri) {
}
// For the recording session only
@@ -653,11 +655,11 @@
}
// For the recording session only
- void postTuned() {
+ void postTuned(final Uri channelUri) {
mHandler.post(new Runnable() {
@Override
public void run() {
- mSessionCallback.onTuned(mSession);
+ mSessionCallback.onTuned(mSession, channelUri);
}
});
}
@@ -1013,14 +1015,14 @@
}
@Override
- public void onTuned(int seq) {
+ public void onTuned(int seq, Uri channelUri) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
if (record == null) {
Log.e(TAG, "Callback not found for seq " + seq);
return;
}
- record.postTuned();
+ record.postTuned(channelUri);
}
}
@@ -1109,7 +1111,7 @@
}
}
} catch (RemoteException e) {
- Log.e(TAG, "TvInputManager initialization failed", e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1122,7 +1124,7 @@
try {
return mService.getTvInputList(mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1138,7 +1140,7 @@
try {
return mService.getTvInputInfo(inputId, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1155,7 +1157,7 @@
try {
mService.updateTvInputInfo(inputInfo, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException("Error trying to update " + inputInfo, e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1226,7 +1228,7 @@
try {
return mService.isParentalControlsEnabled(mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1243,7 +1245,7 @@
try {
mService.setParentalControlsEnabled(enabled, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1258,7 +1260,7 @@
try {
return mService.isRatingBlocked(rating.flattenToString(), mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1277,7 +1279,7 @@
}
return ratings;
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1295,7 +1297,7 @@
try {
mService.addBlockedRating(rating.flattenToString(), mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1313,7 +1315,7 @@
try {
mService.removeBlockedRating(rating.flattenToString(), mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1326,7 +1328,7 @@
try {
return mService.getTvContentRatingSystemList(mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1376,7 +1378,7 @@
try {
mService.createSession(mClient, inputId, isRecordingSession, seq, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -1400,7 +1402,7 @@
try {
return mService.getAvailableTvStreamConfigList(inputId, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1418,7 +1420,7 @@
try {
return mService.captureFrame(inputId, surface, config, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1432,7 +1434,7 @@
try {
return mService.isSingleSessionActive(mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1446,7 +1448,7 @@
try {
return mService.getHardwareList();
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1476,7 +1478,7 @@
}
}, info, mUserId));
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1490,7 +1492,7 @@
try {
mService.releaseTvInputHardware(deviceId, hardware.getInterface(), mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1504,7 +1506,7 @@
try {
return mService.getDvbDeviceList();
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1527,7 +1529,7 @@
}
return mService.openDvbDevice(info, device);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1598,7 +1600,7 @@
try {
mService.releaseSession(mToken, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
releaseInternal();
@@ -1618,7 +1620,7 @@
try {
mService.setMainSession(mToken, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1636,7 +1638,7 @@
try {
mService.setSurface(mToken, surface, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1658,7 +1660,7 @@
try {
mService.dispatchSurfaceChanged(mToken, format, width, height, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1679,7 +1681,7 @@
}
mService.setVolume(mToken, volume, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1719,7 +1721,7 @@
try {
mService.tune(mToken, channelUri, params, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1736,7 +1738,7 @@
try {
mService.setCaptionEnabled(mToken, enabled, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1778,7 +1780,7 @@
try {
mService.selectTrack(mToken, type, trackId, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1926,7 +1928,7 @@
try {
mService.timeShiftPlay(mToken, recordedProgramUri, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1941,7 +1943,7 @@
try {
mService.timeShiftPause(mToken, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1956,7 +1958,7 @@
try {
mService.timeShiftResume(mToken, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1977,7 +1979,7 @@
try {
mService.timeShiftSeekTo(mToken, timeMs, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -1994,7 +1996,7 @@
try {
mService.timeShiftSetPlaybackParams(mToken, params, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2011,7 +2013,7 @@
try {
mService.timeShiftEnablePositionTracking(mToken, enable, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2029,7 +2031,7 @@
try {
mService.startRecording(mToken, programHint, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2044,7 +2046,7 @@
try {
mService.stopRecording(mToken, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2067,7 +2069,7 @@
try {
mService.sendAppPrivateCommand(mToken, action, data, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2095,7 +2097,7 @@
try {
mService.createOverlayView(mToken, view.getWindowToken(), frame, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2113,7 +2115,7 @@
try {
mService.relayoutOverlayView(mToken, frame, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2128,7 +2130,7 @@
try {
mService.removeOverlayView(mToken, mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -2144,7 +2146,7 @@
try {
mService.unblockContent(mToken, unblockedRating.flattenToString(), mUserId);
} catch (RemoteException e) {
- throw new RuntimeException(e);
+ throw e.rethrowFromSystemServer();
}
}
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index db851a3..8fb58b5 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -1567,8 +1567,10 @@
* passed channel and call this method to indicate that it is now available for immediate
* recording. When {@link #onStartRecording(Uri)} is called, recording must start with
* minimal delay.
+ *
+ * @param channelUri The URI of a channel.
*/
- public void notifyTuned() {
+ public void notifyTuned(Uri channelUri) {
executeOrPostRunnableOnMainThread(new Runnable() {
@MainThread
@Override
@@ -1576,7 +1578,7 @@
try {
if (DEBUG) Log.d(TAG, "notifyTuned");
if (mSessionCallback != null) {
- mSessionCallback.onTuned();
+ mSessionCallback.onTuned(channelUri);
}
} catch (RemoteException e) {
Log.w(TAG, "error in notifyTuned", e);
@@ -1679,7 +1681,7 @@
* <p>The application may call this method before starting or after stopping recording, but
* not during recording.
*
- * <p>The session must call {@link #notifyTuned()} if the tune request was fulfilled, or
+ * <p>The session must call {@link #notifyTuned(Uri)} if the tune request was fulfilled, or
* {@link #notifyError(int)} otherwise.
*
* @param channelUri The URI of a channel.
@@ -1708,8 +1710,8 @@
* Called when the application requests to start TV program recording. Recording must start
* immediately when this method is called.
*
- * <p>The application may supply the URI for a TV program as a hint for filling in program
- * specific data fields in the {@link android.media.tv.TvContract.RecordedPrograms} table.
+ * <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
* recording can span across multiple TV programs. In either case, the application must call
@@ -1718,10 +1720,10 @@
* <p>The session must call {@link #notifyError(int)} if the start request cannot be
* fulfilled.
*
- * @param programHint The URI for the TV program to record as a hint, built by
+ * @param programUri The URI for the TV program to record, built by
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
*/
- public abstract void onStartRecording(@Nullable Uri programHint);
+ public abstract void onStartRecording(@Nullable Uri programUri);
/**
* Called when the application requests to stop TV program recording. Recording must stop
diff --git a/media/java/android/media/tv/TvRecordingClient.java b/media/java/android/media/tv/TvRecordingClient.java
index 1c920f5..d48ea21e 100644
--- a/media/java/android/media/tv/TvRecordingClient.java
+++ b/media/java/android/media/tv/TvRecordingClient.java
@@ -76,11 +76,12 @@
* during recording.
*
* <p>The recording session will respond by calling
- * {@link RecordingCallback#onTuned()} if the tune request was fulfilled, or
+ * {@link RecordingCallback#onTuned(Uri)} if the tune request was fulfilled, or
* {@link RecordingCallback#onError(int)} otherwise.
*
* @param inputId The ID of the TV input for the given channel.
* @param channelUri The URI of a channel.
+ * @throws IllegalStateException If recording is already started.
*/
public void tune(String inputId, Uri channelUri) {
tune(inputId, channelUri, null);
@@ -102,6 +103,7 @@
* @param inputId The ID of the TV input for the given channel.
* @param channelUri The URI of a channel.
* @param params Extra parameters.
+ * @throws IllegalStateException If recording is already started.
* @hide
*/
@SystemApi
@@ -152,8 +154,8 @@
* immediately when this method is called. If the current recording session has not yet tuned to
* any channel, this method throws an exception.
*
- * <p>The application may supply the URI for a TV program as a hint for filling in program
- * specific data fields in the {@link android.media.tv.TvContract.RecordedPrograms} table.
+ * <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
* recording can span across multiple TV programs. In either case, the application must call
@@ -162,15 +164,16 @@
* <p>The recording session will respond by calling {@link RecordingCallback#onError(int)} if
* the start request cannot be fulfilled.
*
- * @param programHint The URI for the TV program to record as a hint, built by
+ * @param programUri The URI for the TV program to record, built by
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
+ * @throws IllegalStateException If {@link #tune} request hasn't been handled yet.
*/
- public void startRecording(@Nullable Uri programHint) {
+ public void startRecording(@Nullable Uri programUri) {
if (!mIsTuned) {
throw new IllegalStateException("startRecording failed - not yet tuned");
}
if (mSession != null) {
- mSession.startRecording(programHint);
+ mSession.startRecording(programUri);
mIsRecordingStarted = true;
}
}
@@ -245,8 +248,10 @@
/**
* This is called when the recording session has been tuned to the given channel and is
* ready to start recording.
+ *
+ * @param channelUri The URI of a channel.
*/
- public void onTuned() {
+ public void onTuned(Uri channelUri) {
}
/**
@@ -327,7 +332,7 @@
}
@Override
- void onTuned(TvInputManager.Session session) {
+ void onTuned(TvInputManager.Session session, Uri channelUri) {
if (DEBUG) {
Log.d(TAG, "onTuned()");
}
@@ -336,7 +341,7 @@
return;
}
mIsTuned = true;
- mCallback.onTuned();
+ mCallback.onTuned(channelUri);
}
@Override
diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java
index 29bcc19..760a2d1 100755
--- a/media/java/android/mtp/MtpDatabase.java
+++ b/media/java/android/mtp/MtpDatabase.java
@@ -713,8 +713,7 @@
};
}
-
- private MtpPropertyList getObjectPropertyList(long handle, int format, long property,
+ private MtpPropertyList getObjectPropertyList(int handle, int format, int property,
int groupCode, int depth) {
// FIXME - implement group support
if (groupCode != 0) {
@@ -722,29 +721,29 @@
}
MtpPropertyGroup propertyGroup;
- if (property == 0xFFFFFFFFL) {
- if (format == 0 && handle > 0) {
+ if (property == 0xffffffff) {
+ if (format == 0 && handle != 0 && handle != 0xffffffff) {
// return properties based on the object's format
- format = getObjectFormat((int)handle);
+ format = getObjectFormat(handle);
}
- propertyGroup = mPropertyGroupsByFormat.get(format);
- if (propertyGroup == null) {
+ propertyGroup = mPropertyGroupsByFormat.get(format);
+ if (propertyGroup == null) {
int[] propertyList = getSupportedObjectProperties(format);
propertyGroup = new MtpPropertyGroup(this, mMediaProvider,
mVolumeName, propertyList);
- mPropertyGroupsByFormat.put(new Integer(format), propertyGroup);
+ mPropertyGroupsByFormat.put(format, propertyGroup);
}
} else {
- propertyGroup = mPropertyGroupsByProperty.get(property);
- if (propertyGroup == null) {
- int[] propertyList = new int[] { (int)property };
- propertyGroup = new MtpPropertyGroup(this, mMediaProvider,
- mVolumeName, propertyList);
- mPropertyGroupsByProperty.put(new Integer((int)property), propertyGroup);
+ propertyGroup = mPropertyGroupsByProperty.get(property);
+ if (propertyGroup == null) {
+ final int[] propertyList = new int[] { property };
+ propertyGroup = new MtpPropertyGroup(
+ this, mMediaProvider, mVolumeName, propertyList);
+ mPropertyGroupsByProperty.put(property, propertyGroup);
}
}
- return propertyGroup.getPropertyList((int)handle, format, depth);
+ return propertyGroup.getPropertyList(handle, format, depth);
}
private int renameFile(int handle, String newName) {
@@ -970,7 +969,7 @@
Cursor c = null;
try {
c = mMediaProvider.query(mObjectsUri, FORMAT_PROJECTION,
- ID_WHERE, new String[] { Integer.toString(handle) }, null, null);
+ ID_WHERE, new String[] { Integer.toString(handle) }, null, null);
if (c != null && c.moveToNext()) {
return c.getInt(1);
} else {
diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp
index 556f2c7..5722cb0 100644
--- a/media/jni/android_mtp_MtpDatabase.cpp
+++ b/media/jni/android_mtp_MtpDatabase.cpp
@@ -231,11 +231,11 @@
}
MtpObjectHandle MyMtpDatabase::beginSendObject(const char* path,
- MtpObjectFormat format,
- MtpObjectHandle parent,
- MtpStorageID storage,
- uint64_t size,
- time_t modified) {
+ MtpObjectFormat format,
+ MtpObjectHandle parent,
+ MtpStorageID storage,
+ uint64_t size,
+ time_t modified) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
jstring pathStr = env->NewStringUTF(path);
MtpObjectHandle result = env->CallIntMethod(mDatabase, method_beginSendObject,
@@ -249,7 +249,7 @@
}
void MyMtpDatabase::endSendObject(const char* path, MtpObjectHandle handle,
- MtpObjectFormat format, bool succeeded) {
+ MtpObjectFormat format, bool succeeded) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
jstring pathStr = env->NewStringUTF(path);
env->CallVoidMethod(mDatabase, method_endSendObject, pathStr,
@@ -261,8 +261,8 @@
}
MtpObjectHandleList* MyMtpDatabase::getObjectList(MtpStorageID storageID,
- MtpObjectFormat format,
- MtpObjectHandle parent) {
+ MtpObjectFormat format,
+ MtpObjectHandle parent) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
jintArray array = (jintArray)env->CallObjectMethod(mDatabase, method_getObjectList,
(jint)storageID, (jint)format, (jint)parent);
@@ -281,8 +281,8 @@
}
int MyMtpDatabase::getNumObjects(MtpStorageID storageID,
- MtpObjectFormat format,
- MtpObjectHandle parent) {
+ MtpObjectFormat format,
+ MtpObjectHandle parent) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
int result = env->CallIntMethod(mDatabase, method_getNumObjects,
(jint)storageID, (jint)format, (jint)parent);
@@ -364,11 +364,21 @@
}
MtpResponseCode MyMtpDatabase::getObjectPropertyValue(MtpObjectHandle handle,
- MtpObjectProperty property,
- MtpDataPacket& packet) {
+ MtpObjectProperty property,
+ MtpDataPacket& packet) {
+ static_assert(sizeof(jint) >= sizeof(MtpObjectHandle),
+ "Casting MtpObjectHandle to jint loses a value");
+ static_assert(sizeof(jint) >= sizeof(MtpObjectProperty),
+ "Casting MtpObjectProperty to jint loses a value");
JNIEnv* env = AndroidRuntime::getJNIEnv();
- jobject list = env->CallObjectMethod(mDatabase, method_getObjectPropertyList,
- (jlong)handle, 0, (jlong)property, 0, 0);
+ jobject list = env->CallObjectMethod(
+ mDatabase,
+ method_getObjectPropertyList,
+ static_cast<jint>(handle),
+ 0,
+ static_cast<jint>(property),
+ 0,
+ 0);
MtpResponseCode result = env->GetIntField(list, field_mResult);
int count = env->GetIntField(list, field_mCount);
if (result == MTP_RESPONSE_OK && count != 1)
@@ -532,8 +542,8 @@
}
MtpResponseCode MyMtpDatabase::setObjectPropertyValue(MtpObjectHandle handle,
- MtpObjectProperty property,
- MtpDataPacket& packet) {
+ MtpObjectProperty property,
+ MtpDataPacket& packet) {
int type;
if (!getObjectPropertyInfo(property, type))
@@ -563,7 +573,7 @@
}
MtpResponseCode MyMtpDatabase::getDevicePropertyValue(MtpDeviceProperty property,
- MtpDataPacket& packet) {
+ MtpDataPacket& packet) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
if (property == MTP_DEVICE_PROPERTY_BATTERY_LEVEL) {
@@ -636,7 +646,7 @@
}
MtpResponseCode MyMtpDatabase::setDevicePropertyValue(MtpDeviceProperty property,
- MtpDataPacket& packet) {
+ MtpDataPacket& packet) {
int type;
if (!getDevicePropertyInfo(property, type))
@@ -670,12 +680,20 @@
}
MtpResponseCode MyMtpDatabase::getObjectPropertyList(MtpObjectHandle handle,
- uint32_t format, uint32_t property,
- int groupCode, int depth,
- MtpDataPacket& packet) {
+ uint32_t format, uint32_t property,
+ int groupCode, int depth,
+ MtpDataPacket& packet) {
+ static_assert(sizeof(jint) >= sizeof(MtpObjectHandle),
+ "Casting MtpObjectHandle to jint loses a value");
JNIEnv* env = AndroidRuntime::getJNIEnv();
- jobject list = env->CallObjectMethod(mDatabase, method_getObjectPropertyList,
- (jlong)handle, (jint)format, (jlong)property, (jint)groupCode, (jint)depth);
+ jobject list = env->CallObjectMethod(
+ mDatabase,
+ method_getObjectPropertyList,
+ static_cast<jint>(handle),
+ static_cast<jint>(format),
+ static_cast<jint>(property),
+ static_cast<jint>(groupCode),
+ static_cast<jint>(depth));
checkAndClearExceptionFromCallback(env, __FUNCTION__);
if (!list)
return MTP_RESPONSE_GENERAL_ERROR;
@@ -787,7 +805,7 @@
}
MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle,
- MtpObjectInfo& info) {
+ MtpObjectInfo& info) {
MtpString path;
int64_t length;
MtpObjectFormat format;
@@ -940,9 +958,9 @@
}
MtpResponseCode MyMtpDatabase::getObjectFilePath(MtpObjectHandle handle,
- MtpString& outFilePath,
- int64_t& outFileLength,
- MtpObjectFormat& outFormat) {
+ MtpString& outFilePath,
+ int64_t& outFileLength,
+ MtpObjectFormat& outFormat) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
jint result = env->CallIntMethod(mDatabase, method_getObjectFilePath,
(jint)handle, mStringBuffer, mLongBuffer);
@@ -1056,7 +1074,7 @@
}
MtpResponseCode MyMtpDatabase::setObjectReferences(MtpObjectHandle handle,
- MtpObjectHandleList* references) {
+ MtpObjectHandleList* references) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
int count = references->size();
jintArray array = env->NewIntArray(count);
@@ -1077,7 +1095,7 @@
}
MtpProperty* MyMtpDatabase::getObjectPropertyDesc(MtpObjectProperty property,
- MtpObjectFormat format) {
+ MtpObjectFormat format) {
static const int channelEnum[] = {
1, // mono
2, // stereo
@@ -1313,7 +1331,7 @@
return -1;
}
method_getObjectPropertyList = env->GetMethodID(clazz, "getObjectPropertyList",
- "(JIJII)Landroid/mtp/MtpPropertyList;");
+ "(IIIII)Landroid/mtp/MtpPropertyList;");
if (method_getObjectPropertyList == NULL) {
ALOGE("Can't find getObjectPropertyList");
return -1;
diff --git a/packages/DocumentsUI/res/layout/item_doc_list.xml b/packages/DocumentsUI/res/layout/item_doc_list.xml
index b169ec8..29f65e09 100644
--- a/packages/DocumentsUI/res/layout/item_doc_list.xml
+++ b/packages/DocumentsUI/res/layout/item_doc_list.xml
@@ -73,7 +73,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:orientation="vertical" >
+ android:orientation="vertical"
+ android:layout_gravity="center_vertical" >
<TextView
android:id="@android:id/title"
diff --git a/packages/DocumentsUI/src/com/android/documentsui/Metrics.java b/packages/DocumentsUI/src/com/android/documentsui/Metrics.java
index bff65d5..dcaea15 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/Metrics.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/Metrics.java
@@ -16,10 +16,12 @@
package com.android.documentsui;
+import static android.os.Environment.STANDARD_DIRECTORIES;
import static com.android.documentsui.Shared.DEBUG;
-
import android.annotation.IntDef;
import android.annotation.Nullable;
+import android.annotation.StringDef;
+import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
@@ -32,6 +34,7 @@
import com.android.documentsui.services.FileOperationService;
import com.android.documentsui.services.FileOperationService.OpType;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.MetricsProto.MetricsEvent;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -376,6 +379,84 @@
logHistogram(context, histogram, getOpCode(operationType, PROVIDER_INTRA));
}
+ // Types for logInvalidScopedAccessRequest
+ public static final String SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS =
+ "scoped_directory_access_invalid_args";
+ public static final String SCOPED_DIRECTORY_ACCESS_INVALID_DIRECTORY =
+ "scoped_directory_access_invalid_dir";
+ public static final String SCOPED_DIRECTORY_ACCESS_ERROR =
+ "scoped_directory_access_error";
+
+ @StringDef(value = {
+ SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS,
+ SCOPED_DIRECTORY_ACCESS_INVALID_DIRECTORY,
+ SCOPED_DIRECTORY_ACCESS_ERROR
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface InvalidScopedAccess{}
+
+ public static void logInvalidScopedAccessRequest(Context context,
+ @InvalidScopedAccess String type) {
+ MetricsLogger.count(context, type, 1);
+ switch (type) {
+ case SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS:
+ case SCOPED_DIRECTORY_ACCESS_INVALID_DIRECTORY:
+ case SCOPED_DIRECTORY_ACCESS_ERROR:
+ MetricsLogger.count(context, type, 1);
+ break;
+ default:
+ Log.wtf(TAG, "invalid InvalidScopedAccess: " + type);
+ }
+ }
+
+ // Types for logValidScopedAccessRequest
+ public static final int SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED = 0;
+ public static final int SCOPED_DIRECTORY_ACCESS_GRANTED = 1;
+ public static final int SCOPED_DIRECTORY_ACCESS_DENIED = 2;
+
+ @IntDef(flag = true, value = {
+ SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED,
+ SCOPED_DIRECTORY_ACCESS_GRANTED,
+ SCOPED_DIRECTORY_ACCESS_DENIED
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ScopedAccessGrant {}
+
+ public static void logValidScopedAccessRequest(Activity activity, String directory,
+ @ScopedAccessGrant int type) {
+ int index = -1;
+ for (int i = 0; i < STANDARD_DIRECTORIES.length; i++) {
+ if (STANDARD_DIRECTORIES[i].equals(directory)) {
+ index = i;
+ break;
+ }
+ }
+ final String packageName = activity.getCallingPackage();
+ switch (type) {
+ case SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED:
+ MetricsLogger.action(activity,
+ MetricsEvent.ACTION_SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED_BY_PACKAGE,
+ packageName);
+ MetricsLogger.action(activity,
+ MetricsEvent.ACTION_SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED_BY_FOLDER, index);
+ break;
+ case SCOPED_DIRECTORY_ACCESS_GRANTED:
+ MetricsLogger.action(activity,
+ MetricsEvent.ACTION_SCOPED_DIRECTORY_ACCESS_GRANTED_BY_PACKAGE, packageName);
+ MetricsLogger.action(activity,
+ MetricsEvent.ACTION_SCOPED_DIRECTORY_ACCESS_GRANTED_BY_FOLDER, index);
+ break;
+ case SCOPED_DIRECTORY_ACCESS_DENIED:
+ MetricsLogger.action(activity,
+ MetricsEvent.ACTION_SCOPED_DIRECTORY_ACCESS_DENIED_BY_PACKAGE, packageName);
+ MetricsLogger.action(activity,
+ MetricsEvent.ACTION_SCOPED_DIRECTORY_ACCESS_DENIED_BY_FOLDER, index);
+ break;
+ default:
+ Log.wtf(TAG, "invalid ScopedAccessGrant: " + type);
+ }
+ }
+
/**
* Internal method for making a MetricsLogger.count call. Increments the given counter by 1.
*
diff --git a/packages/DocumentsUI/src/com/android/documentsui/OpenExternalDirectoryActivity.java b/packages/DocumentsUI/src/com/android/documentsui/OpenExternalDirectoryActivity.java
index 27d6797..dc529ce 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/OpenExternalDirectoryActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/OpenExternalDirectoryActivity.java
@@ -17,9 +17,18 @@
package com.android.documentsui;
import static android.os.Environment.isStandardDirectory;
+import static android.os.Environment.STANDARD_DIRECTORIES;
import static android.os.storage.StorageVolume.EXTRA_DIRECTORY_NAME;
import static android.os.storage.StorageVolume.EXTRA_STORAGE_VOLUME;
import static com.android.documentsui.Shared.DEBUG;
+import static com.android.documentsui.Metrics.logInvalidScopedAccessRequest;
+import static com.android.documentsui.Metrics.logValidScopedAccessRequest;
+import static com.android.documentsui.Metrics.SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED;
+import static com.android.documentsui.Metrics.SCOPED_DIRECTORY_ACCESS_DENIED;
+import static com.android.documentsui.Metrics.SCOPED_DIRECTORY_ACCESS_ERROR;
+import static com.android.documentsui.Metrics.SCOPED_DIRECTORY_ACCESS_GRANTED;
+import static com.android.documentsui.Metrics.SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS;
+import static com.android.documentsui.Metrics.SCOPED_DIRECTORY_ACCESS_INVALID_DIRECTORY;
import android.app.Activity;
import android.app.ActivityManager;
@@ -73,6 +82,7 @@
final Intent intent = getIntent();
if (intent == null) {
if (DEBUG) Log.d(TAG, "missing intent");
+ logInvalidScopedAccessRequest(this, SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS);
setResult(RESULT_CANCELED);
finish();
return;
@@ -82,12 +92,14 @@
if (DEBUG)
Log.d(TAG, "extra " + EXTRA_STORAGE_VOLUME + " is not a StorageVolume: "
+ storageVolume);
+ logInvalidScopedAccessRequest(this, SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS);
setResult(RESULT_CANCELED);
finish();
return;
}
final String directoryName = intent.getStringExtra(EXTRA_DIRECTORY_NAME);
if (directoryName == null) {
+ logInvalidScopedAccessRequest(this, SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS);
if (DEBUG) Log.d(TAG, "missing extra " + EXTRA_DIRECTORY_NAME + " on " + intent);
setResult(RESULT_CANCELED);
finish();
@@ -125,6 +137,7 @@
} catch (IOException e) {
Log.e(TAG, "Could not get canonical file for volume " + storageVolume.dump()
+ " and directory " + directoryName);
+ logInvalidScopedAccessRequest(activity, SCOPED_DIRECTORY_ACCESS_ERROR);
return false;
}
final StorageManager sm =
@@ -138,6 +151,7 @@
if (DEBUG)
Log.d(TAG, "Directory '" + directory + "' is not standard (full path: '"
+ file.getAbsolutePath() + "')");
+ logInvalidScopedAccessRequest(activity, SCOPED_DIRECTORY_ACCESS_INVALID_DIRECTORY);
return false;
}
@@ -159,6 +173,8 @@
// Checks if the user has granted the permission already.
final Intent intent = getIntentForExistingPermission(activity, file);
if (intent != null) {
+ logValidScopedAccessRequest(activity, directory,
+ SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED);
activity.setResult(RESULT_OK, intent);
activity.finish();
return true;
@@ -166,12 +182,14 @@
if (volumeLabel == null) {
Log.e(TAG, "Could not get volume for " + file);
+ logInvalidScopedAccessRequest(activity, SCOPED_DIRECTORY_ACCESS_ERROR);
return false;
}
// Gets the package label.
final String appLabel = getAppLabel(activity);
if (appLabel == null) {
+ // Error already logged.
return false;
}
@@ -198,6 +216,7 @@
try {
return pm.getApplicationLabel(pm.getApplicationInfo(packageName, 0)).toString();
} catch (NameNotFoundException e) {
+ logInvalidScopedAccessRequest(activity, SCOPED_DIRECTORY_ACCESS_ERROR);
Log.w(TAG, "Could not get label for package " + packageName);
return null;
}
@@ -217,18 +236,21 @@
return volume.isVisibleForWrite(userId) && root.equals(path);
}
- private static Uri getGrantedUriPermission(ContentProviderClient provider, File file) {
+ private static Uri getGrantedUriPermission(Context context, ContentProviderClient provider,
+ File file) {
// Calls ExternalStorageProvider to get the doc id for the file
final Bundle bundle;
try {
bundle = provider.call("getDocIdForFileCreateNewDir", file.getPath(), null);
} catch (RemoteException e) {
Log.e(TAG, "Did not get doc id from External Storage provider for " + file, e);
+ logInvalidScopedAccessRequest(context, SCOPED_DIRECTORY_ACCESS_ERROR);
return null;
}
final String docId = bundle == null ? null : bundle.getString("DOC_ID");
if (docId == null) {
Log.e(TAG, "Did not get doc id from External Storage provider for " + file);
+ logInvalidScopedAccessRequest(context, SCOPED_DIRECTORY_ACCESS_ERROR);
return null;
}
Log.d(TAG, "doc id for " + file + ": " + docId);
@@ -242,9 +264,9 @@
return uri;
}
- private static Intent createGrantedUriPermissionsIntent(ContentProviderClient provider,
- File file) {
- final Uri uri = getGrantedUriPermission(provider, file);
+ private static Intent createGrantedUriPermissionsIntent(Context context,
+ ContentProviderClient provider, File file) {
+ final Uri uri = getGrantedUriPermission(context, provider, file);
return createGrantedUriPermissionsIntent(uri);
}
@@ -261,7 +283,8 @@
private static Intent getIntentForExistingPermission(OpenExternalDirectoryActivity activity,
File file) {
final String packageName = activity.getCallingPackage();
- final Uri grantedUri = getGrantedUriPermission(activity.getExternalStorageClient(), file);
+ final Uri grantedUri =
+ getGrantedUriPermission(activity, activity.getExternalStorageClient(), file);
if (DEBUG)
Log.d(TAG, "checking if " + packageName + " already has permission for " + grantedUri);
final ActivityManager am =
@@ -298,7 +321,7 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
- final String folder = mFile.getName();
+ final String directory = mFile.getName();
final Activity activity = getActivity();
final OnClickListener listener = new OnClickListener() {
@@ -306,12 +329,16 @@
public void onClick(DialogInterface dialog, int which) {
Intent intent = null;
if (which == DialogInterface.BUTTON_POSITIVE) {
- intent = createGrantedUriPermissionsIntent(
+ intent = createGrantedUriPermissionsIntent(mActivity,
mActivity.getExternalStorageClient(), mFile);
}
if (which == DialogInterface.BUTTON_NEGATIVE || intent == null) {
+ logValidScopedAccessRequest(activity, directory,
+ SCOPED_DIRECTORY_ACCESS_DENIED);
activity.setResult(RESULT_CANCELED);
} else {
+ logValidScopedAccessRequest(activity, directory,
+ SCOPED_DIRECTORY_ACCESS_GRANTED);
activity.setResult(RESULT_OK, intent);
}
activity.finish();
@@ -320,7 +347,7 @@
final CharSequence message = TextUtils
.expandTemplate(
- getText(R.string.open_external_dialog_request), mAppLabel, folder,
+ getText(R.string.open_external_dialog_request), mAppLabel, directory,
mVolumeLabel);
return new AlertDialog.Builder(activity, R.style.AlertDialogTheme)
.setMessage(message)
@@ -333,6 +360,7 @@
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
final Activity activity = getActivity();
+ logValidScopedAccessRequest(activity, mFile.getName(), SCOPED_DIRECTORY_ACCESS_DENIED);
activity.setResult(RESULT_CANCELED);
activity.finish();
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
index ab67a51..b63fefd 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
@@ -17,7 +17,6 @@
package com.android.documentsui;
import static com.android.documentsui.Shared.DEBUG;
-import static com.android.documentsui.Shared.TAG;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
@@ -62,6 +61,8 @@
public static final Uri sNotificationUri = Uri.parse(
"content://com.android.documentsui.roots/");
+ private static final String TAG = "RootsCache";
+
private final Context mContext;
private final ContentObserver mObserver;
private OnCacheUpdateListener mCacheUpdateListener;
@@ -115,7 +116,13 @@
* Gather roots from all known storage providers.
*/
public void updateAsync() {
- // Verifying an assumption about the recents root being immutable.
+
+ // NOTE: This method is called when the UI language changes.
+ // For that reason we upadte our RecentsRoot to reflect
+ // the current language.
+ mRecentsRoot.title = mContext.getString(R.string.root_recent);
+
+ // Nothing else about the root should ever change.
assert(mRecentsRoot.authority == null);
assert(mRecentsRoot.rootId == null);
assert(mRecentsRoot.derivedIcon == R.drawable.ic_root_recent);
@@ -123,7 +130,6 @@
assert(mRecentsRoot.flags == (Root.FLAG_LOCAL_ONLY
| Root.FLAG_SUPPORTS_IS_CHILD
| Root.FLAG_SUPPORTS_CREATE));
- assert(mRecentsRoot.title == mContext.getString(R.string.root_recent));
assert(mRecentsRoot.availableBytes == -1);
new UpdateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@@ -412,25 +418,56 @@
static List<RootInfo> getMatchingRoots(Collection<RootInfo> roots, State state) {
final List<RootInfo> matching = new ArrayList<>();
for (RootInfo root : roots) {
- // Exclude read-only devices when creating
- if (state.action == State.ACTION_CREATE && !root.supportsCreate()) continue;
+
+ if (DEBUG) Log.d(TAG, "Evaluating " + root);
+
+ if (state.action == State.ACTION_CREATE && !root.supportsCreate()) {
+ if (DEBUG) Log.d(TAG, "Excluding read-only root because: ACTION_CREATE.");
+ continue;
+ }
+
if (state.action == State.ACTION_PICK_COPY_DESTINATION
- && !root.supportsCreate()) continue;
- // Exclude roots that don't support directory picking
- if (state.action == State.ACTION_OPEN_TREE && !root.supportsChildren()) continue;
- // Exclude advanced devices when not requested
- if (!state.showAdvanced && root.isAdvanced()) continue;
+ && !root.supportsCreate()) {
+ if (DEBUG) Log.d(
+ TAG, "Excluding read-only root because: ACTION_PICK_COPY_DESTINATION.");
+ continue;
+ }
+
+ if (state.action == State.ACTION_OPEN_TREE && !root.supportsChildren()) {
+ if (DEBUG) Log.d(
+ TAG, "Excluding root !supportsChildren because: ACTION_OPEN_TREE.");
+ continue;
+ }
+
+ if (!state.showAdvanced && root.isAdvanced()) {
+ if (DEBUG) Log.d(TAG, "Excluding root because: unwanted advanced device.");
+ continue;
+ }
+
// Exclude non-local devices when local only
- if (state.localOnly && !root.isLocalOnly()) continue;
+ if (state.localOnly && !root.isLocalOnly()) {
+ if (DEBUG) Log.d(TAG, "Excluding root because: unwanted non-local device.");
+ continue;
+ }
+
// Exclude downloads roots as it doesn't support directory creation (actually
// we just don't show them).
// TODO: Add flag to check the root supports directory creation.
- if (state.directoryCopy && !root.isDownloads()) continue;
+ if (state.directoryCopy && root.isDownloads()) {
+ if (DEBUG) Log.d(
+ TAG, "Excluding downloads root because: unsupported directory copy.");
+ continue;
+ }
// Only show empty roots when creating, or in browse mode.
- if (root.isEmpty() && (state.action == State.ACTION_OPEN
- || state.action == State.ACTION_GET_CONTENT)) {
- if (DEBUG) Log.i(TAG, "Skipping empty root: " + root);
+ if (state.action == State.ACTION_OPEN && root.isEmpty()) {
+ if (DEBUG) Log.d(TAG, "Excluding empty root because: ACTION_OPEN.");
+ continue;
+ }
+
+ // Only show empty roots when creating, or in browse mode.
+ if (state.action == State.ACTION_GET_CONTENT && root.isEmpty()) {
+ if (DEBUG) Log.d(TAG, "Excluding empty root because: ACTION_GET_CONTENT.");
continue;
}
@@ -439,18 +476,19 @@
MimePredicate.mimeMatches(root.derivedMimeTypes, state.acceptMimes) ||
MimePredicate.mimeMatches(state.acceptMimes, root.derivedMimeTypes);
if (!overlap) {
+ if (DEBUG) Log.d(
+ TAG, "Excluding root because: unsupported content types > "
+ + state.acceptMimes);
continue;
}
// Exclude roots from the calling package.
if (state.excludedAuthorities.contains(root.authority)) {
- if (DEBUG) Log.d(
- TAG, "Excluding root " + root.authority + " from calling package.");
+ if (DEBUG) Log.d(TAG, "Excluding root because: calling package.");
continue;
}
- if (DEBUG) Log.d(
- TAG, "Including root " + root + " in roots list.");
+ if (DEBUG) Log.d(TAG, "Including " + root);
matching.add(root);
}
return matching;
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/ListDocumentHolder.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/ListDocumentHolder.java
index b940ffb..11f9aa7 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/ListDocumentHolder.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/ListDocumentHolder.java
@@ -29,6 +29,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.documentsui.R;
@@ -38,9 +39,10 @@
final class ListDocumentHolder extends DocumentHolder {
final TextView mTitle;
- final TextView mSummary;
+ final LinearLayout mDetails; // Container of date/size/summary
final TextView mDate;
final TextView mSize;
+ final TextView mSummary;
final ImageView mIconMime;
final ImageView mIconThumb;
final ImageView mIconCheck;
@@ -50,9 +52,10 @@
super(context, parent, R.layout.item_doc_list);
mTitle = (TextView) itemView.findViewById(android.R.id.title);
- mSummary = (TextView) itemView.findViewById(android.R.id.summary);
+ mDetails = (LinearLayout) itemView.findViewById(R.id.line2);
mDate = (TextView) itemView.findViewById(R.id.date);
mSize = (TextView) itemView.findViewById(R.id.size);
+ mSummary = (TextView) itemView.findViewById(android.R.id.summary);
mIconMime = (ImageView) itemView.findViewById(R.id.icon_mime);
mIconThumb = (ImageView) itemView.findViewById(R.id.icon_thumb);
mIconCheck = (ImageView) itemView.findViewById(R.id.icon_check);
@@ -91,6 +94,7 @@
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
final String docSummary = getCursorString(cursor, Document.COLUMN_SUMMARY);
final long docSize = getCursorLong(cursor, Document.COLUMN_SIZE);
+ final boolean isDirectory = Document.MIME_TYPE_DIR.equals(docMimeType);
mIconHelper.stopLoading(mIconThumb);
@@ -105,24 +109,36 @@
mTitle.setText(docDisplayName, TextView.BufferType.SPANNABLE);
mTitle.setVisibility(View.VISIBLE);
- if (docSummary != null) {
- mSummary.setText(docSummary);
- mSummary.setVisibility(View.VISIBLE);
- } else {
- mSummary.setVisibility(View.INVISIBLE);
- }
- if (docLastModified == -1) {
- mDate.setText(null);
+ // Note, we don't show any details for any directory...ever.
+ if (isDirectory) {
+ mDetails.setVisibility(View.GONE);
} else {
- mDate.setText(Shared.formatTime(mContext, docLastModified));
- }
+ boolean hasDetails = false;
+ if (docSummary != null) {
+ hasDetails = true;
+ mSummary.setText(docSummary);
+ mSummary.setVisibility(View.VISIBLE);
+ } else {
+ mSummary.setVisibility(View.INVISIBLE);
+ }
- if (!state.showSize || Document.MIME_TYPE_DIR.equals(docMimeType) || docSize == -1) {
- mSize.setVisibility(View.GONE);
- } else {
- mSize.setVisibility(View.VISIBLE);
- mSize.setText(Formatter.formatFileSize(mContext, docSize));
+ if (docLastModified == -1) {
+ hasDetails = true;
+ mDate.setText(null);
+ } else {
+ mDate.setText(Shared.formatTime(mContext, docLastModified));
+ }
+
+ if (!state.showSize || docSize == -1) {
+ hasDetails = true;
+ mSize.setVisibility(View.GONE);
+ mDetails.setVisibility(View.GONE);
+ } else {
+ mSize.setVisibility(View.VISIBLE);
+ mSize.setText(Formatter.formatFileSize(mContext, docSize));
+ }
+ mDetails.setVisibility(hasDetails ? View.VISIBLE : View.GONE);
}
}
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java
index 7d3498e..2e81545 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java
@@ -16,6 +16,9 @@
package com.android.documentsui;
+import static com.android.documentsui.RootsCache.getMatchingRoots;
+import static com.google.common.collect.Lists.newArrayList;
+
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
@@ -28,23 +31,18 @@
@SmallTest
public class RootsCacheTest extends AndroidTestCase {
- private static RootInfo buildForMimeTypes(String... mimeTypes) {
- final RootInfo root = new RootInfo();
- root.derivedMimeTypes = mimeTypes;
- return root;
- }
+ private static RootInfo mNull = new RootInfo();
+ private static RootInfo mEmpty = buildForMimeTypes();
+ private static RootInfo mWild = buildForMimeTypes("*/*");
+ private static RootInfo mImages = buildForMimeTypes("image/*");
+ private static RootInfo mAudio = buildForMimeTypes(
+ "audio/*", "application/ogg", "application/x-flac");
+ private static RootInfo mDocs = buildForMimeTypes(
+ "application/msword", "application/vnd.ms-excel");
+ private static RootInfo mMalformed1 = buildForMimeTypes("meow");
+ private static RootInfo mMalformed2 = buildForMimeTypes("*/meow");
- private RootInfo mNull = new RootInfo();
- private RootInfo mEmpty = buildForMimeTypes();
- private RootInfo mWild = buildForMimeTypes("*/*");
- private RootInfo mImages = buildForMimeTypes("image/*");
- private RootInfo mAudio = buildForMimeTypes("audio/*", "application/ogg", "application/x-flac");
- private RootInfo mDocs = buildForMimeTypes("application/msword", "application/vnd.ms-excel");
- private RootInfo mMalformed1 = buildForMimeTypes("meow");
- private RootInfo mMalformed2 = buildForMimeTypes("*/meow");
-
- private List<RootInfo> mRoots = Lists.newArrayList(
- mNull, mWild, mEmpty, mImages, mAudio, mDocs, mMalformed1, mMalformed2);
+ private List<RootInfo> mRoots;
private State mState;
@@ -52,70 +50,87 @@
protected void setUp() throws Exception {
super.setUp();
+ mRoots = Lists.newArrayList(
+ mNull, mWild, mEmpty, mImages, mAudio, mDocs, mMalformed1, mMalformed2);
+
mState = new State();
mState.action = State.ACTION_OPEN;
mState.showAdvanced = true;
mState.localOnly = false;
}
- public void testMatchingRootsEverything() throws Exception {
+ public void testMatchingRoots_Everything() throws Exception {
mState.acceptMimes = new String[] { "*/*" };
assertContainsExactly(
- Lists.newArrayList(mNull, mWild, mImages, mAudio, mDocs, mMalformed1, mMalformed2),
- RootsCache.getMatchingRoots(mRoots, mState));
+ newArrayList(mNull, mWild, mImages, mAudio, mDocs, mMalformed1, mMalformed2),
+ getMatchingRoots(mRoots, mState));
}
- public void testMatchingRootsPngOrWild() throws Exception {
+ public void testMatchingRoots_DirectoryCopy() throws Exception {
+ RootInfo downloads = buildForMimeTypes("*/*");
+ downloads.authority = "com.android.providers.downloads.documents";
+ mRoots.add(downloads);
+
+ mState.acceptMimes = new String[] { "*/*" };
+ mState.directoryCopy = true;
+
+ // basically we're asserting that the results don't contain downloads
+ assertContainsExactly(
+ newArrayList(mNull, mWild, mImages, mAudio, mDocs, mMalformed1, mMalformed2),
+ getMatchingRoots(mRoots, mState));
+ }
+
+ public void testMatchingRoots_PngOrWild() throws Exception {
mState.acceptMimes = new String[] { "image/png", "*/*" };
assertContainsExactly(
- Lists.newArrayList(mNull, mWild, mImages, mAudio, mDocs, mMalformed1, mMalformed2),
- RootsCache.getMatchingRoots(mRoots, mState));
+ newArrayList(mNull, mWild, mImages, mAudio, mDocs, mMalformed1, mMalformed2),
+ getMatchingRoots(mRoots, mState));
}
- public void testMatchingRootsAudioWild() throws Exception {
+ public void testMatchingRoots_AudioWild() throws Exception {
mState.acceptMimes = new String[] { "audio/*" };
assertContainsExactly(
- Lists.newArrayList(mNull, mWild, mAudio),
- RootsCache.getMatchingRoots(mRoots, mState));
+ newArrayList(mNull, mWild, mAudio),
+ getMatchingRoots(mRoots, mState));
}
- public void testMatchingRootsAudioWildOrImageWild() throws Exception {
+ public void testMatchingRoots_AudioWildOrImageWild() throws Exception {
mState.acceptMimes = new String[] { "audio/*", "image/*" };
assertContainsExactly(
- Lists.newArrayList(mNull, mWild, mAudio, mImages),
- RootsCache.getMatchingRoots(mRoots, mState));
+ newArrayList(mNull, mWild, mAudio, mImages),
+ getMatchingRoots(mRoots, mState));
}
- public void testMatchingRootsAudioSpecific() throws Exception {
+ public void testMatchingRoots_AudioSpecific() throws Exception {
mState.acceptMimes = new String[] { "audio/mpeg" };
assertContainsExactly(
- Lists.newArrayList(mNull, mWild, mAudio),
- RootsCache.getMatchingRoots(mRoots, mState));
+ newArrayList(mNull, mWild, mAudio),
+ getMatchingRoots(mRoots, mState));
}
- public void testMatchingRootsDocument() throws Exception {
+ public void testMatchingRoots_Document() throws Exception {
mState.acceptMimes = new String[] { "application/msword" };
assertContainsExactly(
- Lists.newArrayList(mNull, mWild, mDocs),
- RootsCache.getMatchingRoots(mRoots, mState));
+ newArrayList(mNull, mWild, mDocs),
+ getMatchingRoots(mRoots, mState));
}
- public void testMatchingRootsApplication() throws Exception {
+ public void testMatchingRoots_Application() throws Exception {
mState.acceptMimes = new String[] { "application/*" };
assertContainsExactly(
- Lists.newArrayList(mNull, mWild, mAudio, mDocs),
- RootsCache.getMatchingRoots(mRoots, mState));
+ newArrayList(mNull, mWild, mAudio, mDocs),
+ getMatchingRoots(mRoots, mState));
}
- public void testMatchingRootsFlacOrPng() throws Exception {
+ public void testMatchingRoots_FlacOrPng() throws Exception {
mState.acceptMimes = new String[] { "application/x-flac", "image/png" };
assertContainsExactly(
- Lists.newArrayList(mNull, mWild, mAudio, mImages),
- RootsCache.getMatchingRoots(mRoots, mState));
+ newArrayList(mNull, mWild, mAudio, mImages),
+ getMatchingRoots(mRoots, mState));
}
public void testExcludedAuthorities() throws Exception {
- final List<RootInfo> roots = Lists.newArrayList();
+ final List<RootInfo> roots = newArrayList();
// Set up some roots
for (int i = 0; i < 5; ++i) {
@@ -124,7 +139,7 @@
roots.add(root);
}
// Make some allowed authorities
- List<RootInfo> allowedRoots = Lists.newArrayList(
+ List<RootInfo> allowedRoots = newArrayList(
roots.get(0), roots.get(2), roots.get(4));
// Set up the excluded authority list
for (RootInfo root: roots) {
@@ -136,7 +151,7 @@
assertContainsExactly(
allowedRoots,
- RootsCache.getMatchingRoots(roots, mState));
+ getMatchingRoots(roots, mState));
}
private static void assertContainsExactly(List<?> expected, List<?> actual) {
@@ -145,4 +160,10 @@
assertTrue(actual.contains(o));
}
}
+
+ private static RootInfo buildForMimeTypes(String... mimeTypes) {
+ final RootInfo root = new RootInfo();
+ root.derivedMimeTypes = mimeTypes;
+ return root;
+ }
}
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
index 97dfd47..97527dd 100644
--- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
+++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
@@ -391,6 +391,10 @@
if (mArchiveHelper.isArchivedDocument(docId)) {
return mArchiveHelper.isChildDocument(parentDocId, docId);
}
+ // Archives do not contain regular files.
+ if (mArchiveHelper.isArchivedDocument(parentDocId)) {
+ return false;
+ }
final File parent = getFileForDocId(parentDocId).getCanonicalFile();
final File doc = getFileForDocId(docId).getCanonicalFile();
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java
index 63c4ef8b..c031f34 100644
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java
+++ b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java
@@ -404,6 +404,7 @@
for (final int id : keySet) {
closeDeviceInternal(id);
}
+ mRootScanner.pause();
} catch (InterruptedException|IOException e) {
// It should fail unit tests by throwing runtime exception.
throw new RuntimeException(e);
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/RootScanner.java b/packages/MtpDocumentsProvider/src/com/android/mtp/RootScanner.java
index 82ba21f..2f66c5c 100644
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/RootScanner.java
+++ b/packages/MtpDocumentsProvider/src/com/android/mtp/RootScanner.java
@@ -26,7 +26,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
final class RootScanner {
@@ -56,7 +55,7 @@
final MtpDatabase mDatabase;
ExecutorService mExecutor;
- FutureTask<Void> mCurrentTask;
+ private UpdateRootsRunnable mCurrentTask;
RootScanner(
ContentResolver resolver,
@@ -84,13 +83,12 @@
mExecutor = Executors.newSingleThreadExecutor();
}
if (mCurrentTask != null) {
- // Cancel previous task.
- mCurrentTask.cancel(true);
+ // Stop previous task.
+ mCurrentTask.stop();
}
- final UpdateRootsRunnable runnable = new UpdateRootsRunnable();
- mCurrentTask = new FutureTask<Void>(runnable, null);
- mExecutor.submit(mCurrentTask);
- return runnable.mFirstScanCompleted;
+ mCurrentTask = new UpdateRootsRunnable();
+ mExecutor.execute(mCurrentTask);
+ return mCurrentTask.mFirstScanCompleted;
}
/**
@@ -112,13 +110,21 @@
* Runnable to scan roots and update the database information.
*/
private final class UpdateRootsRunnable implements Runnable {
+ /**
+ * Count down latch that specifies the runnable is stopped.
+ */
+ final CountDownLatch mStopped = new CountDownLatch(1);
+
+ /**
+ * Count down latch that specifies the first scan is completed.
+ */
final CountDownLatch mFirstScanCompleted = new CountDownLatch(1);
@Override
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
int pollingCount = 0;
- while (true) {
+ while (mStopped.getCount() > 0) {
boolean changed = false;
// Update devices.
@@ -171,12 +177,16 @@
// Use SHORT_POLLING_PERIOD for the first SHORT_POLLING_TIMES because it is
// more likely to add new root just after the device is added.
// TODO: Use short interval only for a device that is just added.
- Thread.sleep(pollingCount > SHORT_POLLING_TIMES ?
- LONG_POLLING_INTERVAL : SHORT_POLLING_INTERVAL);
+ mStopped.await(pollingCount > SHORT_POLLING_TIMES ?
+ LONG_POLLING_INTERVAL : SHORT_POLLING_INTERVAL, TimeUnit.MILLISECONDS);
} catch (InterruptedException exp) {
break;
}
}
}
+
+ void stop() {
+ mStopped.countDown();
+ }
}
}
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index c590ec7a..b5b7bcd7 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -82,6 +82,7 @@
<uses-permission android:name="android.permission.GET_TOP_ACTIVITY_INFO" />
<uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" />
<uses-permission android:name="android.permission.START_TASKS_FROM_RECENTS" />
+ <uses-permission android:name="android.permission.GET_INTENT_SENDER_INTENT" />
<!-- WindowManager -->
<uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
diff --git a/packages/SystemUI/res/drawable/qs_background_secondary.xml b/packages/SystemUI/res/drawable/qs_background_secondary.xml
deleted file mode 100644
index 31c0162..0000000
--- a/packages/SystemUI/res/drawable/qs_background_secondary.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <solid android:color="@color/system_secondary_color" />
- <corners
- android:topLeftRadius="0dp"
- android:topRightRadius="0dp" />
-</shape>
diff --git a/packages/SystemUI/res/drawable/qs_customizer_background.xml b/packages/SystemUI/res/drawable/qs_customizer_background.xml
index 6bb27cc..d90f820 100644
--- a/packages/SystemUI/res/drawable/qs_customizer_background.xml
+++ b/packages/SystemUI/res/drawable/qs_customizer_background.xml
@@ -15,5 +15,5 @@
-->
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/qs_detail_transition" />
- <item android:drawable="?android:attr/windowBackground" />
+ <item android:drawable="@color/system_primary_color" />
</transition>
diff --git a/packages/SystemUI/res/layout/notification_guts.xml b/packages/SystemUI/res/layout/notification_guts.xml
index 62f2b47..4b0c834 100644
--- a/packages/SystemUI/res/layout/notification_guts.xml
+++ b/packages/SystemUI/res/layout/notification_guts.xml
@@ -39,7 +39,7 @@
android:layout_gravity="center_vertical|start">
<ImageView
- android:id="@android:id/icon"
+ android:id="@+id/app_icon"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginEnd="6dp"
diff --git a/packages/SystemUI/res/layout/notification_settings_icon_row.xml b/packages/SystemUI/res/layout/notification_settings_icon_row.xml
index 52d07fc..f47083a 100644
--- a/packages/SystemUI/res/layout/notification_settings_icon_row.xml
+++ b/packages/SystemUI/res/layout/notification_settings_icon_row.xml
@@ -19,6 +19,7 @@
xmlns:systemui="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:visibility="invisible"
>
<com.android.systemui.statusbar.AlphaOptimizedImageView
@@ -31,7 +32,6 @@
android:paddingBottom="@dimen/notification_gear_padding"
android:src="@drawable/ic_settings"
android:tint="@color/notification_gear_color"
- android:visibility="invisible"
android:alpha="0"
android:background="?android:attr/selectableItemBackgroundBorderless"
/>
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index 289b1d9..656941f 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -39,8 +39,9 @@
android:clipToPadding="false"
android:clipChildren="false">
- <include
- layout="@layout/qs_panel"
+ <com.android.systemui.DensityContainer
+ android:id="@+id/qs_density_container"
+ android:layout="@layout/qs_panel"
android:layout_width="@dimen/notification_panel_width"
android:layout_height="wrap_content"
android:layout_gravity="@integer/notification_panel_layout_gravity" />
diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml
index 189eb3b..e040ab2 100644
--- a/packages/SystemUI/res/values/attrs.xml
+++ b/packages/SystemUI/res/values/attrs.xml
@@ -93,5 +93,9 @@
<attr name="defValue" format="boolean" />
<attr name="metricsAction" format="integer" />
</declare-styleable>
+
+ <declare-styleable name="DensityContainer">
+ <attr name="android:layout" />
+ </declare-styleable>
</resources>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 8f69bbb..30acc72 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -31,7 +31,7 @@
<color name="batterymeter_bolt_color">#FFFFFFFF</color>
<color name="qs_batterymeter_frame_color">#FF404040</color>
<color name="system_primary_color">#ff263238</color><!-- blue grey 900 -->
- <color name="system_secondary_color">#ff384248</color>
+ <color name="system_secondary_color">#ff37474F</color><!-- blue grey 800 -->
<color name="system_accent_color">#ff80CBC4</color><!-- deep teal 200 -->
<color name="system_warning_color">#fff4511e</color><!-- deep orange 600 -->
<color name="qs_text">#FFFFFFFF</color>
diff --git a/packages/SystemUI/src/com/android/systemui/DensityContainer.java b/packages/SystemUI/src/com/android/systemui/DensityContainer.java
new file mode 100644
index 0000000..2e3cb49
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/DensityContainer.java
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import android.annotation.Nullable;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.FrameLayout;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DensityContainer extends FrameLayout {
+
+ private final List<InflateListener> mInflateListeners = new ArrayList<>();
+ private final int mLayout;
+ private int mDensity;
+
+ public DensityContainer(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+
+ mDensity = context.getResources().getConfiguration().densityDpi;
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DensityContainer);
+ if (!a.hasValue(R.styleable.DensityContainer_android_layout)) {
+ throw new IllegalArgumentException("DensityContainer must contain a layout");
+ }
+ mLayout = a.getResourceId(R.styleable.DensityContainer_android_layout, 0);
+ inflateLayout();
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ int density = newConfig.densityDpi;
+ if (density != mDensity) {
+ mDensity = density;
+ inflateLayout();
+ }
+ }
+
+ private void inflateLayout() {
+ removeAllViews();
+ LayoutInflater.from(getContext()).inflate(mLayout, this);
+ final int N = mInflateListeners.size();
+ for (int i = 0; i < N; i++) {
+ mInflateListeners.get(i).onInflated(getChildAt(0));
+ }
+ }
+
+ public void addInflateListener(InflateListener listener) {
+ mInflateListeners.add(listener);
+ listener.onInflated(getChildAt(0));
+ }
+
+ public interface InflateListener {
+ /**
+ * Called whenever a new view is inflated.
+ */
+ void onInflated(View v);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
index ea7270d..4b775a5 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
@@ -38,7 +38,9 @@
import android.os.UserHandle;
import android.provider.Settings.Secure;
import android.text.TextUtils;
+import android.util.Pair;
import android.util.Slog;
+import android.widget.Toast;
import com.android.settingslib.bluetooth.BluetoothCallback;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -46,6 +48,7 @@
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
+import com.android.settingslib.bluetooth.Utils;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
@@ -76,8 +79,9 @@
private static final int STATE_WAITING_FOR_BLUETOOTH = 4;
private static final int STATE_PAIRING = 5;
private static final int STATE_PAIRED = 6;
- private static final int STATE_USER_CANCELLED = 7;
- private static final int STATE_DEVICE_NOT_FOUND = 8;
+ private static final int STATE_PAIRING_FAILED = 7;
+ private static final int STATE_USER_CANCELLED = 8;
+ private static final int STATE_DEVICE_NOT_FOUND = 9;
private static final int MSG_INIT = 0;
private static final int MSG_ON_BOOT_COMPLETED = 1;
@@ -90,6 +94,7 @@
private static final int MSG_SHOW_BLUETOOTH_DIALOG = 8;
private static final int MSG_DISMISS_BLUETOOTH_DIALOG = 9;
private static final int MSG_BLE_ABORT_SCAN = 10;
+ private static final int MSG_SHOW_ERROR = 11;
private volatile KeyboardHandler mHandler;
private volatile KeyboardUIHandler mUIHandler;
@@ -178,6 +183,7 @@
mLocalBluetoothAdapter = bluetoothManager.getBluetoothAdapter();
mProfileManager = bluetoothManager.getProfileManager();
bluetoothManager.getEventManager().registerCallback(new BluetoothCallbackHandler());
+ Utils.setErrorListener(new BluetoothErrorListener());
InputManager im = context.getSystemService(InputManager.class);
im.registerOnTabletModeChangedListener(this, mHandler);
@@ -204,13 +210,15 @@
if (mInTabletMode != InputManager.SWITCH_STATE_OFF) {
if (mState == STATE_WAITING_FOR_DEVICE_DISCOVERY) {
stopScanning();
+ } else if (mState == STATE_WAITING_FOR_BLUETOOTH) {
+ mUIHandler.sendEmptyMessage(MSG_DISMISS_BLUETOOTH_DIALOG);
}
mState = STATE_WAITING_FOR_TABLET_MODE_EXIT;
return;
}
final int btState = mLocalBluetoothAdapter.getState();
- if (btState == BluetoothAdapter.STATE_TURNING_ON || btState == BluetoothAdapter.STATE_ON
+ if ((btState == BluetoothAdapter.STATE_TURNING_ON || btState == BluetoothAdapter.STATE_ON)
&& mState == STATE_WAITING_FOR_BLUETOOTH) {
// If we're waiting for bluetooth but it has come on in the meantime, or is coming
// on, just dismiss the dialog. This frequently happens during device startup.
@@ -334,7 +342,10 @@
private void stopScanning() {
if (mScanCallback != null) {
- mLocalBluetoothAdapter.getBluetoothLeScanner().stopScan(mScanCallback);
+ BluetoothLeScanner scanner = mLocalBluetoothAdapter.getBluetoothLeScanner();
+ if (scanner != null) {
+ scanner.stopScan(mScanCallback);
+ }
mScanCallback = null;
}
}
@@ -370,10 +381,14 @@
// Should only be called on the handler thread
private void onDeviceBondStateChangedInternal(CachedBluetoothDevice d, int bondState) {
- if (d.getName().equals(mKeyboardName) && bondState == BluetoothDevice.BOND_BONDED) {
- // We don't need to manually connect to the device here because it will automatically
- // try to connect after it has been paired.
- mState = STATE_PAIRED;
+ if (mState == STATE_PAIRING && d.getName().equals(mKeyboardName)) {
+ if (bondState == BluetoothDevice.BOND_BONDED) {
+ // We don't need to manually connect to the device here because it will
+ // automatically try to connect after it has been paired.
+ mState = STATE_PAIRED;
+ } else if (bondState == BluetoothDevice.BOND_NONE) {
+ mState = STATE_PAIRING_FAILED;
+ }
}
}
@@ -385,6 +400,17 @@
}
}
+ // Should only be called on the handler thread. We want to be careful not to show errors for
+ // pairings not initiated by this UI, so we only pop up the toast when we're at an appropriate
+ // point in our pairing flow and it's the expected device.
+ private void onShowErrorInternal(Context context, String name, int messageResId) {
+ if ((mState == STATE_PAIRING || mState == STATE_PAIRING_FAILED)
+ && mKeyboardName.equals(name)) {
+ String message = context.getString(messageResId, name);
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
+ }
+ }
+
private final class KeyboardUIHandler extends Handler {
public KeyboardUIHandler() {
super(Looper.getMainLooper(), null, true /*async*/);
@@ -393,19 +419,27 @@
public void handleMessage(Message msg) {
switch(msg.what) {
case MSG_SHOW_BLUETOOTH_DIALOG: {
- DialogInterface.OnClickListener listener = new BluetoothDialogClickListener();
+ if (mDialog != null) {
+ // Don't show another dialog if one is already present
+ break;
+ }
+ DialogInterface.OnClickListener clickListener =
+ new BluetoothDialogClickListener();
+ DialogInterface.OnDismissListener dismissListener =
+ new BluetoothDialogDismissListener();
mDialog = new BluetoothDialog(mContext);
mDialog.setTitle(R.string.enable_bluetooth_title);
mDialog.setMessage(R.string.enable_bluetooth_message);
- mDialog.setPositiveButton(R.string.enable_bluetooth_confirmation_ok, listener);
- mDialog.setNegativeButton(android.R.string.cancel, listener);
+ mDialog.setPositiveButton(
+ R.string.enable_bluetooth_confirmation_ok, clickListener);
+ mDialog.setNegativeButton(android.R.string.cancel, clickListener);
+ mDialog.setOnDismissListener(dismissListener);
mDialog.show();
break;
}
case MSG_DISMISS_BLUETOOTH_DIALOG: {
if (mDialog != null) {
mDialog.dismiss();
- mDialog = null;
}
break;
}
@@ -469,6 +503,10 @@
onBleScanFailedInternal();
break;
}
+ case MSG_SHOW_ERROR: {
+ Pair<Context, String> p = (Pair<Context, String>) msg.obj;
+ onShowErrorInternal(p.first, p.second, msg.arg1);
+ }
}
}
}
@@ -482,6 +520,14 @@
}
}
+ private final class BluetoothDialogDismissListener
+ implements DialogInterface.OnDismissListener {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ mDialog = null;
+ }
+ }
+
private final class KeyboardScanCallback extends ScanCallback {
private boolean isDeviceDiscoverable(ScanResult result) {
@@ -564,6 +610,13 @@
public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { }
}
+ private final class BluetoothErrorListener implements Utils.ErrorListener {
+ public void onShowError(Context context, String name, int messageResId) {
+ mHandler.obtainMessage(MSG_SHOW_ERROR, messageResId, 0 /*unused*/,
+ new Pair<>(context, name)).sendToTarget();
+ }
+ }
+
private static String stateToString(int state) {
switch (state) {
case STATE_NOT_ENABLED:
@@ -580,13 +633,15 @@
return "STATE_PAIRING";
case STATE_PAIRED:
return "STATE_PAIRED";
+ case STATE_PAIRING_FAILED:
+ return "STATE_PAIRING_FAILED";
case STATE_USER_CANCELLED:
return "STATE_USER_CANCELLED";
case STATE_DEVICE_NOT_FOUND:
return "STATE_DEVICE_NOT_FOUND";
case STATE_UNKNOWN:
default:
- return "STATE_UNKNOWN";
+ return "STATE_UNKNOWN (" + state + ")";
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
index 267ed16..546f8c3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
@@ -23,7 +23,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
-
import android.widget.ImageView.ScaleType;
import com.android.systemui.R;
@@ -34,6 +33,7 @@
private final View mIcon;
private final int mIconSizePx;
private final int mTilePaddingBelowIconPx;
+ private boolean mAnimationEnabled = true;
public QSIconView(Context context) {
super(context);
@@ -46,6 +46,10 @@
addView(mIcon);
}
+ public void disableAnimation() {
+ mAnimationEnabled = false;
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int w = MeasureSpec.getSize(widthMeasureSpec);
@@ -69,7 +73,9 @@
protected void setIcon(ImageView iv, QSTile.State state) {
if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
- Drawable d = state.icon != null ? state.icon.getDrawable(mContext) : null;
+ Drawable d = state.icon != null
+ ? iv.isShown() && mAnimationEnabled ? state.icon.getDrawable(mContext)
+ : state.icon.getInvisibleDrawable(mContext) : null;
int padding = state.icon != null ? state.icon.getPadding() : null;
if (d != null && state.autoMirrorDrawable) {
d.setAutoMirrored(true);
@@ -77,7 +83,7 @@
iv.setImageDrawable(d);
iv.setTag(R.id.qs_icon_tag, state.icon);
iv.setPadding(0, padding, 0, padding);
- if (d instanceof Animatable) {
+ if (d instanceof Animatable && iv.isShown()) {
Animatable a = (Animatable) d;
a.start();
if (!iv.isShown()) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 30a9850..71c1913d 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -31,6 +31,7 @@
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile.DetailAdapter;
+import com.android.systemui.qs.QSTile.Host.Callback;
import com.android.systemui.qs.customize.QSCustomizer;
import com.android.systemui.qs.external.CustomTile;
import com.android.systemui.settings.BrightnessController;
@@ -44,7 +45,7 @@
import java.util.Collection;
/** View that represents the quick settings tile panel. **/
-public class QSPanel extends LinearLayout implements Tunable {
+public class QSPanel extends LinearLayout implements Tunable, Callback {
public static final String QS_SHOW_BRIGHTNESS = "qs_show_brightness";
@@ -123,10 +124,16 @@
@Override
protected void onDetachedFromWindow() {
TunerService.get(mContext).removeTunable(this);
+ mHost.removeCallback(this);
super.onDetachedFromWindow();
}
@Override
+ public void onTilesChanged() {
+ setTiles(mHost.getTiles());
+ }
+
+ @Override
public void onTuningChanged(String key, String newValue) {
if (QS_SHOW_BRIGHTNESS.equals(key)) {
mBrightnessView.setVisibility(newValue == null || Integer.parseInt(newValue) != 0
@@ -168,6 +175,8 @@
public void setHost(QSTileHost host) {
mHost = host;
+ mHost.addCallback(this);
+ setTiles(mHost.getTiles());
mFooter.setHost(host);
createCustomizePanel();
}
@@ -272,7 +281,7 @@
}
}
- private void drawTile(TileRecord r, QSTile.State state) {
+ protected void drawTile(TileRecord r, QSTile.State state) {
r.tileView.onStateChanged(state);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index df622b8..42e98aa 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -390,6 +390,7 @@
Context getContext();
Collection<QSTile<?>> getTiles();
void addCallback(Callback callback);
+ void removeCallback(Callback callback);
BluetoothController getBluetoothController();
LocationController getLocationController();
RotationLockController getRotationLockController();
@@ -416,6 +417,10 @@
public static abstract class Icon {
abstract public Drawable getDrawable(Context context);
+ public Drawable getInvisibleDrawable(Context context) {
+ return getDrawable(context);
+ }
+
@Override
public int hashCode() {
return Icon.class.hashCode();
@@ -437,6 +442,11 @@
public Drawable getDrawable(Context context) {
return mDrawable;
}
+
+ @Override
+ public Drawable getInvisibleDrawable(Context context) {
+ return mDrawable;
+ }
}
public static class ResourceIcon extends Icon {
@@ -463,6 +473,11 @@
}
@Override
+ public Drawable getInvisibleDrawable(Context context) {
+ return context.getDrawable(mResId);
+ }
+
+ @Override
public boolean equals(Object o) {
return o instanceof ResourceIcon && ((ResourceIcon) o).mResId == mResId;
}
@@ -474,14 +489,17 @@
}
protected class AnimationIcon extends ResourceIcon {
- public AnimationIcon(int resId) {
- super(resId);
+ private final int mAnimatedResId;
+
+ public AnimationIcon(int resId, int staticResId) {
+ super(staticResId);
+ mAnimatedResId = resId;
}
@Override
public Drawable getDrawable(Context context) {
// workaround: get a clean state for every new AVD
- return context.getDrawable(mResId).getConstantState().newDrawable();
+ return context.getDrawable(mAnimatedResId).getConstantState().newDrawable();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
index f35aacf..9e40cfd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
@@ -48,7 +48,7 @@
// Default to Quick Tile padding, and QSTileView will specify its own padding.
int padding = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_padding);
- setPadding(padding, padding, padding, padding);
+ setPadding(0, padding, 0, padding);
setClipChildren(false);
setClipToPadding(false);
}
@@ -113,7 +113,7 @@
setContentDescription(state.contentDescription);
}
- View getIcon() {
+ public QSIconView getIcon() {
return mIcon;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
index 4408dbf..8b826ee 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
@@ -24,6 +24,8 @@
import android.widget.LinearLayout;
import android.widget.Space;
import com.android.systemui.R;
+import com.android.systemui.qs.QSTile.SignalState;
+import com.android.systemui.qs.QSTile.State;
import java.util.ArrayList;
import java.util.Collection;
@@ -60,6 +62,19 @@
}
@Override
+ protected void drawTile(TileRecord r, State state) {
+ if (state instanceof SignalState) {
+ State copy = r.tile.newTileState();
+ state.copyTo(copy);
+ // No activity shown in the quick panel.
+ ((SignalState) copy).activityIn = false;
+ ((SignalState) copy).activityOut = false;
+ state = copy;
+ }
+ super.drawTile(r, state);
+ }
+
+ @Override
protected void showDetail(boolean show, Record r) {
// Do nothing, will be handled by the QSPanel.
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
index d1953b1..aba9251 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
@@ -172,6 +172,7 @@
if (itemView instanceof FrameLayout) {
mTileView = (QSTileView) ((FrameLayout) itemView).getChildAt(0);
mTileView.setBackground(null);
+ mTileView.getIcon().disableAnimation();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
index f0860fe..89f1985b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
@@ -33,9 +33,11 @@
/** Quick settings tile: Airplane mode **/
public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
private final AnimationIcon mEnable =
- new AnimationIcon(R.drawable.ic_signal_airplane_enable_animation);
+ new AnimationIcon(R.drawable.ic_signal_airplane_enable_animation,
+ R.drawable.ic_signal_airplane_disable);
private final AnimationIcon mDisable =
- new AnimationIcon(R.drawable.ic_signal_airplane_disable_animation);
+ new AnimationIcon(R.drawable.ic_signal_airplane_disable_animation,
+ R.drawable.ic_signal_airplane_enable);
private final GlobalSetting mSetting;
private boolean mListening;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
index 42ce69c..a608316 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
@@ -30,9 +30,11 @@
public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
private final AnimationIcon mEnable
- = new AnimationIcon(R.drawable.ic_invert_colors_enable_animation);
+ = new AnimationIcon(R.drawable.ic_invert_colors_enable_animation,
+ R.drawable.ic_invert_colors_disable);
private final AnimationIcon mDisable
- = new AnimationIcon(R.drawable.ic_invert_colors_disable_animation);
+ = new AnimationIcon(R.drawable.ic_invert_colors_disable_animation,
+ R.drawable.ic_invert_colors_enable);
private final SecureSetting mSetting;
private boolean mListening;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
index 8982b3e..8b22868 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
@@ -56,9 +56,11 @@
ResourceIcon.get(R.drawable.ic_qs_dnd_on_total_silence);
private final AnimationIcon mDisable =
- new AnimationIcon(R.drawable.ic_dnd_disable_animation);
+ new AnimationIcon(R.drawable.ic_dnd_disable_animation,
+ R.drawable.ic_qs_dnd_off);
private final AnimationIcon mDisableTotalSilence =
- new AnimationIcon(R.drawable.ic_dnd_total_silence_disable_animation);
+ new AnimationIcon(R.drawable.ic_dnd_total_silence_disable_animation,
+ R.drawable.ic_qs_dnd_off);
private final ZenModeController mController;
private final DndDetailAdapter mDetailAdapter;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
index 12c8c44..a01a9a5 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
@@ -33,9 +33,11 @@
FlashlightController.FlashlightListener {
private final AnimationIcon mEnable
- = new AnimationIcon(R.drawable.ic_signal_flashlight_enable_animation);
+ = new AnimationIcon(R.drawable.ic_signal_flashlight_enable_animation,
+ R.drawable.ic_signal_flashlight_disable);
private final AnimationIcon mDisable
- = new AnimationIcon(R.drawable.ic_signal_flashlight_disable_animation);
+ = new AnimationIcon(R.drawable.ic_signal_flashlight_disable_animation,
+ R.drawable.ic_signal_flashlight_enable);
private final FlashlightController mFlashlightController;
public FlashlightTile(Host host) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
index ad1c7a0..da93120 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
@@ -29,9 +29,11 @@
/** Quick settings tile: Hotspot **/
public class HotspotTile extends QSTile<QSTile.BooleanState> {
private final AnimationIcon mEnable =
- new AnimationIcon(R.drawable.ic_hotspot_enable_animation);
+ new AnimationIcon(R.drawable.ic_hotspot_enable_animation,
+ R.drawable.ic_hotspot_disable);
private final AnimationIcon mDisable =
- new AnimationIcon(R.drawable.ic_hotspot_disable_animation);
+ new AnimationIcon(R.drawable.ic_hotspot_disable_animation,
+ R.drawable.ic_hotspot_enable);
private final HotspotController mController;
private final Callback mCallback = new Callback();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
index 6533252..b1d1c77 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
@@ -32,9 +32,11 @@
public class LocationTile extends QSTile<QSTile.BooleanState> {
private final AnimationIcon mEnable =
- new AnimationIcon(R.drawable.ic_signal_location_enable_animation);
+ new AnimationIcon(R.drawable.ic_signal_location_enable_animation,
+ R.drawable.ic_signal_location_disable);
private final AnimationIcon mDisable =
- new AnimationIcon(R.drawable.ic_signal_location_disable_animation);
+ new AnimationIcon(R.drawable.ic_signal_location_disable_animation,
+ R.drawable.ic_signal_location_enable);
private final LocationController mController;
private final KeyguardMonitor mKeyguard;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
index b267ccd..d80ca10 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
@@ -31,14 +31,18 @@
/** Quick settings tile: Rotation **/
public class RotationLockTile extends QSTile<QSTile.BooleanState> {
private final AnimationIcon mPortraitToAuto
- = new AnimationIcon(R.drawable.ic_portrait_to_auto_rotate_animation);
+ = new AnimationIcon(R.drawable.ic_portrait_to_auto_rotate_animation,
+ R.drawable.ic_portrait_from_auto_rotate);
private final AnimationIcon mAutoToPortrait
- = new AnimationIcon(R.drawable.ic_portrait_from_auto_rotate_animation);
+ = new AnimationIcon(R.drawable.ic_portrait_from_auto_rotate_animation,
+ R.drawable.ic_portrait_to_auto_rotate);
private final AnimationIcon mLandscapeToAuto
- = new AnimationIcon(R.drawable.ic_landscape_to_auto_rotate_animation);
+ = new AnimationIcon(R.drawable.ic_landscape_to_auto_rotate_animation,
+ R.drawable.ic_landscape_from_auto_rotate);
private final AnimationIcon mAutoToLandscape
- = new AnimationIcon(R.drawable.ic_landscape_from_auto_rotate_animation);
+ = new AnimationIcon(R.drawable.ic_landscape_from_auto_rotate_animation,
+ R.drawable.ic_landscape_to_auto_rotate);
private final RotationLockController mController;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
index 003e9c1..421a2cf 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
@@ -28,9 +28,11 @@
public class WorkModeTile extends QSTile<QSTile.BooleanState> implements
ManagedProfileController.Callback {
private final AnimationIcon mEnable =
- new AnimationIcon(R.drawable.ic_signal_workmode_enable_animation);
+ new AnimationIcon(R.drawable.ic_signal_workmode_enable_animation,
+ R.drawable.ic_signal_workmode_disable);
private final AnimationIcon mDisable =
- new AnimationIcon(R.drawable.ic_signal_workmode_disable_animation);
+ new AnimationIcon(R.drawable.ic_signal_workmode_disable_animation,
+ R.drawable.ic_signal_workmode_enable);
private final ManagedProfileController mProfileController;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
index 6fef8a2..abcb563 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
@@ -133,7 +133,6 @@
SparseIntArray affiliatedTaskCounts = new SparseIntArray();
String dismissDescFormat = mContext.getString(
R.string.accessibility_recents_item_will_be_dismissed);
- Formatter dismissDescFormatter = new Formatter();
long lastStackActiveTime = Prefs.getLong(mContext,
Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0);
if (RecentsDebugFlags.Static.EnableMockTasks) {
@@ -184,8 +183,7 @@
ActivityInfo info = loader.getAndUpdateActivityInfo(taskKey);
String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription);
String contentDescription = loader.getAndUpdateContentDescription(taskKey, res);
- String dismissDescription = dismissDescFormatter.format(dismissDescFormat,
- contentDescription).toString();
+ String dismissDescription = String.format(dismissDescFormat, contentDescription);
Drawable icon = isStackTask
? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false)
: null;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java
index 2cd0c19..d152010 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java
@@ -20,8 +20,8 @@
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Resources;
-import android.graphics.Path;
import android.graphics.RectF;
+import android.util.Log;
import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
@@ -441,11 +441,13 @@
TaskStackViewScroller stackScroller = mStackView.getScroller();
TaskStack stack = mStackView.getStack();
+ final float curScroll = stackScroller.getStackScroll();
final float newScroll = stackLayout.getStackScrollForTask(newFocusedTask);
- boolean willScrollToFront = newScroll > stackScroller.getStackScroll();
- boolean willScroll = Float.compare(newScroll, stackScroller.getStackScroll()) != 0;
+ boolean willScrollToFront = newScroll > curScroll;
+ boolean willScroll = Float.compare(newScroll, curScroll) != 0;
// Get the current set of task transforms
+ int taskViewCount = mStackView.getTaskViews().size();
ArrayList<Task> stackTasks = stack.getStackTasks();
mStackView.getCurrentTaskTransforms(stackTasks, mTmpCurrentTaskTransforms);
@@ -463,6 +465,13 @@
// Focus the task view
TaskView newFocusedTaskView = mStackView.getChildViewForTask(newFocusedTask);
+ if (newFocusedTaskView == null) {
+ // Log the error if we have no task view, and skip the animation
+ Log.e("TaskStackAnimationHelper", "b/27389156 null-task-view prebind:" + taskViewCount +
+ " postbind:" + mStackView.getTaskViews().size() + " prescroll:" + curScroll +
+ " postscroll: " + newScroll);
+ return false;
+ }
newFocusedTaskView.setFocusedState(true, requestViewFocus);
// Setup the end listener to return all the hidden views to the view pool after the
@@ -476,7 +485,7 @@
});
List<TaskView> taskViews = mStackView.getTaskViews();
- int taskViewCount = taskViews.size();
+ taskViewCount = taskViews.size();
int newFocusTaskViewIndex = taskViews.indexOf(newFocusedTaskView);
for (int i = 0; i < taskViewCount; i++) {
TaskView tv = taskViews.get(i);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index d0358f4..178838e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -983,7 +983,7 @@
pkgicon = pmUser.getDefaultActivityIcon();
}
- ((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(pkgicon);
+ ((ImageView) row.findViewById(R.id.app_icon)).setImageDrawable(pkgicon);
((TextView) row.findViewById(R.id.pkgname)).setText(appname);
final View settingsButton = guts.findViewById(R.id.more_settings);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 939cacb..f446593 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -412,7 +412,8 @@
}
public ExpandableNotificationRow getViewAtPosition(float y) {
- if (!mIsSummaryWithChildren || !mChildrenExpanded) {
+ if (!mIsSummaryWithChildren || !mChildrenExpanded
+ || (getNotificationChildren().size() == 1 && isClearable())) {
return this;
} else {
ExpandableNotificationRow view = mChildrenContainer.getViewAtPosition(y);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
index 476e146..375459f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
@@ -97,12 +97,12 @@
private void setGearAlpha(float alpha) {
if (alpha == 0) {
mSettingsFadedIn = false; // Can fade in again once it's gone.
- mGearIcon.setVisibility(View.INVISIBLE);
+ setVisibility(View.INVISIBLE);
} else {
if (alpha == 1) {
mSettingsFadedIn = true;
}
- mGearIcon.setVisibility(View.VISIBLE);
+ setVisibility(View.VISIBLE);
}
mGearIcon.setAlpha(alpha);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index c892b11..960e4cf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -227,6 +227,8 @@
protected void onDetachedFromWindow() {
mMobileSignalGroup.removeAllViews();
TunerService.get(mContext).removeTunable(this);
+ mSC.removeCallback(this);
+ mNC.removeSignalCallback(this);
super.onDetachedFromWindow();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java
index 5ab441d..d3393b3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TextViewTransformState.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.notification;
+import android.text.Layout;
import android.text.TextUtils;
import android.util.Pools;
import android.view.View;
@@ -28,14 +29,13 @@
private static Pools.SimplePool<TextViewTransformState> sInstancePool
= new Pools.SimplePool<>(40);
- private CharSequence mText;
+ private TextView mText;
@Override
public void initFrom(View view) {
super.initFrom(view);
if (view instanceof TextView) {
- TextView txt = (TextView) view;
- mText = txt.getText();
+ mText = (TextView) view;
}
}
@@ -43,11 +43,27 @@
protected boolean sameAs(TransformState otherState) {
if (otherState instanceof TextViewTransformState) {
TextViewTransformState otherTvs = (TextViewTransformState) otherState;
- return TextUtils.equals(otherTvs.mText, mText);
+ if(TextUtils.equals(otherTvs.mText.getText(), mText.getText())) {
+ int ownEllipsized = getEllipsisCount();
+ int otherEllipsized = otherTvs.getEllipsisCount();
+ return ownEllipsized == otherEllipsized;
+ }
}
return super.sameAs(otherState);
}
+ private int getEllipsisCount() {
+ Layout l = mText.getLayout();
+ if (l != null) {
+ int lines = l.getLineCount();
+ if (lines > 0) {
+ // we only care about the first line
+ return l.getEllipsisCount(0);
+ }
+ }
+ return 0;
+ }
+
public static TextViewTransformState obtain() {
TextViewTransformState instance = sInstancePool.acquire();
if (instance != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
index 5796edb..ed71e57 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
@@ -22,8 +22,12 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
+import android.graphics.Paint;
import android.graphics.PixelFormat;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
+import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.util.Log;
@@ -55,6 +59,7 @@
private final BarBackgroundDrawable mBarBackground;
private int mMode;
+ private boolean mAlwaysOpaque = false;
public BarTransitions(View view, int gradientResourceId) {
mTag = "BarTransitions." + view.getClass().getSimpleName();
@@ -69,13 +74,25 @@
return mMode;
}
+ /**
+ * @param alwaysOpaque if {@code true}, the bar's background will always be opaque, regardless
+ * of what mode it is currently set to.
+ */
+ public void setAlwaysOpaque(boolean alwaysOpaque) {
+ mAlwaysOpaque = alwaysOpaque;
+ }
+
+ public boolean isAlwaysOpaque() {
+ // Low-end devices do not support translucent modes, fallback to opaque
+ return !HIGH_END || mAlwaysOpaque;
+ }
+
public void transitionTo(int mode, boolean animate) {
- // low-end devices do not support translucent modes, fallback to opaque
- if (!HIGH_END && (mode == MODE_SEMI_TRANSPARENT || mode == MODE_TRANSLUCENT
+ if (isAlwaysOpaque() && (mode == MODE_SEMI_TRANSPARENT || mode == MODE_TRANSLUCENT
|| mode == MODE_TRANSPARENT)) {
mode = MODE_OPAQUE;
}
- if (!HIGH_END && (mode == MODE_LIGHTS_OUT_TRANSPARENT)) {
+ if (isAlwaysOpaque() && (mode == MODE_LIGHTS_OUT_TRANSPARENT)) {
mode = MODE_LIGHTS_OUT;
}
if (mMode == mode) return;
@@ -131,10 +148,13 @@
private int mGradientAlpha;
private int mColor;
+ private PorterDuffColorFilter mTintFilter;
+ private Paint mPaint = new Paint();
private int mGradientAlphaStart;
private int mColorStart;
+
public BarBackgroundDrawable(Context context, int gradientResourceId) {
final Resources res = context.getResources();
if (DEBUG_COLORS) {
@@ -163,6 +183,26 @@
}
@Override
+ public void setTint(int color) {
+ if (mTintFilter == null) {
+ mTintFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
+ } else {
+ mTintFilter.setColor(color);
+ }
+ invalidateSelf();
+ }
+
+ @Override
+ public void setTintMode(Mode tintMode) {
+ if (mTintFilter == null) {
+ mTintFilter = new PorterDuffColorFilter(0, tintMode);
+ } else {
+ mTintFilter.setMode(tintMode);
+ }
+ invalidateSelf();
+ }
+
+ @Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
mGradient.setBounds(bounds);
@@ -208,6 +248,7 @@
} else {
targetColor = mOpaque;
}
+
if (!mAnimating) {
mColor = targetColor;
mGradientAlpha = targetGradientAlpha;
@@ -234,7 +275,11 @@
mGradient.draw(canvas);
}
if (Color.alpha(mColor) > 0) {
- canvas.drawColor(mColor);
+ mPaint.setColor(mColor);
+ if (mTintFilter != null) {
+ mPaint.setColorFilter(mTintFilter);
+ }
+ canvas.drawPaint(mPaint);
}
if (mAnimating) {
invalidateSelf(); // keep going
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BaseStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BaseStatusBarHeader.java
index eade2a8..6e1c862 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BaseStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BaseStatusBarHeader.java
@@ -19,7 +19,6 @@
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
-
import com.android.systemui.qs.QSPanel;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.NetworkControllerImpl;
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 05ae41b..127feba 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -42,6 +42,8 @@
import com.android.internal.logging.MetricsLogger;
import com.android.keyguard.KeyguardStatusView;
import com.android.systemui.DejankUtils;
+import com.android.systemui.DensityContainer;
+import com.android.systemui.DensityContainer.InflateListener;
import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogTags;
import com.android.systemui.Interpolators;
@@ -215,8 +217,14 @@
super.onFinishInflate();
mKeyguardStatusBar = (KeyguardStatusBarView) findViewById(R.id.keyguard_header);
mKeyguardStatusView = (KeyguardStatusView) findViewById(R.id.keyguard_status_view);
- mQsContainer = (QSContainer) findViewById(R.id.quick_settings_container);
- mQsContainer.getHeader().setOnClickListener(this);
+ DensityContainer container = (DensityContainer) findViewById(R.id.qs_density_container);
+ container.addInflateListener(new InflateListener() {
+ @Override
+ public void onInflated(View v) {
+ mQsContainer = (QSContainer) v.findViewById(R.id.quick_settings_container);
+ mQsContainer.getHeader().setOnClickListener(NotificationPanelView.this);
+ }
+ });
mClockView = (TextView) findViewById(R.id.clock_view);
mNotificationContainerParent = (NotificationsQuickSettingsContainer)
findViewById(R.id.notification_container_parent);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java
index 7cc720d..6d90e5c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java
@@ -47,7 +47,7 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- mQsContainer = findViewById(R.id.quick_settings_container);
+ mQsContainer = findViewById(R.id.qs_density_container);
mStackScroller = findViewById(R.id.notification_stack_scroller);
mKeyguardStatusBar = findViewById(R.id.keyguard_header);
ViewStub userSwitcher = (ViewStub) findViewById(R.id.keyguard_user_switcher);
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 9b87a8a..e739944 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -23,7 +23,6 @@
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
-import android.app.IWallpaperManagerCallback;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.StatusBarManager;
@@ -104,6 +103,8 @@
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.DemoMode;
+import com.android.systemui.DensityContainer;
+import com.android.systemui.DensityContainer.InflateListener;
import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogTags;
import com.android.systemui.Interpolators;
@@ -778,8 +779,6 @@
mStatusBarView.setScrimController(mScrimController);
mDozeScrimController = new DozeScrimController(mScrimController, context);
- mHeader = (BaseStatusBarHeader) mStatusBarWindow.findViewById(R.id.header);
- mHeader.setActivityStarter(this);
mKeyguardStatusBar = (KeyguardStatusBarView) mStatusBarWindow.findViewById(R.id.keyguard_header);
mKeyguardStatusView = mStatusBarWindow.findViewById(R.id.keyguard_status_view);
mKeyguardBottomArea =
@@ -839,12 +838,6 @@
initSignalCluster(mStatusBarView);
initSignalCluster(mKeyguardStatusBar);
- initSignalCluster(mHeader);
-
- final boolean isAPhone = mNetworkController.hasVoiceCallingFeature();
- if (isAPhone) {
- mNetworkController.addEmergencyListener(mHeader);
- }
mFlashlightController = new FlashlightController(mContext);
mKeyguardBottomArea.setFlashlightController(mFlashlightController);
@@ -863,39 +856,40 @@
}
// Set up the quick settings tile panel
- mQSPanel = (QSPanel) mStatusBarWindow.findViewById(R.id.quick_settings_panel);
- if (mQSPanel != null) {
+ DensityContainer container = (DensityContainer) mStatusBarWindow.findViewById(
+ R.id.qs_density_container);
+ if (container != null) {
final QSTileHost qsh = new QSTileHost(mContext, this,
mBluetoothController, mLocationController, mRotationLockController,
mNetworkController, mZenModeController, mHotspotController,
mCastController, mFlashlightController,
mUserSwitcherController, mUserInfoController, mKeyguardMonitor,
- mSecurityController, mBatteryController, mIconController);
- mQSPanel.setTiles(qsh.getTiles());
+ mSecurityController, mBatteryController, mIconController,
+ mNextAlarmController);
mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow);
- mQSPanel.setBrightnessMirror(mBrightnessMirrorController);
- QSContainer qsContainer = (QSContainer) mStatusBarWindow.findViewById(
- R.id.quick_settings_container);
- qsContainer.setHost(qsh);
- qsh.addCallback(new QSTileHost.Callback() {
+ container.addInflateListener(new InflateListener() {
@Override
- public void onTilesChanged() {
- mQSPanel.setTiles(qsh.getTiles());
+ public void onInflated(View v) {
+ QSContainer qsContainer = (QSContainer) v.findViewById(
+ R.id.quick_settings_container);
+ qsContainer.setHost(qsh);
+ mQSPanel = qsContainer.getQsPanel();
+ mQSPanel.setBrightnessMirror(mBrightnessMirrorController);
+ mHeader = qsContainer.getHeader();
+ initSignalCluster(mHeader);
+ mHeader.setActivityStarter(PhoneStatusBar.this);
}
});
}
// User info. Trigger first load.
- mHeader.setUserInfoController(mUserInfoController);
mKeyguardStatusBar.setUserInfoController(mUserInfoController);
mKeyguardStatusBar.setUserSwitcherController(mUserSwitcherController);
mUserInfoController.reloadUserInfo();
- mHeader.setBatteryController(mBatteryController);
((BatteryMeterView) mStatusBarView.findViewById(R.id.battery)).setBatteryController(
mBatteryController);
mKeyguardStatusBar.setBatteryController(mBatteryController);
- mHeader.setNextAlarmController(mNextAlarmController);
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mBroadcastReceiver.onReceive(mContext,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
index 80afb9a..f894a22 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
@@ -57,6 +57,7 @@
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.CastController;
+import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.NightModeController;
import com.android.systemui.statusbar.policy.FlashlightController;
import com.android.systemui.statusbar.policy.HotspotController;
@@ -111,16 +112,18 @@
private final NightModeController mNightModeController;
private final AutoTileManager mAutoTiles;
private final ManagedProfileController mProfileController;
+ private final NextAlarmController mNextAlarmController;
private View mHeader;
public QSTileHost(Context context, PhoneStatusBar statusBar,
- BluetoothController bluetooth, LocationController location,
- RotationLockController rotation, NetworkController network,
- ZenModeController zen, HotspotController hotspot,
- CastController cast, FlashlightController flashlight,
- UserSwitcherController userSwitcher, UserInfoController userInfo,
- KeyguardMonitor keyguard, SecurityController security,
- BatteryController battery, StatusBarIconController iconController) {
+ BluetoothController bluetooth, LocationController location,
+ RotationLockController rotation, NetworkController network,
+ ZenModeController zen, HotspotController hotspot,
+ CastController cast, FlashlightController flashlight,
+ UserSwitcherController userSwitcher, UserInfoController userInfo,
+ KeyguardMonitor keyguard, SecurityController security,
+ BatteryController battery, StatusBarIconController iconController,
+ NextAlarmController nextAlarmController) {
mContext = context;
mStatusBar = statusBar;
mBluetooth = bluetooth;
@@ -137,6 +140,7 @@
mSecurity = security;
mBattery = battery;
mIconController = iconController;
+ mNextAlarmController = nextAlarmController;
mNightModeController = new NightModeController(mContext, true);
mProfileController = new ManagedProfileController(this);
@@ -152,6 +156,10 @@
mAutoTiles = new AutoTileManager(context, this);
}
+ public NextAlarmController getNextAlarmController() {
+ return mNextAlarmController;
+ }
+
public void setHeaderView(View view) {
mHeader = view;
}
@@ -171,6 +179,11 @@
}
@Override
+ public void removeCallback(Callback callback) {
+ mCallbacks.remove(callback);
+ }
+
+ @Override
public Collection<QSTile<?>> getTiles() {
return mTiles.values();
}
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 b549d59..256cc6b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
@@ -35,13 +35,13 @@
import com.android.systemui.R;
import com.android.systemui.qs.QSAnimator;
import com.android.systemui.qs.QSPanel;
-import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.QuickQSPanel;
import com.android.systemui.qs.TouchAnimator;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.NextAlarmController.NextAlarmChangeCallback;
import com.android.systemui.statusbar.policy.UserInfoController;
+import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
import com.android.systemui.tuner.TunerService;
public class QuickStatusBarHeader extends BaseStatusBarHeader implements
@@ -90,6 +90,7 @@
private TouchAnimator mAlarmTranslation;
private TouchAnimator mSettingsAlpha;
private float mExpansionAmount;
+ private QSTileHost mHost;
public QuickStatusBarHeader(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -222,6 +223,14 @@
mExpandIndicator.setExpanded(headerExpansionFraction > EXPAND_INDICATOR_THRESHOLD);
}
+ @Override
+ protected void onDetachedFromWindow() {
+ setListening(false);
+ mHost.getUserInfoController().remListener(mUserListener);
+ mHost.getNetworkController().removeEmergencyListener(this);
+ super.onDetachedFromWindow();
+ }
+
private void updateAlarmVisibilities() {
mAlarmStatus.setVisibility(mAlarmShowing ? View.VISIBLE : View.INVISIBLE);
mAlarmStatusCollapsed.setVisibility(mAlarmShowing ? View.VISIBLE : View.INVISIBLE);
@@ -284,17 +293,19 @@
}
public void setupHost(final QSTileHost host) {
+ mHost = host;
host.setHeaderView(this);
mHeaderQsPanel.setQSPanelAndHeader(mQsPanel, this);
- mHeaderQsPanel.setHost(host);
mHeaderQsPanel.setMaxTiles(5);
- mHeaderQsPanel.setTiles(host.getTiles());
- host.addCallback(new QSTile.Host.Callback() {
- @Override
- public void onTilesChanged() {
- mHeaderQsPanel.setTiles(host.getTiles());
- }
- });
+ mHeaderQsPanel.setHost(host);
+ setUserInfoController(host.getUserInfoController());
+ setBatteryController(host.getBatteryController());
+ setNextAlarmController(host.getNextAlarmController());
+
+ final boolean isAPhone = mHost.getNetworkController().hasVoiceCallingFeature();
+ if (isAPhone) {
+ mHost.getNetworkController().addEmergencyListener(this);
+ }
}
@Override
@@ -340,12 +351,7 @@
@Override
public void setUserInfoController(UserInfoController userInfoController) {
- userInfoController.addListener(new UserInfoController.OnUserInfoChangedListener() {
- @Override
- public void onUserInfoChanged(String name, Drawable picture) {
- mMultiUserAvatar.setImageDrawable(picture);
- }
- });
+ userInfoController.addListener(mUserListener);
}
@Override
@@ -358,4 +364,11 @@
}
}
}
+
+ private final OnUserInfoChangedListener mUserListener = new OnUserInfoChangedListener() {
+ @Override
+ public void onUserInfoChanged(String name, Drawable picture) {
+ mMultiUserAvatar.setImageDrawable(picture);
+ }
+ };
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
index 3e3b169..a051973 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
@@ -39,7 +39,6 @@
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
-
import com.android.keyguard.KeyguardStatusView;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.FontSizeUtils;
@@ -48,7 +47,7 @@
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.QSTile.DetailAdapter;
import com.android.systemui.statusbar.policy.BatteryController;
-import com.android.systemui.statusbar.policy.NetworkControllerImpl.EmergencyListener;
+import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.tuner.TunerService;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
index e618cb8..3142ddf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
@@ -19,11 +19,10 @@
import android.os.Looper;
import android.os.Message;
import android.telephony.SubscriptionInfo;
-
import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
-import com.android.systemui.statusbar.policy.NetworkControllerImpl.EmergencyListener;
import java.util.ArrayList;
import java.util.List;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 93c7322..348e0b0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -19,7 +19,6 @@
import android.content.Context;
import android.content.Intent;
import android.telephony.SubscriptionInfo;
-
import com.android.settingslib.net.DataUsageController;
import com.android.settingslib.wifi.AccessPoint;
@@ -36,6 +35,11 @@
DataUsageController getMobileDataController();
DataSaverController getDataSaverController();
+ boolean hasVoiceCallingFeature();
+
+ void addEmergencyListener(EmergencyListener listener);
+ void removeEmergencyListener(EmergencyListener listener);
+
public interface SignalCallback {
void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
boolean activityIn, boolean activityOut, String description);
@@ -53,6 +57,10 @@
void setMobileDataEnabled(boolean enabled);
}
+ public interface EmergencyListener {
+ void setEmergencyCallsOnly(boolean emergencyOnly);
+ }
+
public static class IconState {
public final boolean visible;
public final int icon;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index eecf8c2..8193b52 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -252,6 +252,10 @@
mCallbackHandler.setEmergencyCallsOnly(isEmergencyOnly());
}
+ public void removeEmergencyListener(EmergencyListener listener) {
+ mCallbackHandler.setListening(listener, false);
+ }
+
public boolean hasMobileDataFeature() {
return mHasMobileDataFeature;
}
@@ -812,10 +816,6 @@
}
};
- public interface EmergencyListener {
- void setEmergencyCallsOnly(boolean emergencyOnly);
- }
-
public static class SubscriptionDefaults {
public int getDefaultVoiceSubId() {
return SubscriptionManager.getDefaultVoiceSubscriptionId();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NightModeController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NightModeController.java
index 0b1911b..4611ef9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NightModeController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NightModeController.java
@@ -14,17 +14,13 @@
package com.android.systemui.statusbar.policy;
-import libcore.util.Objects;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.opengl.Matrix;
-import android.provider.Settings;
import android.provider.Settings.Secure;
import android.util.MathUtils;
-
import com.android.systemui.tuner.TunerService;
import java.util.ArrayList;
@@ -189,8 +185,8 @@
}
private void updateNightMode(Intent intent) {
- mIsNight = intent.getBooleanExtra(EXTRA_IS_NIGHT, false);
- mAmount = intent.getFloatExtra(EXTRA_AMOUNT, 0);
+ mIsNight = intent != null && intent.getBooleanExtra(EXTRA_IS_NIGHT, false);
+ mAmount = intent != null ? intent.getFloatExtra(EXTRA_AMOUNT, 0) : 0;
}
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
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 53fd446..cedc3c7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -37,6 +37,8 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
@@ -99,7 +101,6 @@
private boolean mSimpleUserSwitcher;
private boolean mAddUsersWhenLocked;
private boolean mPauseRefreshUsers;
- private boolean mAllowUserSwitchingWhenSystemUserLocked;
private SparseBooleanArray mForcePictureLoadForUserId = new SparseBooleanArray(2);
public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor,
@@ -140,6 +141,7 @@
mSettingsObserver.onChange(false);
keyguardMonitor.addCallback(mCallback);
+ listenForCallState();
refreshUsers(UserHandle.USER_NULL);
}
@@ -186,8 +188,7 @@
}
ArrayList<UserRecord> records = new ArrayList<>(infos.size());
int currentId = ActivityManager.getCurrentUser();
- boolean allowUserSwitching = mAllowUserSwitchingWhenSystemUserLocked
- || mUserManager.isUserUnlocked(UserHandle.SYSTEM);
+ boolean canSwitchUsers = mUserManager.canSwitchUsers();
UserInfo currentUserInfo = null;
UserRecord guestRecord = null;
int avatarSize = mContext.getResources()
@@ -198,12 +199,14 @@
if (isCurrent) {
currentUserInfo = info;
}
- boolean switchToEnabled = allowUserSwitching || isCurrent;
+ boolean switchToEnabled = canSwitchUsers || isCurrent;
if (info.isEnabled()) {
if (info.isGuest()) {
+ // Tapping guest icon triggers remove and a user switch therefore
+ // the icon shouldn't be enabled even if the user is current
guestRecord = new UserRecord(info, null /* picture */,
true /* isGuest */, isCurrent, false /* isAddUser */,
- false /* isRestricted */, switchToEnabled);
+ false /* isRestricted */, canSwitchUsers);
} else if (info.supportsSwitchToByUser()) {
Bitmap picture = bitmaps.get(info.id);
if (picture == null) {
@@ -240,7 +243,7 @@
if (canCreateGuest) {
guestRecord = new UserRecord(null /* info */, null /* picture */,
true /* isGuest */, false /* isCurrent */,
- false /* isAddUser */, createIsRestricted, allowUserSwitching);
+ false /* isAddUser */, createIsRestricted, canSwitchUsers);
checkIfAddUserDisallowedByAdminOnly(guestRecord);
records.add(guestRecord);
}
@@ -253,7 +256,7 @@
if (!mSimpleUserSwitcher && canCreateUser) {
UserRecord addUserRecord = new UserRecord(null /* info */, null /* picture */,
false /* isGuest */, false /* isCurrent */, true /* isAddUser */,
- createIsRestricted, allowUserSwitching);
+ createIsRestricted, canSwitchUsers);
checkIfAddUserDisallowedByAdminOnly(addUserRecord);
records.add(addUserRecord);
}
@@ -417,6 +420,24 @@
mUserManager.removeUser(id);
}
+ private void listenForCallState() {
+ TelephonyManager.from(mContext).listen(new PhoneStateListener() {
+ private int mCallState;
+ @Override
+ public void onCallStateChanged(int state, String incomingNumber) {
+ if (mCallState == state) return;
+ if (DEBUG) Log.v(TAG, "Call state changed: " + state);
+ mCallState = state;
+ int currentUserId = ActivityManager.getCurrentUser();
+ UserInfo userInfo = mUserManager.getUserInfo(currentUserId);
+ if (userInfo != null && userInfo.isGuest()) {
+ showGuestNotification(currentUserId);
+ }
+ refreshUsers(UserHandle.USER_NULL);
+ }
+ }, PhoneStateListener.LISTEN_CALL_STATE);
+ }
+
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -488,25 +509,6 @@
}
}
- private void showGuestNotification(int guestUserId) {
- PendingIntent removeGuestPI = PendingIntent.getBroadcastAsUser(mContext,
- 0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.SYSTEM);
- Notification notification = new Notification.Builder(mContext)
- .setVisibility(Notification.VISIBILITY_SECRET)
- .setPriority(Notification.PRIORITY_MIN)
- .setSmallIcon(R.drawable.ic_person)
- .setContentTitle(mContext.getString(R.string.guest_notification_title))
- .setContentText(mContext.getString(R.string.guest_notification_text))
- .setContentIntent(removeGuestPI)
- .setShowWhen(false)
- .addAction(R.drawable.ic_delete,
- mContext.getString(R.string.guest_notification_remove_action),
- removeGuestPI)
- .build();
- NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST, ID_REMOVE_GUEST,
- notification, new UserHandle(guestUserId));
- }
-
private void showLogoutNotification(int userId) {
PendingIntent logoutPI = PendingIntent.getBroadcastAsUser(mContext,
0, new Intent(ACTION_LOGOUT_USER), 0, UserHandle.SYSTEM);
@@ -528,6 +530,28 @@
}
};
+ private void showGuestNotification(int guestUserId) {
+ boolean canSwitchUsers = mUserManager.canSwitchUsers();
+ // Disable 'Remove guest' action if cannot switch users right now
+ PendingIntent removeGuestPI = canSwitchUsers ? PendingIntent.getBroadcastAsUser(mContext,
+ 0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.SYSTEM) : null;
+
+ Notification notification = new Notification.Builder(mContext)
+ .setVisibility(Notification.VISIBILITY_SECRET)
+ .setPriority(Notification.PRIORITY_MIN)
+ .setSmallIcon(R.drawable.ic_person)
+ .setContentTitle(mContext.getString(R.string.guest_notification_title))
+ .setContentText(mContext.getString(R.string.guest_notification_text))
+ .setContentIntent(removeGuestPI)
+ .setShowWhen(false)
+ .addAction(R.drawable.ic_delete,
+ mContext.getString(R.string.guest_notification_remove_action),
+ removeGuestPI)
+ .build();
+ NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST, ID_REMOVE_GUEST,
+ notification, new UserHandle(guestUserId));
+ }
+
private final Runnable mUnpauseRefreshUsers = new Runnable() {
@Override
public void run() {
@@ -543,9 +567,6 @@
SIMPLE_USER_SWITCHER_GLOBAL_SETTING, 0) != 0;
mAddUsersWhenLocked = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ADD_USERS_WHEN_LOCKED, 0) != 0;
- mAllowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt(
- mContext.getContentResolver(),
- Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED, 0) != 0;
refreshUsers(UserHandle.USER_NULL);
};
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
index 123a5c3..7955733 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
@@ -167,6 +167,7 @@
int newIndex = childIndex < 0 ? mChildren.size() : childIndex;
mChildren.add(newIndex, row);
addView(row);
+ row.setUserLocked(mUserLocked);
View divider = inflateDivider();
addView(divider);
@@ -191,6 +192,7 @@
});
row.setSystemChildExpanded(false);
+ row.setUserLocked(false);
updateGroupOverflow();
}
@@ -262,10 +264,14 @@
}
private void updateExpansionStates() {
- // Let's make the first child expanded if the parent is
- for (int i = 0; i < mChildren.size(); i++) {
+ if (mChildrenExpanded || mUserLocked) {
+ // we don't modify it the group is expanded or if we are expanding it
+ return;
+ }
+ int size = mChildren.size();
+ for (int i = 0; i < size; i++) {
ExpandableNotificationRow child = mChildren.get(i);
- child.setSystemChildExpanded(false);
+ child.setSystemChildExpanded(i == 0 && size == 1);
}
}
@@ -489,6 +495,7 @@
public void setChildrenExpanded(boolean childrenExpanded) {
mChildrenExpanded = childrenExpanded;
+ updateExpansionStates();
}
public void setNotificationParent(ExpandableNotificationRow parent) {
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
index c06b63b..005767f 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
@@ -131,7 +131,7 @@
final boolean isForever = mConfig != null && mConfig.manualRule != null
&& mConfig.manualRule.conditionId == null;
- final String line2 =
+ final CharSequence line2 =
isForever ? mContext.getString(com.android.internal.R.string.zen_mode_forever_dnd)
: ZenModeConfig.getConditionSummary(mContext, mConfig, mController.getCurrentUser(),
true /*shortVersion*/);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTests.java b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTests.java
index 1841251..01514646b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTests.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTests.java
@@ -43,7 +43,7 @@
QSTileHost host = new QSTileHost(mContext, null, null, null, null,
networkController, null,
Mockito.mock(HotspotController.class), null,
- null, null, null, null, null, null, null);
+ null, null, null, null, null, null, null, null);
mTileService = new TestTileServices(host, Looper.myLooper());
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
index 00b8de2..19cb243 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
@@ -19,12 +19,10 @@
import android.telephony.SubscriptionInfo;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
-
import com.android.systemui.R;
+import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
-import com.android.systemui.statusbar.policy.NetworkControllerImpl.EmergencyListener;
-
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index 471feef..077b121 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -478,5 +478,34 @@
// Logged when we execute an app transition. This indicates the device uptime in seconds when
// the transition was executed.
APP_TRANSITION_DEVICE_UPTIME_SECONDS = 325;
+
+ // User granted access to the request folder; action takes an integer
+ // representing the folder's index on Environment.STANDARD_DIRECTORIES
+ ACTION_SCOPED_DIRECTORY_ACCESS_GRANTED_BY_FOLDER = 326;
+
+ // User denied access to the request folder; action takes an integer
+ // representing the folder's index on Environment.STANDARD_DIRECTORIES
+ ACTION_SCOPED_DIRECTORY_ACCESS_DENIED_BY_FOLDER = 327;
+
+ // User granted access to the request folder; action pass package name
+ // of calling package.
+ ACTION_SCOPED_DIRECTORY_ACCESS_GRANTED_BY_PACKAGE = 328;
+
+ // User denied access to the request folder; action pass package name
+ // of calling package.
+ ACTION_SCOPED_DIRECTORY_ACCESS_DENIED_BY_PACKAGE = 329;
+
+ // App requested access to a directory it has already been granted
+ // access before; action takes an integer representing the folder's
+ // index on Environment.STANDARD_DIRECTORIES
+ ACTION_SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED_BY_FOLDER = 330;
+
+ // App requested access to a directory it has already been granted
+ // access before; action pass package name of calling package.
+ ACTION_SCOPED_DIRECTORY_ACCESS_ALREADY_GRANTED_BY_PACKAGE = 331;
+
+ // Add new aosp constants above this line.
+ // END OF AOSP CONSTANTS
+
}
}
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 4300920..25b6fdd 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -750,7 +750,7 @@
intentFilter.addAction(Intent.ACTION_USER_STOPPING);
intentFilter.addAction(Intent.ACTION_USER_ADDED);
intentFilter.addAction(Intent.ACTION_USER_REMOVED);
- intentFilter.addAction(Intent.ACTION_USER_PRESENT);
+ intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
mContext.registerReceiverAsUser(
mUserIntentReceiver, UserHandle.ALL, intentFilter, null, null);
@@ -3633,7 +3633,7 @@
}
}
- private void onUserPresent(int userId) {
+ private void onUserUnlocked(int userId) {
// User present may be sent because of an unlock, which might mean an unlocked keystore.
if (mUserManager.getUserInfo(userId).isPrimary() && LockdownVpnTracker.isEnabled()) {
updateLockdownVpn();
@@ -3657,8 +3657,8 @@
onUserAdded(userId);
} else if (Intent.ACTION_USER_REMOVED.equals(action)) {
onUserRemoved(userId);
- } else if (Intent.ACTION_USER_PRESENT.equals(action)) {
- onUserPresent(userId);
+ } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
+ onUserUnlocked(userId);
}
}
};
diff --git a/services/core/java/com/android/server/LockGuard.java b/services/core/java/com/android/server/LockGuard.java
new file mode 100644
index 0000000..3a381ae
--- /dev/null
+++ b/services/core/java/com/android/server/LockGuard.java
@@ -0,0 +1,149 @@
+/*
+ * 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;
+
+import android.util.ArrayMap;
+import android.util.ArraySet;
+import android.util.Slog;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
+/**
+ * LockGuard is a mechanism to help detect lock inversions inside the system
+ * server. It works by requiring each lock acquisition site to follow this
+ * pattern:
+ *
+ * <pre>
+ * synchronized (LockGuard.guard(lock)) {
+ * }
+ * </pre>
+ *
+ * <pre>
+ * $ find services/ -name "*.java" -exec sed -i -r \
+ * 's/synchronized.?\((.+?)\)/synchronized \(com.android.server.LockGuard.guard\(\1\)\)/' {} \;
+ * </pre>
+ *
+ * The {@link #guard(Object)} method internally verifies that all locking is
+ * done in a consistent order, and will log if any inversion is detected. For
+ * example, if the calling thread is trying to acquire the
+ * {@code ActivityManager} lock while holding the {@code PackageManager} lock,
+ * it will yell.
+ * <p>
+ * This class requires no prior knowledge of locks or their ordering; it derives
+ * all of this data at runtime. However, this means the overhead is
+ * <em>substantial</em> and it should not be enabled by default. For example,
+ * here are some benchmarked timings:
+ * <ul>
+ * <li>An unguarded synchronized block takes 40ns.
+ * <li>A guarded synchronized block takes 50ns when disabled.
+ * <li>A guarded synchronized block takes 460ns per lock checked when enabled.
+ * </ul>
+ */
+public class LockGuard {
+ private static final String TAG = "LockGuard";
+
+ private static ArrayMap<Object, LockInfo> sKnown = new ArrayMap<>(0, true);
+
+ private static class LockInfo {
+ /** Friendly label to describe this lock */
+ public String label;
+
+ /** Child locks that can be acquired while this lock is already held */
+ public ArraySet<Object> children = new ArraySet<>(0, true);
+ }
+
+ private static LockInfo findOrCreateLockInfo(Object lock) {
+ LockInfo info = sKnown.get(lock);
+ if (info == null) {
+ info = new LockInfo();
+ info.label = "0x" + Integer.toHexString(System.identityHashCode(lock)) + " ["
+ + new Throwable().getStackTrace()[2].toString() + "]";
+ sKnown.put(lock, info);
+ }
+ return info;
+ }
+
+ /**
+ * Check if the calling thread is holding any locks in an inverted order.
+ *
+ * @param lock The lock the calling thread is attempting to acquire.
+ */
+ public static Object guard(Object lock) {
+ // If we already hold this lock, ignore
+ if (lock == null || Thread.holdsLock(lock)) return lock;
+
+ // Check to see if we're already holding any child locks
+ boolean triggered = false;
+ final LockInfo info = findOrCreateLockInfo(lock);
+ for (int i = 0; i < info.children.size(); i++) {
+ final Object child = info.children.valueAt(i);
+ if (child == null) continue;
+
+ if (Thread.holdsLock(child)) {
+ Slog.w(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding "
+ + lockToString(child) + " while trying to acquire "
+ + lockToString(lock), new Throwable());
+ triggered = true;
+ }
+ }
+
+ if (!triggered) {
+ // If no trouble found above, record this lock as being a valid
+ // child of all locks currently being held
+ for (int i = 0; i < sKnown.size(); i++) {
+ final Object test = sKnown.keyAt(i);
+ if (test == null || test == lock) continue;
+
+ if (Thread.holdsLock(test)) {
+ sKnown.valueAt(i).children.add(lock);
+ }
+ }
+ }
+
+ return lock;
+ }
+
+ /**
+ * Report the given lock with a well-known label.
+ */
+ public static void installLock(Object lock, String label) {
+ final LockInfo info = findOrCreateLockInfo(lock);
+ info.label = label;
+ }
+
+ private static String lockToString(Object lock) {
+ final LockInfo info = sKnown.get(lock);
+ if (info != null) {
+ return info.label;
+ } else {
+ return "0x" + Integer.toHexString(System.identityHashCode(lock));
+ }
+ }
+
+ public static void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ for (int i = 0; i < sKnown.size(); i++) {
+ final Object lock = sKnown.keyAt(i);
+ final LockInfo info = sKnown.valueAt(i);
+ pw.println("Lock " + lockToString(lock) + ":");
+ for (int j = 0; j < info.children.size(); j++) {
+ pw.println(" Child " + lockToString(info.children.valueAt(j)));
+ }
+ pw.println();
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index cf7b537..12ebf44 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -45,6 +45,7 @@
import com.android.server.DeviceIdleController;
import com.android.server.IntentResolver;
import com.android.server.LocalServices;
+import com.android.server.LockGuard;
import com.android.server.ServiceThread;
import com.android.server.SystemService;
import com.android.server.SystemServiceManager;
@@ -1895,6 +1896,9 @@
final int userId = msg.arg1;
mSystemServiceManager.unlockUser(userId);
mRecentTasks.loadUserRecentsLocked(userId);
+ if (userId == UserHandle.USER_SYSTEM) {
+ startPersistentApps(PackageManager.MATCH_ENCRYPTION_UNAWARE);
+ }
installEncryptionUnawareProviders(userId);
break;
}
@@ -6984,6 +6988,8 @@
@Override
public Intent getIntentForIntentSender(IIntentSender pendingResult) {
+ enforceCallingPermission(Manifest.permission.GET_INTENT_SENDER_INTENT,
+ "getIntentForIntentSender()");
if (!(pendingResult instanceof PendingIntentRecord)) {
return null;
}
@@ -10776,6 +10782,23 @@
//mUsageStatsService.monitorPackages();
}
+ private void startPersistentApps(int matchFlags) {
+ if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL) return;
+
+ synchronized (this) {
+ try {
+ final List<ApplicationInfo> apps = AppGlobals.getPackageManager()
+ .getPersistentApplications(STOCK_PM_FLAGS | matchFlags);
+ for (ApplicationInfo app : apps) {
+ if (!"android".equals(app.packageName)) {
+ addAppLocked(app, false, null /* ABI override */);
+ }
+ }
+ } catch (RemoteException ex) {
+ }
+ }
+ }
+
/**
* When a user is unlocked, we need to install encryption-unaware providers
* belonging to any running apps.
@@ -10792,8 +10815,7 @@
// We're only interested in providers that are encryption unaware, and
// we don't care about uninstalled apps, since there's no way they're
// running at this point.
- final int matchFlags = GET_PROVIDERS | MATCH_ENCRYPTION_UNAWARE
- | MATCH_DEBUG_TRIAGED_MISSING;
+ final int matchFlags = GET_PROVIDERS | MATCH_ENCRYPTION_UNAWARE;
synchronized (this) {
final int NP = mProcessNames.getMap().size();
@@ -12679,26 +12701,9 @@
mSystemServiceManager.startUser(currentUserId);
synchronized (this) {
- if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
- try {
- List apps = AppGlobals.getPackageManager().
- getPersistentApplications(STOCK_PM_FLAGS);
- if (apps != null) {
- int N = apps.size();
- int i;
- for (i=0; i<N; i++) {
- ApplicationInfo info
- = (ApplicationInfo)apps.get(i);
- if (info != null &&
- !info.packageName.equals("android")) {
- addAppLocked(info, false, null /* ABI override */);
- }
- }
- }
- } catch (RemoteException ex) {
- // pm is in same process, this will never happen.
- }
- }
+ // Only start up encryption-aware persistent apps; once user is
+ // unlocked we'll come back around and start unaware apps
+ startPersistentApps(PackageManager.MATCH_ENCRYPTION_AWARE);
// Start up initial activity.
mBooting = true;
@@ -13583,6 +13588,8 @@
synchronized (this) {
mServices.dumpServicesLocked(fd, pw, args, opti, true, dumpClient, dumpPackage);
}
+ } else if ("locks".equals(cmd)) {
+ LockGuard.dump(fd, pw, args);
} else {
// Dumping a single activity?
if (!dumpActivity(fd, pw, cmd, args, opti, dumpAll)) {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 5491b4f..769bee4 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -3005,6 +3005,8 @@
if (!r.visible) {
mWindowManager.setAppVisibility(r.appToken, false);
}
+ EventLogTags.writeAmStopActivity(
+ r.userId, System.identityHashCode(r), r.shortComponentName);
r.app.thread.scheduleStopActivity(r.appToken, r.visible, r.configChangeFlags);
if (mService.isSleepingOrShuttingDown()) {
r.setSleeping(true);
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 20f8285..c7fc5e2 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -2186,7 +2186,7 @@
final int resizeMode = task.mResizeMode;
- if (stackId == DOCKED_STACK_ID && resizeMode == RESIZE_MODE_UNRESIZEABLE) {
+ if (stackId == DOCKED_STACK_ID && !task.isResizeable()) {
// We don't allow moving a unresizeable task to the docked stack since the docked
// stack is used for split-screen mode and will cause things like the docked divider to
// show up. We instead leave the task in its current stack or move it to the fullscreen
diff --git a/services/core/java/com/android/server/am/EventLogTags.logtags b/services/core/java/com/android/server/am/EventLogTags.logtags
index f2e8d09..2329b2f 100644
--- a/services/core/java/com/android/server/am/EventLogTags.logtags
+++ b/services/core/java/com/android/server/am/EventLogTags.logtags
@@ -54,9 +54,9 @@
# An activity has been relaunched:
30020 am_relaunch_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)
# The activity's onPause has been called.
-30021 am_on_paused_called (User|1|5),(Component Name|3)
+30021 am_on_paused_called (User|1|5),(Component Name|3),(Reason|3)
# The activity's onResume has been called.
-30022 am_on_resume_called (User|1|5),(Component Name|3)
+30022 am_on_resume_called (User|1|5),(Component Name|3),(Reason|3)
# Kill a process to reclaim memory.
30023 am_kill (User|1|5),(PID|1|5),(Process Name|3),(OomAdj|1|5),(Reason|3)
# Discard an undelivered serialized broadcast (timeout/ANR/crash)
@@ -103,3 +103,8 @@
30046 am_meminfo (Cached|2|2),(Free|2|2),(Zram|2|2),(Kernel|2|2),(Native|2|2)
# Report collection of memory used by a process
30047 am_pss (Pid|1|5),(UID|1|5),(Process Name|3),(Pss|2|2),(Uss|2|2),(SwapPss|2|2)
+
+# Attempting to stop an activity
+30048 am_stop_activity (User|1|5),(Token|1|5),(Component Name|3)
+# The activity's onStop has been called.
+30049 am_on_stop_called (User|1|5),(Component Name|3),(Reason|3)
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java
index 5d81dae..7b134ca 100644
--- a/services/core/java/com/android/server/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java
@@ -905,13 +905,15 @@
// Group ID is arbitrarily set to parent profile user ID. It just represents
// the default fingerprints for the user.
- final int effectiveGroupId = getEffectiveUserId(groupId);
+ if (!isCurrentUserOrProfile(groupId)) {
+ return;
+ }
final boolean restricted = isRestricted();
mHandler.post(new Runnable() {
@Override
public void run() {
- startEnrollment(token, cryptoClone, effectiveGroupId, receiver, flags, restricted);
+ startEnrollment(token, cryptoClone, groupId, receiver, flags, restricted);
}
});
}
@@ -1011,15 +1013,14 @@
@Override // Binder call
public void rename(final int fingerId, final int groupId, final String name) {
checkPermission(MANAGE_FINGERPRINT);
-
- // Group ID is arbitrarily set to parent profile user ID. It just represents
- // the default fingerprints for the user.
- final int effectiveGroupId = getEffectiveUserId(groupId);
+ if (!isCurrentUserOrProfile(groupId)) {
+ return;
+ }
mHandler.post(new Runnable() {
@Override
public void run() {
mFingerprintUtils.renameFingerprintForUser(mContext, fingerId,
- effectiveGroupId, name);
+ groupId, name);
}
});
}
@@ -1029,9 +1030,11 @@
if (!canUseFingerprint(opPackageName, false /* foregroundOnly */)) {
return Collections.emptyList();
}
- int effectiveUserId = getEffectiveUserId(userId);
+ if (!isCurrentUserOrProfile(userId)) {
+ return Collections.emptyList();
+ }
- return FingerprintService.this.getEnrolledFingerprints(effectiveUserId);
+ return FingerprintService.this.getEnrolledFingerprints(userId);
}
@Override // Binder call
@@ -1040,8 +1043,10 @@
return false;
}
- int effectiveUserId = getEffectiveUserId(userId);
- return FingerprintService.this.hasEnrolledFingerprints(effectiveUserId);
+ if (!isCurrentUserOrProfile(userId)) {
+ return false;
+ }
+ return FingerprintService.this.hasEnrolledFingerprints(userId);
}
@Override // Binder call
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java b/services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java
index a5dc008..a626b5b 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerShellCommand.java
@@ -16,6 +16,8 @@
package com.android.server.net;
+import static android.net.NetworkPolicyManager.POLICY_NONE;
+import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
import static android.net.wifi.WifiInfo.removeDoubleQuotes;
import static com.android.server.net.NetworkPolicyManagerService.newWifiPolicy;
import static com.android.server.net.NetworkPolicyManagerService.TAG;
@@ -83,6 +85,8 @@
pw.println("");
pw.println(" add restrict-background-whitelist UID");
pw.println(" Adds a UID to the whitelist for restrict background usage.");
+ pw.println(" add restrict-background-blacklist UID");
+ pw.println(" Adds a UID to the blacklist for restrict background usage.");
pw.println(" get metered-network ID");
pw.println(" Checks whether the given non-mobile network is metered or not.");
pw.println(" get restrict-background");
@@ -93,8 +97,12 @@
pw.println(" networks.");
pw.println(" list restrict-background-whitelist");
pw.println(" Lists UIDs that are whitelisted for restrict background usage.");
+ pw.println(" list restrict-background-blacklist");
+ pw.println(" Lists UIDs that are blacklisted for restrict background usage.");
pw.println(" remove restrict-background-whitelist UID");
pw.println(" Removes a UID from the whitelist for restrict background usage.");
+ pw.println(" remove restrict-background-blacklist UID");
+ pw.println(" Removes a UID from the blacklist for restrict background usage.");
pw.println(" set metered-network ID BOOLEAN");
pw.println(" Toggles whether the given non-mobile network is metered.");
pw.println(" set restrict-background BOOLEAN");
@@ -147,6 +155,8 @@
return listMeteredWifiNetworks();
case "restrict-background-whitelist":
return listRestrictBackgroundWhitelist();
+ case "restrict-background-blacklist":
+ return listRestrictBackgroundBlacklist();
}
pw.println("Error: unknown list type '" + type + "'");
return -1;
@@ -162,6 +172,8 @@
switch(type) {
case "restrict-background-whitelist":
return addRestrictBackgroundWhitelist();
+ case "restrict-background-blacklist":
+ return addRestrictBackgroundBlacklist();
}
pw.println("Error: unknown add type '" + type + "'");
return -1;
@@ -177,6 +189,8 @@
switch(type) {
case "restrict-background-whitelist":
return removeRestrictBackgroundWhitelist();
+ case "restrict-background-blacklist":
+ return removeRestrictBackgroundBlacklist();
}
pw.println("Error: unknown remove type '" + type + "'");
return -1;
@@ -199,6 +213,24 @@
return 0;
}
+ private int listRestrictBackgroundBlacklist() throws RemoteException {
+ final PrintWriter pw = getOutPrintWriter();
+
+ final int[] uids = mInterface.getUidsWithPolicy(POLICY_REJECT_METERED_BACKGROUND);
+ pw.print("Restrict background blacklisted UIDs: ");
+ if (uids.length == 0) {
+ pw.println("none");
+ } else {
+ for (int i = 0; i < uids.length; i++) {
+ int uid = uids[i];
+ pw.print(uid);
+ pw.print(' ');
+ }
+ }
+ pw.println();
+ return 0;
+ }
+
private int getRestrictBackground() throws RemoteException {
final PrintWriter pw = getOutPrintWriter();
pw.print("Restrict background status: ");
@@ -233,6 +265,24 @@
return 0;
}
+ private int addRestrictBackgroundBlacklist() throws RemoteException {
+ final int uid = getUidFromNextArg();
+ if (uid < 0) {
+ return uid;
+ }
+ mInterface.setUidPolicy(uid, POLICY_REJECT_METERED_BACKGROUND);
+ return 0;
+ }
+
+ private int removeRestrictBackgroundBlacklist() throws RemoteException {
+ final int uid = getUidFromNextArg();
+ if (uid < 0) {
+ return uid;
+ }
+ mInterface.setUidPolicy(uid, POLICY_NONE);
+ return 0;
+ }
+
private int listMeteredWifiNetworks() throws RemoteException {
final PrintWriter pw = getOutPrintWriter();
final String arg = getNextArg();
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index e4c3c14..e8d27db 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1698,9 +1698,9 @@
}
@Override
- public List<AutomaticZenRule> getAutomaticZenRules() throws RemoteException {
+ public List<ZenModeConfig.ZenRule> getZenRules() throws RemoteException {
enforcePolicyAccess(Binder.getCallingUid(), "getAutomaticZenRules");
- return mZenModeHelper.getAutomaticZenRules();
+ return mZenModeHelper.getZenRules();
}
@Override
@@ -1711,7 +1711,7 @@
}
@Override
- public AutomaticZenRule addAutomaticZenRule(AutomaticZenRule automaticZenRule)
+ public String addAutomaticZenRule(AutomaticZenRule automaticZenRule)
throws RemoteException {
Preconditions.checkNotNull(automaticZenRule, "automaticZenRule is null");
Preconditions.checkNotNull(automaticZenRule.getName(), "Name is null");
@@ -1724,7 +1724,7 @@
}
@Override
- public boolean updateAutomaticZenRule(AutomaticZenRule automaticZenRule)
+ public boolean updateAutomaticZenRule(String id, AutomaticZenRule automaticZenRule)
throws RemoteException {
Preconditions.checkNotNull(automaticZenRule, "automaticZenRule is null");
Preconditions.checkNotNull(automaticZenRule.getName(), "Name is null");
@@ -1732,7 +1732,7 @@
Preconditions.checkNotNull(automaticZenRule.getConditionId(), "ConditionId is null");
enforcePolicyAccess(Binder.getCallingUid(), "updateAutomaticZenRule");
- return mZenModeHelper.updateAutomaticZenRule(automaticZenRule,
+ return mZenModeHelper.updateAutomaticZenRule(id, automaticZenRule,
"updateAutomaticZenRule");
}
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 383c1ab..5c5c8f8 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -238,13 +238,13 @@
return mZenMode;
}
- public List<AutomaticZenRule> getAutomaticZenRules() {
- List<AutomaticZenRule> rules = new ArrayList<>();
+ public List<ZenRule> getZenRules() {
+ List<ZenRule> rules = new ArrayList<>();
synchronized (mConfig) {
if (mConfig == null) return rules;
for (ZenRule rule : mConfig.automaticRules.values()) {
if (canManageAutomaticZenRule(rule)) {
- rules.add(createAutomaticZenRule(rule));
+ rules.add(rule);
}
}
}
@@ -264,18 +264,18 @@
return null;
}
- public AutomaticZenRule addAutomaticZenRule(AutomaticZenRule automaticZenRule, String reason) {
- if (!TextUtils.isEmpty(automaticZenRule.getId())) {
- throw new IllegalArgumentException("Rule already exists");
- }
+ public String addAutomaticZenRule(AutomaticZenRule automaticZenRule, String reason) {
if (!isSystemRule(automaticZenRule)) {
ServiceInfo owner = getServiceInfo(automaticZenRule.getOwner());
if (owner == null) {
throw new IllegalArgumentException("Owner is not a condition provider service");
}
- final int ruleInstanceLimit = owner.metaData.getInt(
- ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1);
+ int ruleInstanceLimit = -1;
+ if (owner.metaData != null) {
+ ruleInstanceLimit = owner.metaData.getInt(
+ ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1);
+ }
if (ruleInstanceLimit > 0 && ruleInstanceLimit
< (getCurrentInstanceCount(automaticZenRule.getOwner()) + 1)) {
throw new IllegalArgumentException("Rule instance limit exceeded");
@@ -293,14 +293,15 @@
populateZenRule(automaticZenRule, rule, true);
newConfig.automaticRules.put(rule.id, rule);
if (setConfigLocked(newConfig, reason, true)) {
- return createAutomaticZenRule(rule);
+ return rule.id;
} else {
return null;
}
}
}
- public boolean updateAutomaticZenRule(AutomaticZenRule automaticZenRule, String reason) {
+ public boolean updateAutomaticZenRule(String ruleId, AutomaticZenRule automaticZenRule,
+ String reason) {
ZenModeConfig newConfig;
synchronized (mConfig) {
if (mConfig == null) return false;
@@ -309,7 +310,6 @@
+ " reason=" + reason);
}
newConfig = mConfig.copy();
- final String ruleId = automaticZenRule.getId();
ZenModeConfig.ZenRule rule;
if (ruleId == null) {
throw new IllegalArgumentException("Rule doesn't exist");
@@ -437,7 +437,7 @@
private AutomaticZenRule createAutomaticZenRule(ZenRule rule) {
return new AutomaticZenRule(rule.name, rule.component, rule.conditionId,
NotificationManager.zenModeToInterruptionFilter(rule.zenMode), rule.enabled,
- rule.id, rule.creationTime);
+ rule.creationTime);
}
public void setManualZenMode(int zenMode, Uri conditionId, String reason) {
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
index a3af561..a084d86 100644
--- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java
+++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
@@ -21,6 +21,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser.Package;
+import android.os.Environment;
import android.os.PowerManager;
import android.os.UserHandle;
import android.os.WorkSource;
@@ -164,6 +165,10 @@
}
for (String path : paths) {
+ if (useProfiles && isUsedByOtherApps(path)) {
+ // We cannot use profile guided compilation if the apk was used by another app.
+ useProfiles = false;
+ }
int dexoptNeeded;
try {
@@ -204,8 +209,10 @@
+ " vmSafeMode=" + vmSafeMode + " debuggable=" + debuggable
+ " extractOnly=" + extractOnly + " oatDir = " + oatDir);
final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid);
+ // Profile guide compiled oat files should not be public.
+ final boolean isPublic = !pkg.isForwardLocked() && !useProfiles;
final int dexFlags = adjustDexoptFlags(
- (!pkg.isForwardLocked() ? DEXOPT_PUBLIC : 0)
+ ( isPublic ? DEXOPT_PUBLIC : 0)
| (vmSafeMode ? DEXOPT_SAFEMODE : 0)
| (debuggable ? DEXOPT_DEBUGGABLE : 0)
| (extractOnly ? DEXOPT_EXTRACTONLY : 0)
@@ -275,6 +282,25 @@
mSystemReady = true;
}
+ private boolean isUsedByOtherApps(String apkPath) {
+ try {
+ apkPath = new File(apkPath).getCanonicalPath();
+ } catch (IOException e) {
+ // Log an error but continue without it.
+ Slog.w(TAG, "Failed to get canonical path", e);
+ }
+ String useMarker = apkPath.replace('/', '@');
+ final int[] currentUserIds = UserManagerService.getInstance().getUserIds();
+ for (int i = 0; i < currentUserIds.length; i++) {
+ File profileDir = Environment.getDataProfilesDeForeignDexDirectory(currentUserIds[i]);
+ File foreignUseMark = new File(profileDir, useMarker);
+ if (foreignUseMark.exists()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* A specialized PackageDexOptimizer that overrides already-installed checks, forcing a
* dexopt path.
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 9988694..bafcb64 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -62,7 +62,9 @@
import static android.content.pm.PackageManager.MATCH_ALL;
import static android.content.pm.PackageManager.MATCH_DEBUG_TRIAGED_MISSING;
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
+import static android.content.pm.PackageManager.MATCH_ENCRYPTION_AWARE;
import static android.content.pm.PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE;
+import static android.content.pm.PackageManager.MATCH_ENCRYPTION_UNAWARE;
import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES;
import static android.content.pm.PackageManager.MOVE_FAILED_DEVICE_ADMIN;
@@ -153,7 +155,6 @@
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import android.content.pm.UserInfo;
-import android.content.pm.VerificationParams;
import android.content.pm.VerifierDeviceIdentity;
import android.content.pm.VerifierInfo;
import android.content.res.Resources;
@@ -173,6 +174,7 @@
import android.os.Message;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
+import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
@@ -2888,7 +2890,8 @@
@Override
public boolean isPackageAvailable(String packageName, int userId) {
if (!sUserManager.exists(userId)) return false;
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "is package available");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "is package available");
synchronized (mPackages) {
PackageParser.Package p = mPackages.get(packageName);
if (p != null) {
@@ -2908,7 +2911,8 @@
public PackageInfo getPackageInfo(String packageName, int flags, int userId) {
if (!sUserManager.exists(userId)) return null;
flags = updateFlagsForPackage(flags, userId, packageName);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "get package info");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "get package info");
// reader
synchronized (mPackages) {
PackageParser.Package p = mPackages.get(packageName);
@@ -2954,7 +2958,8 @@
public int getPackageUid(String packageName, int flags, int userId) {
if (!sUserManager.exists(userId)) return -1;
flags = updateFlagsForPackage(flags, userId, packageName);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "get package uid");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "get package uid");
// reader
synchronized (mPackages) {
@@ -2977,7 +2982,8 @@
public int[] getPackageGids(String packageName, int flags, int userId) {
if (!sUserManager.exists(userId)) return null;
flags = updateFlagsForPackage(flags, userId, packageName);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */,
"getPackageGids");
// reader
@@ -3117,7 +3123,8 @@
public ApplicationInfo getApplicationInfo(String packageName, int flags, int userId) {
if (!sUserManager.exists(userId)) return null;
flags = updateFlagsForApplication(flags, userId, packageName);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "get application info");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "get application info");
// writer
synchronized (mPackages) {
PackageParser.Package p = mPackages.get(packageName);
@@ -3332,7 +3339,8 @@
public ActivityInfo getActivityInfo(ComponentName component, int flags, int userId) {
if (!sUserManager.exists(userId)) return null;
flags = updateFlagsForComponent(flags, userId, component);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "get activity info");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "get activity info");
synchronized (mPackages) {
PackageParser.Activity a = mActivities.mActivities.get(component);
@@ -3377,7 +3385,8 @@
public ActivityInfo getReceiverInfo(ComponentName component, int flags, int userId) {
if (!sUserManager.exists(userId)) return null;
flags = updateFlagsForComponent(flags, userId, component);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "get receiver info");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "get receiver info");
synchronized (mPackages) {
PackageParser.Activity a = mReceivers.mActivities.get(component);
if (DEBUG_PACKAGE_INFO) Log.v(
@@ -3396,7 +3405,8 @@
public ServiceInfo getServiceInfo(ComponentName component, int flags, int userId) {
if (!sUserManager.exists(userId)) return null;
flags = updateFlagsForComponent(flags, userId, component);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "get service info");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "get service info");
synchronized (mPackages) {
PackageParser.Service s = mServices.mServices.get(component);
if (DEBUG_PACKAGE_INFO) Log.v(
@@ -3415,7 +3425,8 @@
public ProviderInfo getProviderInfo(ComponentName component, int flags, int userId) {
if (!sUserManager.exists(userId)) return null;
flags = updateFlagsForComponent(flags, userId, component);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "get provider info");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "get provider info");
synchronized (mPackages) {
PackageParser.Provider p = mProviders.mProviders.get(component);
if (DEBUG_PACKAGE_INFO) Log.v(
@@ -3807,7 +3818,8 @@
android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
"grantRuntimePermission");
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, true /* checkShell */,
"grantRuntimePermission");
final int uid;
@@ -3918,7 +3930,8 @@
android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS,
"revokeRuntimePermission");
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, true /* checkShell */,
"revokeRuntimePermission");
final int appId;
@@ -4022,7 +4035,8 @@
enforceGrantRevokeRuntimePermissionPermissions("getPermissionFlags");
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */,
"getPermissionFlags");
synchronized (mPackages) {
@@ -4055,7 +4069,8 @@
enforceGrantRevokeRuntimePermissionPermissions("updatePermissionFlags");
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, true /* checkShell */,
"updatePermissionFlags");
// Only the system can change these flags and nothing else.
@@ -4112,7 +4127,8 @@
enforceGrantRevokeRuntimePermissionPermissions("updatePermissionFlagsForAllApps");
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, true /* checkShell */,
"updatePermissionFlagsForAllApps");
// Only the system can change system fixed flags.
@@ -4545,7 +4561,8 @@
int flags, int userId) {
if (!sUserManager.exists(userId)) return null;
flags = updateFlagsForResolve(flags, userId, intent);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "resolve intent");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */, "resolve intent");
List<ResolveInfo> query = queryIntentActivities(intent, resolvedType, flags, userId);
final ResolveInfo bestChoice =
chooseBestActivity(intent, resolvedType, flags, query, userId);
@@ -5006,7 +5023,9 @@
String resolvedType, int flags, int userId) {
if (!sUserManager.exists(userId)) return Collections.emptyList();
flags = updateFlagsForResolve(flags, userId, intent);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "query intent activities");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */,
+ "query intent activities");
ComponentName comp = intent.getComponent();
if (comp == null) {
if (intent.getSelector() != null) {
@@ -5496,8 +5515,9 @@
String resolvedType, int flags, int userId) {
if (!sUserManager.exists(userId)) return Collections.emptyList();
flags = updateFlagsForResolve(flags, userId, intent);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, false,
- false, "query intent activity options");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /* requireFullPermission */, false /* checkShell */,
+ "query intent activity options");
final String resultsAction = intent.getAction();
List<ResolveInfo> results = queryIntentActivities(intent, resolvedType, flags
@@ -5798,7 +5818,9 @@
if (!sUserManager.exists(userId)) return ParceledListSlice.emptyList();
flags = updateFlagsForPackage(flags, userId, null);
final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "get installed packages");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */,
+ "get installed packages");
// writer
synchronized (mPackages) {
@@ -5950,7 +5972,8 @@
mContext.enforceCallingOrSelfPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS,
"getEphemeralApplications");
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */,
"getEphemeralApplications");
synchronized (mPackages) {
List<EphemeralApplicationInfo> ephemeralApps = mEphemeralApplicationRegistry
@@ -5964,7 +5987,8 @@
@Override
public boolean isEphemeralApplication(String packageName, int userId) {
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */,
"isEphemeral");
if (DISABLE_EPHEMERAL_APPS) {
return false;
@@ -5988,7 +6012,8 @@
return null;
}
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */,
"getCookie");
if (!isCallerSameApp(packageName)) {
return null;
@@ -6005,7 +6030,8 @@
return true;
}
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, true /* checkShell */,
"setCookie");
if (!isCallerSameApp(packageName)) {
return false;
@@ -6024,7 +6050,8 @@
mContext.enforceCallingOrSelfPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS,
"getEphemeralApplicationIcon");
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */,
"getEphemeralApplicationIcon");
synchronized (mPackages) {
return mEphemeralApplicationRegistry.getEphemeralApplicationIconLPw(
@@ -6047,9 +6074,16 @@
final int userId = UserHandle.getCallingUserId();
while (i.hasNext()) {
final PackageParser.Package p = i.next();
- if (p.applicationInfo != null
- && (p.applicationInfo.flags&ApplicationInfo.FLAG_PERSISTENT) != 0
- && (!mSafeMode || isSystemApp(p))) {
+ if (p.applicationInfo == null) continue;
+
+ final boolean matchesUnaware = ((flags & MATCH_ENCRYPTION_UNAWARE) != 0)
+ && !p.applicationInfo.isEncryptionAware();
+ final boolean matchesAware = ((flags & MATCH_ENCRYPTION_AWARE) != 0)
+ && p.applicationInfo.isEncryptionAware();
+
+ if ((p.applicationInfo.flags & ApplicationInfo.FLAG_PERSISTENT) != 0
+ && (!mSafeMode || isSystemApp(p))
+ && (matchesUnaware || matchesAware)) {
PackageSetting ps = mSettings.mPackages.get(p.packageName);
if (ps != null) {
ApplicationInfo ai = PackageParser.generateApplicationInfo(p, flags,
@@ -10376,21 +10410,13 @@
}
@Override
- public void installPackage(String originPath, IPackageInstallObserver2 observer,
- int installFlags, String installerPackageName, VerificationParams verificationParams,
- String packageAbiOverride) {
- installPackageAsUser(originPath, observer, installFlags, installerPackageName,
- verificationParams, packageAbiOverride, UserHandle.getCallingUserId());
- }
-
- @Override
public void installPackageAsUser(String originPath, IPackageInstallObserver2 observer,
- int installFlags, String installerPackageName, VerificationParams verificationParams,
- String packageAbiOverride, int userId) {
+ int installFlags, String installerPackageName, int userId) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.INSTALL_PACKAGES, null);
final int callingUid = Binder.getCallingUid();
- enforceCrossUserPermission(callingUid, userId, true, true, "installPackageAsUser");
+ enforceCrossUserPermission(callingUid, userId,
+ true /* requireFullPermission */, true /* checkShell */, "installPackageAsUser");
if (isUserRestricted(userId, UserManager.DISALLOW_INSTALL_APPS)) {
try {
@@ -10429,14 +10455,15 @@
+ "to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag");
}
- verificationParams.setInstallerUid(callingUid);
-
final File originFile = new File(originPath);
final OriginInfo origin = OriginInfo.fromUntrustedFile(originFile);
final Message msg = mHandler.obtainMessage(INIT_COPY);
- final InstallParams params = new InstallParams(origin, null, observer, installFlags,
- installerPackageName, null, verificationParams, user, packageAbiOverride, null);
+ final VerificationInfo verificationInfo = new VerificationInfo(
+ null /*originatingUri*/, null /*referrer*/, -1 /*originatingUid*/, callingUid);
+ final InstallParams params = new InstallParams(origin, null /*moveInfo*/, observer,
+ installFlags, installerPackageName, null /*volumeUuid*/, verificationInfo, user,
+ null /*packageAbiOverride*/, null /*grantedPermissions*/);
params.setTraceMethod("installAsUser").setTraceCookie(System.identityHashCode(params));
msg.obj = params;
@@ -10456,10 +10483,9 @@
Slog.d(TAG, "Ephemeral install of " + packageName);
}
}
- final VerificationParams verifParams = new VerificationParams(
- null, sessionParams.originatingUri, sessionParams.referrerUri,
- sessionParams.originatingUid);
- verifParams.setInstallerUid(installerUid);
+ final VerificationInfo verificationInfo = new VerificationInfo(
+ sessionParams.originatingUri, sessionParams.referrerUri,
+ sessionParams.originatingUid, installerUid);
final OriginInfo origin;
if (stagedDir != null) {
@@ -10471,7 +10497,7 @@
final Message msg = mHandler.obtainMessage(INIT_COPY);
final InstallParams params = new InstallParams(origin, null, observer,
sessionParams.installFlags, installerPackageName, sessionParams.volumeUuid,
- verifParams, user, sessionParams.abiOverride,
+ verificationInfo, user, sessionParams.abiOverride,
sessionParams.grantedRuntimePermissions);
params.setTraceMethod("installStage").setTraceCookie(System.identityHashCode(params));
msg.obj = params;
@@ -10521,7 +10547,8 @@
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USERS, null);
PackageSetting pkgSetting;
final int uid = Binder.getCallingUid();
- enforceCrossUserPermission(uid, userId, true, true,
+ enforceCrossUserPermission(uid, userId,
+ true /* requireFullPermission */, true /* checkShell */,
"setApplicationHiddenSetting for user " + userId);
if (hidden && isPackageDeviceAdmin(packageName, userId)) {
@@ -10594,8 +10621,9 @@
@Override
public boolean getApplicationHiddenSettingAsUser(String packageName, int userId) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USERS, null);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true,
- false, "getApplicationHidden for user " + userId);
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */,
+ "getApplicationHidden for user " + userId);
PackageSetting pkgSetting;
long callingId = Binder.clearCallingIdentity();
try {
@@ -10621,8 +10649,9 @@
null);
PackageSetting pkgSetting;
final int uid = Binder.getCallingUid();
- enforceCrossUserPermission(uid, userId, true, true, "installExistingPackage for user "
- + userId);
+ enforceCrossUserPermission(uid, userId,
+ true /* requireFullPermission */, true /* checkShell */,
+ "installExistingPackage for user " + userId);
if (isUserRestricted(userId, UserManager.DISALLOW_INSTALL_APPS)) {
return PackageManager.INSTALL_FAILED_USER_RESTRICTED;
}
@@ -10671,7 +10700,8 @@
public String[] setPackagesSuspendedAsUser(String[] packageNames, boolean suspended,
int userId) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USERS, null);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, true,
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, true /* checkShell */,
"setPackagesSuspended for user " + userId);
if (ArrayUtils.isEmpty(packageNames)) {
@@ -10729,8 +10759,9 @@
@Override
public boolean isPackageSuspendedForUser(String packageName, int userId) {
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true,
- false, "isPackageSuspendedForUser for user " + userId);
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */,
+ "isPackageSuspendedForUser for user " + userId);
synchronized (mPackages) {
final PackageSetting pkgSetting = mSettings.mPackages.get(packageName);
return pkgSetting != null && pkgSetting.getSuspended(userId);
@@ -11506,6 +11537,30 @@
}
}
+ static class VerificationInfo {
+ /** A constant used to indicate that a uid value is not present. */
+ public static final int NO_UID = -1;
+
+ /** URI referencing where the package was downloaded from. */
+ final Uri originatingUri;
+
+ /** HTTP referrer URI associated with the originatingURI. */
+ final Uri referrer;
+
+ /** UID of the application that the install request originated from. */
+ final int originatingUid;
+
+ /** UID of application requesting the install */
+ final int installerUid;
+
+ VerificationInfo(Uri originatingUri, Uri referrer, int originatingUid, int installerUid) {
+ this.originatingUri = originatingUri;
+ this.referrer = referrer;
+ this.originatingUid = originatingUid;
+ this.installerUid = installerUid;
+ }
+ }
+
class InstallParams extends HandlerParams {
final OriginInfo origin;
final MoveInfo move;
@@ -11513,15 +11568,15 @@
int installFlags;
final String installerPackageName;
final String volumeUuid;
- final VerificationParams verificationParams;
private InstallArgs mArgs;
private int mRet;
final String packageAbiOverride;
final String[] grantedRuntimePermissions;
+ final VerificationInfo verificationInfo;
InstallParams(OriginInfo origin, MoveInfo move, IPackageInstallObserver2 observer,
int installFlags, String installerPackageName, String volumeUuid,
- VerificationParams verificationParams, UserHandle user, String packageAbiOverride,
+ VerificationInfo verificationInfo, UserHandle user, String packageAbiOverride,
String[] grantedPermissions) {
super(user);
this.origin = origin;
@@ -11530,7 +11585,7 @@
this.installFlags = installFlags;
this.installerPackageName = installerPackageName;
this.volumeUuid = volumeUuid;
- this.verificationParams = verificationParams;
+ this.verificationInfo = verificationInfo;
this.packageAbiOverride = packageAbiOverride;
this.grantedRuntimePermissions = grantedPermissions;
}
@@ -11794,26 +11849,22 @@
verification.putExtra(PackageManager.EXTRA_VERIFICATION_VERSION_CODE,
pkgLite.versionCode);
- if (verificationParams != null) {
- if (verificationParams.getVerificationURI() != null) {
- verification.putExtra(PackageManager.EXTRA_VERIFICATION_URI,
- verificationParams.getVerificationURI());
- }
- if (verificationParams.getOriginatingURI() != null) {
+ if (verificationInfo != null) {
+ if (verificationInfo.originatingUri != null) {
verification.putExtra(Intent.EXTRA_ORIGINATING_URI,
- verificationParams.getOriginatingURI());
+ verificationInfo.originatingUri);
}
- if (verificationParams.getReferrer() != null) {
+ if (verificationInfo.referrer != null) {
verification.putExtra(Intent.EXTRA_REFERRER,
- verificationParams.getReferrer());
+ verificationInfo.referrer);
}
- if (verificationParams.getOriginatingUid() >= 0) {
+ if (verificationInfo.originatingUid >= 0) {
verification.putExtra(Intent.EXTRA_ORIGINATING_UID,
- verificationParams.getOriginatingUid());
+ verificationInfo.originatingUid);
}
- if (verificationParams.getInstallerUid() >= 0) {
+ if (verificationInfo.installerUid >= 0) {
verification.putExtra(PackageManager.EXTRA_VERIFICATION_INSTALLER_UID,
- verificationParams.getInstallerUid());
+ verificationInfo.installerUid);
}
}
@@ -14102,25 +14153,48 @@
return;
}
- for (int currentUserId : users) {
- if (getBlockUninstallForUser(packageName, currentUserId)) {
- try {
- observer.onPackageDeleted(packageName,
- PackageManager.DELETE_FAILED_OWNER_BLOCKED, null);
- } catch (RemoteException re) {
- }
- return;
+ if (!deleteAllUsers && getBlockUninstallForUser(packageName, userId)) {
+ try {
+ observer.onPackageDeleted(packageName,
+ PackageManager.DELETE_FAILED_OWNER_BLOCKED, null);
+ } catch (RemoteException re) {
}
+ return;
}
if (DEBUG_REMOVE) {
- Slog.d(TAG, "deletePackageAsUser: pkg=" + packageName + " user=" + userId);
+ Slog.d(TAG, "deletePackageAsUser: pkg=" + packageName + " user=" + userId
+ + " deleteAllUsers: " + deleteAllUsers );
}
// Queue up an async operation since the package deletion may take a little while.
mHandler.post(new Runnable() {
public void run() {
mHandler.removeCallbacks(this);
- final int returnCode = deletePackageX(packageName, userId, flags);
+ int returnCode;
+ if (!deleteAllUsers) {
+ returnCode = deletePackageX(packageName, userId, flags);
+ } else {
+ int[] blockUninstallUserIds = getBlockUninstallForUsers(packageName, users);
+ // If nobody is blocking uninstall, proceed with delete for all users
+ if (ArrayUtils.isEmpty(blockUninstallUserIds)) {
+ returnCode = deletePackageX(packageName, userId, flags);
+ } else {
+ // Otherwise uninstall individually for users with blockUninstalls=false
+ final int userFlags = flags & ~PackageManager.DELETE_ALL_USERS;
+ for (int userId : users) {
+ if (!ArrayUtils.contains(blockUninstallUserIds, userId)) {
+ returnCode = deletePackageX(packageName, userId, userFlags);
+ if (returnCode != PackageManager.DELETE_SUCCEEDED) {
+ Slog.w(TAG, "Package delete failed for user " + userId
+ + ", returnCode " + returnCode);
+ }
+ }
+ }
+ // The app has only been marked uninstalled for certain users.
+ // We still need to report that delete was blocked
+ returnCode = PackageManager.DELETE_FAILED_OWNER_BLOCKED;
+ }
+ }
try {
observer.onPackageDeleted(packageName, returnCode, null);
} catch (RemoteException e) {
@@ -14130,6 +14204,16 @@
});
}
+ private int[] getBlockUninstallForUsers(String packageName, int[] userIds) {
+ int[] result = EMPTY_INT_ARRAY;
+ for (int userId : userIds) {
+ if (getBlockUninstallForUser(packageName, userId)) {
+ result = ArrayUtils.appendInt(result, userId);
+ }
+ }
+ return result;
+ }
+
@Override
public boolean isPackageDeviceAdminOnAnyUser(String packageName) {
return isPackageDeviceAdmin(packageName, UserHandle.USER_ALL);
@@ -14981,7 +15065,8 @@
final IPackageDataObserver observer, final int userId) {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.CLEAR_APP_USER_DATA, null);
- enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "clear application data");
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ true /* requireFullPermission */, false /* checkShell */, "clear application data");
// Queue up an async operation since the package deletion may take a little while.
mHandler.post(new Runnable() {
public void run() {
@@ -15444,7 +15529,8 @@
String opname) {
// writer
int callingUid = Binder.getCallingUid();
- enforceCrossUserPermission(callingUid, userId, true, false, "add preferred activity");
+ enforceCrossUserPermission(callingUid, userId,
+ true /* requireFullPermission */, false /* checkShell */, "add preferred activity");
if (filter.countActions() == 0) {
Slog.w(TAG, "Cannot set a preferred activity with no filter actions");
return;
@@ -15489,7 +15575,9 @@
}
final int callingUid = Binder.getCallingUid();
- enforceCrossUserPermission(callingUid, userId, true, false, "replace preferred activity");
+ enforceCrossUserPermission(callingUid, userId,
+ true /* requireFullPermission */, false /* checkShell */,
+ "replace preferred activity");
synchronized (mPackages) {
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
@@ -16307,7 +16395,8 @@
final int uid = Binder.getCallingUid();
final int permission = mContext.checkCallingOrSelfPermission(
android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE);
- enforceCrossUserPermission(uid, userId, false, true, "set enabled");
+ enforceCrossUserPermission(uid, userId,
+ false /* requireFullPermission */, true /* checkShell */, "set enabled");
final boolean allowedByPermission = (permission == PackageManager.PERMISSION_GRANTED);
boolean sendNow = false;
boolean isApp = (className == null);
@@ -16446,7 +16535,8 @@
final int permission = mContext.checkCallingOrSelfPermission(
android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE);
final boolean allowedByPermission = (permission == PackageManager.PERMISSION_GRANTED);
- enforceCrossUserPermission(uid, userId, true, true, "stop package");
+ enforceCrossUserPermission(uid, userId,
+ true /* requireFullPermission */, true /* checkShell */, "stop package");
// writer
synchronized (mPackages) {
if (mSettings.setPackageStoppedStateLPw(this, packageName, stopped,
@@ -16468,7 +16558,8 @@
public int getApplicationEnabledSetting(String packageName, int userId) {
if (!sUserManager.exists(userId)) return COMPONENT_ENABLED_STATE_DISABLED;
int uid = Binder.getCallingUid();
- enforceCrossUserPermission(uid, userId, false, false, "get enabled");
+ enforceCrossUserPermission(uid, userId,
+ false /* requireFullPermission */, false /* checkShell */, "get enabled");
// reader
synchronized (mPackages) {
return mSettings.getApplicationEnabledSettingLPr(packageName, userId);
@@ -16479,7 +16570,8 @@
public int getComponentEnabledSetting(ComponentName componentName, int userId) {
if (!sUserManager.exists(userId)) return COMPONENT_ENABLED_STATE_DISABLED;
int uid = Binder.getCallingUid();
- enforceCrossUserPermission(uid, userId, false, false, "get component enabled");
+ enforceCrossUserPermission(uid, userId,
+ false /* requireFullPermission */, false /* checkShell */, "get component enabled");
// reader
synchronized (mPackages) {
return mSettings.getComponentEnabledSettingLPr(componentName, userId);
@@ -18384,7 +18476,8 @@
final Message msg = mHandler.obtainMessage(INIT_COPY);
final OriginInfo origin = OriginInfo.fromExistingFile(codeFile);
final InstallParams params = new InstallParams(origin, move, installObserver, installFlags,
- installerPackageName, volumeUuid, null, user, packageAbiOverride, null);
+ installerPackageName, volumeUuid, null /*verificationInfo*/, user,
+ packageAbiOverride, null);
params.setTraceMethod("movePackage").setTraceCookie(System.identityHashCode(params));
msg.obj = params;
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 1652185..310ad53 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -3049,7 +3049,7 @@
tmpPa.dump(new LogPrinter(Log.DEBUG, TAG), " ");
}
Intent intent = new Intent();
- int flags = 0;
+ int flags = PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE;
intent.setAction(tmpPa.getAction(0));
for (int i=0; i<tmpPa.countCategories(); i++) {
String cat = tmpPa.getCategory(i);
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index 8a2729e..49aaa4a 100644
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -2512,7 +2512,7 @@
// For the recording session only
@Override
- public void onTuned() {
+ public void onTuned(Uri channelUri) {
synchronized (mLock) {
if (DEBUG) {
Slog.d(TAG, "onTuned()");
@@ -2521,7 +2521,7 @@
return;
}
try {
- mSessionState.client.onTuned(mSessionState.seq);
+ mSessionState.client.onTuned(mSessionState.seq, channelUri);
} catch (RemoteException e) {
Slog.e(TAG, "error in onTuned", e);
}
diff --git a/services/core/java/com/android/server/vr/VrManagerService.java b/services/core/java/com/android/server/vr/VrManagerService.java
index 2f076d1..7611527 100644
--- a/services/core/java/com/android/server/vr/VrManagerService.java
+++ b/services/core/java/com/android/server/vr/VrManagerService.java
@@ -15,9 +15,12 @@
*/
package com.android.server.vr;
+import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.os.Binder;
+import android.os.IBinder;
import android.os.UserHandle;
import android.util.ArraySet;
import android.util.Slog;
@@ -40,6 +43,9 @@
private static native void setVrModeNative(boolean enabled);
private final Object mLock = new Object();
+
+ private final IBinder mOverlayToken = new Binder();
+
private boolean mVrModeEnabled = false;
private ArraySet<VrStateListener> mListeners = new ArraySet<>();
@@ -97,11 +103,25 @@
// Log mode change event.
Slog.i(TAG, "VR mode " + ((mVrModeEnabled) ? "enabled" : "disabled"));
setVrModeNative(mVrModeEnabled);
+ updateOverlayStateLocked();
onVrModeChangedLocked();
}
}
}
+ private void updateOverlayStateLocked() {
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ AppOpsManager appOpsManager = getContext().getSystemService(AppOpsManager.class);
+ if (appOpsManager != null) {
+ appOpsManager.setUserRestriction(AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
+ mVrModeEnabled, mOverlayToken);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
private boolean getVrMode() {
synchronized (mLock) {
return mVrModeEnabled;
diff --git a/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java b/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
index 0979cd3..ccba88d 100644
--- a/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
+++ b/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
@@ -35,7 +35,7 @@
static final boolean DEBUG_RESIZE = false;
static final boolean DEBUG = false;
- static final boolean DEBUG_ADD_REMOVE = false;
+ static final boolean DEBUG_ADD_REMOVE = true;
static final boolean DEBUG_FOCUS = false;
static final boolean DEBUG_FOCUS_LIGHT = DEBUG_FOCUS || false;
static final boolean DEBUG_ANIM = false;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 69d2d20..fe215d5 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -8777,10 +8777,10 @@
i -= lastBelow;
if (i != numRemoved) {
displayContent.layoutNeeded = true;
- Slog.w(TAG_WM, "On display=" + displayContent.getDisplayId() + " Rebuild removed " +
- numRemoved + " windows but added " + i,
- new RuntimeException("here").fillInStackTrace());
- for (i=0; i<numRemoved; i++) {
+ Slog.w(TAG_WM, "On display=" + displayContent.getDisplayId() + " Rebuild removed "
+ + numRemoved + " windows but added " + i + " rebuildAppWindowListLocked() "
+ + " callers=" + Debug.getCallers(10));
+ for (i = 0; i < numRemoved; i++) {
WindowState ws = mRebuildTmp[i];
if (ws.mRebuilding) {
StringWriter sw = new StringWriter();
diff --git a/services/net/java/android/net/ip/IpManager.java b/services/net/java/android/net/ip/IpManager.java
index 2a90c60..46ecc50 100644
--- a/services/net/java/android/net/ip/IpManager.java
+++ b/services/net/java/android/net/ip/IpManager.java
@@ -241,15 +241,22 @@
public IpManager(Context context, String ifName, Callback callback)
throws IllegalArgumentException {
+ this(context, ifName, callback, INetworkManagementService.Stub.asInterface(
+ ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE)));
+ }
+
+ /**
+ * An expanded constructor, useful for dependency injection.
+ */
+ public IpManager(Context context, String ifName, Callback callback,
+ INetworkManagementService nwService) throws IllegalArgumentException {
super(IpManager.class.getSimpleName() + "." + ifName);
mTag = getName();
mContext = context;
mInterfaceName = ifName;
mCallback = callback;
-
- mNwService = INetworkManagementService.Stub.asInterface(
- ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
+ mNwService = nwService;
mNetlinkTracker = new NetlinkTracker(
mInterfaceName,
@@ -277,25 +284,6 @@
super.start();
}
- /**
- * A special constructor for use in testing that bypasses some of the more
- * complicated setup bits.
- *
- * TODO: Figure out how to delete this yet preserve testability.
- */
- @VisibleForTesting
- protected IpManager(String ifName, Callback callback) {
- super(IpManager.class.getSimpleName() + ".test-" + ifName);
- mTag = getName();
-
- mInterfaceName = ifName;
- mCallback = callback;
-
- mContext = null;
- mNwService = null;
- mNetlinkTracker = null;
- }
-
@Override
protected void onQuitting() {
mCallback.onQuit();
diff --git a/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java b/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java
index 5874429..20a0131 100644
--- a/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java
@@ -67,6 +67,7 @@
import com.android.server.connectivity.NetworkAgentInfo;
import com.android.server.connectivity.NetworkMonitor;
+import com.android.server.net.NetworkPinner;
import java.net.InetAddress;
import java.util.concurrent.CountDownLatch;
@@ -87,10 +88,30 @@
private BroadcastInterceptingContext mServiceContext;
private WrappedConnectivityService mService;
- private ConnectivityManager mCm;
+ private WrappedConnectivityManager mCm;
private MockNetworkAgent mWiFiNetworkAgent;
private MockNetworkAgent mCellNetworkAgent;
+ // This class exists to test bindProcessToNetwork and getBoundNetworkForProcess. These methods
+ // do not go through ConnectivityService but talk to netd directly, so they don't automatically
+ // reflect the state of our test ConnectivityService.
+ private class WrappedConnectivityManager extends ConnectivityManager {
+ private Network mFakeBoundNetwork;
+
+ public synchronized boolean bindProcessToNetwork(Network network) {
+ mFakeBoundNetwork = network;
+ return true;
+ }
+
+ public synchronized Network getBoundNetworkForProcess() {
+ return mFakeBoundNetwork;
+ }
+
+ public WrappedConnectivityManager(Context context, ConnectivityService service) {
+ super(context, service);
+ }
+ }
+
private class MockContext extends BroadcastInterceptingContext {
MockContext(Context base) {
super(base);
@@ -607,7 +628,8 @@
mock(INetworkPolicyManager.class));
mService.systemReady();
- mCm = new ConnectivityManager(getContext(), mService);
+ mCm = new WrappedConnectivityManager(getContext(), mService);
+ mCm.bindProcessToNetwork(null);
}
private int transportToLegacyType(int transport) {
@@ -1543,4 +1565,103 @@
String url = mCm.getCaptivePortalServerUrl();
assertEquals("http://connectivitycheck.gstatic.com/generate_204", url);
}
+
+ private static class TestNetworkPinner extends NetworkPinner {
+ public static boolean awaitPin(int timeoutMs) {
+ synchronized(sLock) {
+ if (sNetwork == null) {
+ try {
+ sLock.wait(timeoutMs);
+ } catch (InterruptedException e) {}
+ }
+ return sNetwork != null;
+ }
+ }
+
+ public static boolean awaitUnpin(int timeoutMs) {
+ synchronized(sLock) {
+ if (sNetwork != null) {
+ try {
+ sLock.wait(timeoutMs);
+ } catch (InterruptedException e) {}
+ }
+ return sNetwork == null;
+ }
+ }
+ }
+
+ private void assertPinnedToWifiWithCellDefault() {
+ assertEquals(mWiFiNetworkAgent.getNetwork(), mCm.getBoundNetworkForProcess());
+ assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork());
+ }
+
+ private void assertPinnedToWifiWithWifiDefault() {
+ assertEquals(mWiFiNetworkAgent.getNetwork(), mCm.getBoundNetworkForProcess());
+ assertEquals(mWiFiNetworkAgent.getNetwork(), mCm.getActiveNetwork());
+ }
+
+ private void assertNotPinnedToWifi() {
+ assertNull(mCm.getBoundNetworkForProcess());
+ assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork());
+ }
+
+ @SmallTest
+ public void testNetworkPinner() {
+ NetworkRequest wifiRequest = new NetworkRequest.Builder()
+ .addTransportType(TRANSPORT_WIFI)
+ .build();
+ assertNull(mCm.getBoundNetworkForProcess());
+
+ TestNetworkPinner.pin(mServiceContext, wifiRequest);
+ assertNull(mCm.getBoundNetworkForProcess());
+
+ mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
+ mCellNetworkAgent.connect(true);
+ mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
+ mWiFiNetworkAgent.connect(false);
+
+ // When wi-fi connects, expect to be pinned.
+ assertTrue(TestNetworkPinner.awaitPin(100));
+ assertPinnedToWifiWithCellDefault();
+
+ // Disconnect and expect the pin to drop.
+ mWiFiNetworkAgent.disconnect();
+ assertTrue(TestNetworkPinner.awaitUnpin(100));
+ assertNotPinnedToWifi();
+
+ // Reconnecting does not cause the pin to come back.
+ mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
+ mWiFiNetworkAgent.connect(false);
+ assertFalse(TestNetworkPinner.awaitPin(100));
+ assertNotPinnedToWifi();
+
+ // Pinning while connected causes the pin to take effect immediately.
+ TestNetworkPinner.pin(mServiceContext, wifiRequest);
+ assertTrue(TestNetworkPinner.awaitPin(100));
+ assertPinnedToWifiWithCellDefault();
+
+ // Explicitly unpin and expect to use the default network again.
+ TestNetworkPinner.unpin();
+ assertNotPinnedToWifi();
+
+ // Disconnect cell and wifi.
+ ConditionVariable cv = waitForConnectivityBroadcasts(3); // cell down, wifi up, wifi down.
+ mCellNetworkAgent.disconnect();
+ mWiFiNetworkAgent.disconnect();
+ waitFor(cv);
+
+ // Pinning takes effect even if the pinned network is the default when the pin is set...
+ TestNetworkPinner.pin(mServiceContext, wifiRequest);
+ mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
+ mWiFiNetworkAgent.connect(false);
+ assertTrue(TestNetworkPinner.awaitPin(100));
+ assertPinnedToWifiWithWifiDefault();
+
+ // ... and is maintained even when that network is no longer the default.
+ cv = waitForConnectivityBroadcasts(1);
+ mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
+ mCellNetworkAgent.connect(true);
+ waitFor(cv);
+ assertPinnedToWifiWithCellDefault();
+ }
}
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index 8b250f4..8da1785 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -437,7 +437,7 @@
return false;
}
} catch (RemoteException re) {
- return false;
+ throw re.rethrowFromSystemServer();
}
final long elapsedRealtime = SystemClock.elapsedRealtime();
@@ -805,6 +805,7 @@
return false;
}
} catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
}
if (isActiveDeviceAdmin(packageName, userId)) {
@@ -849,7 +850,7 @@
}
apps = slice.getList();
} catch (RemoteException e) {
- return new int[0];
+ throw e.rethrowFromSystemServer();
}
// State of each uid. Key is the uid. Value lower 16 bits is the number of apps
@@ -1258,7 +1259,7 @@
userId = ActivityManagerNative.getDefault().handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userId, false, true, "isAppInactive", null);
} catch (RemoteException re) {
- return false;
+ throw re.rethrowFromSystemServer();
}
final long token = Binder.clearCallingIdentity();
try {
@@ -1277,7 +1278,7 @@
Binder.getCallingPid(), callingUid, userId, false, true,
"setAppIdle", null);
} catch (RemoteException re) {
- return;
+ throw re.rethrowFromSystemServer();
}
getContext().enforceCallingPermission(Manifest.permission.CHANGE_APP_IDLE_STATE,
"No permission to change app idle state");
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index de902025..10808da 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -624,6 +624,21 @@
parcelableCall.getExtras(),
parcelableCall.getIntentExtras());
}
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("[pa: ");
+ sb.append(mAccountHandle);
+ sb.append(", hdl: ");
+ sb.append(Log.pii(mHandle));
+ sb.append(", caps: ");
+ sb.append(capabilitiesToString(mCallCapabilities));
+ sb.append(", props: ");
+ sb.append(mCallProperties);
+ sb.append("]");
+ return sb.toString();
+ }
}
public static abstract class Callback {
@@ -1000,6 +1015,48 @@
}
}
+ @Override
+ public String toString() {
+ return new StringBuilder().
+ append("Call [id: ").
+ append(mTelecomCallId).
+ append(", state: ").
+ append(stateToString(mState)).
+ append(", details: ").
+ append(mDetails).
+ append("]").toString();
+ }
+
+ /**
+ * @param state An integer value of a {@code STATE_*} constant.
+ * @return A string representation of the value.
+ */
+ private static String stateToString(int state) {
+ switch (state) {
+ case STATE_NEW:
+ return "NEW";
+ case STATE_RINGING:
+ return "RINGING";
+ case STATE_DIALING:
+ return "DIALING";
+ case STATE_ACTIVE:
+ return "ACTIVE";
+ case STATE_HOLDING:
+ return "HOLDING";
+ case STATE_DISCONNECTED:
+ return "DISCONNECTED";
+ case STATE_CONNECTING:
+ return "CONNECTING";
+ case STATE_DISCONNECTING:
+ return "DISCONNECTING";
+ case STATE_SELECT_PHONE_ACCOUNT:
+ return "SELECT_PHONE_ACCOUNT";
+ default:
+ Log.w(Call.class, "Unknown state %d", state);
+ return "UNKNOWN";
+ }
+ }
+
/**
* Adds a listener to this {@code Call}.
*
diff --git a/telecomm/java/android/telecom/Log.java b/telecomm/java/android/telecom/Log.java
index 3f32dbe..2ab0525 100644
--- a/telecomm/java/android/telecom/Log.java
+++ b/telecomm/java/android/telecom/Log.java
@@ -16,7 +16,10 @@
package android.telecom;
+import android.net.Uri;
import android.os.AsyncTask;
+import android.telephony.PhoneNumberUtils;
+import android.text.TextUtils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -152,10 +155,37 @@
public static String pii(Object pii) {
if (pii == null || VERBOSE) {
return String.valueOf(pii);
+ } if (pii instanceof Uri) {
+ return piiUri((Uri) pii);
}
return "[" + secureHash(String.valueOf(pii).getBytes()) + "]";
}
+ private static String piiUri(Uri handle) {
+ StringBuilder sb = new StringBuilder();
+ String scheme = handle.getScheme();
+ if (!TextUtils.isEmpty(scheme)) {
+ sb.append(scheme).append(":");
+ }
+ String value = handle.getSchemeSpecificPart();
+ if (!TextUtils.isEmpty(value)) {
+ for (int i = 0; i < value.length(); i++) {
+ char c = value.charAt(i);
+ if (PhoneNumberUtils.isStartsPostDial(c)) {
+ sb.append(c);
+ } else if (PhoneNumberUtils.isDialable(c)) {
+ sb.append("*");
+ } else if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
+ sb.append("*");
+ } else {
+ sb.append(c);
+ }
+ }
+ }
+ return sb.toString();
+
+ }
+
private static String secureHash(byte[] input) {
if (sMessageDigest != null) {
sMessageDigest.reset();
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 857d2df..605e0d3 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -1425,6 +1425,7 @@
* <p> This method displays the UI to manage blocked numbers only if
* {@link android.provider.BlockedNumberContract#canCurrentUserBlockNumbers(Context)} returns
* {@code true} for the current user.
+ * @deprecated Use {@link #createManageBlockedNumbersIntent()} instead.
*/
// TODO: Delete this.
public void launchManageBlockedNumbersActivity() {
diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java
index da43460..c34d4a9 100644
--- a/test-runner/src/android/test/mock/MockPackageManager.java
+++ b/test-runner/src/android/test/mock/MockPackageManager.java
@@ -25,7 +25,6 @@
import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
-import android.content.pm.ContainerEncryptionParams;
import android.content.pm.EphemeralApplicationInfo;
import android.content.pm.FeatureInfo;
import android.content.pm.IPackageDataObserver;
@@ -44,7 +43,6 @@
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
-import android.content.pm.VerificationParams;
import android.content.pm.VerifierDeviceIdentity;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
@@ -602,14 +600,6 @@
throw new UnsupportedOperationException();
}
- /** @hide */
- @Override
- public void installPackageAsUser(Uri packageURI, PackageInstallObserver observer,
- int flags, String installerPackageName, int userId) {
- throw new UnsupportedOperationException();
- }
-
-
@Override
public void setInstallerPackageName(String targetPackage,
String installerPackageName) {
@@ -873,26 +863,6 @@
* @hide
*/
@Override
- public void installPackageWithVerification(Uri packageURI, IPackageInstallObserver observer,
- int flags, String installerPackageName, Uri verificationURI,
- ContainerEncryptionParams encryptionParams) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @hide
- */
- @Override
- public void installPackageWithVerificationAndEncryption(Uri packageURI,
- IPackageInstallObserver observer, int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @hide
- */
- @Override
public boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
UserHandle user) {
return false;
@@ -1024,27 +994,6 @@
* @hide
*/
@Override
- public void installPackageWithVerification(Uri packageURI,
- PackageInstallObserver observer, int flags, String installerPackageName,
- Uri verificationURI,
- ContainerEncryptionParams encryptionParams) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @hide
- */
- @Override
- public void installPackageWithVerificationAndEncryption(Uri packageURI,
- PackageInstallObserver observer, int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @hide
- */
- @Override
public void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, int targetUserId,
int flags) {
throw new UnsupportedOperationException();
diff --git a/tests/HwAccelerationTest/res/drawable/default_wallpaper.jpg b/tests/HwAccelerationTest/res/drawable/default_wallpaper.jpg
deleted file mode 100644
index 5acad94..0000000
--- a/tests/HwAccelerationTest/res/drawable/default_wallpaper.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/HwAccelerationTest/res/drawable/default_wallpaper.png b/tests/HwAccelerationTest/res/drawable/default_wallpaper.png
new file mode 100644
index 0000000..91ad252
--- /dev/null
+++ b/tests/HwAccelerationTest/res/drawable/default_wallpaper.png
Binary files differ
diff --git a/tools/aapt2/compile/Png.cpp b/tools/aapt2/compile/Png.cpp
index 9837c4e..bbf7f41 100644
--- a/tools/aapt2/compile/Png.cpp
+++ b/tools/aapt2/compile/Png.cpp
@@ -1175,7 +1175,7 @@
if (errorMsg) {
std::stringstream err;
err << "9-patch malformed: " << errorMsg;
- if (!errorEdge) {
+ if (errorEdge) {
err << "." << std::endl;
if (errorPixel >= 0) {
err << "Found at pixel #" << errorPixel << " along " << errorEdge << " edge";
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
index fcfbad2..85e2610 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
@@ -24,7 +24,6 @@
import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
-import android.content.pm.ContainerEncryptionParams;
import android.content.pm.EphemeralApplicationInfo;
import android.content.pm.FeatureInfo;
import android.content.pm.IPackageDataObserver;
@@ -43,7 +42,6 @@
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
-import android.content.pm.VerificationParams;
import android.content.pm.VerifierDeviceIdentity;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
@@ -555,40 +553,11 @@
}
@Override
- public void installPackageWithVerification(Uri packageURI, IPackageInstallObserver observer,
- int flags, String installerPackageName, Uri verificationURI,
- ContainerEncryptionParams encryptionParams) {
- }
-
- @Override
- public void installPackageWithVerificationAndEncryption(Uri packageURI,
- IPackageInstallObserver observer, int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
- }
-
- @Override
public void installPackage(Uri packageURI, PackageInstallObserver observer, int flags,
String installerPackageName) {
}
@Override
- public void installPackageAsUser(Uri packageURI, PackageInstallObserver observer,int flags,
- String installerPackageName, int userId) {
- }
-
- @Override
- public void installPackageWithVerification(Uri packageURI, PackageInstallObserver observer,
- int flags, String installerPackageName, Uri verificationURI,
- ContainerEncryptionParams encryptionParams) {
- }
-
- @Override
- public void installPackageWithVerificationAndEncryption(Uri packageURI,
- PackageInstallObserver observer, int flags, String installerPackageName,
- VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
- }
-
- @Override
public int installExistingPackage(String packageName) throws NameNotFoundException {
return 0;
}
diff --git a/wifi/java/android/net/wifi/RttManager.java b/wifi/java/android/net/wifi/RttManager.java
index 59416b8..13abaff 100644
--- a/wifi/java/android/net/wifi/RttManager.java
+++ b/wifi/java/android/net/wifi/RttManager.java
@@ -300,7 +300,7 @@
try {
mRttCapabilities = mService.getRttCapabilities();
} catch (RemoteException e) {
- Log.e(TAG, "Can not get RTT Capabilities");
+ throw e.rethrowFromSystemServer();
}
}
return mRttCapabilities;
@@ -1132,7 +1132,7 @@
Log.d(TAG, "Get the messenger from " + mService);
messenger = mService.getMessenger();
} catch (RemoteException e) {
- /* do nothing */
+ throw e.rethrowFromSystemServer();
} catch (SecurityException e) {
/* do nothing */
}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 4921073..e2dd111 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -39,9 +39,9 @@
import android.util.Log;
import android.util.SparseArray;
-import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.AsyncChannel;
import com.android.internal.util.Protocol;
+import com.android.server.net.NetworkPinner;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -678,11 +678,6 @@
private static int sThreadRefCount;
private static HandlerThread sHandlerThread;
- @GuardedBy("sCM")
- // TODO: Introduce refcounting and make this a per-process static callback, instead of a
- // per-WifiManager callback.
- private PinningNetworkCallback mNetworkCallback;
-
/**
* Create a new WifiManager instance.
* Applications will almost always want to use
@@ -723,8 +718,7 @@
try {
return mService.getConfiguredNetworks();
} catch (RemoteException e) {
- Log.w(TAG, "Caught RemoteException trying to get configured networks: " + e);
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -734,7 +728,7 @@
try {
return mService.getPrivilegedConfiguredNetworks();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -744,7 +738,7 @@
try {
return mService.getConnectionStatistics();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -758,7 +752,7 @@
try {
return mService.getMatchingWifiConfig(scanResult);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -818,7 +812,7 @@
try {
return mService.addOrUpdateNetwork(config);
} catch (RemoteException e) {
- return -1;
+ throw e.rethrowFromSystemServer();
}
}
@@ -832,7 +826,7 @@
try {
return mService.addPasspointManagementObject(mo);
} catch (RemoteException e) {
- return -1;
+ throw e.rethrowFromSystemServer();
}
}
@@ -848,7 +842,7 @@
try {
return mService.modifyPasspointManagementObject(fqdn, mos);
} catch (RemoteException e) {
- return -1;
+ throw e.rethrowFromSystemServer();
}
}
@@ -862,6 +856,7 @@
try {
mService.queryPasspointIcon(bssid, fileName);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -875,7 +870,7 @@
try {
return mService.matchProviderWithCurrentNetwork(fqdn);
} catch (RemoteException e) {
- return -1;
+ throw e.rethrowFromSystemServer();
}
}
@@ -889,6 +884,7 @@
try {
mService.deauthenticateNetwork(holdoff, ess);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -922,7 +918,7 @@
try {
return mService.removeNetwork(netId);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -955,18 +951,22 @@
public boolean enableNetwork(int netId, boolean disableOthers) {
final boolean pin = disableOthers && mTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP;
if (pin) {
- registerPinningNetworkCallback();
+ NetworkRequest request = new NetworkRequest.Builder()
+ .clearCapabilities()
+ .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
+ .build();
+ NetworkPinner.pin(mContext, request);
}
boolean success;
try {
success = mService.enableNetwork(netId, disableOthers);
} catch (RemoteException e) {
- success = false;
+ throw e.rethrowFromSystemServer();
}
if (pin && !success) {
- unregisterPinningNetworkCallback();
+ NetworkPinner.unpin();
}
return success;
@@ -983,7 +983,7 @@
try {
return mService.disableNetwork(netId);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -997,7 +997,7 @@
mService.disconnect();
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1012,7 +1012,7 @@
mService.reconnect();
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1027,7 +1027,7 @@
mService.reassociate();
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1042,7 +1042,7 @@
try {
return mService.pingSupplicant();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1090,7 +1090,7 @@
try {
return mService.getSupportedFeatures();
} catch (RemoteException e) {
- return 0;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1216,9 +1216,8 @@
return mService.reportActivityInfo();
}
} catch (RemoteException e) {
- Log.e(TAG, "getControllerActivityEnergyInfo: " + e);
+ throw e.rethrowFromSystemServer();
}
- return null;
}
/**
@@ -1232,7 +1231,7 @@
mService.startScan(null, null);
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1243,7 +1242,7 @@
mService.startScan(null, workSource);
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1299,7 +1298,7 @@
try {
return mService.getWpsNfcConfigurationToken(netId);
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1311,7 +1310,7 @@
try {
return mService.getConnectionInfo();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1328,7 +1327,7 @@
try {
return mService.getScanResults(mContext.getOpPackageName());
} catch (RemoteException e) {
- return new ArrayList<ScanResult>();
+ throw e.rethrowFromSystemServer();
}
}
@@ -1344,7 +1343,7 @@
try {
return mService.isScanAlwaysAvailable();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1361,7 +1360,7 @@
try {
return mService.saveConfiguration();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1375,7 +1374,9 @@
public void setCountryCode(String country, boolean persist) {
try {
mService.setCountryCode(country, persist);
- } catch (RemoteException e) { }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -1387,9 +1388,9 @@
public String getCountryCode() {
try {
String country = mService.getCountryCode();
- return(country);
+ return country;
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1405,7 +1406,9 @@
public void setFrequencyBand(int band, boolean persist) {
try {
mService.setFrequencyBand(band, persist);
- } catch (RemoteException e) { }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -1421,7 +1424,7 @@
try {
return mService.getFrequencyBand();
} catch (RemoteException e) {
- return -1;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1434,7 +1437,7 @@
try {
return mService.isDualBandSupported();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1447,7 +1450,7 @@
try {
return mService.getDhcpInfo();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1461,7 +1464,7 @@
try {
return mService.setWifiEnabled(enabled);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1476,7 +1479,7 @@
try {
return mService.getWifiEnabledState();
} catch (RemoteException e) {
- return WIFI_STATE_UNKNOWN;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1553,7 +1556,7 @@
mService.setWifiApEnabled(wifiConfig, enabled);
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1571,7 +1574,7 @@
try {
return mService.getWifiApEnabledState();
} catch (RemoteException e) {
- return WIFI_AP_STATE_FAILED;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1598,7 +1601,7 @@
try {
return mService.getWifiApConfiguration();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1612,8 +1615,7 @@
try {
return mService.buildWifiConfig(uriString, mimeType, data);
} catch (RemoteException e) {
- Log.w(TAG, "Caught RemoteException trying to build wifi config: " + e);
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1629,7 +1631,7 @@
mService.setWifiApConfiguration(wifiConfig);
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1646,7 +1648,7 @@
mService.addToBlacklist(bssid);
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1663,7 +1665,7 @@
mService.clearBlacklist();
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1692,7 +1694,7 @@
try {
mService.enableTdls(remoteIPAddress.getHostAddress(), enable);
} catch (RemoteException e) {
- // Just ignore the exception
+ throw e.rethrowFromSystemServer();
}
}
@@ -1706,7 +1708,7 @@
try {
mService.enableTdlsWithMacAddress(remoteMacAddress, enable);
} catch (RemoteException e) {
- // Just ignore the exception
+ throw e.rethrowFromSystemServer();
}
}
@@ -2012,100 +2014,6 @@
"No permission to access and change wifi or a bad initialization");
}
- private void initConnectivityManager() {
- // TODO: what happens if an app calls a WifiManager API before ConnectivityManager is
- // registered? Can we fix this by starting ConnectivityService before WifiService?
- if (sCM == null) {
- sCM = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (sCM == null) {
- throw new IllegalStateException("Bad luck, ConnectivityService not started.");
- }
- }
- }
-
- /**
- * A NetworkCallback that pins the process to the first wifi network to connect.
- *
- * We use this to maintain compatibility with pre-M apps that call WifiManager.enableNetwork()
- * to connect to a Wi-Fi network that has no Internet access, and then assume that they will be
- * able to use that network because it's the system default.
- *
- * In order to maintain compatibility with apps that call setProcessDefaultNetwork themselves,
- * we try not to set the default network unless they have already done so, and we try not to
- * clear the default network unless we set it ourselves.
- *
- * This should maintain behaviour that's compatible with L, which would pin the whole system to
- * any wifi network that was created via enableNetwork(..., true) until that network
- * disconnected.
- *
- * Note that while this hack allows network traffic to flow, it is quite limited. For example:
- *
- * 1. setProcessDefaultNetwork only affects this process, so:
- * - Any subprocesses spawned by this process will not be pinned to Wi-Fi.
- * - If this app relies on any other apps on the device also being on Wi-Fi, that won't work
- * either, because other apps on the device will not be pinned.
- * 2. The behaviour of other APIs is not modified. For example:
- * - getActiveNetworkInfo will return the system default network, not Wi-Fi.
- * - There will be no CONNECTIVITY_ACTION broadcasts about TYPE_WIFI.
- * - getProcessDefaultNetwork will not return null, so if any apps are relying on that, they
- * will be surprised as well.
- */
- private class PinningNetworkCallback extends NetworkCallback {
- private Network mPinnedNetwork;
-
- @Override
- public void onPreCheck(Network network) {
- if (sCM.getProcessDefaultNetwork() == null && mPinnedNetwork == null) {
- sCM.setProcessDefaultNetwork(network);
- mPinnedNetwork = network;
- Log.d(TAG, "Wifi alternate reality enabled on network " + network);
- }
- }
-
- @Override
- public void onLost(Network network) {
- if (network.equals(mPinnedNetwork) && network.equals(sCM.getProcessDefaultNetwork())) {
- sCM.setProcessDefaultNetwork(null);
- Log.d(TAG, "Wifi alternate reality disabled on network " + network);
- mPinnedNetwork = null;
- unregisterPinningNetworkCallback();
- }
- }
- }
-
- private void registerPinningNetworkCallback() {
- initConnectivityManager();
- synchronized (sCM) {
- if (mNetworkCallback == null) {
- // TODO: clear all capabilities.
- NetworkRequest request = new NetworkRequest.Builder()
- .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
- .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
- .build();
- mNetworkCallback = new PinningNetworkCallback();
- try {
- sCM.registerNetworkCallback(request, mNetworkCallback);
- } catch (SecurityException e) {
- Log.d(TAG, "Failed to register network callback", e);
- }
- }
- }
- }
-
- private void unregisterPinningNetworkCallback() {
- initConnectivityManager();
- synchronized (sCM) {
- if (mNetworkCallback != null) {
- try {
- sCM.unregisterNetworkCallback(mNetworkCallback);
- } catch (SecurityException e) {
- Log.d(TAG, "Failed to unregister network callback", e);
- }
- mNetworkCallback = null;
- }
- }
- }
-
/**
* Connect to a network with the given configuration. The network also
* gets added to the supplicant configuration.
@@ -2219,6 +2127,7 @@
try {
mService.disableEphemeralNetwork(SSID);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -2259,7 +2168,7 @@
try {
return mService.getWifiServiceMessenger();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
} catch (SecurityException e) {
return null;
}
@@ -2274,7 +2183,7 @@
try {
return mService.getConfigFile();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2340,7 +2249,8 @@
}
mActiveLockCount++;
}
- } catch (RemoteException ignore) {
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
mHeld = true;
}
@@ -2367,7 +2277,8 @@
synchronized (WifiManager.this) {
mActiveLockCount--;
}
- } catch (RemoteException ignore) {
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
mHeld = false;
}
@@ -2427,6 +2338,7 @@
try {
mService.updateWifiLockWorkSource(mBinder, mWorkSource);
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2456,7 +2368,8 @@
synchronized (WifiManager.this) {
mActiveLockCount--;
}
- } catch (RemoteException ignore) {
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
}
@@ -2572,7 +2485,8 @@
}
mActiveLockCount++;
}
- } catch (RemoteException ignore) {
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
mHeld = true;
}
@@ -2611,7 +2525,8 @@
synchronized (WifiManager.this) {
mActiveLockCount--;
}
- } catch (RemoteException ignore) {
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
mHeld = false;
}
@@ -2685,7 +2600,7 @@
try {
return mService.isMulticastEnabled();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2698,7 +2613,7 @@
mService.initializeMulticastFiltering();
return true;
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2736,7 +2651,7 @@
try {
return mService.getVerboseLoggingLevel();
} catch (RemoteException e) {
- return 0;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2748,7 +2663,7 @@
try {
mService.enableAggressiveHandover(enabled);
} catch (RemoteException e) {
-
+ throw e.rethrowFromSystemServer();
}
}
@@ -2761,7 +2676,7 @@
try {
return mService.getAggressiveHandover();
} catch (RemoteException e) {
- return 0;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2773,7 +2688,7 @@
try {
mService.setAllowScansWithTraffic(enabled);
} catch (RemoteException e) {
-
+ throw e.rethrowFromSystemServer();
}
}
@@ -2785,7 +2700,7 @@
try {
return mService.getAllowScansWithTraffic();
} catch (RemoteException e) {
- return 0;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2798,6 +2713,7 @@
try {
mService.factoryReset();
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -2810,7 +2726,7 @@
try {
return mService.getCurrentNetwork();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2824,7 +2740,7 @@
try {
return mService.enableAutoJoinWhenAssociated(enabled);
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
@@ -2836,7 +2752,7 @@
try {
return mService.getEnableAutoJoinWhenAssociated();
} catch (RemoteException e) {
- return false;
+ throw e.rethrowFromSystemServer();
}
}
/**
@@ -2847,7 +2763,7 @@
try {
mService.setHalBasedAutojoinOffload(enabled);
} catch (RemoteException e) {
-
+ throw e.rethrowFromSystemServer();
}
}
@@ -2859,7 +2775,7 @@
try {
return mService.getHalBasedAutojoinOffload();
} catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
- return 0;
}
}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanManager.java b/wifi/java/android/net/wifi/nan/WifiNanManager.java
index 667c4b1..1b78beb 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanManager.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanManager.java
@@ -75,7 +75,7 @@
}
mService.connect(mBinder, listener.callback, events);
} catch (RemoteException e) {
- Log.w(TAG, "connect RemoteException (FYI - ignoring): " + e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -94,7 +94,7 @@
mService.disconnect(mBinder);
mBinder = null;
} catch (RemoteException e) {
- Log.w(TAG, "disconnect RemoteException (FYI - ignoring): " + e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -116,7 +116,7 @@
try {
mService.requestConfig(configRequest);
} catch (RemoteException e) {
- Log.w(TAG, "requestConfig RemoteException (FYI - ignoring): " + e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -173,8 +173,7 @@
if (DBG) Log.d(TAG, "publish: session created - sessionId=" + sessionId);
mService.publish(sessionId, publishData, publishSettings);
} catch (RemoteException e) {
- Log.w(TAG, "createSession/publish RemoteException: " + e);
- return null;
+ throw e.rethrowFromSystemServer();
}
return new WifiNanPublishSession(this, sessionId);
@@ -200,7 +199,7 @@
try {
mService.publish(sessionId, publishData, publishSettings);
} catch (RemoteException e) {
- Log.w(TAG, "publish RemoteException: " + e);
+ throw e.rethrowFromSystemServer();
}
}
/**
@@ -256,8 +255,7 @@
if (DBG) Log.d(TAG, "subscribe: session created - sessionId=" + sessionId);
mService.subscribe(sessionId, subscribeData, subscribeSettings);
} catch (RemoteException e) {
- Log.w(TAG, "createSession/subscribe RemoteException: " + e);
- return null;
+ throw e.rethrowFromSystemServer();
}
return new WifiNanSubscribeSession(this, sessionId);
@@ -286,7 +284,7 @@
try {
mService.subscribe(sessionId, subscribeData, subscribeSettings);
} catch (RemoteException e) {
- Log.w(TAG, "subscribe RemoteException: " + e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -299,7 +297,7 @@
try {
mService.stopSession(sessionId);
} catch (RemoteException e) {
- Log.w(TAG, "stopSession RemoteException (FYI - ignoring): " + e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -312,7 +310,7 @@
try {
mService.destroySession(sessionId);
} catch (RemoteException e) {
- Log.w(TAG, "destroySession RemoteException (FYI - ignoring): " + e);
+ throw e.rethrowFromSystemServer();
}
}
@@ -328,7 +326,7 @@
}
mService.sendMessage(sessionId, peerId, message, messageLength, messageId);
} catch (RemoteException e) {
- Log.w(TAG, "subscribe RemoteException (FYI - ignoring): " + e);
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index 6409450..8d5cf63 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -1362,8 +1362,8 @@
public void setMiracastMode(int mode) {
try {
mService.setMiracastMode(mode);
- } catch(RemoteException e) {
- // ignore
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
}
@@ -1378,7 +1378,7 @@
try {
return mService.getMessenger();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}
@@ -1393,7 +1393,7 @@
try {
return mService.getP2pStateMachineMessenger();
} catch (RemoteException e) {
- return null;
+ throw e.rethrowFromSystemServer();
}
}