Merge "Keyboard shortcuts: minor type change" into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index fbbb2e3..732c500 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9498,9 +9498,10 @@
public class LauncherApps {
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
- method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo, android.os.UserHandle);
- method public int getShortcutIconResId(android.content.pm.ShortcutInfo, android.os.UserHandle);
- method public java.util.List<android.content.pm.ShortcutInfo> getShortcutInfo(java.lang.String, java.util.List<java.lang.String>, android.os.UserHandle);
+ method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo);
+ method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle);
+ method public int getShortcutIconResId(android.content.pm.ShortcutInfo);
+ method public int getShortcutIconResId(java.lang.String, java.lang.String, android.os.UserHandle);
method public java.util.List<android.content.pm.ShortcutInfo> getShortcuts(android.content.pm.LauncherApps.ShortcutQuery, android.os.UserHandle);
method public boolean hasShortcutHostPermission();
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
@@ -9512,6 +9513,7 @@
method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
method public boolean startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
+ method public boolean startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
}
@@ -9533,6 +9535,7 @@
method public void setChangedSince(long);
method public void setPackage(java.lang.String);
method public void setQueryFlags(int);
+ method public void setShortcutIds(java.util.List<java.lang.String>);
field public static final int FLAG_GET_DYNAMIC = 1; // 0x1
field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
field public static final int FLAG_GET_PINNED = 2; // 0x2
@@ -10046,6 +10049,7 @@
method public java.lang.String getPackageName();
method public java.lang.String getText();
method public java.lang.String getTitle();
+ method public android.os.UserHandle getUserHandle();
method public int getWeight();
method public boolean hasIconFile();
method public boolean hasIconResource();
@@ -19853,8 +19857,8 @@
public class AudioRecord implements android.media.AudioRouting {
ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
+ method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public deprecated void addOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener, android.os.Handler);
- method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public int getAudioFormat();
method public int getAudioSessionId();
method public int getAudioSource();
@@ -19879,8 +19883,8 @@
method public int read(java.nio.ByteBuffer, int);
method public int read(java.nio.ByteBuffer, int, int);
method public void release();
+ method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public deprecated void removeOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener);
- method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
method public int setNotificationMarkerPosition(int);
method public int setPositionNotificationPeriod(int);
method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
@@ -19914,8 +19918,9 @@
method public abstract void onPeriodicNotification(android.media.AudioRecord);
}
- public static abstract interface AudioRecord.OnRoutingChangedListener {
+ public static abstract deprecated interface AudioRecord.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
method public abstract void onRoutingChanged(android.media.AudioRecord);
+ method public default void onRoutingChanged(android.media.AudioRouting);
}
public final class AudioRecordingConfiguration implements android.os.Parcelable {
@@ -19930,10 +19935,10 @@
}
public abstract interface AudioRouting {
- method public abstract void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
+ method public abstract void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public abstract android.media.AudioDeviceInfo getPreferredDevice();
method public abstract android.media.AudioDeviceInfo getRoutedDevice();
- method public abstract void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
+ method public abstract void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public abstract boolean setPreferredDevice(android.media.AudioDeviceInfo);
}
@@ -19953,8 +19958,8 @@
ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException;
+ method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler);
- method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public int attachAuxEffect(int);
method public void flush();
method public int getAudioFormat();
@@ -19986,8 +19991,8 @@
method public void play() throws java.lang.IllegalStateException;
method public void release();
method public int reloadStaticData();
+ method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public deprecated void removeOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener);
- method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
method public int setAuxEffectSendLevel(float);
method public int setBufferSizeInFrames(int);
method public int setLoopPoints(int, int, int);
@@ -20041,8 +20046,9 @@
method public abstract void onPeriodicNotification(android.media.AudioTrack);
}
- public static abstract deprecated interface AudioTrack.OnRoutingChangedListener {
- method public abstract deprecated void onRoutingChanged(android.media.AudioTrack);
+ public static abstract deprecated interface AudioTrack.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
+ method public abstract void onRoutingChanged(android.media.AudioTrack);
+ method public default void onRoutingChanged(android.media.AudioRouting);
}
public class CamcorderProfile {
@@ -20718,10 +20724,12 @@
field public static final int VP9Level6 = 1024; // 0x400
field public static final int VP9Level61 = 2048; // 0x800
field public static final int VP9Level62 = 4096; // 0x1000
- field public static final int VP9Profile0 = 0; // 0x0
- field public static final int VP9Profile1 = 1; // 0x1
- field public static final int VP9Profile2 = 2; // 0x2
- field public static final int VP9Profile3 = 3; // 0x3
+ field public static final int VP9Profile0 = 1; // 0x1
+ field public static final int VP9Profile1 = 2; // 0x2
+ field public static final int VP9Profile2 = 4; // 0x4
+ field public static final int VP9Profile2HDR = 4096; // 0x1000
+ field public static final int VP9Profile3 = 8; // 0x8
+ field public static final int VP9Profile3HDR = 8192; // 0x2000
field public int level;
field public int profile;
}
diff --git a/api/system-current.txt b/api/system-current.txt
index d91f5d1..56b2f58 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -9836,9 +9836,10 @@
public class LauncherApps {
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
- method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo, android.os.UserHandle);
- method public int getShortcutIconResId(android.content.pm.ShortcutInfo, android.os.UserHandle);
- method public java.util.List<android.content.pm.ShortcutInfo> getShortcutInfo(java.lang.String, java.util.List<java.lang.String>, android.os.UserHandle);
+ method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo);
+ method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle);
+ method public int getShortcutIconResId(android.content.pm.ShortcutInfo);
+ method public int getShortcutIconResId(java.lang.String, java.lang.String, android.os.UserHandle);
method public java.util.List<android.content.pm.ShortcutInfo> getShortcuts(android.content.pm.LauncherApps.ShortcutQuery, android.os.UserHandle);
method public boolean hasShortcutHostPermission();
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
@@ -9850,6 +9851,7 @@
method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
method public boolean startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
+ method public boolean startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
}
@@ -9871,6 +9873,7 @@
method public void setChangedSince(long);
method public void setPackage(java.lang.String);
method public void setQueryFlags(int);
+ method public void setShortcutIds(java.util.List<java.lang.String>);
field public static final int FLAG_GET_DYNAMIC = 1; // 0x1
field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
field public static final int FLAG_GET_PINNED = 2; // 0x2
@@ -10446,6 +10449,7 @@
method public java.lang.String getPackageName();
method public java.lang.String getText();
method public java.lang.String getTitle();
+ method public android.os.UserHandle getUserHandle();
method public int getWeight();
method public boolean hasIconFile();
method public boolean hasIconResource();
@@ -15491,6 +15495,7 @@
public class NanoApp {
ctor public NanoApp();
+ ctor public NanoApp(int, byte[]);
method public int describeContents();
method public byte[] getAppBinary();
method public int getAppId();
@@ -21331,8 +21336,8 @@
public class AudioRecord implements android.media.AudioRouting {
ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
ctor public AudioRecord(android.media.AudioAttributes, android.media.AudioFormat, int, int) throws java.lang.IllegalArgumentException;
+ method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public deprecated void addOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener, android.os.Handler);
- method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public int getAudioFormat();
method public int getAudioSessionId();
method public int getAudioSource();
@@ -21357,8 +21362,8 @@
method public int read(java.nio.ByteBuffer, int);
method public int read(java.nio.ByteBuffer, int, int);
method public void release();
+ method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public deprecated void removeOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener);
- method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
method public int setNotificationMarkerPosition(int);
method public int setPositionNotificationPeriod(int);
method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
@@ -21394,8 +21399,9 @@
method public abstract void onPeriodicNotification(android.media.AudioRecord);
}
- public static abstract interface AudioRecord.OnRoutingChangedListener {
+ public static abstract deprecated interface AudioRecord.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
method public abstract void onRoutingChanged(android.media.AudioRecord);
+ method public default void onRoutingChanged(android.media.AudioRouting);
}
public final class AudioRecordingConfiguration implements android.os.Parcelable {
@@ -21410,10 +21416,10 @@
}
public abstract interface AudioRouting {
- method public abstract void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
+ method public abstract void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public abstract android.media.AudioDeviceInfo getPreferredDevice();
method public abstract android.media.AudioDeviceInfo getRoutedDevice();
- method public abstract void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
+ method public abstract void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public abstract boolean setPreferredDevice(android.media.AudioDeviceInfo);
}
@@ -21433,8 +21439,8 @@
ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException;
+ method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler);
- method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public int attachAuxEffect(int);
method public void flush();
method public int getAudioFormat();
@@ -21466,8 +21472,8 @@
method public void play() throws java.lang.IllegalStateException;
method public void release();
method public int reloadStaticData();
+ method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public deprecated void removeOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener);
- method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
method public int setAuxEffectSendLevel(float);
method public int setBufferSizeInFrames(int);
method public int setLoopPoints(int, int, int);
@@ -21521,8 +21527,9 @@
method public abstract void onPeriodicNotification(android.media.AudioTrack);
}
- public static abstract deprecated interface AudioTrack.OnRoutingChangedListener {
- method public abstract deprecated void onRoutingChanged(android.media.AudioTrack);
+ public static abstract deprecated interface AudioTrack.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
+ method public abstract void onRoutingChanged(android.media.AudioTrack);
+ method public default void onRoutingChanged(android.media.AudioRouting);
}
public class CamcorderProfile {
@@ -22198,10 +22205,12 @@
field public static final int VP9Level6 = 1024; // 0x400
field public static final int VP9Level61 = 2048; // 0x800
field public static final int VP9Level62 = 4096; // 0x1000
- field public static final int VP9Profile0 = 0; // 0x0
- field public static final int VP9Profile1 = 1; // 0x1
- field public static final int VP9Profile2 = 2; // 0x2
- field public static final int VP9Profile3 = 3; // 0x3
+ field public static final int VP9Profile0 = 1; // 0x1
+ field public static final int VP9Profile1 = 2; // 0x2
+ field public static final int VP9Profile2 = 4; // 0x4
+ field public static final int VP9Profile2HDR = 4096; // 0x1000
+ field public static final int VP9Profile3 = 8; // 0x8
+ field public static final int VP9Profile3HDR = 8192; // 0x2000
field public int level;
field public int profile;
}
diff --git a/api/test-current.txt b/api/test-current.txt
index bad9733..679347d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -9505,11 +9505,13 @@
}
public class LauncherApps {
+ ctor public LauncherApps(android.content.Context);
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
- method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo, android.os.UserHandle);
- method public int getShortcutIconResId(android.content.pm.ShortcutInfo, android.os.UserHandle);
- method public java.util.List<android.content.pm.ShortcutInfo> getShortcutInfo(java.lang.String, java.util.List<java.lang.String>, android.os.UserHandle);
+ method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo);
+ method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle);
+ method public int getShortcutIconResId(android.content.pm.ShortcutInfo);
+ method public int getShortcutIconResId(java.lang.String, java.lang.String, android.os.UserHandle);
method public java.util.List<android.content.pm.ShortcutInfo> getShortcuts(android.content.pm.LauncherApps.ShortcutQuery, android.os.UserHandle);
method public boolean hasShortcutHostPermission();
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
@@ -9521,6 +9523,7 @@
method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
method public boolean startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
+ method public boolean startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
}
@@ -9542,6 +9545,7 @@
method public void setChangedSince(long);
method public void setPackage(java.lang.String);
method public void setQueryFlags(int);
+ method public void setShortcutIds(java.util.List<java.lang.String>);
field public static final int FLAG_GET_DYNAMIC = 1; // 0x1
field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
field public static final int FLAG_GET_PINNED = 2; // 0x2
@@ -10056,6 +10060,7 @@
method public java.lang.String getPackageName();
method public java.lang.String getText();
method public java.lang.String getTitle();
+ method public android.os.UserHandle getUserHandle();
method public int getWeight();
method public boolean hasIconFile();
method public boolean hasIconResource();
@@ -10088,6 +10093,7 @@
}
public class ShortcutManager {
+ ctor public ShortcutManager(android.content.Context);
method public boolean addDynamicShortcut(android.content.pm.ShortcutInfo);
method public void deleteAllDynamicShortcuts();
method public void deleteDynamicShortcut(java.lang.String);
@@ -19919,8 +19925,8 @@
public class AudioRecord implements android.media.AudioRouting {
ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
+ method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public deprecated void addOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener, android.os.Handler);
- method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public int getAudioFormat();
method public int getAudioSessionId();
method public int getAudioSource();
@@ -19945,8 +19951,8 @@
method public int read(java.nio.ByteBuffer, int);
method public int read(java.nio.ByteBuffer, int, int);
method public void release();
+ method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public deprecated void removeOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener);
- method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
method public int setNotificationMarkerPosition(int);
method public int setPositionNotificationPeriod(int);
method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
@@ -19980,8 +19986,9 @@
method public abstract void onPeriodicNotification(android.media.AudioRecord);
}
- public static abstract interface AudioRecord.OnRoutingChangedListener {
+ public static abstract deprecated interface AudioRecord.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
method public abstract void onRoutingChanged(android.media.AudioRecord);
+ method public default void onRoutingChanged(android.media.AudioRouting);
}
public final class AudioRecordingConfiguration implements android.os.Parcelable {
@@ -19996,10 +20003,10 @@
}
public abstract interface AudioRouting {
- method public abstract void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
+ method public abstract void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public abstract android.media.AudioDeviceInfo getPreferredDevice();
method public abstract android.media.AudioDeviceInfo getRoutedDevice();
- method public abstract void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
+ method public abstract void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public abstract boolean setPreferredDevice(android.media.AudioDeviceInfo);
}
@@ -20019,8 +20026,8 @@
ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException;
+ method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler);
- method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
method public int attachAuxEffect(int);
method public void flush();
method public int getAudioFormat();
@@ -20052,8 +20059,8 @@
method public void play() throws java.lang.IllegalStateException;
method public void release();
method public int reloadStaticData();
+ method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
method public deprecated void removeOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener);
- method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
method public int setAuxEffectSendLevel(float);
method public int setBufferSizeInFrames(int);
method public int setLoopPoints(int, int, int);
@@ -20107,8 +20114,9 @@
method public abstract void onPeriodicNotification(android.media.AudioTrack);
}
- public static abstract deprecated interface AudioTrack.OnRoutingChangedListener {
- method public abstract deprecated void onRoutingChanged(android.media.AudioTrack);
+ public static abstract deprecated interface AudioTrack.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
+ method public abstract void onRoutingChanged(android.media.AudioTrack);
+ method public default void onRoutingChanged(android.media.AudioRouting);
}
public class CamcorderProfile {
@@ -20784,10 +20792,12 @@
field public static final int VP9Level6 = 1024; // 0x400
field public static final int VP9Level61 = 2048; // 0x800
field public static final int VP9Level62 = 4096; // 0x1000
- field public static final int VP9Profile0 = 0; // 0x0
- field public static final int VP9Profile1 = 1; // 0x1
- field public static final int VP9Profile2 = 2; // 0x2
- field public static final int VP9Profile3 = 3; // 0x3
+ field public static final int VP9Profile0 = 1; // 0x1
+ field public static final int VP9Profile1 = 2; // 0x2
+ field public static final int VP9Profile2 = 4; // 0x4
+ field public static final int VP9Profile2HDR = 4096; // 0x1000
+ field public static final int VP9Profile3 = 8; // 0x8
+ field public static final int VP9Profile3HDR = 8192; // 0x2000
field public int level;
field public int profile;
}
diff --git a/core/java/android/app/LoaderManager.java b/core/java/android/app/LoaderManager.java
index f0e35c9..f203f46 100644
--- a/core/java/android/app/LoaderManager.java
+++ b/core/java/android/app/LoaderManager.java
@@ -318,7 +318,7 @@
if (mStarted) {
if (mReportNextStart) {
mReportNextStart = false;
- if (mHaveData) {
+ if (mHaveData && !mRetaining) {
callOnLoadFinished(mLoader, mData);
}
}
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 4bf1aa3..784872c 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1955,9 +1955,16 @@
* @hide
*/
public static void addFieldsFromContext(Context context, Notification notification) {
- notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO,
- context.getApplicationInfo());
- notification.extras.putInt(EXTRA_ORIGINATING_USERID, context.getUserId());
+ addFieldsFromContext(context.getApplicationInfo(), context.getUserId(), notification);
+ }
+
+ /**
+ * @hide
+ */
+ public static void addFieldsFromContext(ApplicationInfo ai, int userId,
+ Notification notification) {
+ notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, ai);
+ notification.extras.putInt(EXTRA_ORIGINATING_USERID, userId);
}
@Override
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index bdc4404..d5d4ca7 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -589,9 +589,7 @@
new CachedServiceFetcher<LauncherApps>() {
@Override
public LauncherApps createService(ContextImpl ctx) {
- IBinder b = ServiceManager.getService(Context.LAUNCHER_APPS_SERVICE);
- ILauncherApps service = ILauncherApps.Stub.asInterface(b);
- return new LauncherApps(ctx, service);
+ return new LauncherApps(ctx);
}});
registerService(Context.RESTRICTIONS_SERVICE, RestrictionsManager.class,
@@ -758,8 +756,7 @@
new CachedServiceFetcher<ShortcutManager>() {
@Override
public ShortcutManager createService(ContextImpl ctx) {
- IBinder b = ServiceManager.getService(Context.SHORTCUT_SERVICE);
- return new ShortcutManager(ctx, IShortcutService.Stub.asInterface(b));
+ return new ShortcutManager(ctx);
}});
registerService(Context.SYSTEM_HEALTH_SERVICE, SystemHealthManager.class,
diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl
index 6b3d4f1..46321a4 100644
--- a/core/java/android/content/pm/ILauncherApps.aidl
+++ b/core/java/android/content/pm/ILauncherApps.aidl
@@ -47,17 +47,16 @@
ApplicationInfo getApplicationInfo(String packageName, int flags, in UserHandle user);
ParceledListSlice getShortcuts(String callingPackage, long changedSince, String packageName,
- in ComponentName componentName, int flags, in UserHandle user);
- ParceledListSlice getShortcutInfo(String callingPackage, String packageName, in List<String> ids,
- in UserHandle user);
+ in List shortcutIds, in ComponentName componentName, int flags, in UserHandle user);
void pinShortcuts(String callingPackage, String packageName, in List<String> shortcutIds,
in UserHandle user);
boolean startShortcut(String callingPackage, String packageName, String id,
- in Rect sourceBounds, in Bundle startActivityOptions, in UserHandle user);
+ in Rect sourceBounds, in Bundle startActivityOptions, int userId);
- int getShortcutIconResId(String callingPackage, in ShortcutInfo shortcut, in UserHandle user);
- ParcelFileDescriptor getShortcutIconFd(String callingPackage, in ShortcutInfo shortcut,
- in UserHandle user);
+ int getShortcutIconResId(String callingPackage, String packageName, String id,
+ int userId);
+ ParcelFileDescriptor getShortcutIconFd(String callingPackage, String packageName, String id,
+ int userId);
boolean hasShortcutHostPermission(String callingPackage);
}
diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java
index d865f345..a0d2339 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -19,6 +19,7 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.TestApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -30,6 +31,7 @@
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
@@ -205,6 +207,9 @@
String mPackage;
@Nullable
+ List<String> mShortcutIds;
+
+ @Nullable
ComponentName mActivity;
@QueryFlags
@@ -229,6 +234,14 @@
}
/**
+ * If non-null, return only the specified shortcuts by ID. When setting this field,
+ * a packange name must also be set with {@link #setPackage}.
+ */
+ public void setShortcutIds(@Nullable List<String> shortcutIds) {
+ mShortcutIds = shortcutIds;
+ }
+
+ /**
* If non-null, returns only shortcuts associated with the activity.
*/
public void setActivity(@Nullable ComponentName activity) {
@@ -250,6 +263,13 @@
mPm = context.getPackageManager();
}
+ /** @hide */
+ @TestApi
+ public LauncherApps(Context context) {
+ this(context, ILauncherApps.Stub.asInterface(
+ ServiceManager.getService(Context.LAUNCHER_APPS_SERVICE)));
+ }
+
/**
* Retrieves a list of launchable activities that match {@link Intent#ACTION_MAIN} and
* {@link Intent#CATEGORY_LAUNCHER}, for a specified user.
@@ -429,7 +449,8 @@
@NonNull UserHandle user) {
try {
return mService.getShortcuts(mContext.getPackageName(),
- query.mChangedSince, query.mPackage, query.mActivity, query.mQueryFlags, user)
+ query.mChangedSince, query.mPackage, query.mShortcutIds, query.mActivity,
+ query.mQueryFlags, user)
.getList();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -437,29 +458,18 @@
}
/**
- * Returns {@link ShortcutInfo}s with the given IDs from a package.
- *
- * <p>Callers must be allowed to access the shortcut information, as defined in {@link
- * #hasShortcutHostPermission()}.
- *
- * @param packageName The target package.
- * @param ids IDs of the shortcuts to retrieve.
- * @param user The UserHandle of the profile.
- *
- * @return list of {@link ShortcutInfo} associated with the package.
+ * @hide // No longer used. Use getShortcuts() instead. Kept for unit tests.
*/
@Nullable
public List<ShortcutInfo> getShortcutInfo(@NonNull String packageName,
@NonNull List<String> ids, @NonNull UserHandle user) {
- try {
- return mService.getShortcutInfo(mContext.getPackageName(), packageName, ids, user)
- .getList();
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
+ final ShortcutQuery q = new ShortcutQuery();
+ q.setPackage(packageName);
+ q.setShortcutIds(ids);
+ q.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED);
+ return getShortcuts(q, user);
}
-
/**
* Pin shortcuts on a package.
*
@@ -490,11 +500,33 @@
* #hasShortcutHostPermission()}.
*
* @param shortcut The target shortcut.
+ */
+ public int getShortcutIconResId(@NonNull ShortcutInfo shortcut) {
+ return getShortcutIconResId(shortcut.getPackageName(), shortcut.getId(),
+ shortcut.getUserId());
+ }
+
+ /**
+ * Return the icon resource ID, if {@code shortcut} has one
+ * (i.e. when {@link ShortcutInfo#hasIconResource()} returns {@code true}).
+ *
+ * <p>Callers must be allowed to access the shortcut information, as defined in {@link
+ * #hasShortcutHostPermission()}.
+ *
+ * @param packageName The target package name.
+ * @param shortcutId The ID of the shortcut to lad rom.
* @param user The UserHandle of the profile.
*/
- public int getShortcutIconResId(@NonNull ShortcutInfo shortcut, @NonNull UserHandle user) {
+ public int getShortcutIconResId(@NonNull String packageName, @NonNull String shortcutId,
+ @NonNull UserHandle user) {
+ return getShortcutIconResId(packageName, shortcutId, user.getIdentifier());
+ }
+
+ private int getShortcutIconResId(@NonNull String packageName, @NonNull String shortcutId,
+ int userId) {
try {
- return mService.getShortcutIconResId(mContext.getPackageName(), shortcut, user);
+ return mService.getShortcutIconResId(mContext.getPackageName(),
+ packageName, shortcutId, userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -508,12 +540,34 @@
* #hasShortcutHostPermission()}.
*
* @param shortcut The target shortcut.
+ */
+ public ParcelFileDescriptor getShortcutIconFd(
+ @NonNull ShortcutInfo shortcut) {
+ return getShortcutIconFd(shortcut.getPackageName(), shortcut.getId(),
+ shortcut.getUserId());
+ }
+
+ /**
+ * Return the icon as {@link ParcelFileDescriptor}, when it's stored as a file
+ * (i.e. when {@link ShortcutInfo#hasIconFile()} returns {@code true}).
+ *
+ * <p>Callers must be allowed to access the shortcut information, as defined in {@link
+ * #hasShortcutHostPermission()}.
+ *
+ * @param packageName The target package name.
+ * @param shortcutId The ID of the shortcut to lad rom.
* @param user The UserHandle of the profile.
*/
public ParcelFileDescriptor getShortcutIconFd(
- @NonNull ShortcutInfo shortcut, @NonNull UserHandle user) {
+ @NonNull String packageName, @NonNull String shortcutId, @NonNull UserHandle user) {
+ return getShortcutIconFd(packageName, shortcutId, user.getIdentifier());
+ }
+
+ private ParcelFileDescriptor getShortcutIconFd(
+ @NonNull String packageName, @NonNull String shortcutId, int userId) {
try {
- return mService.getShortcutIconFd(mContext.getPackageName(), shortcut, user);
+ return mService.getShortcutIconFd(mContext.getPackageName(),
+ packageName, shortcutId, userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -536,9 +590,35 @@
public boolean startShortcut(@NonNull String packageName, @NonNull String shortcutId,
@Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions,
@NonNull UserHandle user) {
+ return startShortcut(packageName, shortcutId, sourceBounds, startActivityOptions,
+ user.getIdentifier());
+ }
+
+ /**
+ * Launches a shortcut.
+ *
+ * <p>Callers must be allowed to access the shortcut information, as defined in {@link
+ * #hasShortcutHostPermission()}.
+ *
+ * @param shortcut The target shortcut.
+ * @param sourceBounds The Rect containing the source bounds of the clicked icon.
+ * @param startActivityOptions Options to pass to startActivity.
+ * @return {@code false} when the shortcut is no longer valid (e.g. the creator application
+ * has been uninstalled). {@code true} when the shortcut is still valid.
+ */
+ public boolean startShortcut(@NonNull ShortcutInfo shortcut,
+ @Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions) {
+ return startShortcut(shortcut.getPackageName(), shortcut.getId(),
+ sourceBounds, startActivityOptions,
+ shortcut.getUserId());
+ }
+
+ private boolean startShortcut(@NonNull String packageName, @NonNull String shortcutId,
+ @Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions,
+ int userId) {
try {
return mService.startShortcut(mContext.getPackageName(), packageName, shortcutId,
- sourceBounds, startActivityOptions, user);
+ sourceBounds, startActivityOptions, userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/core/java/android/content/pm/ShortcutInfo.java b/core/java/android/content/pm/ShortcutInfo.java
index 1812575a..7a807c4 100644
--- a/core/java/android/content/pm/ShortcutInfo.java
+++ b/core/java/android/content/pm/ShortcutInfo.java
@@ -18,6 +18,7 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.UserIdInt;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -153,7 +154,11 @@
@Nullable
private String mBitmapPath;
+ private final int mUserId;
+
private ShortcutInfo(Builder b) {
+ mUserId = b.mContext.getUserId();
+
mId = Preconditions.checkStringNotEmpty(b.mId, "Shortcut ID must be provided");
// Note we can't do other null checks here because SM.updateShortcuts() takes partial
@@ -191,6 +196,7 @@
* Copy constructor.
*/
private ShortcutInfo(ShortcutInfo source, @CloneFlags int cloneFlags) {
+ mUserId = source.mUserId;
mId = source.mId;
mPackageName = source.mPackageName;
mFlags = source.mFlags;
@@ -238,6 +244,7 @@
* @hide
*/
public void copyNonNullFieldsFrom(ShortcutInfo source) {
+ Preconditions.checkState(mUserId == source.mUserId, "Owner User ID must match");
Preconditions.checkState(mId.equals(source.mId), "ID must match");
Preconditions.checkState(mPackageName.equals(source.mPackageName),
"Package name must match");
@@ -362,8 +369,8 @@
*
* <p>For performance reasons, icons will <b>NOT</b> be available on instances
* returned by {@link ShortcutManager} or {@link LauncherApps}. Launcher applications
- * need to use {@link LauncherApps#getShortcutIconFd(ShortcutInfo, UserHandle)}
- * and {@link LauncherApps#getShortcutIconResId(ShortcutInfo, UserHandle)}.
+ * need to use {@link LauncherApps#getShortcutIconFd(ShortcutInfo)}
+ * and {@link LauncherApps#getShortcutIconResId(ShortcutInfo)}.
*/
@NonNull
public Builder setIcon(Icon icon) {
@@ -544,6 +551,18 @@
return mExtras;
}
+ /** @hide */
+ public int getUserId() {
+ return mUserId;
+ }
+
+ /**
+ * {@link UserHandle} on which the publisher created shortcuts.
+ */
+ public UserHandle getUserHandle() {
+ return UserHandle.of(mUserId);
+ }
+
/**
* Last time when any of the fields was updated.
*/
@@ -590,7 +609,7 @@
/**
* Return whether a shortcut's icon is a resource in the owning package.
*
- * @see LauncherApps#getShortcutIconResId(ShortcutInfo, UserHandle)
+ * @see LauncherApps#getShortcutIconResId(ShortcutInfo)
*/
public boolean hasIconResource() {
return hasFlags(FLAG_HAS_ICON_RES);
@@ -599,7 +618,7 @@
/**
* Return whether a shortcut's icon is stored as a file.
*
- * @see LauncherApps#getShortcutIconFd(ShortcutInfo, UserHandle)
+ * @see LauncherApps#getShortcutIconFd(ShortcutInfo)
*/
public boolean hasIconFile() {
return hasFlags(FLAG_HAS_ICON_FILE);
@@ -661,6 +680,7 @@
private ShortcutInfo(Parcel source) {
final ClassLoader cl = getClass().getClassLoader();
+ mUserId = source.readInt();
mId = source.readString();
mPackageName = source.readString();
mActivityComponent = source.readParcelable(cl);
@@ -679,6 +699,7 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mUserId);
dest.writeString(mId);
dest.writeString(mPackageName);
dest.writeParcelable(mActivityComponent, flags);
@@ -784,11 +805,13 @@
}
/** @hide */
- public ShortcutInfo(String id, String packageName, ComponentName activityComponent,
+ public ShortcutInfo(
+ @UserIdInt int userId, String id, String packageName, ComponentName activityComponent,
Icon icon, String title, String text, Intent intent,
PersistableBundle intentPersistableExtras,
int weight, PersistableBundle extras, long lastChangedTimestamp,
int flags, int iconResId, String bitmapPath) {
+ mUserId = userId;
mId = id;
mPackageName = packageName;
mActivityComponent = activityComponent;
diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java
index e4a98b5..919ccda 100644
--- a/core/java/android/content/pm/ShortcutManager.java
+++ b/core/java/android/content/pm/ShortcutManager.java
@@ -16,8 +16,11 @@
package android.content.pm;
import android.annotation.NonNull;
+import android.annotation.TestApi;
import android.content.Context;
+import android.os.IBinder;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.UserHandle;
import com.android.internal.annotations.VisibleForTesting;
@@ -97,6 +100,15 @@
}
/**
+ * @hide
+ */
+ @TestApi
+ public ShortcutManager(Context context) {
+ this(context, IShortcutService.Stub.asInterface(
+ ServiceManager.getService(Context.SHORTCUT_SERVICE)));
+ }
+
+ /**
* Publish a list of shortcuts. All existing dynamic shortcuts from the caller application
* will be replaced.
*
diff --git a/core/java/android/content/pm/ShortcutServiceInternal.java b/core/java/android/content/pm/ShortcutServiceInternal.java
index d57f2e6e..dc3d317 100644
--- a/core/java/android/content/pm/ShortcutServiceInternal.java
+++ b/core/java/android/content/pm/ShortcutServiceInternal.java
@@ -42,15 +42,10 @@
public abstract List<ShortcutInfo>
getShortcuts(int launcherUserId,
@NonNull String callingPackage, long changedSince,
- @Nullable String packageName, @Nullable ComponentName componentName,
- @ShortcutQuery.QueryFlags int flags,
+ @Nullable String packageName, @Nullable List<String> shortcutIds,
+ @Nullable ComponentName componentName, @ShortcutQuery.QueryFlags int flags,
int userId);
- public abstract List<ShortcutInfo>
- getShortcutInfo(int launcherUserId, @NonNull String callingPackage,
- @NonNull String packageName, @Nullable List<String> ids, int userId);
-
-
public abstract boolean
isPinnedByCaller(int launcherUserId, @NonNull String callingPackage,
@NonNull String packageName, @NonNull String id, int userId);
@@ -65,11 +60,11 @@
public abstract void addListener(@NonNull ShortcutChangeListener listener);
public abstract int getShortcutIconResId(int launcherUserId, @NonNull String callingPackage,
- @NonNull ShortcutInfo shortcut, int userId);
+ @NonNull String packageName, @NonNull String shortcutId, int userId);
public abstract ParcelFileDescriptor getShortcutIconFd(int launcherUserId,
@NonNull String callingPackage,
- @NonNull ShortcutInfo shortcut, int userId);
+ @NonNull String packageName, @NonNull String shortcutId, int userId);
public abstract boolean hasShortcutHostPermission(int launcherUserId,
@NonNull String callingPackage);
diff --git a/core/java/android/hardware/location/NanoApp.java b/core/java/android/hardware/location/NanoApp.java
index c8f3439..03ac4a2 100644
--- a/core/java/android/hardware/location/NanoApp.java
+++ b/core/java/android/hardware/location/NanoApp.java
@@ -18,6 +18,7 @@
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
+import android.util.Log;
/** A class describing nano apps.
* A nano app is a piece of executable code that can be
@@ -31,10 +32,15 @@
*/
@SystemApi
public class NanoApp {
+ private final String TAG = "NanoApp";
+
+ private final String UNKNOWN = "Unknown";
+
private String mPublisher;
private String mName;
private int mAppId;
+ private boolean mAppIdSet;
private int mAppVersion;
private int mNeededReadMemBytes;
@@ -45,7 +51,48 @@
private int[] mOutputEvents;
private byte[] mAppBinary;
+ /**
+ * If this version of the constructor is used, the methods
+ * {@link #setAppBinary(byte[])} and {@link #setAppId(int)} must be called
+ * prior to passing this object to any managers.
+ *
+ * @see #NanoApp(int, byte[])
+ */
public NanoApp() {
+ this(0, null);
+ mAppIdSet = false;
+ }
+
+ /**
+ * Initialize a NanoApp with the given id and binary.
+ *
+ * While this sets defaults for other fields, users will want to provide
+ * other values for those fields in most cases.
+ *
+ * @see #setPublisher(String)
+ * @see #setName(String)
+ * @see #setAppVersion(int)
+ * @see #setNeededReadMemBytes(int)
+ * @see #setNeededWriteMemBytes(int)
+ * @see #setNeededExecMemBytes(int)
+ * @see #setNeededSensors(int[])
+ * @see #setOutputEvents(int[])
+ */
+ public NanoApp(int appId, byte[] appBinary) {
+ mPublisher = UNKNOWN;
+ mName = UNKNOWN;
+
+ mAppId = appId;
+ mAppIdSet = true;
+ mAppVersion = 0;
+
+ mNeededReadMemBytes = 0;
+ mNeededWriteMemBytes = 0;
+ mNeededExecMemBytes = 0;
+
+ mNeededSensors = new int[0];
+ mOutputEvents = new int[0];
+ mAppBinary = appBinary;
}
/**
@@ -73,6 +120,7 @@
*/
public void setAppId(int appId) {
mAppId = appId;
+ mAppIdSet = true;
}
/**
@@ -144,7 +192,7 @@
* @return publisher name
*/
public String getPublisher() {
- return mPublisher;
+ return mPublisher;
}
/**
@@ -153,7 +201,7 @@
* @return app name
*/
public String getName() {
- return mName;
+ return mName;
}
/**
@@ -162,7 +210,7 @@
* @return identifier for this app
*/
public int getAppId() {
- return mAppId;
+ return mAppId;
}
/**
@@ -171,7 +219,7 @@
* @return app version
*/
public int getAppVersion() {
- return mAppVersion;
+ return mAppVersion;
}
/**
@@ -180,7 +228,7 @@
* @return readable memory needed in bytes
*/
public int getNeededReadMemBytes() {
- return mNeededReadMemBytes;
+ return mNeededReadMemBytes;
}
/**
@@ -189,7 +237,7 @@
* @return writable memory needed in bytes
*/
public int getNeededWriteMemBytes() {
- return mNeededWriteMemBytes;
+ return mNeededWriteMemBytes;
}
/**
@@ -198,7 +246,7 @@
* @return executable memory needed in bytes
*/
public int getNeededExecMemBytes() {
- return mNeededExecMemBytes;
+ return mNeededExecMemBytes;
}
/**
@@ -207,7 +255,7 @@
* @return sensors needed
*/
public int[] getNeededSensors() {
- return mNeededSensors;
+ return mNeededSensors;
}
/**
@@ -216,7 +264,7 @@
* @return generated events
*/
public int[] getOutputEvents() {
- return mOutputEvents;
+ return mOutputEvents;
}
/**
@@ -225,7 +273,7 @@
* @return app binary
*/
public byte[] getAppBinary() {
- return mAppBinary;
+ return mAppBinary;
}
private NanoApp(Parcel in) {
@@ -256,6 +304,13 @@
}
public void writeToParcel(Parcel out, int flags) {
+ if (mAppBinary == null) {
+ throw new IllegalStateException("Must set non-null AppBinary for nanoapp " + mName);
+ }
+ if (!mAppIdSet) {
+ throw new IllegalStateException("Must set AppId for nanoapp " + mName);
+ }
+
out.writeString(mPublisher);
out.writeString(mName);
out.writeInt(mAppId);
diff --git a/core/java/android/hardware/soundtrigger/KeyphraseEnrollmentInfo.java b/core/java/android/hardware/soundtrigger/KeyphraseEnrollmentInfo.java
index cc018e9..458c584 100644
--- a/core/java/android/hardware/soundtrigger/KeyphraseEnrollmentInfo.java
+++ b/core/java/android/hardware/soundtrigger/KeyphraseEnrollmentInfo.java
@@ -35,9 +35,11 @@
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
-import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
/**
* Enrollment information about the different available keyphrases.
@@ -82,8 +84,16 @@
public static final String EXTRA_VOICE_KEYPHRASE_LOCALE =
"com.android.intent.extra.VOICE_KEYPHRASE_LOCALE";
- private KeyphraseMetadata[] mKeyphrases;
- private String mEnrollmentPackage;
+ /**
+ * List of available keyphrases.
+ */
+ final private KeyphraseMetadata[] mKeyphrases;
+
+ /**
+ * Map between KeyphraseMetadata and the package name of the enrollment app that provides it.
+ */
+ final private Map<KeyphraseMetadata, String> mKeyphrasePackageMap;
+
private String mParseError;
public KeyphraseEnrollmentInfo(PackageManager pm) {
@@ -94,15 +104,17 @@
new Intent(ACTION_MANAGE_VOICE_KEYPHRASES), PackageManager.MATCH_DEFAULT_ONLY);
if (ris == null || ris.isEmpty()) {
// No application capable of enrolling for voice keyphrases is present.
- mParseError = "No enrollment application found";
+ mParseError = "No enrollment applications found";
+ mKeyphrasePackageMap = null;
+ mKeyphrases = null;
return;
}
- boolean found = false;
- ApplicationInfo ai = null;
+ List<String> parseErrors = new LinkedList<String>();
+ mKeyphrasePackageMap = new HashMap<KeyphraseMetadata, String>();
for (ResolveInfo ri : ris) {
try {
- ai = pm.getApplicationInfo(
+ ApplicationInfo ai = pm.getApplicationInfo(
ri.activityInfo.packageName, PackageManager.GET_META_DATA);
if ((ai.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) == 0) {
// The application isn't privileged (/system/priv-app).
@@ -116,27 +128,45 @@
Slog.w(TAG, ai.packageName + " does not require MANAGE_VOICE_KEYPHRASES");
continue;
}
- mEnrollmentPackage = ai.packageName;
- found = true;
- break;
+
+ mKeyphrasePackageMap.put(
+ getKeyphraseMetadataFromApplicationInfo(pm, ai, parseErrors),
+ ai.packageName);
} catch (PackageManager.NameNotFoundException e) {
- Slog.w(TAG, "error parsing voice enrollment meta-data", e);
+ String error = "error parsing voice enrollment meta-data for "
+ + ri.activityInfo.packageName;
+ parseErrors.add(error + ": " + e);
+ Slog.w(TAG, error, e);
}
}
- if (!found) {
+ if (mKeyphrasePackageMap.isEmpty()) {
+ String error = "No suitable enrollment application found";
+ parseErrors.add(error);
+ Slog.w(TAG, error);
mKeyphrases = null;
- mParseError = "No suitable enrollment application found";
- return;
+ } else {
+ mKeyphrases = mKeyphrasePackageMap.keySet().toArray(
+ new KeyphraseMetadata[mKeyphrasePackageMap.size()]);
}
+ if (!parseErrors.isEmpty()) {
+ mParseError = TextUtils.join("\n", parseErrors);
+ }
+ }
+
+ private KeyphraseMetadata getKeyphraseMetadataFromApplicationInfo(PackageManager pm,
+ ApplicationInfo ai, List<String> parseErrors) {
XmlResourceParser parser = null;
+ String packageName = ai.packageName;
+ KeyphraseMetadata keyphraseMetadata = null;
try {
parser = ai.loadXmlMetaData(pm, VOICE_KEYPHRASE_META_DATA);
if (parser == null) {
- mParseError = "No " + VOICE_KEYPHRASE_META_DATA + " meta-data for "
- + ai.packageName;
- return;
+ String error = "No " + VOICE_KEYPHRASE_META_DATA + " meta-data for " + packageName;
+ parseErrors.add(error);
+ Slog.w(TAG, error);
+ return null;
}
Resources res = pm.getResourcesForApplication(ai);
@@ -149,48 +179,55 @@
String nodeName = parser.getName();
if (!"voice-enrollment-application".equals(nodeName)) {
- mParseError = "Meta-data does not start with voice-enrollment-application tag";
- return;
+ String error = "Meta-data does not start with voice-enrollment-application tag for "
+ + packageName;
+ parseErrors.add(error);
+ Slog.w(TAG, error);
+ return null;
}
TypedArray array = res.obtainAttributes(attrs,
com.android.internal.R.styleable.VoiceEnrollmentApplication);
- initializeKeyphrasesFromTypedArray(array);
+ keyphraseMetadata = getKeyphraseFromTypedArray(array, packageName, parseErrors);
array.recycle();
} catch (XmlPullParserException e) {
- mParseError = "Error parsing keyphrase enrollment meta-data: " + e;
- Slog.w(TAG, "error parsing keyphrase enrollment meta-data", e);
- return;
+ String error = "Error parsing keyphrase enrollment meta-data for " + packageName;
+ parseErrors.add(error + ": " + e);
+ Slog.w(TAG, error, e);
} catch (IOException e) {
- mParseError = "Error parsing keyphrase enrollment meta-data: " + e;
- Slog.w(TAG, "error parsing keyphrase enrollment meta-data", e);
- return;
+ String error = "Error parsing keyphrase enrollment meta-data for " + packageName;
+ parseErrors.add(error + ": " + e);
+ Slog.w(TAG, error, e);
} catch (PackageManager.NameNotFoundException e) {
- mParseError = "Error parsing keyphrase enrollment meta-data: " + e;
- Slog.w(TAG, "error parsing keyphrase enrollment meta-data", e);
- return;
+ String error = "Error parsing keyphrase enrollment meta-data for " + packageName;
+ parseErrors.add(error + ": " + e);
+ Slog.w(TAG, error, e);
} finally {
if (parser != null) parser.close();
}
+ return keyphraseMetadata;
}
- private void initializeKeyphrasesFromTypedArray(TypedArray array) {
+ private KeyphraseMetadata getKeyphraseFromTypedArray(TypedArray array, String packageName,
+ List<String> parseErrors) {
// Get the keyphrase ID.
int searchKeyphraseId = array.getInt(
com.android.internal.R.styleable.VoiceEnrollmentApplication_searchKeyphraseId, -1);
if (searchKeyphraseId <= 0) {
- mParseError = "No valid searchKeyphraseId specified in meta-data";
- Slog.w(TAG, mParseError);
- return;
+ String error = "No valid searchKeyphraseId specified in meta-data for " + packageName;
+ parseErrors.add(error);
+ Slog.w(TAG, error);
+ return null;
}
// Get the keyphrase text.
String searchKeyphrase = array.getString(
com.android.internal.R.styleable.VoiceEnrollmentApplication_searchKeyphrase);
if (searchKeyphrase == null) {
- mParseError = "No valid searchKeyphrase specified in meta-data";
- Slog.w(TAG, mParseError);
- return;
+ String error = "No valid searchKeyphrase specified in meta-data for " + packageName;
+ parseErrors.add(error);
+ Slog.w(TAG, error);
+ return null;
}
// Get the supported locales.
@@ -198,9 +235,11 @@
com.android.internal.R.styleable
.VoiceEnrollmentApplication_searchKeyphraseSupportedLocales);
if (searchKeyphraseSupportedLocales == null) {
- mParseError = "No valid searchKeyphraseSupportedLocales specified in meta-data";
- Slog.w(TAG, mParseError);
- return;
+ String error = "No valid searchKeyphraseSupportedLocales specified in meta-data for "
+ + packageName;
+ parseErrors.add(error);
+ Slog.w(TAG, error);
+ return null;
}
ArraySet<Locale> locales = new ArraySet<>();
// Try adding locales if the locale string is non-empty.
@@ -214,9 +253,11 @@
// We catch a generic exception here because we don't want the system service
// to be affected by a malformed metadata because invalid locales were specified
// by the system application.
- mParseError = "Error reading searchKeyphraseSupportedLocales from meta-data";
- Slog.w(TAG, mParseError, ex);
- return;
+ String error = "Error reading searchKeyphraseSupportedLocales from meta-data for "
+ + packageName;
+ parseErrors.add(error);
+ Slog.w(TAG, error);
+ return null;
}
}
@@ -224,13 +265,13 @@
int recognitionModes = array.getInt(com.android.internal.R.styleable
.VoiceEnrollmentApplication_searchKeyphraseRecognitionFlags, -1);
if (recognitionModes < 0) {
- mParseError = "No valid searchKeyphraseRecognitionFlags specified in meta-data";
- Slog.w(TAG, mParseError);
- return;
+ String error = "No valid searchKeyphraseRecognitionFlags specified in meta-data for "
+ + packageName;
+ parseErrors.add(error);
+ Slog.w(TAG, error);
+ return null;
}
- mKeyphrases = new KeyphraseMetadata[1];
- mKeyphrases[0] = new KeyphraseMetadata(searchKeyphraseId, searchKeyphrase, locales,
- recognitionModes);
+ return new KeyphraseMetadata(searchKeyphraseId, searchKeyphrase, locales, recognitionModes);
}
public String getParseError() {
@@ -259,14 +300,15 @@
* given keyphrase/locale combination isn't possible.
*/
public Intent getManageKeyphraseIntent(int action, String keyphrase, Locale locale) {
- if (mEnrollmentPackage == null || mEnrollmentPackage.isEmpty()) {
+ if (mKeyphrasePackageMap == null || mKeyphrasePackageMap.isEmpty()) {
Slog.w(TAG, "No enrollment application exists");
return null;
}
- if (getKeyphraseMetadata(keyphrase, locale) != null) {
+ KeyphraseMetadata keyphraseMetadata = getKeyphraseMetadata(keyphrase, locale);
+ if (keyphraseMetadata != null) {
Intent intent = new Intent(ACTION_MANAGE_VOICE_KEYPHRASES)
- .setPackage(mEnrollmentPackage)
+ .setPackage(mKeyphrasePackageMap.get(keyphraseMetadata))
.putExtra(EXTRA_VOICE_KEYPHRASE_HINT_TEXT, keyphrase)
.putExtra(EXTRA_VOICE_KEYPHRASE_LOCALE, locale.toLanguageTag())
.putExtra(EXTRA_VOICE_KEYPHRASE_ACTION, action);
@@ -298,14 +340,13 @@
return keyphraseMetadata;
}
}
- Slog.w(TAG, "Enrollment application doesn't support the given keyphrase/locale");
+ Slog.w(TAG, "No Enrollment application supports the given keyphrase/locale");
return null;
}
@Override
public String toString() {
- return "KeyphraseEnrollmentInfo [Keyphrases=" + Arrays.toString(mKeyphrases)
- + ", EnrollmentPackage=" + mEnrollmentPackage + ", ParseError=" + mParseError
- + "]";
+ return "KeyphraseEnrollmentInfo [Keyphrases=" + mKeyphrasePackageMap.toString()
+ + ", ParseError=" + mParseError + "]";
}
}
diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl
index c38bf3c..67d3959 100644
--- a/core/java/android/os/IUserManager.aidl
+++ b/core/java/android/os/IUserManager.aidl
@@ -45,6 +45,7 @@
UserInfo getPrimaryUser();
List<UserInfo> getUsers(boolean excludeDying);
List<UserInfo> getProfiles(int userHandle, boolean enabledOnly);
+ int[] getProfileIds(int userId, boolean enabledOnly);
boolean canAddMoreManagedProfiles(int userHandle, boolean allowedToRemoveOne);
UserInfo getProfileParent(int userHandle);
boolean isSameProfileGroup(int userHandle, int otherUserHandle);
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 707d5f5..d5b3b35 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -1590,18 +1590,46 @@
* @return A non-empty list of UserHandles associated with the calling user.
*/
public List<UserHandle> getUserProfiles() {
- ArrayList<UserHandle> profiles = new ArrayList<UserHandle>();
- List<UserInfo> users;
+ int[] userIds = getProfileIds(UserHandle.myUserId(), true /* enabledOnly */);
+ List<UserHandle> result = new ArrayList<>(userIds.length);
+ for (int userId : userIds) {
+ result.add(UserHandle.of(userId));
+ }
+ return result;
+ }
+
+ /**
+ * Returns a list of ids for profiles associated with the specified user including the user
+ * itself.
+ *
+ * @param userId id of the user to return profiles for
+ * @param enabledOnly whether return only {@link UserInfo#isEnabled() enabled} profiles
+ * @return A non-empty list of ids of profiles associated with the specified user.
+ *
+ * @hide
+ */
+ public int[] getProfileIds(@UserIdInt int userId, boolean enabledOnly) {
try {
- users = mService.getProfiles(UserHandle.myUserId(), true /* enabledOnly */);
+ return mService.getProfileIds(userId, enabledOnly);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
- for (UserInfo info : users) {
- UserHandle userHandle = new UserHandle(info.id);
- profiles.add(userHandle);
- }
- return profiles;
+ }
+
+ /**
+ * @see #getProfileIds(int, boolean)
+ * @hide
+ */
+ public int[] getProfileIdsWithDisabled(@UserIdInt int userId) {
+ return getProfileIds(userId, false /* enabledOnly */);
+ }
+
+ /**
+ * @see #getProfileIds(int, boolean)
+ * @hide
+ */
+ public int[] getEnabledProfileIds(@UserIdInt int userId) {
+ return getProfileIds(userId, true /* enabledOnly */);
}
/**
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 2a3c3fe..638be51 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -6666,6 +6666,17 @@
public static final String DEVICE_PROVISIONED = "device_provisioned";
/**
+ * Whether mobile data should be allowed while the device is being provisioned.
+ * This allows the provisioning process to turn off mobile data before the user
+ * has an opportunity to set things up, preventing other processes from burning
+ * precious bytes before wifi is setup.
+ * (0 = false, 1 = true)
+ * @hide
+ */
+ public static final String DEVICE_PROVISIONING_MOBILE_DATA_ENABLED =
+ "device_provisioning_mobile_data";
+
+ /**
* The saved value for WindowManagerService.setForcedDisplaySize().
* Two integers separated by a comma. If unset, then use the real display size.
* @hide
diff --git a/core/java/android/util/Patterns.java b/core/java/android/util/Patterns.java
index 9ed4850..0a452db 100644
--- a/core/java/android/util/Patterns.java
+++ b/core/java/android/util/Patterns.java
@@ -251,9 +251,9 @@
+ "|[1-9][0-9]|[0-9]))");
/**
- * Valid UCS characters defined in RFC 3987.
+ * Valid UCS characters defined in RFC 3987. Excludes space characters.
*/
- private static final String UCS_CHAR =
+ private static final String UCS_CHAR = "[" +
"\u00A0-\uD7FF" +
"\uF900-\uFDCF" +
"\uFDF0-\uFFEF" +
@@ -270,7 +270,8 @@
"\uDA80\uDC00-\uDABF\uDFFD" +
"\uDAC0\uDC00-\uDAFF\uDFFD" +
"\uDB00\uDC00-\uDB3F\uDFFD" +
- "\uDB44\uDC00-\uDB7F\uDFFD";
+ "\uDB44\uDC00-\uDB7F\uDFFD" +
+ "&&[^\u00A0[\u2000-\u200A]\u2028\u2029\u202F\u3000]]";
/**
* Valid characters for IRI label defined in RFC 3987.
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index f44d4c1a..c972476 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -485,25 +485,15 @@
}
/**
- * Halts any current rendering into the surface. Use this if it is unclear whether
+ * Stops any rendering into the surface. Use this if it is unclear whether
* or not the surface used by the HardwareRenderer will be changing. It
- * Suspends any rendering into the surface, but will not do any destruction.
- *
- * Any subsequent draws will override the pause, resuming normal operation.
+ * Suspends any rendering into the surface, but will not do any destruction
*/
boolean pauseSurface(Surface surface) {
return nPauseSurface(mNativeProxy, surface);
}
/**
- * Hard stops or resumes rendering into the surface. This flag is used to
- * determine whether or not it is safe to use the given surface *at all*
- */
- void setStopped(boolean stopped) {
- nSetStopped(mNativeProxy, stopped);
- }
-
- /**
* Destroys all hardware rendering resources associated with the specified
* view hierarchy.
*
@@ -998,7 +988,6 @@
private static native void nInitialize(long nativeProxy, Surface window);
private static native void nUpdateSurface(long nativeProxy, Surface window);
private static native boolean nPauseSurface(long nativeProxy, Surface window);
- private static native void nSetStopped(long nativeProxy, boolean stopped);
private static native void nSetup(long nativeProxy, int width, int height,
float lightRadius, int ambientShadowAlpha, int spotShadowAlpha);
private static native void nSetLightCenter(long nativeProxy,
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 94c4cef..a324767 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1079,16 +1079,13 @@
void setWindowStopped(boolean stopped) {
if (mStopped != stopped) {
mStopped = stopped;
- final ThreadedRenderer renderer = mAttachInfo.mHardwareRenderer;
- if (renderer != null) {
- if (DEBUG_DRAW) Log.d(mTag, "WindowStopped on " + getTitle() + " set to " + mStopped);
- renderer.setStopped(mStopped);
- }
if (!mStopped) {
scheduleTraversals();
} else {
- if (renderer != null) {
- renderer.destroyHardwareResources(mView);
+ if (mAttachInfo.mHardwareRenderer != null) {
+ if (DEBUG_DRAW) Log.d(mTag, "WindowStopped on " + getTitle());
+ mAttachInfo.mHardwareRenderer.updateSurface(null);
+ mAttachInfo.mHardwareRenderer.destroyHardwareResources(mView);
}
}
}
diff --git a/core/java/android/view/inputmethod/InputMethodSubtype.java b/core/java/android/view/inputmethod/InputMethodSubtype.java
index a42f4d9..dc433b1 100644
--- a/core/java/android/view/inputmethod/InputMethodSubtype.java
+++ b/core/java/android/view/inputmethod/InputMethodSubtype.java
@@ -68,6 +68,7 @@
// TODO: remove this
private static final String EXTRA_KEY_UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME =
"UntranslatableReplacementStringInSubtypeName";
+ private static final int SUBTYPE_ID_NONE = 0;
private final boolean mIsAuxiliary;
private final boolean mOverridesImplicitlyEnabledSubtype;
@@ -157,13 +158,13 @@
* track of enabled subtypes by ID. When the IME package gets upgraded, enabled IDs will
* stay enabled even if other attributes are different. If the ID is unspecified or 0,
* Arrays.hashCode(new Object[] {locale, mode, extraValue,
- * isAuxiliary, overridesImplicitlyEnabledSubtype}) will be used instead.
+ * isAuxiliary, overridesImplicitlyEnabledSubtype, isAsciiCapable}) will be used instead.
*/
public InputMethodSubtypeBuilder setSubtypeId(int subtypeId) {
mSubtypeId = subtypeId;
return this;
}
- private int mSubtypeId = 0;
+ private int mSubtypeId = SUBTYPE_ID_NONE;
/**
* @param subtypeLocale is the locale supported by this subtype.
@@ -268,7 +269,7 @@
* subtypes by ID. When the IME package gets upgraded, enabled IDs will stay enabled even if
* other attributes are different. If the ID is unspecified or 0,
* Arrays.hashCode(new Object[] {locale, mode, extraValue,
- * isAuxiliary, overridesImplicitlyEnabledSubtype}) will be used instead.
+ * isAuxiliary, overridesImplicitlyEnabledSubtype, isAsciiCapable}) will be used instead.
*/
public InputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue,
boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype, int id) {
@@ -293,9 +294,12 @@
mIsAsciiCapable = builder.mIsAsciiCapable;
// If hashCode() of this subtype is 0 and you want to specify it as an id of this subtype,
// just specify 0 as this subtype's id. Then, this subtype's id is treated as 0.
- mSubtypeHashCode = mSubtypeId != 0 ? mSubtypeId : hashCodeInternal(mSubtypeLocale,
- mSubtypeMode, mSubtypeExtraValue, mIsAuxiliary, mOverridesImplicitlyEnabledSubtype,
- mIsAsciiCapable);
+ if (mSubtypeId != SUBTYPE_ID_NONE) {
+ mSubtypeHashCode = mSubtypeId;
+ } else {
+ mSubtypeHashCode = hashCodeInternal(mSubtypeLocale, mSubtypeMode, mSubtypeExtraValue,
+ mIsAuxiliary, mOverridesImplicitlyEnabledSubtype, mIsAsciiCapable);
+ }
}
InputMethodSubtype(Parcel source) {
@@ -501,6 +505,22 @@
return mSubtypeHashCode;
}
+ /**
+ * @hide
+ * @return {@code true} if a valid subtype ID exists.
+ */
+ public final boolean hasSubtypeId() {
+ return mSubtypeId != SUBTYPE_ID_NONE;
+ }
+
+ /**
+ * @hide
+ * @return subtype ID. {@code 0} means that not subtype ID is specified.
+ */
+ public final int getSubtypeId() {
+ return mSubtypeId;
+ }
+
@Override
public boolean equals(Object o) {
if (o instanceof InputMethodSubtype) {
diff --git a/core/java/com/android/internal/app/LocaleHelper.java b/core/java/com/android/internal/app/LocaleHelper.java
index a9d5113..7e9587a 100644
--- a/core/java/com/android/internal/app/LocaleHelper.java
+++ b/core/java/com/android/internal/app/LocaleHelper.java
@@ -90,6 +90,15 @@
return str.toUpperCase();
}
+ // For some locales we want to use a "dialect" form, for instance
+ // "Dari" instead of "Persian (Afghanistan)", or "Moldavian" instead of "Romanian (Moldova)"
+ private static boolean shouldUseDialectName(Locale locale) {
+ final String lang = locale.getLanguage();
+ return "fa".equals(lang) // Persian
+ || "ro".equals(lang) // Romanian
+ || "zh".equals(lang); // Chinese
+ }
+
/**
* Returns the locale localized for display in the provided locale.
*
@@ -99,8 +108,10 @@
* @return the localized name of the locale.
*/
public static String getDisplayName(Locale locale, Locale displayLocale, boolean sentenceCase) {
- String result = ULocale.getDisplayNameWithDialect(locale.toLanguageTag(),
- ULocale.forLocale(displayLocale));
+ final ULocale displayULocale = ULocale.forLocale(displayLocale);
+ String result = shouldUseDialectName(locale)
+ ? ULocale.getDisplayNameWithDialect(locale.toLanguageTag(), displayULocale)
+ : ULocale.getDisplayName(locale.toLanguageTag(), displayULocale);
return sentenceCase ? toSentenceCase(result, displayLocale) : result;
}
@@ -112,9 +123,7 @@
* @return the localized name of the locale.
*/
public static String getDisplayName(Locale locale, boolean sentenceCase) {
- String result = ULocale.getDisplayNameWithDialect(locale.toLanguageTag(),
- ULocale.getDefault());
- return sentenceCase ? toSentenceCase(result, Locale.getDefault()) : result;
+ return getDisplayName(locale, Locale.getDefault(), sentenceCase);
}
/**
diff --git a/core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java b/core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java
index 46b49de..8d11783 100644
--- a/core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java
+++ b/core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java
@@ -16,6 +16,7 @@
package com.android.internal.inputmethod;
+import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.TextUtils;
@@ -284,8 +285,22 @@
return -1;
}
+ /**
+ * Provides the basic operation to implement bi-directional IME rotation.
+ * @param onlyCurrentIme {@code true} to limit the search space to IME subtypes that belong
+ * to {@code imi}.
+ * @param imi {@link InputMethodInfo} that will be used in conjunction with {@code subtype}
+ * from which we find the adjacent IME subtype.
+ * @param subtype {@link InputMethodSubtype} that will be used in conjunction with
+ * {@code imi} from which we find the next IME subtype. {@code null} if the input method
+ * does not have a subtype.
+ * @param forward {@code true} to do forward search the next IME subtype. Specify
+ * {@code false} to do backward search.
+ * @return The IME subtype found. {@code null} if no IME subtype is found.
+ */
+ @Nullable
public ImeSubtypeListItem getNextInputMethodLocked(boolean onlyCurrentIme,
- InputMethodInfo imi, InputMethodSubtype subtype, boolean forward) {
+ InputMethodInfo imi, @Nullable InputMethodSubtype subtype, boolean forward) {
if (imi == null) {
return null;
}
@@ -298,7 +313,7 @@
}
final int N = mImeSubtypeList.size();
for (int i = 1; i < N; ++i) {
- // Start searching the next IME/subtype from the next of the current index.
+ // Start searching the next IME/subtype from +/- 1 indices.
final int offset = forward ? i : N - i;
final int candidateIndex = (currentIndex + offset) % N;
final ImeSubtypeListItem candidate = mImeSubtypeList.get(candidateIndex);
@@ -371,8 +386,22 @@
mUsageHistoryOfSubtypeListItemIndex[0] = currentItemIndex;
}
+ /**
+ * Provides the basic operation to implement bi-directional IME rotation.
+ * @param onlyCurrentIme {@code true} to limit the search space to IME subtypes that belong
+ * to {@code imi}.
+ * @param imi {@link InputMethodInfo} that will be used in conjunction with {@code subtype}
+ * from which we find the adjacent IME subtype.
+ * @param subtype {@link InputMethodSubtype} that will be used in conjunction with
+ * {@code imi} from which we find the next IME subtype. {@code null} if the input method
+ * does not have a subtype.
+ * @param forward {@code true} to do forward search the next IME subtype. Specify
+ * {@code false} to do backward search.
+ * @return The IME subtype found. {@code null} if no IME subtype is found.
+ */
+ @Nullable
public ImeSubtypeListItem getNextInputMethodLocked(boolean onlyCurrentIme,
- InputMethodInfo imi, InputMethodSubtype subtype, boolean forward) {
+ InputMethodInfo imi, @Nullable InputMethodSubtype subtype, boolean forward) {
int currentUsageRank = getUsageRank(imi, subtype);
if (currentUsageRank < 0) {
if (DEBUG) {
@@ -456,8 +485,22 @@
mSwitchingUnawareRotationList = switchingUnawareRotationList;
}
+ /**
+ * Provides the basic operation to implement bi-directional IME rotation.
+ * @param onlyCurrentIme {@code true} to limit the search space to IME subtypes that belong
+ * to {@code imi}.
+ * @param imi {@link InputMethodInfo} that will be used in conjunction with {@code subtype}
+ * from which we find the adjacent IME subtype.
+ * @param subtype {@link InputMethodSubtype} that will be used in conjunction with
+ * {@code imi} from which we find the next IME subtype. {@code null} if the input method
+ * does not have a subtype.
+ * @param forward {@code true} to do forward search the next IME subtype. Specify
+ * {@code false} to do backward search.
+ * @return The IME subtype found. {@code null} if no IME subtype is found.
+ */
+ @Nullable
public ImeSubtypeListItem getNextInputMethod(boolean onlyCurrentIme, InputMethodInfo imi,
- InputMethodSubtype subtype, boolean forward) {
+ @Nullable InputMethodSubtype subtype, boolean forward) {
if (imi == null) {
return null;
}
diff --git a/core/java/com/android/internal/widget/ResolverDrawerLayout.java b/core/java/com/android/internal/widget/ResolverDrawerLayout.java
index 25b487e..c4347f8 100644
--- a/core/java/com/android/internal/widget/ResolverDrawerLayout.java
+++ b/core/java/com/android/internal/widget/ResolverDrawerLayout.java
@@ -17,14 +17,9 @@
package com.android.internal.widget;
-import android.annotation.NonNull;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Rect;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -90,10 +85,6 @@
private final float mMinFlingVelocity;
private final OverScroller mScroller;
private final VelocityTracker mVelocityTracker;
- private final Drawable mScrollIndicatorDrawable;
- private final Drawable mFakeForeground;
-
- private View mButtonBar;
private OnDismissedListener mOnDismissedListener;
private RunOnDismissedListener mRunOnDismissedListener;
@@ -115,8 +106,6 @@
}
};
- private final int[] mTempOffset = new int[2];
-
public ResolverDrawerLayout(Context context) {
this(context, null);
}
@@ -138,9 +127,6 @@
mMaxCollapsedHeight);
a.recycle();
- mScrollIndicatorDrawable = mContext.getDrawable(R.drawable.scroll_indicator_material);
- mFakeForeground = new ColorDrawable(Color.TRANSPARENT);
-
mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
android.R.interpolator.decelerate_quint));
mVelocityTracker = VelocityTracker.obtain();
@@ -152,13 +138,6 @@
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- mButtonBar = findViewById(R.id.button_bar);
- }
-
public void setSmallCollapsed(boolean smallCollapsed) {
mSmallCollapsed = smallCollapsed;
requestLayout();
@@ -223,7 +202,8 @@
}
final boolean isCollapsedNew = mCollapseOffset != 0;
if (isCollapsedOld != isCollapsedNew) {
- onCollapsedChanged(isCollapsedNew);
+ notifyViewAccessibilityStateChangedIfNeeded(
+ AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
}
} else {
// Start out collapsed at first unless we restored state for otherwise
@@ -462,7 +442,8 @@
mTopOffset += dy;
final boolean isCollapsedNew = newPos != 0;
if (isCollapsedOld != isCollapsedNew) {
- onCollapsedChanged(isCollapsedNew);
+ notifyViewAccessibilityStateChangedIfNeeded(
+ AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
}
postInvalidateOnAnimation();
return dy;
@@ -470,14 +451,6 @@
return 0;
}
- private void onCollapsedChanged(boolean isCollapsed) {
- notifyViewAccessibilityStateChangedIfNeeded(
- AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
-
- // Set a fake foreground so that we receive onDrawForeground().
- setForeground(isCollapsed ? mFakeForeground : null);
- }
-
void dispatchOnDismissed() {
if (mOnDismissedListener != null) {
mOnDismissedListener.onDismissed();
@@ -736,23 +709,6 @@
}
@Override
- public void onDrawForeground(Canvas canvas) {
- if (isCollapsed() && mButtonBar != null) {
- // Draw the scroll indicator directly above the button bar.
- final int height = mScrollIndicatorDrawable.getIntrinsicHeight();
- mButtonBar.getLocationInWindow(mTempOffset);
- final int barTop = mTempOffset[1];
- getLocationInWindow(mTempOffset);
- final int myTop = mTempOffset[1];
- final int top = (barTop - myTop) - height;
- mScrollIndicatorDrawable.setBounds(0, top, getWidth(), top + height);
- mScrollIndicatorDrawable.draw(canvas);
- }
-
- super.onDrawForeground(canvas);
- }
-
- @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int sourceWidth = MeasureSpec.getSize(widthMeasureSpec);
int widthSize = sourceWidth;
diff --git a/core/jni/android_hardware_location_ContextHubService.cpp b/core/jni/android_hardware_location_ContextHubService.cpp
index 91a3b4f..90d69d2 100644
--- a/core/jni/android_hardware_location_ContextHubService.cpp
+++ b/core/jni/android_hardware_location_ContextHubService.cpp
@@ -21,8 +21,8 @@
#include <inttypes.h>
#include <jni.h>
-#include <map>
#include <queue>
+#include <unordered_map>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
@@ -105,7 +105,7 @@
context_hub_info_s hubInfo;
jniInfo_s jniInfo;
std::queue<int> freeIds;
- std::map<int, app_instance_info_s *> appInstances;
+ std::unordered_map<int, app_instance_info_s> appInstances;
};
} // unnamed namespace
@@ -137,7 +137,7 @@
const context_hub_t *info = get_hub_info(hubHandle);
if (info) {
- msg->app = info->os_app_name;
+ msg->app_name = info->os_app_name;
return 0;
} else {
ALOGD("%s: Hub information is null for hubHandle %d", __FUNCTION__, hubHandle);
@@ -154,23 +154,23 @@
}
static int get_hub_id_for_app_instance(int id) {
- if (db.appInstances.find(id) == db.appInstances.end()) {
+ if (!db.appInstances.count(id)) {
ALOGD("%s: Cannot find app for app instance %d", __FUNCTION__, id);
return -1;
}
- int hubHandle = db.appInstances[id]->hubHandle;
+ int hubHandle = db.appInstances[id].hubHandle;
return db.hubInfo.hubs[hubHandle].hub_id;
}
static int set_dest_app(hub_message_t *msg, int id) {
- if (db.appInstances.find(id) == db.appInstances.end()) {
+ if (!db.appInstances.count(id)) {
ALOGD("%s: Cannod find app for app instance %d", __FUNCTION__, id);
return -1;
}
- msg->app = db.appInstances[id]->appInfo.name;
+ msg->app_name = db.appInstances[id].appInfo.app_name;
return 0;
}
@@ -210,76 +210,43 @@
int add_app_instance(const hub_app_info *appInfo, uint32_t hubHandle, JNIEnv *env) {
// Not checking if the apps are indeed distinct
-
- app_instance_info_s *entry;
- void *appName;
- hub_app_name_t *name;
-
- assert(appInfo && appInfo->name && appInfo->name->app_name);
-
- entry = (app_instance_info_s *) malloc(sizeof(app_instance_info_s));
- appName = malloc(appInfo->name->app_name_len);
- name = (hub_app_name_t *) malloc(sizeof(hub_app_name_t));
-
+ app_instance_info_s entry;
int appInstanceHandle = generate_id();
- if (appInstanceHandle < 0 || !appName || !entry || !name) {
- ALOGE("Cannot find resources to add app instance %d, %p, %p",
- appInstanceHandle, appName, entry);
+ assert(appInfo);
- free(appName);
- free(entry);
- free(name);
-
- if (appInstanceHandle >= 0) {
- return_id(appInstanceHandle);
- }
-
+ if (appInstanceHandle < 0) {
+ ALOGE("Cannot find resources to add app instance %d",
+ appInstanceHandle);
return -1;
}
- memcpy(&(entry->appInfo), appInfo, sizeof(entry->appInfo));
- memcpy(appName, appInfo->name->app_name, appInfo->name->app_name_len);
- name->app_name = appName;
- name->app_name_len = appInfo->name->app_name_len;
- entry->appInfo.name = name;
- entry->truncName = 0;
- memcpy(&(entry->truncName), name->app_name,
- sizeof(entry->truncName) < name->app_name_len ?
- sizeof(entry->truncName) : name->app_name_len);
-
- // Not checking for sanity of hubId
- entry->hubHandle = hubHandle;
- entry->instanceId = appInstanceHandle;
+ entry.appInfo = *appInfo;
+ entry.instanceId = appInstanceHandle;
+ entry.truncName = appInfo->app_name.id;
+ entry.hubHandle = hubHandle;
db.appInstances[appInstanceHandle] = entry;
// Finally - let the service know of this app instance
env->CallIntMethod(db.jniInfo.jContextHubService,
db.jniInfo.contextHubServiceAddAppInstance,
- hubHandle, entry->instanceId, entry->truncName,
- entry->appInfo.version);
+ hubHandle, entry.instanceId, entry.truncName,
+ entry.appInfo.version);
ALOGW("Added App 0x%" PRIx64 " on hub Handle %" PRId32
- " as appInstance %d, original name_length %" PRId32, entry->truncName,
- entry->hubHandle, appInstanceHandle, name->app_name_len);
+ " as appInstance %d", entry.truncName,
+ entry.hubHandle, appInstanceHandle);
return appInstanceHandle;
}
int delete_app_instance(int id) {
- if (db.appInstances.find(id) == db.appInstances.end()) {
+ if (!db.appInstances.count(id)) {
return -1;
}
return_id(id);
-
- if (db.appInstances[id]) {
- // Losing the const cast below. This is intentional.
- free((void *)db.appInstances[id]->appInfo.name->app_name);
- free((void *)db.appInstances[id]->appInfo.name);
- free(db.appInstances[id]);
- db.appInstances.erase(id);
- }
+ db.appInstances.erase(id);
return 0;
}
@@ -353,27 +320,20 @@
}
int handle_query_apps_response(char *msg, int msgLen, uint32_t hubHandle) {
- int i;
JNIEnv *env;
if ((db.jniInfo.vm)->AttachCurrentThread(&env, nullptr) != JNI_OK) {
return -1;
}
int numApps = msgLen/sizeof(hub_app_info);
- hub_app_info *info = (hub_app_info *)malloc(msgLen); // handle possible alignment
+ hub_app_info info;
+ hub_app_info *unalignedInfoAddr = (hub_app_info*)msg;
- if (!info) {
- return -1;
+ for (int i = 0; i < numApps; i++, unalignedInfoAddr++) {
+ memcpy(&info, unalignedInfoAddr, sizeof(info));
+ add_app_instance(&info, hubHandle, env);
}
- memcpy(info, msg, msgLen);
- for (i = 0; i < numApps; i++) {
- add_app_instance(info, hubHandle, env);
- info++;
- }
-
- free(info);
-
return 0;
}
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index ef45c87..3d65209 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -479,12 +479,6 @@
return proxy->pauseSurface(surface);
}
-static void android_view_ThreadedRenderer_setStopped(JNIEnv* env, jobject clazz,
- jlong proxyPtr, jboolean stopped) {
- RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
- proxy->setStopped(stopped);
-}
-
static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr,
jint width, jint height, jfloat lightRadius, jint ambientShadowAlpha, jint spotShadowAlpha) {
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
@@ -738,7 +732,6 @@
{ "nInitialize", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_initialize },
{ "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
{ "nPauseSurface", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_pauseSurface },
- { "nSetStopped", "(JZ)V", (void*) android_view_ThreadedRenderer_setStopped },
{ "nSetup", "(JIIFII)V", (void*) android_view_ThreadedRenderer_setup },
{ "nSetLightCenter", "(JFFF)V", (void*) android_view_ThreadedRenderer_setLightCenter },
{ "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
diff --git a/core/res/res/layout/resolver_list.xml b/core/res/res/layout/resolver_list.xml
index fe43e1c..4b8640c 100644
--- a/core/res/res/layout/resolver_list.xml
+++ b/core/res/res/layout/resolver_list.xml
@@ -30,37 +30,33 @@
android:layout_height="wrap_content"
android:layout_alwaysShow="true"
android:elevation="8dp"
- android:background="@color/white">
-
- <TextView
- android:id="@+id/profile_button"
- android:layout_width="wrap_content"
- android:layout_height="48dp"
- android:layout_marginEnd="8dp"
- android:paddingStart="8dp"
- android:paddingEnd="8dp"
- android:visibility="gone"
- style="?attr/borderlessButtonStyle"
- android:textAppearance="?attr/textAppearanceButton"
- android:textColor="@color/material_deep_teal_500"
- android:gravity="center_vertical"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:singleLine="true" />
-
- <TextView
- android:id="@+id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minHeight="56dp"
- android:textAppearance="?attr/textAppearanceMedium"
- android:gravity="start|center_vertical"
- android:paddingStart="?attr/dialogPreferredPadding"
- android:paddingEnd="?attr/dialogPreferredPadding"
- android:paddingTop="8dp"
- android:layout_below="@id/profile_button"
- android:layout_alignParentLeft="true"
- android:paddingBottom="8dp" />
+ android:background="@color/white" >
+ <TextView android:id="@+id/profile_button"
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_marginEnd="8dp"
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp"
+ android:visibility="gone"
+ style="?attr/borderlessButtonStyle"
+ android:textAppearance="?attr/textAppearanceButton"
+ android:textColor="@color/material_deep_teal_500"
+ android:gravity="center_vertical"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentRight="true"
+ android:singleLine="true"/>
+ <TextView android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minHeight="56dp"
+ android:textAppearance="?attr/textAppearanceMedium"
+ android:gravity="start|center_vertical"
+ android:paddingStart="?attr/dialogPreferredPadding"
+ android:paddingEnd="?attr/dialogPreferredPadding"
+ android:paddingTop="8dp"
+ android:layout_below="@id/profile_button"
+ android:layout_alignParentLeft="true"
+ android:paddingBottom="8dp" />
</RelativeLayout>
<ListView
@@ -72,23 +68,21 @@
android:background="@color/white"
android:elevation="8dp"
android:nestedScrollingEnabled="true"
- android:scrollIndicators="top|bottom"
android:divider="@null" />
- <TextView
- android:id="@+id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alwaysShow="true"
- android:text="@string/noApplications"
- android:padding="32dp"
- android:gravity="center"
- android:visibility="gone" />
+ <TextView android:id="@+id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alwaysShow="true"
+ android:text="@string/noApplications"
+ android:padding="32dp"
+ android:gravity="center"
+ android:visibility="gone" />
<LinearLayout
android:id="@+id/button_bar"
android:visibility="gone"
- style="?attr/buttonBarStyle"
+ style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_ignoreOffset="true"
@@ -103,30 +97,26 @@
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:elevation="8dp">
-
- <Button
- android:id="@+id/button_once"
- android:layout_width="wrap_content"
- android:layout_gravity="start"
- android:maxLines="2"
- style="?attr/buttonBarNegativeButtonStyle"
- android:minHeight="@dimen/alert_dialog_button_bar_height"
- android:layout_height="wrap_content"
- android:enabled="false"
- android:text="@string/activity_resolver_use_once"
- android:onClick="onButtonClick" />
-
- <Button
- android:id="@+id/button_always"
- android:layout_width="wrap_content"
- android:layout_gravity="end"
- android:maxLines="2"
- android:minHeight="@dimen/alert_dialog_button_bar_height"
- style="?attr/buttonBarPositiveButtonStyle"
- android:layout_height="wrap_content"
- android:enabled="false"
- android:text="@string/activity_resolver_use_always"
- android:onClick="onButtonClick" />
+ <Button android:id="@+id/button_once"
+ android:layout_width="wrap_content"
+ android:layout_gravity="start"
+ android:maxLines="2"
+ style="?android:attr/buttonBarNegativeButtonStyle"
+ android:minHeight="@dimen/alert_dialog_button_bar_height"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="@string/activity_resolver_use_once"
+ android:onClick="onButtonClick" />
+ <Button android:id="@+id/button_always"
+ android:layout_width="wrap_content"
+ android:layout_gravity="end"
+ android:maxLines="2"
+ android:minHeight="@dimen/alert_dialog_button_bar_height"
+ style="?android:attr/buttonBarPositiveButtonStyle"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="@string/activity_resolver_use_always"
+ android:onClick="onButtonClick" />
</LinearLayout>
</com.android.internal.widget.ResolverDrawerLayout>
diff --git a/core/res/res/layout/resolver_list_with_default.xml b/core/res/res/layout/resolver_list_with_default.xml
index ed7ef5e..31361e5 100644
--- a/core/res/res/layout/resolver_list_with_default.xml
+++ b/core/res/res/layout/resolver_list_with_default.xml
@@ -22,7 +22,8 @@
android:layout_height="match_parent"
android:maxWidth="@dimen/resolver_max_width"
android:maxCollapsedHeight="144dp"
- android:id="@id/contentPanel">
+ android:id="@id/contentPanel"
+ >
<LinearLayout
android:layout_width="match_parent"
@@ -30,75 +31,66 @@
android:layout_alwaysShow="true"
android:orientation="vertical"
android:background="@color/white"
- android:elevation="8dp">
+ android:elevation="8dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="64dp"
- android:orientation="horizontal">
+ android:orientation="horizontal" >
- <ImageView
- android:id="@+id/icon"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_gravity="start|top"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="16dp"
- android:layout_marginTop="20dp"
- android:scaleType="fitCenter" />
-
- <TextView
- android:id="@+id/title"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="?attr/listPreferredItemHeight"
- android:layout_marginStart="16dp"
- android:textAppearance="?attr/textAppearanceMedium"
- android:gravity="start|center_vertical"
- android:paddingEnd="16dp" />
-
- <LinearLayout
- android:id="@+id/profile_button"
- android:layout_width="wrap_content"
- android:layout_height="48dp"
- android:layout_marginTop="4dp"
- android:layout_marginEnd="4dp"
- android:paddingStart="8dp"
- android:paddingEnd="8dp"
- android:paddingTop="4dp"
- android:paddingBottom="4dp"
- android:focusable="true"
- android:visibility="gone"
- style="?attr/borderlessButtonStyle">
-
- <ImageView
- android:id="@+id/icon"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_gravity="start|center_vertical"
- android:layout_marginEnd="?attr/listPreferredItemPaddingEnd"
- android:layout_marginTop="12dp"
- android:layout_marginBottom="12dp"
- android:scaleType="fitCenter" />
-
- <TextView
- android:id="@id/text1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start|center_vertical"
- android:layout_marginEnd="?attr/listPreferredItemPaddingEnd"
- android:textAppearance="?attr/textAppearanceButton"
- android:textColor="?attr/textColorPrimary"
- android:minLines="1"
- android:maxLines="1"
- android:ellipsize="marquee" />
+ <ImageView android:id="@+id/icon"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="start|top"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:layout_marginTop="20dp"
+ android:scaleType="fitCenter" />
+ <TextView android:id="@+id/title"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:layout_marginStart="16dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:gravity="start|center_vertical"
+ android:paddingEnd="16dp" />
+ <LinearLayout android:id="@+id/profile_button"
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_marginTop="4dp"
+ android:layout_marginEnd="4dp"
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:focusable="true"
+ android:visibility="gone"
+ style="?attr/borderlessButtonStyle">
+ <ImageView android:id="@+id/icon"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="start|center_vertical"
+ android:layout_marginEnd="?attr/listPreferredItemPaddingEnd"
+ android:layout_marginTop="12dp"
+ android:layout_marginBottom="12dp"
+ android:scaleType="fitCenter" />
+ <TextView android:id="@id/text1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="start|center_vertical"
+ android:layout_marginEnd="?attr/listPreferredItemPaddingEnd"
+ android:textAppearance="?attr/textAppearanceButton"
+ android:textColor="?attr/textColorPrimary"
+ android:minLines="1"
+ android:maxLines="1"
+ android:ellipsize="marquee" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/button_bar"
android:visibility="gone"
- style="?attr/buttonBarStyle"
+ style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alwaysShow="true"
@@ -112,36 +104,30 @@
android:paddingEnd="12dp"
android:background="@color/white"
android:elevation="8dp">
-
- <Button
- android:id="@+id/button_once"
- android:layout_width="wrap_content"
- android:layout_gravity="start"
- android:maxLines="2"
- style="?attr/buttonBarNegativeButtonStyle"
- android:minHeight="@dimen/alert_dialog_button_bar_height"
- android:layout_height="wrap_content"
- android:enabled="false"
- android:text="@string/activity_resolver_use_once"
- android:onClick="onButtonClick" />
-
- <Button
- android:id="@+id/button_always"
- android:layout_width="wrap_content"
- android:layout_gravity="end"
- android:maxLines="2"
- android:minHeight="@dimen/alert_dialog_button_bar_height"
- style="?attr/buttonBarPositiveButtonStyle"
- android:layout_height="wrap_content"
- android:enabled="false"
- android:text="@string/activity_resolver_use_always"
- android:onClick="onButtonClick" />
+ <Button android:id="@+id/button_once"
+ android:layout_width="wrap_content"
+ android:layout_gravity="start"
+ android:maxLines="2"
+ style="?android:attr/buttonBarNegativeButtonStyle"
+ android:minHeight="@dimen/alert_dialog_button_bar_height"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="@string/activity_resolver_use_once"
+ android:onClick="onButtonClick" />
+ <Button android:id="@+id/button_always"
+ android:layout_width="wrap_content"
+ android:layout_gravity="end"
+ android:maxLines="2"
+ android:minHeight="@dimen/alert_dialog_button_bar_height"
+ style="?android:attr/buttonBarPositiveButtonStyle"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="@string/activity_resolver_use_always"
+ android:onClick="onButtonClick" />
</LinearLayout>
-
- <View
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?attr/dividerVertical" />
+ <View android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="?android:attr/dividerVertical" />
</LinearLayout>
<ListView
@@ -154,6 +140,6 @@
android:elevation="8dp"
android:nestedScrollingEnabled="true"
android:divider="@null"
- android:scrollIndicators="top|bottom" />
+ />
</com.android.internal.widget.ResolverDrawerLayout>
diff --git a/core/res/res/values-h426dp-port/integers.xml b/core/res/res/values-w320dp-h426dp/integers.xml
similarity index 100%
rename from core/res/res/values-h426dp-port/integers.xml
rename to core/res/res/values-w320dp-h426dp/integers.xml
diff --git a/core/res/res/values-w426dp-land/integers.xml b/core/res/res/values-w426dp-h320dp/integers.xml
similarity index 100%
rename from core/res/res/values-w426dp-land/integers.xml
rename to core/res/res/values-w426dp-h320dp/integers.xml
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index dfa5143b..cb551e8 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -420,9 +420,6 @@
<!-- Boolean indicating we re-try re-associating once upon disconnection and RSSI is high failure -->
<bool translatable="true" name="config_wifi_enable_disconnection_debounce">true</bool>
- <!-- Boolean indicating autojoin will prefer 5GHz and choose 5GHz BSSIDs -->
- <bool translatable="true" name="config_wifi_enable_5GHz_preference">true</bool>
-
<!-- Boolean indicating whether or not to revert to default country code when cellular
radio is unable to find any MCC information to infer wifi country code from -->
<bool translatable="false" name="config_wifi_revert_country_code_on_cellular_loss">false</bool>
@@ -439,8 +436,6 @@
<!-- Integer specifying the basic autojoin parameters -->
<integer translatable="false" name="config_wifi_framework_5GHz_preference_boost_threshold">-65</integer>
<integer translatable="false" name="config_wifi_framework_5GHz_preference_boost_factor">40</integer>
- <integer translatable="false" name="config_wifi_framework_current_association_hysteresis_high">16</integer>
- <integer translatable="false" name="config_wifi_framework_current_association_hysteresis_low">10</integer>
<integer translatable="false" name="config_wifi_framework_5GHz_preference_penalty_threshold">-75</integer>
<integer translatable="false" name="config_wifi_framework_RSSI_SCORE_OFFSET">85</integer>
<integer translatable="false" name="config_wifi_framework_RSSI_SCORE_SLOPE">4</integer>
@@ -495,15 +490,9 @@
<!-- Integer indicating disconnect mode short scan interval in milliseconds -->
<integer translatable="false" name="config_wifi_disconnected_short_scan_interval">15000</integer>
- <!-- Integer indicating disconnect mode long scan interval in milliseconds -->
- <integer translatable="false" name="config_wifi_disconnected_long_scan_interval">120000</integer>
-
<!-- Integer indicating associated partial scan short interval in milliseconds -->
<integer translatable="false" name="config_wifi_associated_short_scan_interval">20000</integer>
- <!-- Integer indicating associated partial scan long interval in milliseconds -->
- <integer translatable="false" name="config_wifi_associated_long_scan_interval">180000</integer>
-
<!-- Integer indicating associated full scan backoff, representing a fraction: xx/8 -->
<integer translatable="false" name="config_wifi_framework_associated_full_scan_backoff">12</integer>
@@ -516,18 +505,6 @@
<!-- Integer indicating associated full scan max num active channels -->
<integer translatable="false" name="config_wifi_framework_associated_partial_scan_max_num_active_channels">6</integer>
- <!-- Integer indicating associated full scan max num passive channels -->
- <integer translatable="false" name="config_wifi_framework_associated_partial_scan_max_num_passive_channels">3</integer>
-
- <!-- Integer indicating number of association errors leading to blacklisting of the network -->
- <integer translatable="false" name="config_wifi_framework_max_connection_errors_to_blacklist">4</integer>
-
- <!-- Integer indicating number of authentication errors leading to blacklisting of the network -->
- <integer translatable="false" name="config_wifi_framework_max_auth_errors_to_blacklist">4</integer>
-
- <!-- Integer indicating minimum blacklisting delay of a wofo configuration due to connectin or auth errors -->
- <integer translatable="false" name="config_wifi_framework_network_black_list_min_time_milli">120000</integer>
-
<!-- Integer indicating RSSI boost given to current network -->
<integer translatable="false" name="config_wifi_framework_current_network_boost">16</integer>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 8d8b832..29c6951 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -295,7 +295,6 @@
<java-symbol type="bool" name="config_wifi_framework_enable_associated_network_selection" />
<java-symbol type="bool" name="config_wifi_only_link_same_credential_configurations" />
<java-symbol type="bool" name="config_wifi_enable_disconnection_debounce" />
- <java-symbol type="bool" name="config_wifi_enable_5GHz_preference" />
<java-symbol type="bool" name="config_wifi_revert_country_code_on_cellular_loss" />
<java-symbol type="bool" name="config_wifi_enable_wifi_firmware_debugging" />
<java-symbol type="integer" name="config_wifi_logger_ring_buffer_size_limit_kb" />
@@ -312,8 +311,6 @@
<java-symbol type="integer" name="config_wifi_framework_5GHz_preference_boost_threshold" />
<java-symbol type="integer" name="config_wifi_framework_5GHz_preference_boost_factor" />
<java-symbol type="integer" name="config_wifi_framework_5GHz_preference_penalty_threshold" />
- <java-symbol type="integer" name="config_wifi_framework_current_association_hysteresis_high" />
- <java-symbol type="integer" name="config_wifi_framework_current_association_hysteresis_low" />
<java-symbol type="integer" name="config_wifi_framework_5GHz_preference_penalty_threshold" />
<java-symbol type="integer" name="config_wifi_framework_RSSI_SCORE_OFFSET" />
<java-symbol type="integer" name="config_wifi_framework_RSSI_SCORE_SLOPE" />
@@ -322,14 +319,11 @@
<java-symbol type="integer" name="config_wifi_framework_PASSPOINT_SECURITY_AWARD" />
<java-symbol type="integer" name="config_wifi_framework_SECURITY_AWARD" />
<java-symbol type="integer" name="config_wifi_disconnected_short_scan_interval" />
- <java-symbol type="integer" name="config_wifi_disconnected_long_scan_interval" />
<java-symbol type="integer" name="config_wifi_associated_short_scan_interval" />
- <java-symbol type="integer" name="config_wifi_associated_long_scan_interval" />
<java-symbol type="integer" name="config_wifi_framework_associated_full_scan_backoff" />
<java-symbol type="integer" name="config_wifi_framework_associated_full_scan_max_interval" />
<java-symbol type="integer" name="config_wifi_framework_associated_full_scan_max_total_dwell_time" />
<java-symbol type="integer" name="config_wifi_framework_associated_partial_scan_max_num_active_channels" />
- <java-symbol type="integer" name="config_wifi_framework_associated_partial_scan_max_num_passive_channels" />
<java-symbol type="integer" name="config_wifi_framework_wifi_score_bad_rssi_threshold_24GHz" />
<java-symbol type="integer" name="config_wifi_framework_wifi_score_low_rssi_threshold_24GHz" />
<java-symbol type="integer" name="config_wifi_framework_wifi_score_good_rssi_threshold_24GHz" />
@@ -359,9 +353,6 @@
<java-symbol type="integer" name="config_wifi_framework_associated_partial_scan_rx_packet_threshold" />
<java-symbol type="integer" name="config_wifi_framework_network_switch_tx_packet_threshold" />
<java-symbol type="integer" name="config_wifi_framework_network_switch_rx_packet_threshold" />
- <java-symbol type="integer" name="config_wifi_framework_max_connection_errors_to_blacklist" />
- <java-symbol type="integer" name="config_wifi_framework_max_auth_errors_to_blacklist" />
- <java-symbol type="integer" name="config_wifi_framework_network_black_list_min_time_milli" />
<java-symbol type="integer" name="config_wifi_framework_current_network_boost" />
<java-symbol type="integer" name="config_bluetooth_max_advertisers" />
<java-symbol type="integer" name="config_bluetooth_max_scan_filters" />
diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml
index 6611eb1..2ea5c5e 100644
--- a/core/res/res/values/themes_material.xml
+++ b/core/res/res/values/themes_material.xml
@@ -890,6 +890,11 @@
<item name="listDivider">@null</item>
<item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
+
+ <item name="windowFixedWidthMajor">@null</item>
+ <item name="windowFixedWidthMinor">@null</item>
+ <item name="windowFixedHeightMajor">@null</item>
+ <item name="windowFixedHeightMinor">@null</item>
</style>
<!-- Theme overlay that overrides window properties to display as a date picker dialog. -->
diff --git a/core/tests/coretests/src/android/util/PatternsTest.java b/core/tests/coretests/src/android/util/PatternsTest.java
index 348f8fd..edb3082 100644
--- a/core/tests/coretests/src/android/util/PatternsTest.java
+++ b/core/tests/coretests/src/android/util/PatternsTest.java
@@ -419,6 +419,36 @@
Patterns.AUTOLINK_WEB_URL.matcher(url).matches());
}
+ @SmallTest
+ public void testAutoLinkWebUrl_doesNotMatchUnicodeSpaces() throws Exception {
+ String part1 = "http://and";
+ String part2 = "roid";
+ String[] emptySpaces = new String[]{
+ "\u00A0", // no-break space
+ "\u2000", // en quad
+ "\u2001", // em quad
+ "\u2002", // en space
+ "\u2003", // em space
+ "\u2004", // three-per-em space
+ "\u2005", // four-per-em space
+ "\u2006", // six-per-em space
+ "\u2007", // figure space
+ "\u2008", // punctuation space
+ "\u2009", // thin space
+ "\u200A", // hair space
+ "\u2028", // line separator
+ "\u2029", // paragraph separator
+ "\u202F", // narrow no-break space
+ "\u3000" // ideographic space
+ };
+
+ for (String emptySpace : emptySpaces) {
+ String url = part1 + emptySpace + part2;
+ assertFalse("Should not match empty space - code:" + emptySpace.codePointAt(0),
+ Patterns.AUTOLINK_WEB_URL.matcher(url).matches());
+ }
+ }
+
// Tests for Patterns.IP_ADDRESS
@SmallTest
diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h
index e209e2a..aba5d4b 100644
--- a/libs/hwui/DisplayList.h
+++ b/libs/hwui/DisplayList.h
@@ -137,6 +137,9 @@
// whether children with non-zero Z in the chunk should be reordered
bool reorderChildren;
+#if HWUI_NEW_OPS
+ const ClipBase* reorderClip;
+#endif
};
DisplayList();
diff --git a/libs/hwui/FrameBuilder.cpp b/libs/hwui/FrameBuilder.cpp
index f12e523..6fc74a5 100644
--- a/libs/hwui/FrameBuilder.cpp
+++ b/libs/hwui/FrameBuilder.cpp
@@ -269,7 +269,8 @@
}
template <typename V>
-void FrameBuilder::defer3dChildren(ChildrenSelectMode mode, const V& zTranslatedNodes) {
+void FrameBuilder::defer3dChildren(const ClipBase* reorderClip, ChildrenSelectMode mode,
+ const V& zTranslatedNodes) {
const int size = zTranslatedNodes.size();
if (size == 0
|| (mode == ChildrenSelectMode::Negative&& zTranslatedNodes[0].key > 0.0f)
@@ -305,7 +306,7 @@
// attempt to render the shadow if the caster about to be drawn is its caster,
// OR if its caster's Z value is similar to the previous potential caster
if (shadowIndex == drawIndex || casterZ - lastCasterZ < 0.1f) {
- deferShadow(*casterNodeOp);
+ deferShadow(reorderClip, *casterNodeOp);
lastCasterZ = casterZ; // must do this even if current caster not casting a shadow
shadowIndex++;
@@ -319,7 +320,7 @@
}
}
-void FrameBuilder::deferShadow(const RenderNodeOp& casterNodeOp) {
+void FrameBuilder::deferShadow(const ClipBase* reorderClip, const RenderNodeOp& casterNodeOp) {
auto& node = *casterNodeOp.renderNode;
auto& properties = node.properties();
@@ -365,6 +366,10 @@
casterPath = frameAllocatedPath;
}
+ // apply reorder clip to shadow, so it respects clip at beginning of reorderable chunk
+ int restoreTo = mCanvasState.save(SaveFlags::MatrixClip);
+ mCanvasState.writableSnapshot()->applyClip(reorderClip,
+ *mCanvasState.currentSnapshot()->transform);
if (CC_LIKELY(!mCanvasState.getRenderTargetClipBounds().isEmpty())) {
Matrix4 shadowMatrixXY(casterNodeOp.localMatrix);
Matrix4 shadowMatrixZ(casterNodeOp.localMatrix);
@@ -386,6 +391,7 @@
currentLayer().deferUnmergeableOp(mAllocator, bakedOpState, OpBatchType::Shadow);
}
}
+ mCanvasState.restoreToCount(restoreTo);
}
void FrameBuilder::deferProjectedChildren(const RenderNode& renderNode) {
@@ -438,11 +444,11 @@
// can't be null, since DL=null node rejection happens before deferNodePropsAndOps
const DisplayList& displayList = *(renderNode.getDisplayList());
- for (const DisplayList::Chunk& chunk : displayList.getChunks()) {
+ for (auto& chunk : displayList.getChunks()) {
FatVector<ZRenderNodeOpPair, 16> zTranslatedNodes;
buildZSortedChildList(&zTranslatedNodes, displayList, chunk);
- defer3dChildren(ChildrenSelectMode::Negative, zTranslatedNodes);
+ defer3dChildren(chunk.reorderClip, ChildrenSelectMode::Negative, zTranslatedNodes);
for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) {
const RecordedOp* op = displayList.getOps()[opIndex];
receivers[op->opId](*this, *op);
@@ -453,7 +459,7 @@
deferProjectedChildren(renderNode);
}
}
- defer3dChildren(ChildrenSelectMode::Positive, zTranslatedNodes);
+ defer3dChildren(chunk.reorderClip, ChildrenSelectMode::Positive, zTranslatedNodes);
}
}
diff --git a/libs/hwui/FrameBuilder.h b/libs/hwui/FrameBuilder.h
index 039ab6b..a6fd761 100644
--- a/libs/hwui/FrameBuilder.h
+++ b/libs/hwui/FrameBuilder.h
@@ -193,9 +193,10 @@
void deferNodePropsAndOps(RenderNode& node);
template <typename V>
- void defer3dChildren(ChildrenSelectMode mode, const V& zTranslatedNodes);
+ void defer3dChildren(const ClipBase* reorderClip, ChildrenSelectMode mode,
+ const V& zTranslatedNodes);
- void deferShadow(const RenderNodeOp& casterOp);
+ void deferShadow(const ClipBase* reorderClip, const RenderNodeOp& casterOp);
void deferProjectedChildren(const RenderNode& renderNode);
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 8f914ac..a8ace8c 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -19,6 +19,7 @@
#include <SkColor.h>
#include <SkPaint.h>
#include <SkPath.h>
+#include <SkPathEffect.h>
#include <SkRect.h>
#include <utils/JenkinsHash.h>
@@ -35,18 +36,34 @@
namespace android {
namespace uirenderer {
+template <class T>
+static bool compareWidthHeight(const T& lhs, const T& rhs) {
+ return (lhs.mWidth == rhs.mWidth) && (lhs.mHeight == rhs.mHeight);
+}
+
+static bool compareRoundRects(const PathDescription::Shape::RoundRect& lhs,
+ const PathDescription::Shape::RoundRect& rhs) {
+ return compareWidthHeight(lhs, rhs) && lhs.mRx == rhs.mRx && lhs.mRy == rhs.mRy;
+}
+
+static bool compareArcs(const PathDescription::Shape::Arc& lhs, const PathDescription::Shape::Arc& rhs) {
+ return compareWidthHeight(lhs, rhs) && lhs.mStartAngle == rhs.mStartAngle &&
+ lhs.mSweepAngle == rhs.mSweepAngle && lhs.mUseCenter == rhs.mUseCenter;
+}
+
///////////////////////////////////////////////////////////////////////////////
// Cache entries
///////////////////////////////////////////////////////////////////////////////
PathDescription::PathDescription()
- : type(kShapeNone)
+ : type(ShapeType::None)
, join(SkPaint::kDefault_Join)
, cap(SkPaint::kDefault_Cap)
, style(SkPaint::kFill_Style)
, miter(4.0f)
, strokeWidth(1.0f)
, pathEffect(nullptr) {
+ // Shape bits should be set to zeroes, because they are used for hash calculation.
memset(&shape, 0, sizeof(Shape));
}
@@ -58,11 +75,12 @@
, miter(paint->getStrokeMiter())
, strokeWidth(paint->getStrokeWidth())
, pathEffect(paint->getPathEffect()) {
+ // Shape bits should be set to zeroes, because they are used for hash calculation.
memset(&shape, 0, sizeof(Shape));
}
hash_t PathDescription::hash() const {
- uint32_t hash = JenkinsHashMix(0, type);
+ uint32_t hash = JenkinsHashMix(0, static_cast<int>(type));
hash = JenkinsHashMix(hash, join);
hash = JenkinsHashMix(hash, cap);
hash = JenkinsHashMix(hash, style);
@@ -73,6 +91,32 @@
return JenkinsHashWhiten(hash);
}
+bool PathDescription::operator==(const PathDescription& rhs) const {
+ if (type != rhs.type) return false;
+ if (join != rhs.join) return false;
+ if (cap != rhs.cap) return false;
+ if (style != rhs.style) return false;
+ if (miter != rhs.miter) return false;
+ if (strokeWidth != rhs.strokeWidth) return false;
+ if (pathEffect != rhs.pathEffect) return false;
+ switch (type) {
+ case ShapeType::None:
+ return 0;
+ case ShapeType::Rect:
+ return compareWidthHeight(shape.rect, rhs.shape.rect);
+ case ShapeType::RoundRect:
+ return compareRoundRects(shape.roundRect, rhs.shape.roundRect);
+ case ShapeType::Circle:
+ return shape.circle.mRadius == rhs.shape.circle.mRadius;
+ case ShapeType::Oval:
+ return compareWidthHeight(shape.oval, rhs.shape.oval);
+ case ShapeType::Arc:
+ return compareArcs(shape.arc, rhs.shape.arc);
+ case ShapeType::Path:
+ return shape.path.mGenerationID == rhs.shape.path.mGenerationID;
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
// Utilities
///////////////////////////////////////////////////////////////////////////////
@@ -322,7 +366,7 @@
LruCache<PathDescription, PathTexture*>::Iterator iter(mCache);
while (iter.next()) {
const PathDescription& key = iter.key();
- if (key.type == kShapePath && key.shape.path.mGenerationID == generationID) {
+ if (key.type == ShapeType::Path && key.shape.path.mGenerationID == generationID) {
pathsToRemove.push(key);
}
}
@@ -336,7 +380,7 @@
}
PathTexture* PathCache::get(const SkPath* path, const SkPaint* paint) {
- PathDescription entry(kShapePath, paint);
+ PathDescription entry(ShapeType::Path, paint);
entry.shape.path.mGenerationID = path->getGenerationID();
PathTexture* texture = mCache.get(entry);
@@ -366,9 +410,8 @@
return texture;
}
-void PathCache::remove(const SkPath* path, const SkPaint* paint)
-{
- PathDescription entry(kShapePath, paint);
+void PathCache::remove(const SkPath* path, const SkPaint* paint) {
+ PathDescription entry(ShapeType::Path, paint);
entry.shape.path.mGenerationID = path->getGenerationID();
mCache.remove(entry);
}
@@ -378,7 +421,7 @@
return;
}
- PathDescription entry(kShapePath, paint);
+ PathDescription entry(ShapeType::Path, paint);
entry.shape.path.mGenerationID = path->getGenerationID();
PathTexture* texture = mCache.get(entry);
@@ -417,7 +460,7 @@
PathTexture* PathCache::getRoundRect(float width, float height,
float rx, float ry, const SkPaint* paint) {
- PathDescription entry(kShapeRoundRect, paint);
+ PathDescription entry(ShapeType::RoundRect, paint);
entry.shape.roundRect.mWidth = width;
entry.shape.roundRect.mHeight = height;
entry.shape.roundRect.mRx = rx;
@@ -442,7 +485,7 @@
///////////////////////////////////////////////////////////////////////////////
PathTexture* PathCache::getCircle(float radius, const SkPaint* paint) {
- PathDescription entry(kShapeCircle, paint);
+ PathDescription entry(ShapeType::Circle, paint);
entry.shape.circle.mRadius = radius;
PathTexture* texture = get(entry);
@@ -462,7 +505,7 @@
///////////////////////////////////////////////////////////////////////////////
PathTexture* PathCache::getOval(float width, float height, const SkPaint* paint) {
- PathDescription entry(kShapeOval, paint);
+ PathDescription entry(ShapeType::Oval, paint);
entry.shape.oval.mWidth = width;
entry.shape.oval.mHeight = height;
@@ -485,7 +528,7 @@
///////////////////////////////////////////////////////////////////////////////
PathTexture* PathCache::getRect(float width, float height, const SkPaint* paint) {
- PathDescription entry(kShapeRect, paint);
+ PathDescription entry(ShapeType::Rect, paint);
entry.shape.rect.mWidth = width;
entry.shape.rect.mHeight = height;
@@ -509,7 +552,7 @@
PathTexture* PathCache::getArc(float width, float height,
float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) {
- PathDescription entry(kShapeArc, paint);
+ PathDescription entry(ShapeType::Arc, paint);
entry.shape.arc.mWidth = width;
entry.shape.arc.mHeight = height;
entry.shape.arc.mStartAngle = startAngle;
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index d2633aa..6368ddd 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -25,6 +25,7 @@
#include "utils/Pair.h"
#include <GLES2/gl2.h>
+#include <SkPaint.h>
#include <SkPath.h>
#include <utils/LruCache.h>
#include <utils/Mutex.h>
@@ -108,18 +109,18 @@
sp<Task<SkBitmap*> > mTask;
}; // struct PathTexture
-enum ShapeType {
- kShapeNone,
- kShapeRect,
- kShapeRoundRect,
- kShapeCircle,
- kShapeOval,
- kShapeArc,
- kShapePath
+enum class ShapeType {
+ None,
+ Rect,
+ RoundRect,
+ Circle,
+ Oval,
+ Arc,
+ Path
};
struct PathDescription {
- DESCRIPTION_TYPE(PathDescription);
+ HASHABLE_TYPE(PathDescription);
ShapeType type;
SkPaint::Join join;
SkPaint::Cap cap;
@@ -159,8 +160,6 @@
PathDescription();
PathDescription(ShapeType shapeType, const SkPaint* paint);
-
- hash_t hash() const;
};
/**
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp
index b78497d..ab733f1 100644
--- a/libs/hwui/RecordingCanvas.cpp
+++ b/libs/hwui/RecordingCanvas.cpp
@@ -57,6 +57,16 @@
return displayList;
}
+void RecordingCanvas::insertReorderBarrier(bool enableReorder) {
+ if (enableReorder) {
+ mDeferredBarrierType = DeferredBarrierType::OutOfOrder;
+ mDeferredBarrierClip = getRecordedClip();
+ } else {
+ mDeferredBarrierType = DeferredBarrierType::InOrder;
+ mDeferredBarrierClip = nullptr;
+ }
+}
+
SkCanvas* RecordingCanvas::asSkCanvas() {
LOG_ALWAYS_FATAL_IF(!mDisplayList,
"attempting to get an SkCanvas when we are not recording!");
@@ -610,6 +620,7 @@
newChunk.beginOpIndex = insertIndex;
newChunk.endOpIndex = insertIndex + 1;
newChunk.reorderChildren = (mDeferredBarrierType == DeferredBarrierType::OutOfOrder);
+ newChunk.reorderClip = mDeferredBarrierClip;
int nextChildIndex = mDisplayList->children.size();
newChunk.beginChildIndex = newChunk.endChildIndex = nextChildIndex;
diff --git a/libs/hwui/RecordingCanvas.h b/libs/hwui/RecordingCanvas.h
index acb88e2..219296c 100644
--- a/libs/hwui/RecordingCanvas.h
+++ b/libs/hwui/RecordingCanvas.h
@@ -55,10 +55,7 @@
// ----------------------------------------------------------------------------
// MISC HWUI OPERATIONS - TODO: CATEGORIZE
// ----------------------------------------------------------------------------
- virtual void insertReorderBarrier(bool enableReorder) override {
- mDeferredBarrierType = enableReorder
- ? DeferredBarrierType::OutOfOrder : DeferredBarrierType::InOrder;
- }
+ virtual void insertReorderBarrier(bool enableReorder) override;
virtual void drawLayer(DeferredLayerUpdater* layerHandle) override;
virtual void drawRenderNode(RenderNode* renderNode) override;
@@ -312,6 +309,7 @@
std::unique_ptr<SkiaCanvasProxy> mSkiaCanvasProxy;
ResourceCache& mResourceCache;
DeferredBarrierType mDeferredBarrierType = DeferredBarrierType::None;
+ const ClipBase* mDeferredBarrierClip = nullptr;
DisplayList* mDisplayList = nullptr;
bool mHighContrastText = false;
SkAutoTUnref<SkDrawFilter> mDrawFilter;
diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp
index 14c8f392..cfdc084 100644
--- a/libs/hwui/TessellationCache.cpp
+++ b/libs/hwui/TessellationCache.cpp
@@ -35,13 +35,14 @@
///////////////////////////////////////////////////////////////////////////////
TessellationCache::Description::Description()
- : type(kNone)
+ : type(Type::None)
, scaleX(1.0f)
, scaleY(1.0f)
, aa(false)
, cap(SkPaint::kDefault_Cap)
, style(SkPaint::kFill_Style)
, strokeWidth(1.0f) {
+ // Shape bits should be set to zeroes, because they are used for hash calculation.
memset(&shape, 0, sizeof(Shape));
}
@@ -52,11 +53,30 @@
, style(paint.getStyle())
, strokeWidth(paint.getStrokeWidth()) {
PathTessellator::extractTessellationScales(transform, &scaleX, &scaleY);
+ // Shape bits should be set to zeroes, because they are used for hash calculation.
memset(&shape, 0, sizeof(Shape));
}
+bool TessellationCache::Description::operator==(const TessellationCache::Description& rhs) const {
+ if (type != rhs.type) return false;
+ if (scaleX != rhs.scaleX) return false;
+ if (scaleY != rhs.scaleY) return false;
+ if (aa != rhs.aa) return false;
+ if (cap != rhs.cap) return false;
+ if (style != rhs.style) return false;
+ if (strokeWidth != rhs.strokeWidth) return false;
+ if (type == Type::None) return true;
+ const Shape::RoundRect& lRect = shape.roundRect;
+ const Shape::RoundRect& rRect = rhs.shape.roundRect;
+
+ if (lRect.width != rRect.width) return false;
+ if (lRect.height != rRect.height) return false;
+ if (lRect.rx != rRect.rx) return false;
+ return lRect.ry == rRect.ry;
+}
+
hash_t TessellationCache::Description::hash() const {
- uint32_t hash = JenkinsHashMix(0, type);
+ uint32_t hash = JenkinsHashMix(0, static_cast<int>(type));
hash = JenkinsHashMix(hash, aa);
hash = JenkinsHashMix(hash, cap);
hash = JenkinsHashMix(hash, style);
@@ -77,17 +97,23 @@
TessellationCache::ShadowDescription::ShadowDescription()
: nodeKey(nullptr) {
- memset(&matrixData, 0, 16 * sizeof(float));
+ memset(&matrixData, 0, sizeof(matrixData));
}
-TessellationCache::ShadowDescription::ShadowDescription(const void* nodeKey, const Matrix4* drawTransform)
+TessellationCache::ShadowDescription::ShadowDescription(const SkPath* nodeKey, const Matrix4* drawTransform)
: nodeKey(nodeKey) {
- memcpy(&matrixData, drawTransform->data, 16 * sizeof(float));
+ memcpy(&matrixData, drawTransform->data, sizeof(matrixData));
+}
+
+bool TessellationCache::ShadowDescription::operator==(
+ const TessellationCache::ShadowDescription& rhs) const {
+ return nodeKey == rhs.nodeKey
+ && memcmp(&matrixData, &rhs.matrixData, sizeof(matrixData)) == 0;
}
hash_t TessellationCache::ShadowDescription::hash() const {
uint32_t hash = JenkinsHashMixBytes(0, (uint8_t*) &nodeKey, sizeof(const void*));
- hash = JenkinsHashMixBytes(hash, (uint8_t*) &matrixData, 16 * sizeof(float));
+ hash = JenkinsHashMixBytes(hash, (uint8_t*) &matrixData, sizeof(matrixData));
return JenkinsHashWhiten(hash);
}
@@ -428,7 +454,7 @@
TessellationCache::Buffer* TessellationCache::getRoundRectBuffer(
const Matrix4& transform, const SkPaint& paint,
float width, float height, float rx, float ry) {
- Description entry(Description::kRoundRect, transform, paint);
+ Description entry(Description::Type::RoundRect, transform, paint);
entry.shape.roundRect.width = width;
entry.shape.roundRect.height = height;
entry.shape.roundRect.rx = rx;
diff --git a/libs/hwui/TessellationCache.h b/libs/hwui/TessellationCache.h
index 0bd6365..6141b4e 100644
--- a/libs/hwui/TessellationCache.h
+++ b/libs/hwui/TessellationCache.h
@@ -52,10 +52,10 @@
typedef Pair<VertexBuffer*, VertexBuffer*> vertexBuffer_pair_t;
struct Description {
- DESCRIPTION_TYPE(Description);
- enum Type {
- kNone,
- kRoundRect,
+ HASHABLE_TYPE(Description);
+ enum class Type {
+ None,
+ RoundRect,
};
Type type;
@@ -76,18 +76,16 @@
Description();
Description(Type type, const Matrix4& transform, const SkPaint& paint);
- hash_t hash() const;
void setupMatrixAndPaint(Matrix4* matrix, SkPaint* paint) const;
};
struct ShadowDescription {
- DESCRIPTION_TYPE(ShadowDescription);
- const void* nodeKey;
+ HASHABLE_TYPE(ShadowDescription);
+ const SkPath* nodeKey;
float matrixData[16];
ShadowDescription();
- ShadowDescription(const void* nodeKey, const Matrix4* drawTransform);
- hash_t hash() const;
+ ShadowDescription(const SkPath* nodeKey, const Matrix4* drawTransform);
};
class ShadowTask : public Task<vertexBuffer_pair_t> {
diff --git a/libs/hwui/hwui/MinikinSkia.cpp b/libs/hwui/hwui/MinikinSkia.cpp
index b39de26..a455f57 100644
--- a/libs/hwui/hwui/MinikinSkia.cpp
+++ b/libs/hwui/hwui/MinikinSkia.cpp
@@ -24,7 +24,8 @@
MinikinFontSkia::MinikinFontSkia(SkTypeface* typeface, const void* fontData, size_t fontSize,
int ttcIndex) :
- mTypeface(typeface), mFontData(fontData), mFontSize(fontSize), mTtcIndex(ttcIndex) {
+ MinikinFont(typeface->uniqueID()), mTypeface(typeface), mFontData(fontData),
+ mFontSize(fontSize), mTtcIndex(ttcIndex) {
}
MinikinFontSkia::~MinikinFontSkia() {
@@ -99,10 +100,6 @@
return mTtcIndex;
}
-int32_t MinikinFontSkia::GetUniqueId() const {
- return mTypeface->uniqueID();
-}
-
uint32_t MinikinFontSkia::packPaintFlags(const SkPaint* paint) {
uint32_t flags = paint->getFlags();
SkPaint::Hinting hinting = paint->getHinting();
diff --git a/libs/hwui/hwui/MinikinSkia.h b/libs/hwui/hwui/MinikinSkia.h
index dbc65f9..a7c9fb0 100644
--- a/libs/hwui/hwui/MinikinSkia.h
+++ b/libs/hwui/hwui/MinikinSkia.h
@@ -41,8 +41,6 @@
const void* GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy);
- int32_t GetUniqueId() const;
-
SkTypeface* GetSkTypeface() const;
// Access to underlying raw font bytes
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 890d4a1..ab66b2a 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -113,11 +113,18 @@
mBufferPreserved = mEglManager.setPreserveBuffer(mEglSurface, preserveBuffer);
mHaveNewSurface = true;
mSwapHistory.clear();
+ makeCurrent();
} else {
mRenderThread.removeFrameCallback(this);
}
}
+void CanvasContext::requireSurface() {
+ LOG_ALWAYS_FATAL_IF(mEglSurface == EGL_NO_SURFACE,
+ "requireSurface() called but no surface set!");
+ makeCurrent();
+}
+
void CanvasContext::setSwapBehavior(SwapBehavior swapBehavior) {
mSwapBehavior = swapBehavior;
}
@@ -139,18 +146,6 @@
return mRenderThread.removeFrameCallback(this);
}
-void CanvasContext::setStopped(bool stopped) {
- if (mStopped != stopped) {
- mStopped = stopped;
- if (mStopped) {
- mRenderThread.removeFrameCallback(this);
- if (mEglManager.isCurrent(mEglSurface)) {
- mEglManager.makeCurrent(EGL_NO_SURFACE);
- }
- }
- }
-}
-
// TODO: don't pass viewport size, it's automatic via EGL
void CanvasContext::setup(int width, int height, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) {
@@ -177,9 +172,7 @@
mOpaque = opaque;
}
-bool CanvasContext::makeCurrent() {
- if (mStopped) return false;
-
+void CanvasContext::makeCurrent() {
// TODO: Figure out why this workaround is needed, see b/13913604
// In the meantime this matches the behavior of GLRenderer, so it is not a regression
EGLint error = 0;
@@ -187,7 +180,6 @@
if (error) {
setSurface(nullptr);
}
- return !error;
}
static bool wasSkipped(FrameInfo* info) {
@@ -679,7 +671,7 @@
}
Layer* CanvasContext::createTextureLayer() {
- mEglManager.initialize();
+ requireSurface();
return LayerRenderer::createTextureLayer(mRenderThread.renderState());
}
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index 52df3abe..9350114 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -82,14 +82,13 @@
void initialize(Surface* surface);
void updateSurface(Surface* surface);
bool pauseSurface(Surface* surface);
- void setStopped(bool stopped);
bool hasSurface() { return mNativeSurface.get(); }
void setup(int width, int height, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
void setLightCenter(const Vector3& lightCenter);
void setOpaque(bool opaque);
- bool makeCurrent();
+ void makeCurrent();
void prepareTree(TreeInfo& info, int64_t* uiFrameInfo,
int64_t syncQueued, RenderNode* target);
void draw();
@@ -173,6 +172,7 @@
friend class android::uirenderer::RenderState;
void setSurface(Surface* window);
+ void requireSurface();
void freePrefetchedLayers(TreeObserver* observer);
@@ -185,7 +185,6 @@
EglManager& mEglManager;
sp<Surface> mNativeSurface;
EGLSurface mEglSurface = EGL_NO_SURFACE;
- bool mStopped = false;
bool mBufferPreserved = false;
SwapBehavior mSwapBehavior = kSwap_default;
struct SwapHistory {
diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp
index ed472ac..651aaa2 100644
--- a/libs/hwui/renderthread/DrawFrameTask.cpp
+++ b/libs/hwui/renderthread/DrawFrameTask.cpp
@@ -115,7 +115,7 @@
ATRACE_CALL();
int64_t vsync = mFrameInfo[static_cast<int>(FrameInfoIndex::Vsync)];
mRenderThread->timeLord().vsyncReceived(vsync);
- bool canDraw = mContext->makeCurrent();
+ mContext->makeCurrent();
Caches::getInstance().textureCache.resetMarkInUse(mContext);
for (size_t i = 0; i < mLayers.size(); i++) {
@@ -126,9 +126,8 @@
// This is after the prepareTree so that any pending operations
// (RenderNode tree state, prefetched layers, etc...) will be flushed.
- if (CC_UNLIKELY(!mContext->hasSurface() || !canDraw)) {
+ if (CC_UNLIKELY(!mContext->hasSurface())) {
mSyncResult |= kSync_LostSurfaceRewardIfFound;
- info.out.canDrawThisFrame = false;
}
if (info.out.hasAnimations) {
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index ac6a28f..8def7ad 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -270,6 +270,12 @@
// Ensure we always have a valid surface & context
surface = mPBufferSurface;
}
+ // TODO: Temporary to help diagnose b/27286867
+ if (mCurrentSurface == mPBufferSurface || surface == mPBufferSurface) {
+ ALOGD("Switching from surface %p%s to %p%s", mCurrentSurface,
+ mCurrentSurface == mPBufferSurface ? " (pbuffer)" : "",
+ surface, surface == mPBufferSurface ? " (pbuffer)" : "");
+ }
if (!eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
if (errOut) {
*errOut = eglGetError();
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index c5a2dc7..1116383 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -167,18 +167,6 @@
return (bool) postAndWait(task);
}
-CREATE_BRIDGE2(setStopped, CanvasContext* context, bool stopped) {
- args->context->setStopped(args->stopped);
- return nullptr;
-}
-
-void RenderProxy::setStopped(bool stopped) {
- SETUP_TASK(setStopped);
- args->context = mContext;
- args->stopped = stopped;
- postAndWait(task);
-}
-
CREATE_BRIDGE6(setup, CanvasContext* context, int width, int height,
float lightRadius, uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) {
args->context->setup(args->width, args->height, args->lightRadius,
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index 32d3283b..ecc296b 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -79,7 +79,6 @@
ANDROID_API void initialize(const sp<Surface>& surface);
ANDROID_API void updateSurface(const sp<Surface>& surface);
ANDROID_API bool pauseSurface(const sp<Surface>& surface);
- ANDROID_API void setStopped(bool stopped);
ANDROID_API void setup(int width, int height, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
ANDROID_API void setLightCenter(const Vector3& lightCenter);
diff --git a/libs/hwui/tests/unit/FrameBuilderTests.cpp b/libs/hwui/tests/unit/FrameBuilderTests.cpp
index 9877439..209a104 100644
--- a/libs/hwui/tests/unit/FrameBuilderTests.cpp
+++ b/libs/hwui/tests/unit/FrameBuilderTests.cpp
@@ -1722,6 +1722,35 @@
EXPECT_EQ(4, renderer.getIndex());
}
+RENDERTHREAD_TEST(FrameBuilder, shadowClipping) {
+ class ShadowClippingTestRenderer : public TestRendererBase {
+ public:
+ void onShadowOp(const ShadowOp& op, const BakedOpState& state) override {
+ EXPECT_EQ(0, mIndex++);
+ EXPECT_EQ(Rect(25, 25, 75, 75), state.computedState.clipState->rect)
+ << "Shadow must respect pre-barrier canvas clip value.";
+ }
+ void onRectOp(const RectOp& op, const BakedOpState& state) override {
+ EXPECT_EQ(1, mIndex++);
+ }
+ };
+ auto parent = TestUtils::createNode(0, 0, 100, 100,
+ [](RenderProperties& props, RecordingCanvas& canvas) {
+ // Apply a clip before the reorder barrier/shadow casting child is drawn.
+ // This clip must be applied to the shadow cast by the child.
+ canvas.clipRect(25, 25, 75, 75, SkRegion::kIntersect_Op);
+ canvas.insertReorderBarrier(true);
+ canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
+ });
+
+ FrameBuilder frameBuilder(sEmptyLayerUpdateQueue, SkRect::MakeWH(100, 100), 100, 100,
+ TestUtils::createSyncedNodeList(parent),
+ (FrameBuilder::LightGeometry) {{ 100, 100, 100 }, 50}, Caches::getInstance());
+ ShadowClippingTestRenderer renderer;
+ frameBuilder.replayBakedOps<TestDispatcher>(renderer);
+ EXPECT_EQ(2, renderer.getIndex());
+}
+
static void testProperty(std::function<void(RenderProperties&)> propSetupCallback,
std::function<void(const RectOp&, const BakedOpState&)> opValidateCallback) {
class PropertyTestRenderer : public TestRendererBase {
diff --git a/libs/hwui/tests/unit/RecordingCanvasTests.cpp b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
index c49ff71..18171de 100644
--- a/libs/hwui/tests/unit/RecordingCanvasTests.cpp
+++ b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
@@ -603,6 +603,36 @@
EXPECT_TRUE(chunks[1].reorderChildren);
}
+TEST(RecordingCanvas, insertReorderBarrier_clip) {
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
+ // first chunk: no recorded clip
+ canvas.insertReorderBarrier(true);
+ canvas.drawRect(0, 0, 400, 400, SkPaint());
+
+ // second chunk: no recorded clip, since inorder region
+ canvas.clipRect(0, 0, 200, 200, SkRegion::kIntersect_Op);
+ canvas.insertReorderBarrier(false);
+ canvas.drawRect(0, 0, 400, 400, SkPaint());
+
+ // third chunk: recorded clip
+ canvas.insertReorderBarrier(true);
+ canvas.drawRect(0, 0, 400, 400, SkPaint());
+ });
+
+ auto chunks = dl->getChunks();
+ ASSERT_EQ(3u, chunks.size());
+
+ EXPECT_TRUE(chunks[0].reorderChildren);
+ EXPECT_EQ(nullptr, chunks[0].reorderClip);
+
+ EXPECT_FALSE(chunks[1].reorderChildren);
+ EXPECT_EQ(nullptr, chunks[1].reorderClip);
+
+ EXPECT_TRUE(chunks[2].reorderChildren);
+ ASSERT_NE(nullptr, chunks[2].reorderClip);
+ EXPECT_EQ(Rect(200, 200), chunks[2].reorderClip->rect);
+}
+
TEST(RecordingCanvas, refPaint) {
SkPaint paint;
diff --git a/libs/hwui/utils/Macros.h b/libs/hwui/utils/Macros.h
index ccf2287..7212897b 100644
--- a/libs/hwui/utils/Macros.h
+++ b/libs/hwui/utils/Macros.h
@@ -23,12 +23,10 @@
Type(const Type&) = delete; \
void operator=(const Type&) = delete
-#define DESCRIPTION_TYPE(Type) \
- int compare(const Type& rhs) const { return memcmp(this, &rhs, sizeof(Type));} \
- bool operator==(const Type& other) const { return compare(other) == 0; } \
- bool operator!=(const Type& other) const { return compare(other) != 0; } \
- friend inline int strictly_order_type(const Type& lhs, const Type& rhs) { return lhs.compare(rhs) < 0; } \
- friend inline int compare_type(const Type& lhs, const Type& rhs) { return lhs.compare(rhs); } \
+#define HASHABLE_TYPE(Type) \
+ bool operator==(const Type& other) const; \
+ hash_t hash() const; \
+ bool operator!=(const Type& other) const { return !(*this == other); } \
friend inline hash_t hash_type(const Type& entry) { return entry.hash(); }
#define REQUIRE_COMPATIBLE_LAYOUT(Type) \
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index ca306cc..a5550ec 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -37,6 +37,8 @@
import android.util.ArrayMap;
import android.util.Log;
+import com.android.internal.annotations.GuardedBy;
+
/**
* The AudioRecord class manages the audio resources for Java applications
* to record audio from the audio input hardware of the platform. This is
@@ -1320,6 +1322,7 @@
* Note: The query is only valid if the AudioRecord is currently recording. If it is not,
* <code>getRoutedDevice()</code> will return null.
*/
+ @Override
public AudioDeviceInfo getRoutedDevice() {
int deviceId = native_getRoutedDeviceId();
if (deviceId == 0) {
@@ -1338,8 +1341,8 @@
/*
* Call BEFORE adding a routing callback handler.
*/
- private void testEnableNativeRoutingCallbacks() {
- if (mRoutingChangeListeners.size() == 0 && mNewRoutingChangeListeners.size() == 0) {
+ private void testEnableNativeRoutingCallbacksLocked() {
+ if (mRoutingChangeListeners.size() == 0) {
native_enableDeviceCallback();
}
}
@@ -1347,24 +1350,23 @@
/*
* Call AFTER removing a routing callback handler.
*/
- private void testDisableNativeRoutingCallbacks() {
- if (mRoutingChangeListeners.size() == 0 && mNewRoutingChangeListeners.size() == 0) {
+ private void testDisableNativeRoutingCallbacksLocked() {
+ if (mRoutingChangeListeners.size() == 0) {
native_disableDeviceCallback();
}
}
//--------------------------------------------------------------------------
- // >= "N" (Re)Routing Info
+ // (Re)Routing Info
//--------------------
/**
* The list of AudioRouting.OnRoutingChangedListener interfaces added (with
- * {@link AudioRecord#addOnRoutingListener(AudioRouting.OnRoutingChangedListener,
- * android.os.Handler)}
- * by an app to receive (re)routing notifications.
+ * {@link AudioRecord#addOnRoutingChangedListener} by an app to receive
+ * (re)routing notifications.
*/
- private ArrayMap<AudioRouting.OnRoutingChangedListener, NativeNewRoutingEventHandlerDelegate>
- mNewRoutingChangeListeners =
- new ArrayMap<AudioRouting.OnRoutingChangedListener, NativeNewRoutingEventHandlerDelegate>();
+ @GuardedBy("mRoutingChangeListeners")
+ private ArrayMap<AudioRouting.OnRoutingChangedListener,
+ NativeRoutingEventHandlerDelegate> mRoutingChangeListeners = new ArrayMap<>();
/**
* Adds an {@link AudioRouting.OnRoutingChangedListener} to receive notifications of
@@ -1375,14 +1377,15 @@
* the callback. If <code>null</code>, the {@link Handler} associated with the main
* {@link Looper} will be used.
*/
- public void addOnRoutingListener(AudioRouting.OnRoutingChangedListener listener,
+ @Override
+ public void addOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener,
android.os.Handler handler) {
- if (listener != null && !mNewRoutingChangeListeners.containsKey(listener)) {
- synchronized (mNewRoutingChangeListeners) {
- testEnableNativeRoutingCallbacks();
- mNewRoutingChangeListeners.put(
- listener, new NativeNewRoutingEventHandlerDelegate(this, listener,
- handler != null ? handler : new Handler(mInitializationLooper)));
+ synchronized (mRoutingChangeListeners) {
+ if (listener != null && !mRoutingChangeListeners.containsKey(listener)) {
+ testEnableNativeRoutingCallbacksLocked();
+ mRoutingChangeListeners.put(
+ listener, new NativeRoutingEventHandlerDelegate(this, listener,
+ handler != null ? handler : new Handler(mInitializationLooper)));
}
}
}
@@ -1393,39 +1396,42 @@
* @param listener The previously added {@link AudioRouting.OnRoutingChangedListener} interface
* to remove.
*/
- public void removeOnRoutingListener(AudioRouting.OnRoutingChangedListener listener) {
- synchronized (mNewRoutingChangeListeners) {
- if (mNewRoutingChangeListeners.containsKey(listener)) {
- mNewRoutingChangeListeners.remove(listener);
- testDisableNativeRoutingCallbacks();
+ @Override
+ public void removeOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener) {
+ synchronized (mRoutingChangeListeners) {
+ if (mRoutingChangeListeners.containsKey(listener)) {
+ mRoutingChangeListeners.remove(listener);
+ testDisableNativeRoutingCallbacksLocked();
}
}
}
//--------------------------------------------------------------------------
- // Marshmallow (Re)Routing Info
+ // (Re)Routing Info
//--------------------
/**
- * Defines the interface by which applications can receive notifications of routing
- * changes for the associated {@link AudioRecord}.
+ * Defines the interface by which applications can receive notifications of
+ * routing changes for the associated {@link AudioRecord}.
+ *
+ * @deprecated users should switch to the general purpose
+ * {@link AudioRouting.OnRoutingChangedListener} class instead.
*/
- public interface OnRoutingChangedListener {
+ @Deprecated
+ public interface OnRoutingChangedListener extends AudioRouting.OnRoutingChangedListener {
/**
- * Called when the routing of an AudioRecord changes from either and explicit or
- * policy rerouting. Use {@link #getRoutedDevice()} to retrieve the newly routed-from
- * device.
+ * Called when the routing of an AudioRecord changes from either and
+ * explicit or policy rerouting. Use {@link #getRoutedDevice()} to
+ * retrieve the newly routed-from device.
*/
public void onRoutingChanged(AudioRecord audioRecord);
- }
- /**
- * The list of AudioRecord.OnRoutingChangedListener interface added (with
- * {@link AudioRecord#addOnRoutingChangedListener(OnRoutingChangedListener,android.os.Handler)}
- * by an app to receive (re)routing notifications.
- */
- private ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>
- mRoutingChangeListeners =
- new ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>();
+ @Override
+ default public void onRoutingChanged(AudioRouting router) {
+ if (router instanceof AudioRecord) {
+ onRoutingChanged((AudioRecord) router);
+ }
+ }
+ }
/**
* Adds an {@link OnRoutingChangedListener} to receive notifications of routing changes
@@ -1435,88 +1441,28 @@
* @param handler Specifies the {@link Handler} object for the thread on which to execute
* the callback. If <code>null</code>, the {@link Handler} associated with the main
* {@link Looper} will be used.
+ * @deprecated users should switch to the general purpose
+ * {@link AudioRouting.OnRoutingChangedListener} class instead.
*/
@Deprecated
public void addOnRoutingChangedListener(OnRoutingChangedListener listener,
android.os.Handler handler) {
- if (listener != null && !mRoutingChangeListeners.containsKey(listener)) {
- synchronized (mRoutingChangeListeners) {
- testEnableNativeRoutingCallbacks();
- mRoutingChangeListeners.put(
- listener, new NativeRoutingEventHandlerDelegate(this, listener,
- handler != null ? handler : new Handler(mInitializationLooper)));
- }
- }
+ addOnRoutingChangedListener((AudioRouting.OnRoutingChangedListener) listener, handler);
}
/**
* Removes an {@link OnRoutingChangedListener} which has been previously added
* to receive rerouting notifications.
* @param listener The previously added {@link OnRoutingChangedListener} interface to remove.
+ * @deprecated users should switch to the general purpose
+ * {@link AudioRouting.OnRoutingChangedListener} class instead.
*/
@Deprecated
public void removeOnRoutingChangedListener(OnRoutingChangedListener listener) {
- synchronized (mRoutingChangeListeners) {
- if (mRoutingChangeListeners.containsKey(listener)) {
- mRoutingChangeListeners.remove(listener);
- testDisableNativeRoutingCallbacks();
- }
- }
+ removeOnRoutingChangedListener((AudioRouting.OnRoutingChangedListener) listener);
}
/**
- * >= "N" Routing
- * Helper class to handle the forwarding of native events to the appropriate listener
- * (potentially) handled in a different thread
- */
- private class NativeNewRoutingEventHandlerDelegate {
- private final Handler mHandler;
-
- NativeNewRoutingEventHandlerDelegate(final AudioRecord record,
- final AudioRouting.OnRoutingChangedListener listener,
- Handler handler) {
- // find the looper for our new event handler
- Looper looper;
- if (handler != null) {
- looper = handler.getLooper();
- } else {
- // no given handler, use the looper the AudioRecord was created in
- looper = mInitializationLooper;
- }
-
- // construct the event handler with this looper
- if (looper != null) {
- // implement the event handler delegate
- mHandler = new Handler(looper) {
- @Override
- public void handleMessage(Message msg) {
- if (record == null) {
- return;
- }
- switch(msg.what) {
- case AudioSystem.NATIVE_EVENT_ROUTING_CHANGE:
- if (listener != null) {
- listener.onRoutingChanged(record);
- }
- break;
- default:
- loge("Unknown native event type: " + msg.what);
- break;
- }
- }
- };
- } else {
- mHandler = null;
- }
- }
-
- Handler getHandler() {
- return mHandler;
- }
- }
-
- /**
- * Marshmallow Routing
* Helper class to handle the forwarding of native events to the appropriate listener
* (potentially) handled in a different thread
*/
@@ -1524,7 +1470,7 @@
private final Handler mHandler;
NativeRoutingEventHandlerDelegate(final AudioRecord record,
- final OnRoutingChangedListener listener,
+ final AudioRouting.OnRoutingChangedListener listener,
Handler handler) {
// find the looper for our new event handler
Looper looper;
@@ -1571,26 +1517,12 @@
*/
private void broadcastRoutingChange() {
AudioManager.resetAudioPortGeneration();
- // Marshmallow Routing
- Collection<NativeRoutingEventHandlerDelegate> values;
synchronized (mRoutingChangeListeners) {
- values = mRoutingChangeListeners.values();
- }
- for(NativeRoutingEventHandlerDelegate delegate : values) {
- Handler handler = delegate.getHandler();
- if (handler != null) {
- handler.sendEmptyMessage(AudioSystem.NATIVE_EVENT_ROUTING_CHANGE);
- }
- }
- // >= "N" Routing
- Collection<NativeNewRoutingEventHandlerDelegate> newValues;
- synchronized (mNewRoutingChangeListeners) {
- newValues = mNewRoutingChangeListeners.values();
- }
- for(NativeNewRoutingEventHandlerDelegate delegate : newValues) {
- Handler handler = delegate.getHandler();
- if (handler != null) {
- handler.sendEmptyMessage(AudioSystem.NATIVE_EVENT_ROUTING_CHANGE);
+ for (NativeRoutingEventHandlerDelegate delegate : mRoutingChangeListeners.values()) {
+ Handler handler = delegate.getHandler();
+ if (handler != null) {
+ handler.sendEmptyMessage(AudioSystem.NATIVE_EVENT_ROUTING_CHANGE);
+ }
}
}
}
@@ -1623,6 +1555,7 @@
* @return true if successful, false if the specified {@link AudioDeviceInfo} is non-null and
* does not correspond to a valid audio input device.
*/
+ @Override
public boolean setPreferredDevice(AudioDeviceInfo deviceInfo) {
// Do some validation....
if (deviceInfo != null && !deviceInfo.isSource()) {
@@ -1643,6 +1576,7 @@
* Returns the selected input specified by {@link #setPreferredDevice}. Note that this
* is not guarenteed to correspond to the actual device being used for recording.
*/
+ @Override
public AudioDeviceInfo getPreferredDevice() {
synchronized (this) {
return mPreferredDevice;
@@ -1683,7 +1617,6 @@
* (potentially) handled in a different thread
*/
private class NativeEventHandler extends Handler {
-
private final AudioRecord mAudioRecord;
NativeEventHandler(AudioRecord recorder, Looper looper) {
@@ -1714,8 +1647,7 @@
break;
}
}
- };
-
+ }
//---------------------------------------------------------
// Java methods called from the native side
diff --git a/media/java/android/media/AudioRouting.java b/media/java/android/media/AudioRouting.java
index 41f92d4..26fa631 100644
--- a/media/java/android/media/AudioRouting.java
+++ b/media/java/android/media/AudioRouting.java
@@ -57,7 +57,7 @@
* the callback. If <code>null</code>, the {@link Handler} associated with the main
* {@link Looper} will be used.
*/
- public void addOnRoutingListener(OnRoutingChangedListener listener,
+ public void addOnRoutingChangedListener(OnRoutingChangedListener listener,
Handler handler);
/**
@@ -66,7 +66,7 @@
* @param listener The previously added {@link AudioRouting.OnRoutingChangedListener} interface
* to remove.
*/
- public void removeOnRoutingListener(OnRoutingChangedListener listener);
+ public void removeOnRoutingChangedListener(OnRoutingChangedListener listener);
/**
* Defines the interface by which applications can receive notifications of routing
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index 621129d..9d360db 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -40,6 +40,7 @@
import android.util.ArrayMap;
import android.util.Log;
+import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IAppOpsService;
/**
@@ -1489,6 +1490,7 @@
* @deprecated Applications should use {@link #setVolume} instead, as it
* more gracefully scales down to mono, and up to multi-channel content beyond stereo.
*/
+ @Deprecated
public int setStereoVolume(float leftGain, float rightGain) {
if (isRestricted()) {
return SUCCESS;
@@ -2397,6 +2399,7 @@
* @return true if succesful, false if the specified {@link AudioDeviceInfo} is non-null and
* does not correspond to a valid audio output device.
*/
+ @Override
public boolean setPreferredDevice(AudioDeviceInfo deviceInfo) {
// Do some validation....
if (deviceInfo != null && !deviceInfo.isSink()) {
@@ -2416,6 +2419,7 @@
* Returns the selected output specified by {@link #setPreferredDevice}. Note that this
* is not guaranteed to correspond to the actual device being used for playback.
*/
+ @Override
public AudioDeviceInfo getPreferredDevice() {
synchronized (this) {
return mPreferredDevice;
@@ -2427,6 +2431,7 @@
* Note: The query is only valid if the AudioTrack is currently playing. If it is not,
* <code>getRoutedDevice()</code> will return null.
*/
+ @Override
public AudioDeviceInfo getRoutedDevice() {
int deviceId = native_getRoutedDeviceId();
if (deviceId == 0) {
@@ -2445,8 +2450,8 @@
/*
* Call BEFORE adding a routing callback handler.
*/
- private void testEnableNativeRoutingCallbacks() {
- if (mRoutingChangeListeners.size() == 0 && mNewRoutingChangeListeners.size() == 0) {
+ private void testEnableNativeRoutingCallbacksLocked() {
+ if (mRoutingChangeListeners.size() == 0) {
native_enableDeviceCallback();
}
}
@@ -2454,24 +2459,23 @@
/*
* Call AFTER removing a routing callback handler.
*/
- private void testDisableNativeRoutingCallbacks() {
- if (mRoutingChangeListeners.size() == 0 && mNewRoutingChangeListeners.size() == 0) {
+ private void testDisableNativeRoutingCallbacksLocked() {
+ if (mRoutingChangeListeners.size() == 0) {
native_disableDeviceCallback();
}
}
//--------------------------------------------------------------------------
- // >= "N" (Re)Routing Info
+ // (Re)Routing Info
//--------------------
/**
* The list of AudioRouting.OnRoutingChangedListener interfaces added (with
- * {@link AudioTrack#addOnRoutingListener(AudioRouting.OnRoutingChangedListener,
- * android.os.Handler)}
- * by an app to receive (re)routing notifications.
+ * {@link AudioRecord#addOnRoutingChangedListener} by an app to receive
+ * (re)routing notifications.
*/
- private ArrayMap<AudioRouting.OnRoutingChangedListener, NativeNewRoutingEventHandlerDelegate>
- mNewRoutingChangeListeners =
- new ArrayMap<AudioRouting.OnRoutingChangedListener, NativeNewRoutingEventHandlerDelegate>();
+ @GuardedBy("mRoutingChangeListeners")
+ private ArrayMap<AudioRouting.OnRoutingChangedListener,
+ NativeRoutingEventHandlerDelegate> mRoutingChangeListeners = new ArrayMap<>();
/**
* Adds an {@link AudioRouting.OnRoutingChangedListener} to receive notifications of routing
@@ -2482,14 +2486,15 @@
* the callback. If <code>null</code>, the {@link Handler} associated with the main
* {@link Looper} will be used.
*/
- public void addOnRoutingListener(AudioRouting.OnRoutingChangedListener listener,
+ @Override
+ public void addOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener,
Handler handler) {
- if (listener != null && !mNewRoutingChangeListeners.containsKey(listener)) {
- synchronized (mNewRoutingChangeListeners) {
- testEnableNativeRoutingCallbacks();
- mNewRoutingChangeListeners.put(
- listener, new NativeNewRoutingEventHandlerDelegate(this, listener,
- handler != null ? handler : new Handler(mInitializationLooper)));
+ synchronized (mRoutingChangeListeners) {
+ if (listener != null && !mRoutingChangeListeners.containsKey(listener)) {
+ testEnableNativeRoutingCallbacksLocked();
+ mRoutingChangeListeners.put(
+ listener, new NativeRoutingEventHandlerDelegate(this, listener,
+ handler != null ? handler : new Handler(mInitializationLooper)));
}
}
}
@@ -2500,39 +2505,42 @@
* @param listener The previously added {@link AudioRouting.OnRoutingChangedListener} interface
* to remove.
*/
- public void removeOnRoutingListener(AudioRouting.OnRoutingChangedListener listener) {
- if (mNewRoutingChangeListeners.containsKey(listener)) {
- mNewRoutingChangeListeners.remove(listener);
+ @Override
+ public void removeOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener) {
+ synchronized (mRoutingChangeListeners) {
+ if (mRoutingChangeListeners.containsKey(listener)) {
+ mRoutingChangeListeners.remove(listener);
+ }
+ testDisableNativeRoutingCallbacksLocked();
}
- testDisableNativeRoutingCallbacks();
}
//--------------------------------------------------------------------------
- // Marshmallow (Re)Routing Info
+ // (Re)Routing Info
//--------------------
/**
- * Defines the interface by which applications can receive notifications of routing
- * changes for the associated {@link AudioTrack}.
+ * Defines the interface by which applications can receive notifications of
+ * routing changes for the associated {@link AudioTrack}.
+ *
+ * @deprecated users should switch to the general purpose
+ * {@link AudioRouting.OnRoutingChangedListener} class instead.
*/
@Deprecated
- public interface OnRoutingChangedListener {
+ public interface OnRoutingChangedListener extends AudioRouting.OnRoutingChangedListener {
/**
- * Called when the routing of an AudioTrack changes from either and explicit or
- * policy rerouting. Use {@link #getRoutedDevice()} to retrieve the newly routed-to
- * device.
+ * Called when the routing of an AudioTrack changes from either and
+ * explicit or policy rerouting. Use {@link #getRoutedDevice()} to
+ * retrieve the newly routed-to device.
*/
- @Deprecated
public void onRoutingChanged(AudioTrack audioTrack);
- }
- /**
- * The list of AudioTrack.OnRoutingChangedListener interfaces added (with
- * {@link AudioTrack#addOnRoutingChangedListener(OnRoutingChangedListener, android.os.Handler)}
- * by an app to receive (re)routing notifications.
- */
- private ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>
- mRoutingChangeListeners =
- new ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>();
+ @Override
+ default public void onRoutingChanged(AudioRouting router) {
+ if (router instanceof AudioTrack) {
+ onRoutingChanged((AudioTrack) router);
+ }
+ }
+ }
/**
* Adds an {@link OnRoutingChangedListener} to receive notifications of routing changes
@@ -2542,33 +2550,25 @@
* @param handler Specifies the {@link Handler} object for the thread on which to execute
* the callback. If <code>null</code>, the {@link Handler} associated with the main
* {@link Looper} will be used.
+ * @deprecated users should switch to the general purpose
+ * {@link AudioRouting.OnRoutingChangedListener} class instead.
*/
@Deprecated
public void addOnRoutingChangedListener(OnRoutingChangedListener listener,
android.os.Handler handler) {
- if (listener != null && !mRoutingChangeListeners.containsKey(listener)) {
- synchronized (mRoutingChangeListeners) {
- testEnableNativeRoutingCallbacks();
- mRoutingChangeListeners.put(
- listener, new NativeRoutingEventHandlerDelegate(this, listener,
- handler != null ? handler : new Handler(mInitializationLooper)));
- }
- }
+ addOnRoutingChangedListener((AudioRouting.OnRoutingChangedListener) listener, handler);
}
/**
* Removes an {@link OnRoutingChangedListener} which has been previously added
* to receive rerouting notifications.
* @param listener The previously added {@link OnRoutingChangedListener} interface to remove.
+ * @deprecated users should switch to the general purpose
+ * {@link AudioRouting.OnRoutingChangedListener} class instead.
*/
@Deprecated
public void removeOnRoutingChangedListener(OnRoutingChangedListener listener) {
- synchronized (mRoutingChangeListeners) {
- if (mRoutingChangeListeners.containsKey(listener)) {
- mRoutingChangeListeners.remove(listener);
- }
- testDisableNativeRoutingCallbacks();
- }
+ removeOnRoutingChangedListener((AudioRouting.OnRoutingChangedListener) listener);
}
/**
@@ -2576,27 +2576,12 @@
*/
private void broadcastRoutingChange() {
AudioManager.resetAudioPortGeneration();
-
- // Marshmallow Routing
- Collection<NativeRoutingEventHandlerDelegate> values;
synchronized (mRoutingChangeListeners) {
- values = mRoutingChangeListeners.values();
- }
- for(NativeRoutingEventHandlerDelegate delegate : values) {
- Handler handler = delegate.getHandler();
- if (handler != null) {
- handler.sendEmptyMessage(AudioSystem.NATIVE_EVENT_ROUTING_CHANGE);
- }
- }
- // >= "N" Routing
- Collection<NativeNewRoutingEventHandlerDelegate> newValues;
- synchronized (mNewRoutingChangeListeners) {
- newValues = mNewRoutingChangeListeners.values();
- }
- for(NativeNewRoutingEventHandlerDelegate delegate : newValues) {
- Handler handler = delegate.getHandler();
- if (handler != null) {
- handler.sendEmptyMessage(AudioSystem.NATIVE_EVENT_ROUTING_CHANGE);
+ for (NativeRoutingEventHandlerDelegate delegate : mRoutingChangeListeners.values()) {
+ Handler handler = delegate.getHandler();
+ if (handler != null) {
+ handler.sendEmptyMessage(AudioSystem.NATIVE_EVENT_ROUTING_CHANGE);
+ }
}
}
}
@@ -2681,7 +2666,6 @@
}
/**
- * Marshmallow Routing API.
* Helper class to handle the forwarding of native events to the appropriate listener
* (potentially) handled in a different thread
*/
@@ -2689,57 +2673,6 @@
private final Handler mHandler;
NativeRoutingEventHandlerDelegate(final AudioTrack track,
- final OnRoutingChangedListener listener,
- Handler handler) {
- // find the looper for our new event handler
- Looper looper;
- if (handler != null) {
- looper = handler.getLooper();
- } else {
- // no given handler, use the looper the AudioTrack was created in
- looper = mInitializationLooper;
- }
-
- // construct the event handler with this looper
- if (looper != null) {
- // implement the event handler delegate
- mHandler = new Handler(looper) {
- @Override
- public void handleMessage(Message msg) {
- if (track == null) {
- return;
- }
- switch(msg.what) {
- case AudioSystem.NATIVE_EVENT_ROUTING_CHANGE:
- if (listener != null) {
- listener.onRoutingChanged(track);
- }
- break;
- default:
- loge("Unknown native event type: " + msg.what);
- break;
- }
- }
- };
- } else {
- mHandler = null;
- }
- }
-
- Handler getHandler() {
- return mHandler;
- }
- }
-
- /**
- * Marshmallow Routing API.
- * Helper class to handle the forwarding of native events to the appropriate listener
- * (potentially) handled in a different thread
- */
- private class NativeNewRoutingEventHandlerDelegate {
- private final Handler mHandler;
-
- NativeNewRoutingEventHandlerDelegate(final AudioTrack track,
final AudioRouting.OnRoutingChangedListener listener,
Handler handler) {
// find the looper for our new event handler
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index 2bd9781..7af9c24 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -2611,10 +2611,13 @@
public static final int VP8ProfileMain = 0x01;
// from OMX_VIDEO_VP9PROFILETYPE
- public static final int VP9Profile0 = 0x00;
- public static final int VP9Profile1 = 0x01;
- public static final int VP9Profile2 = 0x02;
- public static final int VP9Profile3 = 0x03;
+ public static final int VP9Profile0 = 0x01;
+ public static final int VP9Profile1 = 0x02;
+ public static final int VP9Profile2 = 0x04;
+ public static final int VP9Profile3 = 0x08;
+ // HDR profiles also support passing HDR metadata
+ public static final int VP9Profile2HDR = 0x1000;
+ public static final int VP9Profile3HDR = 0x2000;
// from OMX_VIDEO_VP9LEVELTYPE
public static final int VP9Level1 = 0x0;
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index b78869e..55d5f42 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -1107,6 +1107,9 @@
* as this call returns.
*
* @param afd the AssetFileDescriptor for the file you want to play
+ * @throws IllegalStateException if it is called in an invalid state
+ * @throws IllegalArgumentException if afd is not a valid AssetFileDescriptor
+ * @throws IOException if afd can not be read
*/
public void setDataSource(@NonNull AssetFileDescriptor afd)
throws IOException, IllegalArgumentException, IllegalStateException {
@@ -1127,6 +1130,8 @@
*
* @param fd the FileDescriptor for the file you want to play
* @throws IllegalStateException if it is called in an invalid state
+ * @throws IllegalArgumentException if fd is not a valid FileDescriptor
+ * @throws IOException if fd can not be read
*/
public void setDataSource(FileDescriptor fd)
throws IOException, IllegalArgumentException, IllegalStateException {
@@ -1143,6 +1148,8 @@
* @param offset the offset into the file where the data to be played starts, in bytes
* @param length the length in bytes of the data to be played
* @throws IllegalStateException if it is called in an invalid state
+ * @throws IllegalArgumentException if fd is not a valid FileDescriptor
+ * @throws IOException if fd can not be read
*/
public void setDataSource(FileDescriptor fd, long offset, long length)
throws IOException, IllegalArgumentException, IllegalStateException {
@@ -1157,6 +1164,7 @@
*
* @param dataSource the MediaDataSource for the media you want to play
* @throws IllegalStateException if it is called in an invalid state
+ * @throws IllegalArgumentException if dataSource is not a valid MediaDataSource
*/
public void setDataSource(MediaDataSource dataSource)
throws IllegalArgumentException, IllegalStateException {
diff --git a/media/java/android/media/tv/TvTrackInfo.java b/media/java/android/media/tv/TvTrackInfo.java
index e623353..d718a7e 100644
--- a/media/java/android/media/tv/TvTrackInfo.java
+++ b/media/java/android/media/tv/TvTrackInfo.java
@@ -20,9 +20,12 @@
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
+import android.text.TextUtils;
import com.android.internal.util.Preconditions;
+import java.util.Objects;
+
/**
* Encapsulates the format of tracks played in {@link TvInputService}.
*/
@@ -245,6 +248,37 @@
dest.writeBundle(mExtra);
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof TvTrackInfo)) {
+ return false;
+ }
+
+ TvTrackInfo obj = (TvTrackInfo) o;
+ return TextUtils.equals(mId, obj.mId)
+ && mType == obj.mType
+ && TextUtils.equals(mLanguage, obj.mLanguage)
+ && TextUtils.equals(mDescription, obj.mDescription)
+ && Objects.equals(mExtra, obj.mExtra)
+ && (mType == TYPE_AUDIO
+ ? mAudioChannelCount == obj.mAudioChannelCount
+ && mAudioSampleRate == obj.mAudioSampleRate
+ : (mType == TYPE_VIDEO
+ ? mVideoWidth == obj.mVideoWidth
+ && mVideoHeight == obj.mVideoHeight
+ && mVideoFrameRate == obj.mVideoFrameRate
+ && mVideoPixelAspectRatio == obj.mVideoPixelAspectRatio : true));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(mId);
+ }
+
public static final Parcelable.Creator<TvTrackInfo> CREATOR =
new Parcelable.Creator<TvTrackInfo>() {
@Override
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
index 40b54d3..7a7d3a1 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
@@ -232,12 +232,13 @@
final MenuItem list = menu.findItem(R.id.menu_list);
final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
- boolean recents = cwd == null;
- createDir.setVisible(picking && !recents && cwd.isCreateSupported());
+ createDir.setVisible(picking);
+ createDir.setEnabled(canCreateDirectory());
// No display options in recent directories
- if (picking && recents) {
+ boolean inRecents = cwd == null;
+ if (picking && inRecents) {
grid.setVisible(false);
list.setVisible(false);
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
index bc2133e..aa9f356 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -833,6 +833,15 @@
getActivity(),
DocumentsActivity.class);
+
+ // Relay any config overrides bits present in the original intent.
+ Intent original = getActivity().getIntent();
+ if (original != null && original.hasExtra(Shared.EXTRA_PRODUCTIVITY_MODE)) {
+ intent.putExtra(
+ Shared.EXTRA_PRODUCTIVITY_MODE,
+ original.getBooleanExtra(Shared.EXTRA_PRODUCTIVITY_MODE, false));
+ }
+
// Set an appropriate title on the drawer when it is shown in the picker.
// Coupled with the fact that we auto-open the drawer for copy/move operations
// it should basically be the thing people see first.
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DocumentHolder.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DocumentHolder.java
index 450341f..2288fe74 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DocumentHolder.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DocumentHolder.java
@@ -139,11 +139,13 @@
}
// Do everything in global coordinates - it makes things simpler.
- Rect rect = new Rect();
- mSelectionHotspot.getGlobalVisibleRect(rect);
+ int[] coords = new int[2];
+ mSelectionHotspot.getLocationOnScreen(coords);
+ Rect rect = new Rect(coords[0], coords[1], coords[0] + mSelectionHotspot.getWidth(),
+ coords[1] + mSelectionHotspot.getHeight());
// If the tap occurred within the icon rect, consider it a selection.
- if (rect.contains((int)event.getRawX(), (int)event.getRawY())) {
+ if (rect.contains((int) event.getRawX(), (int) event.getRawY())) {
return mEventListener.onSelect(this);
} else {
return mEventListener.onActivate(this);
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/DocumentLoader.java b/packages/MtpDocumentsProvider/src/com/android/mtp/DocumentLoader.java
index 329afdd..6ed4ea1 100644
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/DocumentLoader.java
+++ b/packages/MtpDocumentsProvider/src/com/android/mtp/DocumentLoader.java
@@ -196,9 +196,10 @@
}
task.loadObjectInfoList(NUM_LOADING_ENTRIES);
final boolean shouldNotify =
- task.mLastNotified.getTime() <
- new Date().getTime() - NOTIFY_PERIOD_MS ||
- task.getState() != LoaderTask.STATE_LOADING;
+ task.getState() != LoaderTask.STATE_CANCELLED &&
+ (task.mLastNotified.getTime() <
+ new Date().getTime() - NOTIFY_PERIOD_MS ||
+ task.getState() != LoaderTask.STATE_LOADING);
if (shouldNotify) {
task.notify(mResolver);
}
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/DocumentLoaderTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/DocumentLoaderTest.java
index 60dd7e1..a3c6bd7 100644
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/DocumentLoaderTest.java
+++ b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/DocumentLoaderTest.java
@@ -143,9 +143,9 @@
}
}
- public void testCancelTask() throws IOException, InterruptedException {
+ public void testCancelTask() throws IOException, InterruptedException, TimeoutException {
setUpDocument(mManager,
- DocumentLoader.NUM_INITIAL_ENTRIES + DocumentLoader.NUM_LOADING_ENTRIES + 1);
+ DocumentLoader.NUM_INITIAL_ENTRIES + 1);
// Block the first iteration in the background thread.
mManager.blockDocument(
@@ -155,19 +155,24 @@
MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier)) {
assertTrue(cursor.getExtras().getBoolean(DocumentsContract.EXTRA_LOADING));
}
- Thread.sleep(DocumentLoader.NOTIFY_PERIOD_MS);
+
+ final Uri uri = DocumentsContract.buildChildDocumentsUri(
+ MtpDocumentsProvider.AUTHORITY, mParentIdentifier.mDocumentId);
+ assertEquals(0, mResolver.getChangeCount(uri));
// Clear task while the first iteration is being blocked.
+ mLoader.cancelTask(mParentIdentifier);
mManager.unblockDocument(
0, DocumentLoader.NUM_INITIAL_ENTRIES + 1);
- mLoader.cancelTask(mParentIdentifier);
-
- Thread.sleep(DocumentLoader.NOTIFY_PERIOD_MS * 2);
+ Thread.sleep(DocumentLoader.NOTIFY_PERIOD_MS);
+ assertEquals(0, mResolver.getChangeCount(uri));
// Check if it's OK to query invalidated task.
try (final Cursor cursor = mLoader.queryChildDocuments(
MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION, mParentIdentifier)) {
+ assertTrue(cursor.getExtras().getBoolean(DocumentsContract.EXTRA_LOADING));
}
+ mResolver.waitForNotification(uri, 1);
}
private void setUpLoader() {
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 5621642..640399f 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -1831,14 +1831,11 @@
private void maybeNotifyProfiles(int userId, Uri uri, String name,
Set<String> keysCloned) {
if (keysCloned.contains(name)) {
- List<UserInfo> profiles = mUserManager.getProfiles(userId);
- int size = profiles.size();
- for (int i = 0; i < size; i++) {
- UserInfo profile = profiles.get(i);
+ for (int profileId : mUserManager.getProfileIdsWithDisabled(userId)) {
// the notification for userId has already been sent.
- if (profile.id != userId) {
+ if (profileId != userId) {
mHandler.obtainMessage(MyHandler.MSG_NOTIFY_URI_CHANGED,
- profile.id, 0, uri).sendToTarget();
+ profileId, 0, uri).sendToTarget();
}
}
}
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index e1e0c3b..3b53055 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -179,42 +179,37 @@
sendBugreportStarted(1000);
waitForScreenshotButtonEnabled(true);
- final NumberFormat nf = NumberFormat.getPercentInstance();
- nf.setMinimumFractionDigits(2);
- nf.setMaximumFractionDigits(2);
-
- assertProgressNotification(NAME, nf.format(0));
+ assertProgressNotification(NAME, 0f);
SystemProperties.set(PROGRESS_PROPERTY, "108");
- assertProgressNotification(NAME, nf.format(0.108));
+ assertProgressNotification(NAME, 10.80f);
- SystemProperties.set(PROGRESS_PROPERTY, "500");
- assertProgressNotification(NAME, nf.format(0.50));
+ assertProgressNotification(NAME, 50.00f);
SystemProperties.set(PROGRESS_PROPERTY, "950");
- assertProgressNotification(NAME, nf.format(0.95));
+ assertProgressNotification(NAME, 95.00f);
// Make sure progress never goes back...
SystemProperties.set(MAX_PROPERTY, "2000");
Thread.sleep(POLLING_FREQUENCY + DateUtils.SECOND_IN_MILLIS);
- assertProgressNotification(NAME, nf.format(0.95));
+ assertProgressNotification(NAME, 95.00f);
SystemProperties.set(PROGRESS_PROPERTY, "1000");
- assertProgressNotification(NAME, nf.format(0.95));
+ assertProgressNotification(NAME, 95.00f);
// ...only forward...
SystemProperties.set(PROGRESS_PROPERTY, "1902");
- assertProgressNotification(NAME, nf.format(0.9510));
+ assertProgressNotification(NAME, 95.10f);
SystemProperties.set(PROGRESS_PROPERTY, "1960");
- assertProgressNotification(NAME, nf.format(0.98));
+ assertProgressNotification(NAME, 98.00f);
// ...but never more than the capped value.
SystemProperties.set(PROGRESS_PROPERTY, "2000");
- assertProgressNotification(NAME, nf.format(0.99));
+ assertProgressNotification(NAME, 99.00f);
SystemProperties.set(PROGRESS_PROPERTY, "3000");
- assertProgressNotification(NAME, nf.format(0.99));
+ assertProgressNotification(NAME, 99.00f);
Bundle extras =
sendBugreportFinishedAndGetSharedIntent(ID, mPlainTextPath, mScreenshotPath);
@@ -233,7 +228,7 @@
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
- assertProgressNotification(NAME, nf.format(0));
+ assertProgressNotification(NAME, 00.00f);
openProgressNotification(ID);
UiObject cancelButton = mUiBot.getVisibleObject(mContext.getString(
@@ -338,7 +333,7 @@
detailsUi.clickOk();
assertPropertyValue(NAME_PROPERTY, NEW_NAME);
- assertProgressNotification(NEW_NAME, "0.00%");
+ assertProgressNotification(NEW_NAME, 00.00f);
Bundle extras = sendBugreportFinishedAndGetSharedIntent(ID, mPlainTextPath,
mScreenshotPath);
@@ -375,7 +370,7 @@
detailsUi.clickOk();
assertPropertyValue(NAME_PROPERTY, NEW_NAME);
- assertProgressNotification(NEW_NAME, "0.00%");
+ assertProgressNotification(NEW_NAME, 00.00f);
Bundle extras = sendBugreportFinishedAndGetSharedIntent(ID,
plainText? mPlainTextPath : mZipPath, mScreenshotPath);
@@ -571,13 +566,13 @@
}
}
- private void assertProgressNotification(String name, String percent) {
+ private void assertProgressNotification(String name, float percent) {
// TODO: it currently looks for 3 distinct objects, without taking advantage of their
// relationship.
openProgressNotification(ID);
Log.v(TAG, "Looking for progress notification details: '" + name + "-" + percent + "'");
mUiBot.getObject(name);
- mUiBot.getObject(percent);
+ // TODO: need a way to get the ProgresBar from the "android:id/progress" UIObject...
}
private UiObject openProgressNotification(int id) {
diff --git a/packages/SystemUI/res/anim/tv_pip_overlay_fade_in_animation.xml b/packages/SystemUI/res/anim/tv_pip_overlay_fade_in_animation.xml
new file mode 100644
index 0000000..33bceaa
--- /dev/null
+++ b/packages/SystemUI/res/anim/tv_pip_overlay_fade_in_animation.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:propertyName="alpha"
+ android:valueTo="1"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:duration="350" />
diff --git a/packages/SystemUI/res/anim/tv_pip_overlay_fade_out_animation.xml b/packages/SystemUI/res/anim/tv_pip_overlay_fade_out_animation.xml
new file mode 100644
index 0000000..a12ddff
--- /dev/null
+++ b/packages/SystemUI/res/anim/tv_pip_overlay_fade_out_animation.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:propertyName="alpha"
+ android:valueTo="0"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:duration="500" />
diff --git a/packages/SystemUI/res/drawable/recents_info_dark.xml b/packages/SystemUI/res/drawable/recents_info_dark.xml
index b1a2242..555a69a 100644
--- a/packages/SystemUI/res/drawable/recents_info_dark.xml
+++ b/packages/SystemUI/res/drawable/recents_info_dark.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48.0dp"
- android:height="48.0dp"
+ android:width="24.0dp"
+ android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
diff --git a/packages/SystemUI/res/drawable/recents_info_light.xml b/packages/SystemUI/res/drawable/recents_info_light.xml
index bc58c3b..65e7bf5 100644
--- a/packages/SystemUI/res/drawable/recents_info_light.xml
+++ b/packages/SystemUI/res/drawable/recents_info_light.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48.0dp"
- android:height="48.0dp"
+ android:width="24.0dp"
+ android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
diff --git a/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml b/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml
index b88846b..5d3b5ff 100644
--- a/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml
@@ -84,6 +84,7 @@
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackgroundBorderless"
+ android:contentDescription="@string/accessibility_quick_settings_expand"
android:padding="12dp" />
</LinearLayout>
diff --git a/packages/SystemUI/res/layout/recents.xml b/packages/SystemUI/res/layout/recents.xml
index 186aaf6..ae89631 100644
--- a/packages/SystemUI/res/layout/recents.xml
+++ b/packages/SystemUI/res/layout/recents.xml
@@ -25,6 +25,14 @@
android:layout_height="match_parent">
</com.android.systemui.recents.views.RecentsView>
+ <!-- Incompatible task overlay -->
+ <ViewStub android:id="@+id/incompatible_app_overlay_stub"
+ android:inflatedId="@+id/incompatible_app_overlay"
+ android:layout="@layout/recents_incompatible_app_overlay"
+ android:layout_width="match_parent"
+ android:layout_height="128dp"
+ android:layout_gravity="center_horizontal|top" />
+
<!-- Nav Bar Scrim View -->
<ImageView
android:id="@+id/nav_bar_scrim"
diff --git a/packages/SystemUI/res/layout/recents_incompatible_app_overlay.xml b/packages/SystemUI/res/layout/recents_incompatible_app_overlay.xml
new file mode 100644
index 0000000..2b49dd3
--- /dev/null
+++ b/packages/SystemUI/res/layout/recents_incompatible_app_overlay.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:alpha="0"
+ android:background="#88000000"
+ android:forceHasOverlappingRendering="false">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:drawableTop="@drawable/recents_info_light"
+ android:drawablePadding="8dp"
+ android:text="@string/recents_incompatible_app_message" />
+</FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/recents_task_view.xml b/packages/SystemUI/res/layout/recents_task_view.xml
index c813818..b1b2f1e 100644
--- a/packages/SystemUI/res/layout/recents_task_view.xml
+++ b/packages/SystemUI/res/layout/recents_task_view.xml
@@ -26,7 +26,9 @@
android:id="@+id/task_view_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+
<include layout="@layout/recents_task_view_header" />
+
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
android:id="@+id/lock_to_app_fab"
android:layout_width="@dimen/recents_lock_to_app_size"
@@ -45,6 +47,17 @@
android:layout_gravity="center"
android:src="@drawable/recents_lock_to_app_pin" />
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
+
+ <!-- The incompatible app toast -->
+ <ViewStub android:id="@+id/incompatible_app_toast_stub"
+ android:inflatedId="@+id/incompatible_app_toast"
+ android:layout="@*android:layout/transient_notification"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top|center_horizontal"
+ android:layout_marginTop="48dp"
+ android:layout_marginLeft="16dp"
+ android:layout_marginRight="16dp" />
</FrameLayout>
</com.android.systemui.recents.views.TaskView>
diff --git a/packages/SystemUI/res/layout/recents_task_view_header.xml b/packages/SystemUI/res/layout/recents_task_view_header.xml
index 2b3c5df..2df57bf 100644
--- a/packages/SystemUI/res/layout/recents_task_view_header.xml
+++ b/packages/SystemUI/res/layout/recents_task_view_header.xml
@@ -31,40 +31,19 @@
android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="12dp" />
- <LinearLayout
- android:id="@+id/title_container"
+ <TextView
+ android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
- android:orientation="vertical">
- <TextView
- android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:textSize="16sp"
- android:textColor="#ffffffff"
- android:text="@string/recents_empty_message"
- android:fontFamily="sans-serif-medium"
- android:singleLine="true"
- android:maxLines="1"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
- <TextView
- android:id="@+id/sub_title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:textSize="11sp"
- android:textColor="#ffffffff"
- android:text="@string/recents_launch_non_dockable_task_label"
- android:fontFamily="sans-serif-medium"
- android:singleLine="true"
- android:maxLines="1"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal"
- android:visibility="gone" />
- </LinearLayout>
+ android:textSize="16sp"
+ android:textColor="#ffffffff"
+ android:text="@string/recents_empty_message"
+ android:fontFamily="sans-serif-medium"
+ android:singleLine="true"
+ android:maxLines="1"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
<com.android.systemui.recents.views.FixedSizeImageView
android:id="@+id/move_task"
android:layout_width="wrap_content"
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index a33b7a3..dc9ffa9 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -735,10 +735,8 @@
<string name="recents_launch_disabled_message"><xliff:g id="app" example="Calendar">%s</xliff:g> is disabled in safe-mode.</string>
<!-- Recents: Stack action button string. [CHAR LIMIT=NONE] -->
<string name="recents_stack_action_button_label">Clear all</string>
- <!-- Recents: Non-dockable task drag message. [CHAR LIMIT=NONE] -->
- <string name="recents_drag_non_dockable_task_message">This app does not support multi-window</string>
- <!-- Recents: Non-dockable task launch sub header. [CHAR LIMIT=NONE] -->
- <string name="recents_launch_non_dockable_task_label">App does not support multi-window</string>
+ <!-- Recents: Incompatible task message. [CHAR LIMIT=NONE] -->
+ <string name="recents_incompatible_app_message">App doesn\'t support split screen</string>
<!-- Recents: MultiStack add stack split horizontal radio button. [CHAR LIMIT=NONE] -->
<string name="recents_multistack_add_stack_dialog_split_horizontal">Split Horizontal</string>
@@ -1594,4 +1592,7 @@
<!-- Warning message when we try to dock a non-resizeble tasks and launch it in fullscreen instead. -->
<string name="dock_non_resizeble_failed_to_dock_text">App does not support split-screen.</string>
+ <!-- accessibility label for button to expand quick settings [CHAR LIMIT=NONE] -->
+ <string name="accessibility_quick_settings_expand">Expand quick settings.</string>
+
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 66754a7..f892fd6 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -847,17 +847,16 @@
private void doKeyguardLaterForChildProfilesLocked() {
UserManager um = UserManager.get(mContext);
- List<UserInfo> profiles = um.getEnabledProfiles(UserHandle.myUserId());
- for (UserInfo info : profiles) {
- if (mLockPatternUtils.isSeparateProfileChallengeEnabled(info.id)) {
- long userTimeout = getLockTimeout(info.id);
+ for (int profileId : um.getEnabledProfileIds(UserHandle.myUserId())) {
+ if (mLockPatternUtils.isSeparateProfileChallengeEnabled(profileId)) {
+ long userTimeout = getLockTimeout(profileId);
if (userTimeout == 0) {
doKeyguardForChildProfilesLocked();
} else {
long userWhen = SystemClock.elapsedRealtime() + userTimeout;
Intent lockIntent = new Intent(DELAYED_LOCK_PROFILE_ACTION);
lockIntent.putExtra("seq", mDelayedProfileShowingSequence);
- lockIntent.putExtra(Intent.EXTRA_USER_ID, info.id);
+ lockIntent.putExtra(Intent.EXTRA_USER_ID, profileId);
PendingIntent lockSender = PendingIntent.getBroadcast(
mContext, 0, lockIntent, PendingIntent.FLAG_CANCEL_CURRENT);
mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
@@ -869,10 +868,9 @@
private void doKeyguardForChildProfilesLocked() {
UserManager um = UserManager.get(mContext);
- List<UserInfo> profiles = um.getEnabledProfiles(UserHandle.myUserId());
- for (UserInfo info : profiles) {
- if (mLockPatternUtils.isSeparateProfileChallengeEnabled(info.id)) {
- lockProfile(info.id);
+ for (int profileId : um.getEnabledProfileIds(UserHandle.myUserId())) {
+ if (mLockPatternUtils.isSeparateProfileChallengeEnabled(profileId)) {
+ lockProfile(profileId);
}
}
}
@@ -1482,9 +1480,8 @@
final UserHandle currentUser = new UserHandle(KeyguardUpdateMonitor.getCurrentUser());
final UserManager um = (UserManager) mContext.getSystemService(
Context.USER_SERVICE);
- List <UserInfo> userHandles = um.getProfiles(currentUser.getIdentifier());
- for (UserInfo ui : userHandles) {
- mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, ui.getUserHandle());
+ for (int profileId : um.getProfileIdsWithDisabled(currentUser.getIdentifier())) {
+ mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, UserHandle.of(profileId));
}
} else {
mBootSendUserPresent = true;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
index 9e40cfd..44b38f1 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
@@ -93,6 +93,12 @@
}
}
+ @Override
+ public boolean hasOverlappingRendering() {
+ // Avoid layers for this layout - we don't need them.
+ return false;
+ }
+
/**
* Update the accessibility order for this view.
*
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
index ab21532..f34df75 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
@@ -16,13 +16,18 @@
package com.android.systemui.qs.external;
import android.app.ActivityManager;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.Uri;
import android.os.Handler;
import android.os.UserHandle;
import android.service.quicksettings.IQSTileService;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
+import libcore.util.Objects;
/**
* Manages the priority which lets {@link TileServices} make decisions about which tiles
@@ -68,6 +73,12 @@
mHandler = handler;
mStateManager = tileLifecycleManager;
mStateManager.setQSService(tileServices);
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+ filter.addDataScheme("package");
+ mServices.getContext().registerReceiverAsUser(mUninstallReceiver,
+ new UserHandle(ActivityManager.getCurrentUser()), filter, null, mHandler);
}
public boolean isActiveTile() {
@@ -106,6 +117,7 @@
}
public void handleDestroy() {
+ mServices.getContext().unregisterReceiver(mUninstallReceiver);
mStateManager.handleDestroy();
}
@@ -198,4 +210,23 @@
mServices.recalculateBindAllowance();
}
};
+
+ private final BroadcastReceiver mUninstallReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (!Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
+ return;
+ }
+ if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
+ return;
+ }
+ Uri data = intent.getData();
+ String pkgName = data.getEncodedSchemeSpecificPart();
+ final ComponentName component = mStateManager.getComponent();
+ if (!Objects.equal(pkgName, component.getPackageName())) {
+ return;
+ }
+ mServices.getHost().removeTile(component);
+ }
+ };
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
index f36d013..2ab6b5f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
@@ -72,6 +72,10 @@
return mContext;
}
+ public QSTileHost getHost() {
+ return mHost;
+ }
+
public TileServiceManager getTileWrapper(CustomTile tile) {
ComponentName component = tile.getComponent();
TileServiceManager service = onCreateTileService(component);
@@ -89,6 +93,7 @@
public void freeService(CustomTile tile, TileServiceManager service) {
synchronized (mServices) {
service.setBindAllowed(false);
+ service.handleDestroy();
mServices.remove(tile);
mTiles.remove(tile.getComponent());
final String slot = tile.getComponent().getClassName();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
index e494fd8..77eaa3b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
@@ -130,6 +130,8 @@
}
};
state.label = percentage;
+ state.contentDescription = mContext.getString(R.string.accessibility_quick_settings_battery,
+ percentage);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
index 287bb22..82daaa6 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
@@ -435,7 +435,7 @@
mDraggingInRecentsCurrentUser = currentUser;
return true;
} else {
- Toast.makeText(mContext, R.string.recents_drag_non_dockable_task_message,
+ Toast.makeText(mContext, R.string.recents_incompatible_app_message,
Toast.LENGTH_SHORT).show();
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index b1d9555..6b476ee 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -38,6 +38,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
+import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
@@ -58,8 +59,10 @@
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
+import com.android.systemui.recents.events.ui.HideIncompatibleAppOverlayEvent;
import com.android.systemui.recents.events.ui.RecentsDrawnEvent;
import com.android.systemui.recents.events.ui.ShowApplicationInfoEvent;
+import com.android.systemui.recents.events.ui.ShowIncompatibleAppOverlayEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
import com.android.systemui.recents.events.ui.UserInteractionEvent;
@@ -68,12 +71,12 @@
import com.android.systemui.recents.events.ui.focus.FocusPreviousTaskViewEvent;
import com.android.systemui.recents.misc.DozeTrigger;
import com.android.systemui.recents.misc.SystemServicesProxy;
+import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.RecentsPackageMonitor;
import com.android.systemui.recents.model.RecentsTaskLoadPlan;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
-import com.android.systemui.recents.views.AnimationProps;
import com.android.systemui.recents.views.RecentsView;
import com.android.systemui.recents.views.SystemBarScrimViews;
import com.android.systemui.statusbar.BaseStatusBar;
@@ -90,6 +93,7 @@
private final static boolean DEBUG = false;
public final static int EVENT_BUS_PRIORITY = Recents.EVENT_BUS_PRIORITY + 1;
+ public final static int INCOMPATIBLE_APP_ALPHA_DURATION = 150;
private RecentsPackageMonitor mPackageMonitor;
private long mLastTabKeyEventTime;
@@ -101,6 +105,7 @@
// Top level views
private RecentsView mRecentsView;
private SystemBarScrimViews mScrimViews;
+ private View mIncompatibleAppOverlay;
// Runnables to finish the Recents activity
private Intent mHomeIntent;
@@ -674,6 +679,30 @@
MetricsLogger.count(this, "overview_app_info", 1);
}
+ public final void onBusEvent(ShowIncompatibleAppOverlayEvent event) {
+ if (mIncompatibleAppOverlay == null) {
+ mIncompatibleAppOverlay = Utilities.findViewStubById(this,
+ R.id.incompatible_app_overlay_stub).inflate();
+ mIncompatibleAppOverlay.setWillNotDraw(false);
+ mIncompatibleAppOverlay.setVisibility(View.VISIBLE);
+ }
+ mIncompatibleAppOverlay.animate()
+ .alpha(1f)
+ .setDuration(INCOMPATIBLE_APP_ALPHA_DURATION)
+ .setInterpolator(Interpolators.ALPHA_IN)
+ .start();
+ }
+
+ public final void onBusEvent(HideIncompatibleAppOverlayEvent event) {
+ if (mIncompatibleAppOverlay != null) {
+ mIncompatibleAppOverlay.animate()
+ .alpha(0f)
+ .setDuration(INCOMPATIBLE_APP_ALPHA_DURATION)
+ .setInterpolator(Interpolators.ALPHA_OUT)
+ .start();
+ }
+ }
+
public final void onBusEvent(DeleteTaskDataEvent event) {
// Remove any stored data from the loader
RecentsTaskLoader loader = Recents.getTaskLoader();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/HideIncompatibleAppOverlayEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/HideIncompatibleAppOverlayEvent.java
new file mode 100644
index 0000000..d6ef636
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/HideIncompatibleAppOverlayEvent.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.events.ui;
+
+import com.android.systemui.recents.events.EventBus;
+
+/**
+ * This is sent when a user stops draggin an incompatible app task.
+ */
+public class HideIncompatibleAppOverlayEvent extends EventBus.Event {
+ // Simple event
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/ShowIncompatibleAppOverlayEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/ShowIncompatibleAppOverlayEvent.java
new file mode 100644
index 0000000..3a4350e
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/ShowIncompatibleAppOverlayEvent.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.events.ui;
+
+import com.android.systemui.recents.events.EventBus;
+
+/**
+ * This is sent when a user starts dragging an incompatible app task.
+ */
+public class ShowIncompatibleAppOverlayEvent extends EventBus.Event {
+ // Simple event
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
index 69d98af..44f220b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
@@ -19,6 +19,7 @@
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.annotation.FloatRange;
+import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
@@ -30,6 +31,7 @@
import android.util.TypedValue;
import android.view.View;
import android.view.ViewParent;
+import android.view.ViewStub;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.views.TaskViewTransform;
@@ -220,6 +222,20 @@
}
/**
+ * Returns a view stub for the given view id.
+ */
+ public static ViewStub findViewStubById(View v, int stubId) {
+ return (ViewStub) v.findViewById(stubId);
+ }
+
+ /**
+ * Returns a view stub for the given view id.
+ */
+ public static ViewStub findViewStubById(Activity a, int stubId) {
+ return (ViewStub) a.findViewById(stubId);
+ }
+
+ /**
* Updates {@param transforms} to be the same size as {@param tasks}.
*/
public static void matchTaskListSize(List<Task> tasks, List<TaskViewTransform> transforms) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
index a867bde..22acb88 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
@@ -20,19 +20,17 @@
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
-import android.provider.Settings;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.ViewDebug;
-import android.widget.Toast;
import com.android.internal.policy.DividerSnapAlgorithm;
-import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsConfiguration;
-import com.android.systemui.recents.RecentsImpl;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.ConfigurationChangedEvent;
+import com.android.systemui.recents.events.ui.HideIncompatibleAppOverlayEvent;
+import com.android.systemui.recents.events.ui.ShowIncompatibleAppOverlayEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragDropTargetChangedEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent;
@@ -166,8 +164,7 @@
if (ActivityManager.supportsMultiWindow() && !ssp.hasDockedTask()
&& mDividerSnapAlgorithm.isSplitScreenFeasible()) {
if (!event.task.isDockable) {
- Toast.makeText(mRv.getContext(), R.string.recents_drag_non_dockable_task_message,
- Toast.LENGTH_SHORT).show();
+ EventBus.getDefault().send(new ShowIncompatibleAppOverlayEvent());
} else {
// Add the dock state drop targets (these take priority)
TaskStack.DockState[] dockStates = getDockStatesForCurrentOrientation();
@@ -184,6 +181,9 @@
}
public final void onBusEvent(DragEndEvent event) {
+ if (!mDragTask.isDockable) {
+ EventBus.getDefault().send(new HideIncompatibleAppOverlayEvent());
+ }
mDragRequested = false;
mDragTask = null;
mTaskView = null;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 6e585ae..6be8a4a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -39,6 +39,7 @@
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewOutlineProvider;
+import android.widget.TextView;
import android.widget.Toast;
import com.android.internal.logging.MetricsLogger;
@@ -157,6 +158,7 @@
@ViewDebug.ExportedProperty(deepExport=true, prefix="header_")
TaskViewHeader mHeaderView;
View mActionButtonView;
+ View mIncompatibleAppToastView;
TaskViewCallbacks mCb;
@ViewDebug.ExportedProperty(category="recents")
@@ -345,6 +347,9 @@
mActionButtonView.setScaleY(1f);
mActionButtonView.setAlpha(0f);
mActionButtonView.setTranslationZ(mActionButtonTranslationZ);
+ if (mIncompatibleAppToastView != null) {
+ mIncompatibleAppToastView.setVisibility(View.INVISIBLE);
+ }
}
/**
@@ -536,6 +541,10 @@
// These values will be animated in when onStartLaunchTargetEnterAnimation() is called
setDimAlphaWithoutHeader(0);
mActionButtonView.setAlpha(0f);
+ if (mIncompatibleAppToastView != null &&
+ mIncompatibleAppToastView.getVisibility() == View.VISIBLE) {
+ mIncompatibleAppToastView.setAlpha(0f);
+ }
}
@Override
@@ -554,6 +563,15 @@
if (screenPinningEnabled) {
showActionButton(true /* fadeIn */, duration /* fadeInDuration */);
}
+
+ if (mIncompatibleAppToastView != null &&
+ mIncompatibleAppToastView.getVisibility() == View.VISIBLE) {
+ mIncompatibleAppToastView.animate()
+ .alpha(1f)
+ .setDuration(duration)
+ .setInterpolator(Interpolators.ALPHA_IN)
+ .start();
+ }
}
@Override
@@ -587,6 +605,18 @@
mTask = t;
mTask.addCallback(this);
mIsDisabledInSafeMode = !mTask.isSystemApp && ssp.isInSafeMode();
+
+ if (!t.isDockable && ssp.hasDockedTask()) {
+ if (mIncompatibleAppToastView == null) {
+ mIncompatibleAppToastView = Utilities.findViewStubById(this,
+ R.id.incompatible_app_toast_stub).inflate();
+ TextView msg = (TextView) findViewById(com.android.internal.R.id.message);
+ msg.setText(R.string.recents_incompatible_app_message);
+ }
+ mIncompatibleAppToastView.setVisibility(View.VISIBLE);
+ } else if (mIncompatibleAppToastView != null) {
+ mIncompatibleAppToastView.setVisibility(View.INVISIBLE);
+ }
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
index 570ff8a..16d8e53 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
@@ -39,7 +39,6 @@
import android.view.ViewAnimationUtils;
import android.view.ViewDebug;
import android.view.ViewGroup;
-import android.view.ViewStub;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
@@ -141,15 +140,12 @@
// Header views
ImageView mIconView;
TextView mTitleView;
- TextView mSubTitleView;
ImageView mMoveTaskButton;
ImageView mDismissButton;
- ViewStub mAppOverlayViewStub;
FrameLayout mAppOverlayView;
ImageView mAppIconView;
ImageView mAppInfoView;
TextView mAppTitleView;
- ViewStub mFocusTimerIndicatorStub;
ProgressBar mFocusTimerIndicator;
// Header drawables
@@ -242,13 +238,10 @@
mIconView.setClickable(false);
mIconView.setOnLongClickListener(this);
mTitleView = (TextView) findViewById(R.id.title);
- mSubTitleView = (TextView) findViewById(R.id.sub_title);
mDismissButton = (ImageView) findViewById(R.id.dismiss_task);
if (ssp.hasFreeformWorkspaceSupport()) {
mMoveTaskButton = (ImageView) findViewById(R.id.move_task);
}
- mFocusTimerIndicatorStub = (ViewStub) findViewById(R.id.focus_timer_indicator_stub);
- mAppOverlayViewStub = (ViewStub) findViewById(R.id.app_overlay_stub);
onConfigurationChanged();
}
@@ -305,8 +298,7 @@
R.dimen.recents_task_view_header_button_padding_tablet_land,
R.dimen.recents_task_view_header_button_padding,
R.dimen.recents_task_view_header_button_padding_tablet_land);
- updateLayoutParams(mIconView, findViewById(R.id.title_container), mMoveTaskButton,
- mDismissButton);
+ updateLayoutParams(mIconView, mTitleView, mMoveTaskButton, mDismissButton);
if (mAppOverlayView != null) {
updateLayoutParams(mAppIconView, mAppTitleView, null, mAppInfoView);
}
@@ -462,13 +454,6 @@
mTitleView.setContentDescription(t.titleDescription);
mTitleView.setTextColor(t.useLightOnPrimaryColor ?
mTaskBarViewLightTextColor : mTaskBarViewDarkTextColor);
- if (!t.isDockable && ssp.hasDockedTask()) {
- mSubTitleView.setVisibility(View.VISIBLE);
- mSubTitleView.setTextColor(t.useLightOnPrimaryColor ?
- mTaskBarViewLightTextColor : mTaskBarViewDarkTextColor);
- } else {
- mSubTitleView.setVisibility(View.GONE);
- }
mDismissButton.setImageDrawable(t.useLightOnPrimaryColor ?
mLightDismissDrawable : mDarkDismissDrawable);
mDismissButton.setContentDescription(t.dismissDescription);
@@ -491,7 +476,8 @@
if (Recents.getDebugFlags().isFastToggleRecentsEnabled()) {
if (mFocusTimerIndicator == null) {
- mFocusTimerIndicator = (ProgressBar) mFocusTimerIndicatorStub.inflate();
+ mFocusTimerIndicator = (ProgressBar) Utilities.findViewStubById(this,
+ R.id.focus_timer_indicator_stub).inflate();
}
mFocusTimerIndicator.getProgressDrawable()
.setColorFilter(
@@ -637,7 +623,8 @@
// Inflate the overlay if necessary
if (mAppOverlayView == null) {
- mAppOverlayView = (FrameLayout) mAppOverlayViewStub.inflate();
+ mAppOverlayView = (FrameLayout) Utilities.findViewStubById(this,
+ R.id.app_overlay_stub).inflate();
mAppOverlayView.setBackground(mOverlayBackground);
mAppIconView = (ImageView) mAppOverlayView.findViewById(R.id.app_icon);
mAppIconView.setOnClickListener(this);
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index 3005535..98e0dd9 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -31,12 +31,13 @@
import android.graphics.Region.Op;
import android.hardware.display.DisplayManager;
import android.os.Bundle;
+import android.os.Vibrator;
import android.util.AttributeSet;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.GestureDetector;
-import android.view.GestureDetector.OnDoubleTapListener;
import android.view.GestureDetector.SimpleOnGestureListener;
+import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.PointerIcon;
import android.view.VelocityTracker;
@@ -45,7 +46,6 @@
import android.view.ViewConfiguration;
import android.view.ViewTreeObserver.InternalInsetsInfo;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
-import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -866,6 +866,9 @@
mEntranceAnimationRunning = true;
resizeStack(position, mSnapAlgorithm.getMiddleTarget().position,
mSnapAlgorithm.getMiddleTarget());
+
+ // Vibrate after docking
+ performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
public final void onBusEvent(RecentsDrawnEvent drawnEvent) {
@@ -894,6 +897,9 @@
// Don't start immediately - give a little bit time to settle the drag resize change.
stopDragging(getCurrentPosition(), target, 336 /* duration */, 100 /* startDelay */,
Interpolators.TOUCH_RESPONSE);
+
+ // Vibrate after undocking
+ performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivity.java b/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivity.java
index d4922c3..177296b 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivity.java
@@ -48,6 +48,7 @@
setContentView(R.layout.forced_resizable_activity);
TextView tv = (TextView) findViewById(com.android.internal.R.id.message);
tv.setText(R.string.dock_forced_resizable);
+ getWindow().setTitle(getString(R.string.dock_forced_resizable));
getWindow().getDecorView().setOnTouchListener(this);
}
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 ea9a5a5..2b03dfb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
@@ -125,6 +125,7 @@
// RenderThread is doing more harm than good when touching the header (to expand quick
// settings), so disable it for this view
((RippleDrawable) mSettingsButton.getBackground()).setForceSoftware(true);
+ ((RippleDrawable) mExpandIndicator.getBackground()).setForceSoftware(true);
updateResources();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
index a85fe0d..5046456 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
@@ -114,8 +114,8 @@
@Override
public String getProfileOwnerName() {
- for (UserInfo profile : mUserManager.getProfiles(mCurrentUserId)) {
- String name = mDevicePolicyManager.getProfileOwnerNameAsUser(profile.id);
+ for (int profileId : mUserManager.getProfileIdsWithDisabled(mCurrentUserId)) {
+ String name = mDevicePolicyManager.getProfileOwnerNameAsUser(profileId);
if (name != null) {
return name;
}
@@ -135,13 +135,13 @@
@Override
public String getProfileVpnName() {
- for (UserInfo profile : mUserManager.getProfiles(mVpnUserId)) {
- if (profile.id == mVpnUserId) {
+ for (int profileId : mUserManager.getProfileIdsWithDisabled(mVpnUserId)) {
+ if (profileId == mVpnUserId) {
continue;
}
- VpnConfig cfg = mCurrentVpns.get(profile.id);
+ VpnConfig cfg = mCurrentVpns.get(profileId);
if (cfg != null) {
- return getNameForVpnConfig(cfg, profile.getUserHandle());
+ return getNameForVpnConfig(cfg, UserHandle.of(profileId));
}
}
return null;
@@ -149,8 +149,8 @@
@Override
public boolean isVpnEnabled() {
- for (UserInfo profile : mUserManager.getProfiles(mVpnUserId)) {
- if (mCurrentVpns.get(profile.id) != null) {
+ for (int profileId : mUserManager.getProfileIdsWithDisabled(mVpnUserId)) {
+ if (mCurrentVpns.get(profileId) != null) {
return true;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipOverlayActivity.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipOverlayActivity.java
index e205ff5..011e159 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipOverlayActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipOverlayActivity.java
@@ -16,6 +16,8 @@
package com.android.systemui.tv.pip;
+import android.animation.Animator;
+import android.animation.AnimatorInflater;
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Context;
@@ -50,9 +52,11 @@
private ImageView mGuideButtonPlayPauseImageView;
private final Runnable mHideGuideOverlayRunnable = new Runnable() {
public void run() {
- mGuideOverlayView.setVisibility(View.GONE);
+ mFadeOutAnimation.start();
}
};
+ private Animator mFadeInAnimation;
+ private Animator mFadeOutAnimation;
/**
* Shows PIP overlay UI only if it's not there.
@@ -74,11 +78,18 @@
setContentView(R.layout.tv_pip_overlay);
mGuideOverlayView = findViewById(R.id.guide_overlay);
mPipManager.addListener(this);
+ mFadeInAnimation = AnimatorInflater.loadAnimator(
+ this, R.anim.tv_pip_overlay_fade_in_animation);
+ mFadeInAnimation.setTarget(mGuideOverlayView);
+ mFadeOutAnimation = AnimatorInflater.loadAnimator(
+ this, R.anim.tv_pip_overlay_fade_out_animation);
+ mFadeOutAnimation.setTarget(mGuideOverlayView);
}
@Override
protected void onResume() {
super.onResume();
+ mFadeInAnimation.start();
mHandler.removeCallbacks(mHideGuideOverlayRunnable);
mHandler.postDelayed(mHideGuideOverlayRunnable, SHOW_GUIDE_OVERLAY_VIEW_DURATION_MS);
}
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index 180d918..2c53e29 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -16,6 +16,7 @@
package com.android.systemui.usb;
+import android.annotation.NonNull;
import android.app.Notification;
import android.app.Notification.Action;
import android.app.NotificationManager;
@@ -97,6 +98,11 @@
public void onDiskScanned(DiskInfo disk, int volumeCount) {
onDiskScannedInternal(disk, volumeCount);
}
+
+ @Override
+ public void onDiskDestroyed(DiskInfo disk) {
+ onDiskDestroyedInternal(disk);
+ }
};
private final BroadcastReceiver mSnoozeReceiver = new BroadcastReceiver() {
@@ -238,6 +244,15 @@
}
}
+ /**
+ * Remove all notifications for a disk when it goes away.
+ *
+ * @param disk The disk that went away.
+ */
+ private void onDiskDestroyedInternal(@NonNull DiskInfo disk) {
+ mNotificationManager.cancelAsUser(disk.getId(), DISK_ID, UserHandle.ALL);
+ }
+
private void onVolumeStateChangedInternal(VolumeInfo vol) {
switch (vol.getType()) {
case VolumeInfo.TYPE_PRIVATE:
diff --git a/packages/SystemUI/src/com/android/systemui/volume/SafetyWarningDialog.java b/packages/SystemUI/src/com/android/systemui/volume/SafetyWarningDialog.java
index 04640a2..d7c4bbf 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/SafetyWarningDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/SafetyWarningDialog.java
@@ -47,6 +47,7 @@
mAudioManager = audioManager;
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
+ setShowForAllUsers(true);
setMessage(mContext.getString(com.android.internal.R.string.safe_media_volume_warning));
setButton(DialogInterface.BUTTON_POSITIVE,
mContext.getString(com.android.internal.R.string.yes), this);
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
index f93fb1b..6ca3af8 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
@@ -460,12 +460,9 @@
}
synchronized (mLock) {
reloadWidgetsMaskedState(userId);
- List<UserInfo> profiles = mUserManager.getEnabledProfiles(userId);
- if (profiles != null) {
- for (int i = 0; i < profiles.size(); i++) {
- UserInfo user = profiles.get(i);
- reloadWidgetsMaskedState(user.id);
- }
+ int[] profileIds = mUserManager.getEnabledProfileIds(userId);
+ for (int profileId : profileIds) {
+ reloadWidgetsMaskedState(profileId);
}
}
}
@@ -3458,33 +3455,12 @@
public int[] getEnabledGroupProfileIds(int userId) {
final int parentId = getGroupParent(userId);
- final List<UserInfo> profiles;
final long identity = Binder.clearCallingIdentity();
try {
- profiles = mUserManager.getProfiles(parentId);
+ return mUserManager.getEnabledProfileIds(parentId);
} finally {
Binder.restoreCallingIdentity(identity);
}
-
- int enabledProfileCount = 0;
- final int profileCount = profiles.size();
- for (int i = 0; i < profileCount; i++) {
- if (profiles.get(i).isEnabled()) {
- enabledProfileCount++;
- }
- }
-
- int enabledProfileIndex = 0;
- final int[] profileIds = new int[enabledProfileCount];
- for (int i = 0; i < profileCount; i++) {
- UserInfo profile = profiles.get(i);
- if (profile.isEnabled()) {
- profileIds[enabledProfileIndex] = profile.getUserHandle().getIdentifier();
- enabledProfileIndex++;
- }
- }
-
- return profileIds;
}
public void enforceServiceExistsAndRequiresBindRemoteViewsPermission(
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index ebef21f..428e192 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -165,7 +165,7 @@
implements PendingIntent.OnFinished {
private static final String TAG = "ConnectivityService";
- private static final boolean DBG = false;
+ private static final boolean DBG = true;
private static final boolean VDBG = false;
private static final boolean LOGD_RULES = false;
@@ -450,9 +450,8 @@
*/
private class LegacyTypeTracker {
- private static final boolean DBG = false;
+ private static final boolean DBG = true;
private static final boolean VDBG = false;
- private static final String TAG = "CSLegacyTypeTracker";
/**
* Array of lists, one per legacy network type (e.g., TYPE_MOBILE_MMS).
@@ -605,12 +604,6 @@
pw.decreaseIndent();
pw.println();
}
-
- // This class needs its own log method because it has a different TAG.
- private void log(String s) {
- Slog.d(TAG, s);
- }
-
}
private LegacyTypeTracker mLegacyTypeTracker = new LegacyTypeTracker();
@@ -1532,7 +1525,7 @@
mInitialBroadcast = new Intent(intent);
}
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
- if (DBG) {
+ if (VDBG) {
log("sendStickyBroadcast: action=" + intent.getAction());
}
@@ -1660,7 +1653,7 @@
}
if (LinkProperties.isValidMtu(mtu, newLp.hasGlobalIPv6Address()) == false) {
- loge("Unexpected mtu value: " + mtu + ", " + iface);
+ if (mtu != 0) loge("Unexpected mtu value: " + mtu + ", " + iface);
return;
}
@@ -1671,7 +1664,7 @@
}
try {
- if (DBG) log("Setting MTU size: " + iface + ", " + mtu);
+ if (VDBG) log("Setting MTU size: " + iface + ", " + mtu);
mNetd.setMtu(iface, mtu);
} catch (Exception e) {
Slog.e(TAG, "exception in setMtu()" + e);
@@ -1707,7 +1700,7 @@
if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return;
try {
- if (DBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes);
+ if (VDBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes);
final String prefix = "/sys/kernel/ipv4/tcp_";
FileUtils.stringToFile(prefix + "rmem_min", values[0]);
@@ -2315,7 +2308,7 @@
if (DBG) log("Attempt to release unowned NetworkRequest " + request);
return;
}
- if (DBG) log("releasing NetworkRequest " + request);
+ if (VDBG || (DBG && nri.isRequest())) log("releasing NetworkRequest " + request);
nri.unlinkDeathRecipient();
mNetworkRequests.remove(request);
mNetworkRequestInfoLogs.log("RELEASE " + nri);
@@ -2328,7 +2321,7 @@
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
if (nai.networkRequests.get(nri.request.requestId) != null) {
nai.networkRequests.remove(nri.request.requestId);
- if (DBG) {
+ if (VDBG) {
log(" Removing from current network " + nai.name() +
", leaving " + nai.networkRequests.size() +
" requests.");
@@ -2439,14 +2432,14 @@
}
private void scheduleUnvalidatedPrompt(NetworkAgentInfo nai) {
- if (DBG) log("scheduleUnvalidatedPrompt " + nai.network);
+ if (VDBG) log("scheduleUnvalidatedPrompt " + nai.network);
mHandler.sendMessageDelayed(
mHandler.obtainMessage(EVENT_PROMPT_UNVALIDATED, nai.network),
PROMPT_UNVALIDATED_DELAY_MS);
}
private void handlePromptUnvalidated(Network network) {
- if (DBG) log("handlePromptUnvalidated " + network);
+ if (VDBG) log("handlePromptUnvalidated " + network);
NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
// Only prompt if the network is unvalidated and was explicitly selected by the user, and if
@@ -2489,11 +2482,14 @@
break;
}
}
- if (msg.what == EVENT_EXPIRE_NET_TRANSITION_WAKELOCK) {
- log("Failed to find a new network - expiring NetTransition Wakelock");
- } else {
- log("NetTransition Wakelock (" + (causedBy == null ? "unknown" : causedBy) +
- " cleared because we found a replacement network");
+ if (VDBG) {
+ if (msg.what == EVENT_EXPIRE_NET_TRANSITION_WAKELOCK) {
+ log("Failed to find a new network - expiring NetTransition Wakelock");
+ } else {
+ log("NetTransition Wakelock (" +
+ (causedBy == null ? "unknown" : causedBy) +
+ " cleared because we found a replacement network");
+ }
}
break;
}
@@ -3347,10 +3343,6 @@
private static enum NotificationType { SIGN_IN, NO_INTERNET; };
private void setProvNotificationVisible(boolean visible, int networkType, String action) {
- if (DBG) {
- log("setProvNotificationVisible: E visible=" + visible + " networkType=" + networkType
- + " action=" + action);
- }
Intent intent = new Intent(action);
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
// Concatenate the range of types onto the range of NetIDs.
@@ -3377,7 +3369,7 @@
private void setProvNotificationVisibleIntent(boolean visible, int id,
NotificationType notifyType, int networkType, String extraInfo, PendingIntent intent,
boolean highPriority) {
- if (DBG) {
+ if (VDBG || (DBG && visible)) {
log("setProvNotificationVisibleIntent " + notifyType + " visible=" + visible
+ " networkType=" + getNetworkTypeName(networkType)
+ " extraInfo=" + extraInfo + " highPriority=" + highPriority);
@@ -3820,8 +3812,7 @@
Bundle thresholds = new Bundle();
thresholds.putIntegerArrayList("thresholds", thresholdsArray);
- // TODO: Switch to VDBG.
- if (DBG) {
+ if (VDBG || (DBG && !"CONNECT".equals(reason))) {
String detail;
if (request != null && request.networkCapabilities.hasSignalStrength()) {
detail = reason + " " + request.networkCapabilities.getSignalStrength();
@@ -3986,7 +3977,7 @@
new NetworkCapabilities(networkCapabilities), TYPE_NONE, nextNetworkRequestId());
NetworkRequestInfo nri = new NetworkRequestInfo(messenger, networkRequest, binder,
NetworkRequestType.LISTEN);
- if (DBG) log("listenForNetwork for " + nri);
+ if (VDBG) log("listenForNetwork for " + nri);
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
return networkRequest;
@@ -4004,7 +3995,7 @@
new NetworkCapabilities(networkCapabilities), TYPE_NONE, nextNetworkRequestId());
NetworkRequestInfo nri = new NetworkRequestInfo(networkRequest, operation,
NetworkRequestType.LISTEN);
- if (DBG) log("pendingListenForNetwork for " + nri);
+ if (VDBG) log("pendingListenForNetwork for " + nri);
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_LISTENER, nri));
}
@@ -4209,7 +4200,7 @@
// do this twice, adding non-nexthop routes first, then routes they are dependent on
for (RouteInfo route : routeDiff.added) {
if (route.hasGateway()) continue;
- if (DBG) log("Adding Route [" + route + "] to network " + netId);
+ if (VDBG) log("Adding Route [" + route + "] to network " + netId);
try {
mNetd.addRoute(netId, route);
} catch (Exception e) {
@@ -4220,7 +4211,7 @@
}
for (RouteInfo route : routeDiff.added) {
if (route.hasGateway() == false) continue;
- if (DBG) log("Adding Route [" + route + "] to network " + netId);
+ if (VDBG) log("Adding Route [" + route + "] to network " + netId);
try {
mNetd.addRoute(netId, route);
} catch (Exception e) {
@@ -4231,7 +4222,7 @@
}
for (RouteInfo route : routeDiff.removed) {
- if (DBG) log("Removing Route [" + route + "] from network " + netId);
+ if (VDBG) log("Removing Route [" + route + "] from network " + netId);
try {
mNetd.removeRoute(netId, route);
} catch (Exception e) {
@@ -4247,7 +4238,7 @@
}
Collection<InetAddress> dnses = newLp.getDnsServers();
- if (DBG) log("Setting Dns servers for network " + netId + " to " + dnses);
+ if (DBG) log("Setting DNS servers for network " + netId + " to " + dnses);
try {
mNetd.setDnsServersForNetwork(
netId, NetworkUtils.makeStrings(dnses), newLp.getDomains());
@@ -4515,14 +4506,14 @@
}
if (currentNetwork == null ||
currentNetwork.getCurrentScore() < newNetwork.getCurrentScore()) {
- if (DBG) log("rematch for " + newNetwork.name());
+ if (VDBG) log("rematch for " + newNetwork.name());
if (currentNetwork != null) {
- if (DBG) log(" accepting network in place of " + currentNetwork.name());
+ if (VDBG) log(" accepting network in place of " + currentNetwork.name());
currentNetwork.networkRequests.remove(nri.request.requestId);
currentNetwork.networkLingered.add(nri.request);
affectedNetworks.add(currentNetwork);
} else {
- if (DBG) log(" accepting network in place of null");
+ if (VDBG) log(" accepting network in place of null");
}
unlinger(newNetwork);
mNetworkForRequestId.put(nri.request.requestId, newNetwork);
@@ -4852,7 +4843,7 @@
}
private void updateNetworkScore(NetworkAgentInfo nai, int score) {
- if (DBG) log("updateNetworkScore for " + nai.name() + " to " + score);
+ if (VDBG) log("updateNetworkScore for " + nai.name() + " to " + score);
if (score < 0) {
loge("updateNetworkScore for " + nai.name() + " got a negative score (" + score +
"). Bumping score to min of 0");
@@ -4930,7 +4921,7 @@
}
protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType) {
- if (DBG) log("notifyType " + notifyTypeToName(notifyType) + " for " + networkAgent.name());
+ if (VDBG) log("notifyType " + notifyTypeToName(notifyType) + " for " + networkAgent.name());
for (int i = 0; i < networkAgent.networkRequests.size(); i++) {
NetworkRequest nr = networkAgent.networkRequests.valueAt(i);
NetworkRequestInfo nri = mNetworkRequests.get(nr);
diff --git a/services/core/java/com/android/server/GestureLauncherService.java b/services/core/java/com/android/server/GestureLauncherService.java
index aa98648..5a90488 100644
--- a/services/core/java/com/android/server/GestureLauncherService.java
+++ b/services/core/java/com/android/server/GestureLauncherService.java
@@ -58,7 +58,6 @@
* as a camera launch.
*/
private static final long CAMERA_POWER_DOUBLE_TAP_MAX_TIME_MS = 300;
- private static final long CAMERA_POWER_DOUBLE_TAP_MIN_TIME_MS = 120;
/** The listener that receives the gesture event. */
private final GestureEventListener mGestureListener = new GestureEventListener();
@@ -260,8 +259,7 @@
synchronized (this) {
doubleTapInterval = event.getEventTime() - mLastPowerDown;
if (mCameraDoubleTapPowerEnabled
- && doubleTapInterval < CAMERA_POWER_DOUBLE_TAP_MAX_TIME_MS
- && doubleTapInterval > CAMERA_POWER_DOUBLE_TAP_MIN_TIME_MS) {
+ && doubleTapInterval < CAMERA_POWER_DOUBLE_TAP_MAX_TIME_MS) {
launched = true;
intercept = interactive;
}
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 58e3674..22cc066 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -66,7 +66,6 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
-import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -1050,12 +1049,8 @@
}
void updateCurrentProfileIds() {
- List<UserInfo> profiles = mUserManager.getProfiles(mSettings.getCurrentUserId());
- int[] currentProfileIds = new int[profiles.size()]; // profiles will not be null
- for (int i = 0; i < currentProfileIds.length; i++) {
- currentProfileIds[i] = profiles.get(i).id;
- }
- mSettings.setCurrentProfileIds(currentProfileIds);
+ mSettings.setCurrentProfileIds(
+ mUserManager.getProfileIdsWithDisabled(mSettings.getCurrentUserId()));
}
@Override
@@ -3649,6 +3644,7 @@
private static final String ATTR_ID = "id";
private static final String ATTR_LABEL = "label";
private static final String ATTR_ICON = "icon";
+ private static final String ATTR_IME_SUBTYPE_ID = "subtypeId";
private static final String ATTR_IME_SUBTYPE_LOCALE = "imeSubtypeLocale";
private static final String ATTR_IME_SUBTYPE_LANGUAGE_TAG = "languageTag";
private static final String ATTR_IME_SUBTYPE_MODE = "imeSubtypeMode";
@@ -3742,6 +3738,10 @@
for (int i = 0; i < N; ++i) {
final InputMethodSubtype subtype = subtypesList.get(i);
out.startTag(null, NODE_SUBTYPE);
+ if (subtype.hasSubtypeId()) {
+ out.attribute(null, ATTR_IME_SUBTYPE_ID,
+ String.valueOf(subtype.getSubtypeId()));
+ }
out.attribute(null, ATTR_ICON, String.valueOf(subtype.getIconResId()));
out.attribute(null, ATTR_LABEL, String.valueOf(subtype.getNameResId()));
out.attribute(null, ATTR_IME_SUBTYPE_LOCALE, subtype.getLocale());
@@ -3820,7 +3820,7 @@
parser.getAttributeValue(null, ATTR_IS_AUXILIARY)));
final boolean isAsciiCapable = "1".equals(String.valueOf(
parser.getAttributeValue(null, ATTR_IS_ASCII_CAPABLE)));
- final InputMethodSubtype subtype = new InputMethodSubtypeBuilder()
+ final InputMethodSubtypeBuilder builder = new InputMethodSubtypeBuilder()
.setSubtypeNameResId(label)
.setSubtypeIconResId(icon)
.setSubtypeLocale(imeSubtypeLocale)
@@ -3828,9 +3828,13 @@
.setSubtypeMode(imeSubtypeMode)
.setSubtypeExtraValue(imeSubtypeExtraValue)
.setIsAuxiliary(isAuxiliary)
- .setIsAsciiCapable(isAsciiCapable)
- .build();
- tempSubtypesArray.add(subtype);
+ .setIsAsciiCapable(isAsciiCapable);
+ final String subtypeIdString =
+ parser.getAttributeValue(null, ATTR_IME_SUBTYPE_ID);
+ if (subtypeIdString != null) {
+ builder.setSubtypeId(Integer.valueOf(subtypeIdString));
+ }
+ tempSubtypesArray.add(builder.build());
}
}
} catch (XmlPullParserException | IOException | NumberFormatException e) {
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index 9884a70..7c48634 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -21,6 +21,7 @@
import com.android.internal.location.ProviderProperties;
import com.android.internal.location.ProviderRequest;
import com.android.internal.os.BackgroundThread;
+import com.android.internal.util.ArrayUtils;
import com.android.server.location.ActivityRecognitionProxy;
import com.android.server.location.FlpHardwareProvider;
import com.android.server.location.FusedProxy;
@@ -53,7 +54,6 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
-import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.hardware.location.ActivityRecognitionHardware;
@@ -359,12 +359,9 @@
* @param currentUserId the current user, who might have an alter-ego.
*/
void updateUserProfiles(int currentUserId) {
- List<UserInfo> profiles = mUserManager.getProfiles(currentUserId);
+ int[] profileIds = mUserManager.getProfileIdsWithDisabled(currentUserId);
synchronized (mLock) {
- mCurrentUserProfiles = new int[profiles.size()];
- for (int i = 0; i < mCurrentUserProfiles.length; i++) {
- mCurrentUserProfiles[i] = profiles.get(i).id;
- }
+ mCurrentUserProfiles = profileIds;
}
}
@@ -374,12 +371,7 @@
*/
private boolean isCurrentProfile(int userId) {
synchronized (mLock) {
- for (int i = 0; i < mCurrentUserProfiles.length; i++) {
- if (mCurrentUserProfiles[i] == userId) {
- return true;
- }
- }
- return false;
+ return ArrayUtils.contains(mCurrentUserProfiles, userId);
}
}
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index fd9a94d..229a3f4 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -1010,7 +1010,7 @@
Configuration config = new Configuration();
config.setLocale(locale);
try {
- ActivityManagerNative.getDefault().updateConfiguration(config);
+ ActivityManagerNative.getDefault().updatePersistentConfiguration(config);
} catch (RemoteException e) {
Slog.e(TAG, "Error setting system locale from mount service", e);
}
diff --git a/services/core/java/com/android/server/TextServicesManagerService.java b/services/core/java/com/android/server/TextServicesManagerService.java
index 3eb20a0..801d6e0 100644
--- a/services/core/java/com/android/server/TextServicesManagerService.java
+++ b/services/core/java/com/android/server/TextServicesManagerService.java
@@ -43,7 +43,6 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
-import android.content.pm.UserInfo;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
@@ -195,12 +194,8 @@
}
void updateCurrentProfileIds() {
- final List<UserInfo> profiles = mUserManager.getProfiles(mSettings.getCurrentUserId());
- int[] currentProfileIds = new int[profiles.size()]; // profiles will not be null
- for (int i = 0; i < currentProfileIds.length; i++) {
- currentProfileIds[i] = profiles.get(i).id;
- }
- mSettings.setCurrentProfileIds(currentProfileIds);
+ mSettings.setCurrentProfileIds(
+ mUserManager.getProfileIdsWithDisabled(mSettings.getCurrentUserId()));
}
private class TextServicesMonitor extends PackageMonitor {
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 810270d..05e4245 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -85,8 +85,10 @@
import android.util.SparseBooleanArray;
import com.android.internal.R;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.IndentingPrintWriter;
+import com.android.internal.util.Preconditions;
import com.android.server.FgThread;
import com.android.server.LocalServices;
import com.google.android.collect.Lists;
@@ -266,10 +268,10 @@
private int debugDbInsertionPoint = -1;
private SQLiteStatement statementForLogging;
- UserAccounts(Context context, int userId) {
+ UserAccounts(Context context, int userId, File preNDbFile, File deDbFile) {
this.userId = userId;
synchronized (cacheLock) {
- openHelper = DeDatabaseHelper.create(context, userId);
+ openHelper = DeDatabaseHelper.create(context, userId, preNDbFile, deDbFile);
}
}
}
@@ -539,7 +541,9 @@
UserAccounts accounts = mUsers.get(userId);
boolean validateAccounts = false;
if (accounts == null) {
- accounts = new UserAccounts(mContext, userId);
+ File preNDbFile = new File(getPreNDatabaseName(userId));
+ File deDbFile = new File(getDeDatabaseName(userId));
+ accounts = new UserAccounts(mContext, userId, preNDbFile, deDbFile);
initializeDebugDbSizeAndCompileSqlStatementForLogging(
accounts.openHelper.getWritableDatabase(), accounts);
mUsers.append(userId, accounts);
@@ -550,10 +554,12 @@
if (!accounts.openHelper.isCeDatabaseAttached() && mUnlockedUsers.get(userId)) {
Log.i(TAG, "User " + userId + " is unlocked - opening CE database");
synchronized (accounts.cacheLock) {
- CeDatabaseHelper.create(mContext, userId);
- accounts.openHelper.attachCeDatabase();
+ File preNDatabaseFile = new File(getPreNDatabaseName(userId));
+ File ceDatabaseFile = new File(getCeDatabaseName(userId));
+ CeDatabaseHelper.create(mContext, userId, preNDatabaseFile, ceDatabaseFile);
+ accounts.openHelper.attachCeDatabase(ceDatabaseFile);
}
- // TODO Synchronize accounts by removing CE account not available in DE
+ syncDeCeAccountsLocked(accounts);
}
if (validateAccounts) {
validateAccountsInternal(accounts, true /* invalidateAuthenticatorCache */);
@@ -562,6 +568,21 @@
}
}
+ private void syncDeCeAccountsLocked(UserAccounts accounts) {
+ Preconditions.checkState(Thread.holdsLock(mUsers), "mUsers lock must be held");
+ final SQLiteDatabase db = accounts.openHelper.getReadableDatabaseUserIsUnlocked();
+ List<Account> accountsToRemove = CeDatabaseHelper.findCeAccountsNotInDe(db);
+ if (!accountsToRemove.isEmpty()) {
+ Slog.i(TAG, "Accounts " + accountsToRemove + " were previously deleted while user "
+ + accounts.userId + " was locked. Removing accounts from CE tables");
+ logRecord(accounts, DebugDbHelper.ACTION_SYNC_DE_CE_ACCOUNTS, TABLE_ACCOUNTS);
+
+ for (Account account : accountsToRemove) {
+ removeAccountInternal(accounts, account, Process.myUid());
+ }
+ }
+ }
+
private void purgeOldGrantsAll() {
synchronized (mUsers) {
for (int i = 0; i < mUsers.size(); i++) {
@@ -631,7 +652,8 @@
}
}
- private void onUserUnlocked(Intent intent) {
+ @VisibleForTesting
+ void onUserUnlocked(Intent intent) {
int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "onUserUnlocked " + userId);
@@ -799,7 +821,7 @@
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "getAuthenticatorTypes: "
+ "for user id " + userId
- + "caller's uid " + callingUid
+ + " caller's uid " + callingUid
+ ", pid " + Binder.getCallingPid());
}
// Only allow the system process to read accounts of other users
@@ -1537,27 +1559,41 @@
}
}
- /* For testing */
+ @VisibleForTesting
protected void removeAccountInternal(Account account) {
removeAccountInternal(getUserAccountsForCaller(), account, getCallingUid());
}
private boolean removeAccountInternal(UserAccounts accounts, Account account, int callingUid) {
- // For now user is required to be unlocked. TODO: Handle both cases in the future
int deleted;
+ boolean userUnlocked = isUserUnlocked(accounts.userId);
+ if (!userUnlocked) {
+ Slog.i(TAG, "Removing account " + account + " while user "+ accounts.userId
+ + " is still locked. CE data will be removed later");
+ }
synchronized (accounts.cacheLock) {
- final SQLiteDatabase db = accounts.openHelper.getWritableDatabaseUserIsUnlocked();
+ final SQLiteDatabase db = userUnlocked
+ ? accounts.openHelper.getWritableDatabaseUserIsUnlocked()
+ : accounts.openHelper.getWritableDatabase();
final long accountId = getAccountIdLocked(db, account);
- deleted = db.delete(TABLE_ACCOUNTS, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE
- + "=?",
- new String[]{account.name, account.type});
- // Delete from CE table
- db.delete(CE_TABLE_ACCOUNTS, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE + "=?",
- new String[]{account.name, account.type});
+ db.beginTransaction();
+ try {
+ deleted = db.delete(TABLE_ACCOUNTS, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE
+ + "=?", new String[]{account.name, account.type});
+ if (userUnlocked) {
+ // Delete from CE table
+ deleted = db.delete(CE_TABLE_ACCOUNTS, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE
+ + "=?", new String[]{account.name, account.type});
+ }
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
removeAccountFromCacheLocked(accounts, account);
sendAccountsChangedBroadcast(accounts.userId);
-
- logRecord(db, DebugDbHelper.ACTION_ACCOUNT_REMOVE, TABLE_ACCOUNTS, accountId, accounts);
+ String action = userUnlocked ? DebugDbHelper.ACTION_ACCOUNT_REMOVE
+ : DebugDbHelper.ACTION_ACCOUNT_REMOVE_DE;
+ logRecord(db, action, TABLE_ACCOUNTS, accountId, accounts);
}
long id = Binder.clearCallingIdentity();
try {
@@ -4014,7 +4050,8 @@
}
}
- static String getPreNDatabaseName(int userId) {
+ @VisibleForTesting
+ String getPreNDatabaseName(int userId) {
File systemDir = Environment.getDataSystemDirectory();
File databaseFile = new File(Environment.getUserSystemDirectory(userId),
PRE_N_DATABASE_NAME);
@@ -4040,13 +4077,15 @@
return databaseFile.getPath();
}
- static String getDeDatabaseName(int userId) {
+ @VisibleForTesting
+ String getDeDatabaseName(int userId) {
File databaseFile = new File(Environment.getDataSystemDeDirectory(userId),
DE_DATABASE_NAME);
return databaseFile.getPath();
}
- static String getCeDatabaseName(int userId) {
+ @VisibleForTesting
+ String getCeDatabaseName(int userId) {
File databaseFile = new File(Environment.getDataSystemCeDirectory(userId),
CE_DATABASE_NAME);
return databaseFile.getPath();
@@ -4072,6 +4111,7 @@
private static String ACTION_CLEAR_PASSWORD = "action_clear_password";
private static String ACTION_ACCOUNT_ADD = "action_account_add";
private static String ACTION_ACCOUNT_REMOVE = "action_account_remove";
+ private static String ACTION_ACCOUNT_REMOVE_DE = "action_account_remove_de";
private static String ACTION_AUTHENTICATOR_REMOVE = "action_authenticator_remove";
private static String ACTION_ACCOUNT_RENAME = "action_account_rename";
@@ -4082,6 +4122,7 @@
// who called.
private static String ACTION_CALLED_ACCOUNT_ADD = "action_called_account_add";
private static String ACTION_CALLED_ACCOUNT_REMOVE = "action_called_account_remove";
+ private static String ACTION_SYNC_DE_CE_ACCOUNTS = "action_sync_de_ce_accounts";
//This action doesn't add account to accountdb. Account is only
// added in finishSession which may be in a different user profile.
@@ -4185,13 +4226,11 @@
}
static class PreNDatabaseHelper extends SQLiteOpenHelper {
-
private final Context mContext;
private final int mUserId;
- public PreNDatabaseHelper(Context context, int userId) {
- super(context, AccountManagerService.getPreNDatabaseName(userId), null,
- PRE_N_DATABASE_VERSION);
+ public PreNDatabaseHelper(Context context, int userId, String preNDatabaseName) {
+ super(context, preNDatabaseName, null, PRE_N_DATABASE_VERSION);
mContext = context;
mUserId = userId;
}
@@ -4328,8 +4367,8 @@
private final int mUserId;
private volatile boolean mCeAttached;
- private DeDatabaseHelper(Context context, int userId) {
- super(context, getDeDatabaseName(userId), null, DE_DATABASE_VERSION);
+ private DeDatabaseHelper(Context context, int userId, String deDatabaseName) {
+ super(context, deDatabaseName, null, DE_DATABASE_VERSION);
mUserId = userId;
}
@@ -4394,8 +4433,7 @@
}
}
- public void attachCeDatabase() {
- File ceDbFile = new File(getCeDatabaseName(mUserId));
+ public void attachCeDatabase(File ceDbFile) {
SQLiteDatabase db = getWritableDatabase();
db.execSQL("ATTACH DATABASE '" + ceDbFile.getPath()+ "' AS ceDb");
mCeAttached = true;
@@ -4408,8 +4446,8 @@
public SQLiteDatabase getReadableDatabaseUserIsUnlocked() {
if(!mCeAttached) {
- Log.wtf(TAG, "getReadableDatabaseUserIsUnlocked called while user "
- + mUserId + " is still locked ", new Throwable());
+ Log.wtf(TAG, "getReadableDatabaseUserIsUnlocked called while user " + mUserId
+ + " is still locked. CE database is not yet available.", new Throwable());
}
return super.getReadableDatabase();
}
@@ -4417,7 +4455,7 @@
public SQLiteDatabase getWritableDatabaseUserIsUnlocked() {
if(!mCeAttached) {
Log.wtf(TAG, "getWritableDatabaseUserIsUnlocked called while user " + mUserId
- + " is still locked ", new Throwable());
+ + " is still locked. CE database is not yet available.", new Throwable());
}
return super.getWritableDatabase();
}
@@ -4470,20 +4508,24 @@
db.execSQL("DETACH DATABASE preNDb");
}
- static DeDatabaseHelper create(Context context, int userId) {
- File oldDb = new File(getPreNDatabaseName(userId));
- File newDb = new File(getDeDatabaseName(userId));
- boolean newDbExists = newDb.exists();
- DeDatabaseHelper deDatabaseHelper = new DeDatabaseHelper(context, userId);
+ static DeDatabaseHelper create(
+ Context context,
+ int userId,
+ File preNDatabaseFile,
+ File deDatabaseFile) {
+ boolean newDbExists = deDatabaseFile.exists();
+ DeDatabaseHelper deDatabaseHelper = new DeDatabaseHelper(context, userId,
+ deDatabaseFile.getPath());
// If the db just created, and there is a legacy db, migrate it
- if (!newDbExists && oldDb.exists()) {
+ if (!newDbExists && preNDatabaseFile.exists()) {
// Migrate legacy db to the latest version - PRE_N_DATABASE_VERSION
- PreNDatabaseHelper preNDatabaseHelper = new PreNDatabaseHelper(context, userId);
+ PreNDatabaseHelper preNDatabaseHelper = new PreNDatabaseHelper(context, userId,
+ preNDatabaseFile.getPath());
// Open the database to force upgrade if required
preNDatabaseHelper.getWritableDatabase();
preNDatabaseHelper.close();
// Move data without SPII to DE
- deDatabaseHelper.migratePreNDbToDe(oldDb);
+ deDatabaseHelper.migratePreNDbToDe(preNDatabaseFile);
}
return deDatabaseHelper;
}
@@ -4491,8 +4533,8 @@
static class CeDatabaseHelper extends SQLiteOpenHelper {
- public CeDatabaseHelper(Context context, int userId) {
- super(context, getCeDatabaseName(userId), null, CE_DATABASE_VERSION);
+ public CeDatabaseHelper(Context context, String ceDatabaseName) {
+ super(context, ceDatabaseName, null, CE_DATABASE_VERSION);
}
/**
@@ -4580,33 +4622,56 @@
}
}
+ static List<Account> findCeAccountsNotInDe(SQLiteDatabase db) {
+ // Select accounts from CE that do not exist in DE
+ Cursor cursor = db.rawQuery(
+ "SELECT " + ACCOUNTS_NAME + "," + ACCOUNTS_TYPE
+ + " FROM " + CE_TABLE_ACCOUNTS
+ + " WHERE NOT EXISTS "
+ + " (SELECT " + ACCOUNTS_ID + " FROM " + TABLE_ACCOUNTS
+ + " WHERE " + ACCOUNTS_ID + "=" + CE_TABLE_ACCOUNTS + "." + ACCOUNTS_ID
+ + " )", null);
+ try {
+ List<Account> accounts = new ArrayList<>(cursor.getCount());
+ while (cursor.moveToNext()) {
+ String accountName = cursor.getString(0);
+ String accountType = cursor.getString(1);
+ accounts.add(new Account(accountName, accountType));
+ }
+ return accounts;
+ } finally {
+ cursor.close();
+ }
+ }
+
/**
* Creates a new {@code CeDatabaseHelper}. If pre-N db file is present at the old location,
* it also performs migration to the new CE database.
* @param context
* @param userId id of the user where the database is located
*/
- static CeDatabaseHelper create(Context context, int userId) {
-
- File oldDatabaseFile = new File(getPreNDatabaseName(userId));
- File ceDatabaseFile = new File(getCeDatabaseName(userId));
+ static CeDatabaseHelper create(
+ Context context,
+ int userId,
+ File preNDatabaseFile,
+ File ceDatabaseFile) {
boolean newDbExists = ceDatabaseFile.exists();
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "CeDatabaseHelper.create userId=" + userId + " oldDbExists="
- + oldDatabaseFile.exists() + " newDbExists=" + newDbExists);
+ + preNDatabaseFile.exists() + " newDbExists=" + newDbExists);
}
boolean removeOldDb = false;
- if (!newDbExists && oldDatabaseFile.exists()) {
- removeOldDb = migratePreNDbToCe(oldDatabaseFile, ceDatabaseFile);
+ if (!newDbExists && preNDatabaseFile.exists()) {
+ removeOldDb = migratePreNDbToCe(preNDatabaseFile, ceDatabaseFile);
}
// Try to open and upgrade if necessary
- CeDatabaseHelper ceHelper = new CeDatabaseHelper(context, userId);
+ CeDatabaseHelper ceHelper = new CeDatabaseHelper(context, ceDatabaseFile.getPath());
ceHelper.getWritableDatabase();
ceHelper.close();
if (removeOldDb) {
// TODO STOPSHIP - backup file during testing. Remove file before the release
- Log.i(TAG, "Migration complete - creating backup of old db " + oldDatabaseFile);
- renameToBakFile(oldDatabaseFile);
+ Log.i(TAG, "Migration complete - creating backup of old db " + preNDatabaseFile);
+ renameToBakFile(preNDatabaseFile);
}
return ceHelper;
}
@@ -4771,12 +4836,14 @@
}
}
+ @VisibleForTesting
protected void installNotification(final int notificationId, final Notification n,
UserHandle user) {
((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE))
.notifyAsUser(null, notificationId, n, user);
}
+ @VisibleForTesting
protected void cancelNotification(int id, UserHandle user) {
long identityToken = clearCallingIdentity();
try {
@@ -5314,7 +5381,7 @@
HashMap<String, String> userDataForAccount = accounts.userDataCache.get(account);
if (userDataForAccount == null) {
// need to populate the cache for this account
- final SQLiteDatabase db = accounts.openHelper.getReadableDatabase();
+ final SQLiteDatabase db = accounts.openHelper.getReadableDatabaseUserIsUnlocked();
userDataForAccount = readUserDataForAccountFromDatabaseLocked(db, account);
accounts.userDataCache.put(account, userDataForAccount);
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 0f48d21..3ec51e3 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -13164,6 +13164,9 @@
}
}
+ private volatile long mWtfClusterStart;
+ private volatile int mWtfClusterCount;
+
/**
* Write a description of an error (crash, WTF, ANR) to the drop box.
* @param eventType to include in the drop box tag ("crash", "wtf", etc.)
@@ -13190,6 +13193,16 @@
// Exit early if the dropbox isn't configured to accept this report type.
if (dbox == null || !dbox.isTagEnabled(dropboxTag)) return;
+ // Rate-limit how often we're willing to do the heavy lifting below to
+ // collect and record logs; currently 5 logs per 10 second period.
+ final long now = SystemClock.elapsedRealtime();
+ if (now - mWtfClusterStart > 10 * DateUtils.SECOND_IN_MILLIS) {
+ mWtfClusterStart = now;
+ mWtfClusterCount = 1;
+ } else {
+ if (mWtfClusterCount++ >= 5) return;
+ }
+
final StringBuilder sb = new StringBuilder(1024);
appendDropBoxProcessHeaders(process, processName, sb);
if (process != null) {
@@ -17131,7 +17144,7 @@
// but historically it has not been protected and apps may be using it
// to poke their own app widget. So, instead of making it protected,
// just limit it to the caller.
- if (callerApp == null) {
+ if (callerPackage == null) {
String msg = "Permission Denial: not allowed to send broadcast "
+ action + " from unknown caller.";
Slog.w(TAG, msg);
@@ -17140,17 +17153,17 @@
// They are good enough to send to an explicit component... verify
// it is being sent to the calling app.
if (!intent.getComponent().getPackageName().equals(
- callerApp.info.packageName)) {
+ callerPackage)) {
String msg = "Permission Denial: not allowed to send broadcast "
+ action + " to "
+ intent.getComponent().getPackageName() + " from "
- + callerApp.info.packageName;
+ + callerPackage;
Slog.w(TAG, msg);
throw new SecurityException(msg);
}
} else {
// Limit broadcast to their own package.
- intent.setPackage(callerApp.info.packageName);
+ intent.setPackage(callerPackage);
}
}
}
diff --git a/services/core/java/com/android/server/am/PreBootBroadcaster.java b/services/core/java/com/android/server/am/PreBootBroadcaster.java
index 1825c88..0e192ea 100644
--- a/services/core/java/com/android/server/am/PreBootBroadcaster.java
+++ b/services/core/java/com/android/server/am/PreBootBroadcaster.java
@@ -69,6 +69,12 @@
return;
}
+ if (!mService.isUserRunning(mUserId, 0)) {
+ Slog.i(TAG, "User " + mUserId + " is no longer running; skipping remaining receivers");
+ onFinished();
+ return;
+ }
+
final ResolveInfo ri = mTargets.get(mIndex++);
final ComponentName componentName = ri.activityInfo.getComponentName();
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index bea26c7..5ebb9a7 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -278,6 +278,31 @@
// Dispatch unlocked to system services
mHandler.sendMessage(mHandler.obtainMessage(SYSTEM_USER_UNLOCK_MSG, userId, 0));
+ // Dispatch unlocked to external apps
+ final Intent unlockedIntent = new Intent(Intent.ACTION_USER_UNLOCKED);
+ unlockedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
+ unlockedIntent.addFlags(
+ Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
+ mService.broadcastIntentLocked(null, null, unlockedIntent, null, null, 0, null,
+ null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, SYSTEM_UID,
+ userId);
+
+ if (getUserInfo(userId).isManagedProfile()) {
+ UserInfo parent = getUserManager().getProfileParent(userId);
+ if (parent != null) {
+ final Intent profileUnlockedIntent = new Intent(
+ Intent.ACTION_MANAGED_PROFILE_UNLOCKED);
+ profileUnlockedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId));
+ profileUnlockedIntent.addFlags(
+ Intent.FLAG_RECEIVER_REGISTERED_ONLY
+ | Intent.FLAG_RECEIVER_FOREGROUND);
+ mService.broadcastIntentLocked(null, null, profileUnlockedIntent,
+ null, null, 0, null, null, null, AppOpsManager.OP_NONE,
+ null, false, false, MY_PID, SYSTEM_UID,
+ parent.id);
+ }
+ }
+
// Send PRE_BOOT broadcasts if fingerprint changed
final UserInfo info = getUserInfo(userId);
if (!Objects.equals(info.lastLoggedInFingerprint, Build.FINGERPRINT)) {
@@ -320,31 +345,6 @@
// Remember that we logged in
mUserManager.onUserLoggedIn(userId);
- // Dispatch unlocked to external apps
- final Intent unlockedIntent = new Intent(Intent.ACTION_USER_UNLOCKED);
- unlockedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
- unlockedIntent.addFlags(
- Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
- mService.broadcastIntentLocked(null, null, unlockedIntent, null, null, 0, null,
- null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, SYSTEM_UID,
- userId);
-
- if (getUserInfo(userId).isManagedProfile()) {
- UserInfo parent = getUserManager().getProfileParent(userId);
- if (parent != null) {
- final Intent profileUnlockedIntent = new Intent(
- Intent.ACTION_MANAGED_PROFILE_UNLOCKED);
- profileUnlockedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId));
- profileUnlockedIntent.addFlags(
- Intent.FLAG_RECEIVER_REGISTERED_ONLY
- | Intent.FLAG_RECEIVER_FOREGROUND);
- mService.broadcastIntentLocked(null, null, profileUnlockedIntent,
- null, null, 0, null, null, null, AppOpsManager.OP_NONE,
- null, false, false, MY_PID, SYSTEM_UID,
- parent.id);
- }
- }
-
final Intent bootIntent = new Intent(Intent.ACTION_BOOT_COMPLETED, null);
bootIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
bootIntent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT
@@ -893,8 +893,9 @@
boolean unlockUserCleared(final int userId, byte[] token, byte[] secret,
ProgressReporter progress) {
synchronized (mService) {
- // Bail if already running unlocked
+ // Bail if already running unlocked, or if not running at all
final UserState uss = mStartedUsers.get(userId);
+ if (uss == null) return false;
switch (uss.state) {
case STATE_RUNNING_UNLOCKING:
case STATE_RUNNING_UNLOCKED:
diff --git a/services/core/java/com/android/server/camera/CameraService.java b/services/core/java/com/android/server/camera/CameraService.java
index cd8eb4e..7d9adf2 100644
--- a/services/core/java/com/android/server/camera/CameraService.java
+++ b/services/core/java/com/android/server/camera/CameraService.java
@@ -15,32 +15,28 @@
*/
package com.android.server.camera;
-import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.pm.UserInfo;
import android.hardware.ICameraService;
import android.hardware.ICameraServiceProxy;
import android.nfc.INfcAdapter;
+import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
-import android.os.Binder;
import android.os.Message;
import android.os.Process;
import android.os.RemoteException;
-import android.os.UserManager;
import android.os.SystemProperties;
-import android.util.Slog;
+import android.os.UserManager;
import android.util.ArraySet;
+import android.util.Slog;
import com.android.server.ServiceThread;
import com.android.server.SystemService;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
import java.util.Set;
/**
@@ -225,11 +221,11 @@
}
private Set<Integer> getEnabledUserHandles(int currentUserHandle) {
- List<UserInfo> userProfiles = mUserManager.getEnabledProfiles(currentUserHandle);
- Set<Integer> handles = new HashSet<>(userProfiles.size());
+ int[] userProfiles = mUserManager.getEnabledProfileIds(currentUserHandle);
+ Set<Integer> handles = new ArraySet<>(userProfiles.length);
- for (UserInfo i : userProfiles) {
- handles.add(i.id);
+ for (int id : userProfiles) {
+ handles.add(id);
}
return handles;
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java
index 3d8bf51..e3f3849 100644
--- a/services/core/java/com/android/server/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java
@@ -541,10 +541,8 @@
UserManager um = UserManager.get(mContext);
// Allow current user or profiles of the current user...
- List<UserInfo> profiles = um.getEnabledProfiles(userId);
- final int n = profiles.size();
- for (int i = 0; i < n; i++) {
- if (profiles.get(i).id == userId) {
+ for (int profileId : um.getEnabledProfileIds(userId)) {
+ if (profileId == userId) {
return true;
}
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index f20d0a1..2765578 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2459,10 +2459,10 @@
// Fix the notification as best we can.
try {
- Notification.addFieldsFromContext(getContext().createApplicationContext(
- getContext().getPackageManager().getApplicationInfoAsUser(
- pkg, PackageManager.MATCH_UNINSTALLED_PACKAGES, userId),
- Context.CONTEXT_RESTRICTED), notification);
+ final ApplicationInfo ai = getContext().getPackageManager().getApplicationInfoAsUser(
+ pkg, PackageManager.MATCH_DEBUG_TRIAGED_MISSING,
+ (userId == UserHandle.USER_ALL) ? UserHandle.USER_SYSTEM : userId);
+ Notification.addFieldsFromContext(ai, userId, notification);
} catch (NameNotFoundException e) {
Slog.e(TAG, "Cannot create a context for sending app", e);
return;
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index a89a422..f29970c 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -176,10 +176,7 @@
mRankingTimeMs = calculateRankingTimeMs(previous.getRankingTimeMs());
mCreationTimeMs = previous.mCreationTimeMs;
mVisibleSinceMs = previous.mVisibleSinceMs;
- mUserImportance = previous.mUserImportance;
- mImportance = previous.mImportance;
- mImportanceExplanation = previous.mImportanceExplanation;
- // Don't copy mGlobalSortKey, recompute it.
+ // Don't copy importance information or mGlobalSortKey, recompute them.
}
public Notification getNotification() { return sbn.getNotification(); }
diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java
index 4c18e15..5ee7cc9 100644
--- a/services/core/java/com/android/server/pm/LauncherAppsService.java
+++ b/services/core/java/com/android/server/pm/LauncherAppsService.java
@@ -147,6 +147,7 @@
@Override
public void addOnAppsChangedListener(String callingPackage, IOnAppsChangedListener listener)
throws RemoteException {
+ verifyCallingPackage(callingPackage);
synchronized (mListeners) {
if (DEBUG) {
Log.d(TAG, "Adding listener from " + Binder.getCallingUserHandle());
@@ -213,8 +214,11 @@
* Checks if the caller is in the same group as the userToCheck.
*/
private void ensureInUserProfiles(UserHandle userToCheck, String message) {
+ ensureInUserProfiles(userToCheck.getIdentifier(), message);
+ }
+
+ private void ensureInUserProfiles(int targetUserId, String message) {
final int callingUserId = injectCallingUserId();
- final int targetUserId = userToCheck.getIdentifier();
if (targetUserId == callingUserId) return;
@@ -253,9 +257,13 @@
* Checks if the user is enabled.
*/
private boolean isUserEnabled(UserHandle user) {
+ return isUserEnabled(user.getIdentifier());
+ }
+
+ private boolean isUserEnabled(int userId) {
long ident = injectClearCallingIdentity();
try {
- UserInfo targetUserInfo = mUm.getUserInfo(user.getIdentifier());
+ UserInfo targetUserInfo = mUm.getUserInfo(userId);
return targetUserInfo != null && targetUserInfo.isEnabled();
} finally {
injectRestoreCallingIdentity(ident);
@@ -346,8 +354,12 @@
}
private void ensureShortcutPermission(@NonNull String callingPackage, UserHandle user) {
+ ensureShortcutPermission(callingPackage, user.getIdentifier());
+ }
+
+ private void ensureShortcutPermission(@NonNull String callingPackage, int userId) {
verifyCallingPackage(callingPackage);
- ensureInUserProfiles(user, "Cannot start activity for unrelated profile " + user);
+ ensureInUserProfiles(userId, "Cannot start activity for unrelated profile " + userId);
if (!mShortcutServiceInternal.hasShortcutHostPermission(getCallingUserId(),
callingPackage)) {
@@ -357,32 +369,24 @@
@Override
public ParceledListSlice getShortcuts(String callingPackage, long changedSince,
- String packageName, ComponentName componentName, int flags, UserHandle user) {
+ String packageName, List shortcutIds, ComponentName componentName, int flags,
+ UserHandle user) {
ensureShortcutPermission(callingPackage, user);
if (!isUserEnabled(user)) {
return new ParceledListSlice<>(new ArrayList(0));
}
+ if (shortcutIds != null && packageName == null) {
+ throw new IllegalArgumentException(
+ "To query by shortcut ID, package name must also be set");
+ }
return new ParceledListSlice<>(
mShortcutServiceInternal.getShortcuts(getCallingUserId(),
- callingPackage, changedSince, packageName,
+ callingPackage, changedSince, packageName, shortcutIds,
componentName, flags, user.getIdentifier()));
}
@Override
- public ParceledListSlice getShortcutInfo(String callingPackage, String packageName,
- List<String> ids, UserHandle user) {
- ensureShortcutPermission(callingPackage, user);
- if (!isUserEnabled(user)) {
- return new ParceledListSlice<>(new ArrayList(0));
- }
-
- return new ParceledListSlice<>(
- mShortcutServiceInternal.getShortcutInfo(getCallingUserId(),
- callingPackage, packageName, ids, user.getIdentifier()));
- }
-
- @Override
public void pinShortcuts(String callingPackage, String packageName, List<String> ids,
UserHandle user) {
ensureShortcutPermission(callingPackage, user);
@@ -396,27 +400,27 @@
}
@Override
- public int getShortcutIconResId(String callingPackage, ShortcutInfo shortcut,
- UserHandle user) {
- ensureShortcutPermission(callingPackage, user);
- if (!isUserEnabled(user)) {
+ public int getShortcutIconResId(String callingPackage, String packageName, String id,
+ int userId) {
+ ensureShortcutPermission(callingPackage, userId);
+ if (!isUserEnabled(userId)) {
return 0;
}
return mShortcutServiceInternal.getShortcutIconResId(getCallingUserId(),
- callingPackage, shortcut, user.getIdentifier());
+ callingPackage, packageName, id, userId);
}
@Override
- public ParcelFileDescriptor getShortcutIconFd(String callingPackage, ShortcutInfo shortcut,
- UserHandle user) {
- ensureShortcutPermission(callingPackage, user);
- if (!isUserEnabled(user)) {
+ public ParcelFileDescriptor getShortcutIconFd(String callingPackage,
+ String packageName, String id, int userId) {
+ ensureShortcutPermission(callingPackage, userId);
+ if (!isUserEnabled(userId)) {
return null;
}
return mShortcutServiceInternal.getShortcutIconFd(getCallingUserId(),
- callingPackage, shortcut, user.getIdentifier());
+ callingPackage, packageName, id, userId);
}
@Override
@@ -428,23 +432,23 @@
@Override
public boolean startShortcut(String callingPackage, String packageName, String shortcutId,
- Rect sourceBounds, Bundle startActivityOptions, UserHandle user) {
+ Rect sourceBounds, Bundle startActivityOptions, int userId) {
verifyCallingPackage(callingPackage);
- ensureInUserProfiles(user, "Cannot start activity for unrelated profile " + user);
+ ensureInUserProfiles(userId, "Cannot start activity for unrelated profile " + userId);
- if (!isUserEnabled(user)) {
+ if (!isUserEnabled(userId)) {
throw new IllegalStateException("Cannot start a shortcut for disabled profile "
- + user);
+ + userId);
}
// Even without the permission, pinned shortcuts are always launchable.
if (!mShortcutServiceInternal.isPinnedByCaller(getCallingUserId(),
- callingPackage, packageName, shortcutId, user.getIdentifier())) {
- ensureShortcutPermission(callingPackage, user);
+ callingPackage, packageName, shortcutId, userId)) {
+ ensureShortcutPermission(callingPackage, userId);
}
final Intent intent = mShortcutServiceInternal.createShortcutIntent(getCallingUserId(),
- callingPackage, packageName, shortcutId, user.getIdentifier());
+ callingPackage, packageName, shortcutId, userId);
if (intent == null) {
return false;
}
@@ -455,7 +459,7 @@
final long ident = Binder.clearCallingIdentity();
try {
- mContext.startActivityAsUser(intent, startActivityOptions, user);
+ mContext.startActivityAsUser(intent, startActivityOptions, UserHandle.of(userId));
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -768,7 +772,8 @@
final List<ShortcutInfo> list =
mShortcutServiceInternal.getShortcuts(launcherUserId,
cookie.packageName,
- /* changedSince= */ 0, packageName, /* component= */ null,
+ /* changedSince= */ 0, packageName, /* shortcutIds=*/ null,
+ /* component= */ null,
ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY
| ShortcutQuery.FLAG_GET_PINNED
| ShortcutQuery.FLAG_GET_DYNAMIC
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index bf41246..3b07fe1 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -229,6 +229,7 @@
import com.android.internal.os.InstallerConnection.InstallerException;
import com.android.internal.os.SomeArgs;
import com.android.internal.os.Zygote;
+import com.android.internal.telephony.CarrierAppUtils;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.FastXmlSerializer;
@@ -2051,6 +2052,10 @@
PackageManagerService m = new PackageManagerService(context, installer,
factoryTest, onlyCore);
m.enableSystemUserPackages();
+ // Disable any carrier apps. We do this very early in boot to prevent the apps from being
+ // disabled after already being started.
+ CarrierAppUtils.disableCarrierAppsUntilPrivileged(context.getOpPackageName(), m,
+ UserHandle.USER_SYSTEM);
ServiceManager.addService("package", m);
return m;
}
@@ -4716,27 +4721,39 @@
@Override
public ResolveInfo resolveIntent(Intent intent, String resolvedType,
int flags, int userId) {
- if (!sUserManager.exists(userId)) return null;
- flags = updateFlagsForResolve(flags, userId, intent);
- enforceCrossUserPermission(Binder.getCallingUid(), userId,
- false /* requireFullPermission */, false /* checkShell */, "resolve intent");
- final List<ResolveInfo> query = queryIntentActivitiesInternal(intent, resolvedType, flags,
- userId);
- final ResolveInfo bestChoice =
- chooseBestActivity(intent, resolvedType, flags, query, userId);
+ try {
+ Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "resolveIntent");
- if (isEphemeralAllowed(intent, query, userId)) {
- final EphemeralResolveInfo ai =
- getEphemeralResolveInfo(intent, resolvedType, userId);
- if (ai != null) {
- if (DEBUG_EPHEMERAL) {
- Slog.v(TAG, "Returning an EphemeralResolveInfo");
+ if (!sUserManager.exists(userId)) return null;
+ flags = updateFlagsForResolve(flags, userId, intent);
+ enforceCrossUserPermission(Binder.getCallingUid(), userId,
+ false /*requireFullPermission*/, false /*checkShell*/, "resolve intent");
+
+ Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "queryIntentActivities");
+ final List<ResolveInfo> query = queryIntentActivitiesInternal(intent, resolvedType,
+ flags, userId);
+ Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
+
+ final ResolveInfo bestChoice =
+ chooseBestActivity(intent, resolvedType, flags, query, userId);
+
+ if (isEphemeralAllowed(intent, query, userId)) {
+ Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "resolveEphemeral");
+ final EphemeralResolveInfo ai =
+ getEphemeralResolveInfo(intent, resolvedType, userId);
+ if (ai != null) {
+ if (DEBUG_EPHEMERAL) {
+ Slog.v(TAG, "Returning an EphemeralResolveInfo");
+ }
+ bestChoice.ephemeralInstaller = mEphemeralInstallerInfo;
+ bestChoice.ephemeralResolveInfo = ai;
}
- bestChoice.ephemeralInstaller = mEphemeralInstallerInfo;
- bestChoice.ephemeralResolveInfo = ai;
+ Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
}
+ return bestChoice;
+ } finally {
+ Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
}
- return bestChoice;
}
@Override
@@ -5183,8 +5200,14 @@
@Override
public @NonNull ParceledListSlice<ResolveInfo> queryIntentActivities(Intent intent,
String resolvedType, int flags, int userId) {
- return new ParceledListSlice<>(
- queryIntentActivitiesInternal(intent, resolvedType, flags, userId));
+ try {
+ Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "queryIntentActivities");
+
+ return new ParceledListSlice<>(
+ queryIntentActivitiesInternal(intent, resolvedType, flags, userId));
+ } finally {
+ Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
+ }
}
private @NonNull List<ResolveInfo> queryIntentActivitiesInternal(Intent intent,
@@ -13648,6 +13671,16 @@
}
}
+ // Check for shared user id changes
+ String invalidPackageName =
+ getParentOrChildPackageChangedSharedUser(oldPackage, pkg);
+ if (invalidPackageName != null) {
+ res.setError(INSTALL_FAILED_SHARED_USER_INCOMPATIBLE,
+ "Package " + invalidPackageName + " tried to change user "
+ + oldPackage.mSharedUserId);
+ return;
+ }
+
// In case of rollback, remember per-user/profile install state
allUsers = sUserManager.getUserIds();
}
@@ -13897,15 +13930,6 @@
setInstallAndUpdateTime(newPackage, deletedPkgSetting.firstInstallTime,
System.currentTimeMillis());
- // Check for shared user id changes
- String invalidPackageName = getParentOrChildPackageChangedSharedUser(
- deletedPackage, newPackage);
- if (invalidPackageName != null) {
- res.setError(INSTALL_FAILED_SHARED_USER_INCOMPATIBLE,
- "Forbidding shared user change from " + deletedPkgSetting.sharedUser
- + " to " + invalidPackageName);
- }
-
// Update the package dynamic state if succeeded
if (res.returnCode == PackageManager.INSTALL_SUCCEEDED) {
// Now that the install succeeded make sure we remove data
@@ -17038,8 +17062,13 @@
}
PackageSetting pkgSetting;
final int uid = Binder.getCallingUid();
- final int permission = mContext.checkCallingOrSelfPermission(
- android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE);
+ final int permission;
+ if (uid == Process.SYSTEM_UID) {
+ permission = PackageManager.PERMISSION_GRANTED;
+ } else {
+ permission = mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE);
+ }
enforceCrossUserPermission(uid, userId,
false /* requireFullPermission */, true /* checkShell */, "set enabled");
final boolean allowedByPermission = (permission == PackageManager.PERMISSION_GRANTED);
diff --git a/services/core/java/com/android/server/pm/ShortcutPackage.java b/services/core/java/com/android/server/pm/ShortcutPackage.java
index 1076a7a..58559a5 100644
--- a/services/core/java/com/android/server/pm/ShortcutPackage.java
+++ b/services/core/java/com/android/server/pm/ShortcutPackage.java
@@ -17,6 +17,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.UserIdInt;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
@@ -522,7 +523,7 @@
ret.getPackageInfo().loadFromXml(parser, fromBackup);
continue;
case TAG_SHORTCUT:
- final ShortcutInfo si = parseShortcut(parser, packageName);
+ final ShortcutInfo si = parseShortcut(parser, packageName, ownerUserId);
// Don't use addShortcut(), we don't need to save the icon.
ret.mShortcuts.put(si.getId(), si);
@@ -534,8 +535,8 @@
return ret;
}
- private static ShortcutInfo parseShortcut(XmlPullParser parser, String packageName)
- throws IOException, XmlPullParserException {
+ private static ShortcutInfo parseShortcut(XmlPullParser parser, String packageName,
+ @UserIdInt int userId) throws IOException, XmlPullParserException {
String id;
ComponentName activityComponent;
// Icon icon;
@@ -586,7 +587,7 @@
throw ShortcutService.throwForInvalidTag(depth, tag);
}
return new ShortcutInfo(
- id, packageName, activityComponent, /* icon =*/ null, title, text, intent,
+ userId, id, packageName, activityComponent, /* icon =*/ null, title, text, intent,
intentPersistableExtras, weight, extras, lastChangedTimestamp, flags,
iconRes, bitmapPath);
}
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index 5c1e7a8..1641e1d 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -419,26 +419,26 @@
result = false;
}
- mSaveDelayMillis = (int) parser.getLong(ConfigConstants.KEY_SAVE_DELAY_MILLIS,
- DEFAULT_SAVE_DELAY_MS);
+ mSaveDelayMillis = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_SAVE_DELAY_MILLIS,
+ DEFAULT_SAVE_DELAY_MS));
- mResetInterval = parser.getLong(
+ mResetInterval = Math.max(1, parser.getLong(
ConfigConstants.KEY_RESET_INTERVAL_SEC, DEFAULT_RESET_INTERVAL_SEC)
- * 1000L;
+ * 1000L);
- mMaxDailyUpdates = (int) parser.getLong(
- ConfigConstants.KEY_MAX_DAILY_UPDATES, DEFAULT_MAX_DAILY_UPDATES);
+ mMaxDailyUpdates = Math.max(0, (int) parser.getLong(
+ ConfigConstants.KEY_MAX_DAILY_UPDATES, DEFAULT_MAX_DAILY_UPDATES));
- mMaxDynamicShortcuts = (int) parser.getLong(
- ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_APP);
+ mMaxDynamicShortcuts = Math.max(0, (int) parser.getLong(
+ ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_APP));
- final int iconDimensionDp = injectIsLowRamDevice()
+ final int iconDimensionDp = Math.max(1, injectIsLowRamDevice()
? (int) parser.getLong(
ConfigConstants.KEY_MAX_ICON_DIMENSION_DP_LOWRAM,
DEFAULT_MAX_ICON_DIMENSION_LOWRAM_DP)
: (int) parser.getLong(
ConfigConstants.KEY_MAX_ICON_DIMENSION_DP,
- DEFAULT_MAX_ICON_DIMENSION_DP);
+ DEFAULT_MAX_ICON_DIMENSION_DP));
mMaxIconDimension = injectDipToPixel(iconDimensionDp);
@@ -968,7 +968,8 @@
return; // has no icon
}
- Bitmap bitmap = null;
+ Bitmap bitmap;
+ Bitmap bitmapToRecycle = null;
try {
switch (icon.getType()) {
case Icon.TYPE_RESOURCE: {
@@ -979,7 +980,7 @@
return;
}
case Icon.TYPE_BITMAP: {
- bitmap = icon.getBitmap();
+ bitmap = icon.getBitmap(); // Don't recycle in this case.
break;
}
case Icon.TYPE_URI: {
@@ -987,7 +988,8 @@
try (InputStream is = mContext.getContentResolver().openInputStream(uri)) {
- bitmap = BitmapFactory.decodeStream(is);
+ bitmapToRecycle = BitmapFactory.decodeStream(is);
+ bitmap = bitmapToRecycle;
} catch (IOException e) {
Slog.e(TAG, "Unable to load icon from " + uri);
@@ -1011,8 +1013,14 @@
try {
path = out.getFile();
- shrinkBitmap(bitmap, mMaxIconDimension)
- .compress(mIconPersistFormat, mIconPersistQuality, out);
+ Bitmap shrunk = shrinkBitmap(bitmap, mMaxIconDimension);
+ try {
+ shrunk.compress(mIconPersistFormat, mIconPersistQuality, out);
+ } finally {
+ if (bitmap != shrunk) {
+ shrunk.recycle();
+ }
+ }
shortcut.setBitmapPath(out.getFile().getAbsolutePath());
shortcut.addFlags(ShortcutInfo.FLAG_HAS_ICON_FILE);
@@ -1027,8 +1035,8 @@
}
}
} finally {
- if (bitmap != null) {
- bitmap.recycle();
+ if (bitmapToRecycle != null) {
+ bitmapToRecycle.recycle();
}
// Once saved, we won't use the original icon information, so null it out.
shortcut.clearIcon();
@@ -1076,8 +1084,6 @@
c.drawBitmap(in, /*src=*/ null, dst, /* paint =*/ null);
- in.recycle();
-
return scaledBitmap;
}
@@ -1122,7 +1128,7 @@
if (injectGetPackageUid(packageName, userId) == injectBinderCallingUid()) {
return; // Caller is valid.
}
- throw new SecurityException("Caller UID= doesn't own " + packageName);
+ throw new SecurityException("Calling package name mismatch");
}
void postToHandler(Runnable r) {
@@ -1419,6 +1425,8 @@
@Override
public int getIconMaxDimensions(String packageName, int userId) throws RemoteException {
+ verifyCaller(packageName, userId);
+
synchronized (mLock) {
return mMaxIconDimension;
}
@@ -1439,7 +1447,15 @@
getUserShortcutsLocked(userId).resetThrottling();
}
scheduleSaveUser(userId);
- Slog.i(TAG, "ShortcutManager: throttling counter reset");
+ Slog.i(TAG, "ShortcutManager: throttling counter reset for user " + userId);
+ }
+
+ void resetAllThrottlingInner() {
+ synchronized (mLock) {
+ mRawLastResetTime = injectCurrentTimeMillis();
+ }
+ scheduleSaveBaseState();
+ Slog.i(TAG, "ShortcutManager: throttling counter reset for all users");
}
// We override this method in unit tests to do a simpler check.
@@ -1522,14 +1538,20 @@
// === House keeping ===
+ @VisibleForTesting
+ void cleanUpPackageLocked(String packageName, int owningUserId, int packageUserId) {
+ cleanUpPackageLocked(packageName, owningUserId, packageUserId,
+ /* forceForCommandLine= */ false);
+ }
+
/**
* Remove all the information associated with a package. This will really remove all the
* information, including the restore information (i.e. it'll remove packages even if they're
* shadow).
*/
- @VisibleForTesting
- void cleanUpPackageLocked(String packageName, int owningUserId, int packageUserId) {
- if (isPackageInstalled(packageName, packageUserId)) {
+ private void cleanUpPackageLocked(String packageName, int owningUserId, int packageUserId,
+ boolean forceForCommandLine) {
+ if (!forceForCommandLine && isPackageInstalled(packageName, packageUserId)) {
wtf("Package " + packageName + " is still installed for user " + packageUserId);
return;
}
@@ -1580,13 +1602,17 @@
@Override
public List<ShortcutInfo> getShortcuts(int launcherUserId,
@NonNull String callingPackage, long changedSince,
- @Nullable String packageName, @Nullable ComponentName componentName,
+ @Nullable String packageName, @Nullable List<String> shortcutIds,
+ @Nullable ComponentName componentName,
int queryFlags, int userId) {
final ArrayList<ShortcutInfo> ret = new ArrayList<>();
final int cloneFlag =
((queryFlags & ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY) == 0)
? ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER
: ShortcutInfo.CLONE_REMOVE_NON_KEY_INFO;
+ if (packageName == null) {
+ shortcutIds = null; // LauncherAppsService already threw for it though.
+ }
synchronized (mLock) {
getLauncherShortcutsLocked(callingPackage, userId, launcherUserId)
@@ -1594,14 +1620,14 @@
if (packageName != null) {
getShortcutsInnerLocked(launcherUserId,
- callingPackage, packageName, changedSince,
+ callingPackage, packageName, shortcutIds, changedSince,
componentName, queryFlags, userId, ret, cloneFlag);
} else {
final ArrayMap<String, ShortcutPackage> packages =
getUserShortcutsLocked(userId).getAllPackages();
for (int i = packages.size() - 1; i >= 0; i--) {
getShortcutsInnerLocked(launcherUserId,
- callingPackage, packages.keyAt(i), changedSince,
+ callingPackage, packages.keyAt(i), shortcutIds, changedSince,
componentName, queryFlags, userId, ret, cloneFlag);
}
}
@@ -1610,14 +1636,20 @@
}
private void getShortcutsInnerLocked(int launcherUserId, @NonNull String callingPackage,
- @Nullable String packageName,long changedSince,
+ @Nullable String packageName, @Nullable List<String> shortcutIds, long changedSince,
@Nullable ComponentName componentName, int queryFlags,
int userId, ArrayList<ShortcutInfo> ret, int cloneFlag) {
+ final ArraySet<String> ids = shortcutIds == null ? null
+ : new ArraySet<>(shortcutIds);
+
getPackageShortcutsLocked(packageName, userId).findAll(ShortcutService.this, ret,
(ShortcutInfo si) -> {
if (si.getLastChangedTimestamp() < changedSince) {
return false;
}
+ if (ids != null && !ids.contains(si.getId())) {
+ return false;
+ }
if (componentName != null
&& !componentName.equals(si.getActivityComponent())) {
return false;
@@ -1633,27 +1665,6 @@
}
@Override
- public List<ShortcutInfo> getShortcutInfo(int launcherUserId,
- @NonNull String callingPackage,
- @NonNull String packageName, @Nullable List<String> ids, int userId) {
- // Calling permission must be checked by LauncherAppsImpl.
- Preconditions.checkStringNotEmpty(packageName, "packageName");
-
- final ArrayList<ShortcutInfo> ret = new ArrayList<>(ids.size());
- final ArraySet<String> idSet = new ArraySet<>(ids);
- synchronized (mLock) {
- getLauncherShortcutsLocked(callingPackage, userId, launcherUserId)
- .attemptToRestoreIfNeededAndSave(ShortcutService.this);
-
- getPackageShortcutsLocked(packageName, userId).findAll(
- ShortcutService.this, ret,
- (ShortcutInfo si) -> idSet.contains(si.getId()),
- ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER, callingPackage, launcherUserId);
- }
- return ret;
- }
-
- @Override
public boolean isPinnedByCaller(int launcherUserId, @NonNull String callingPackage,
@NonNull String packageName, @NonNull String shortcutId, int userId) {
Preconditions.checkStringNotEmpty(packageName, "packageName");
@@ -1733,17 +1744,18 @@
}
@Override
- public int getShortcutIconResId(int launcherUserId,
- @NonNull String callingPackage,
- @NonNull ShortcutInfo shortcut, int userId) {
- Preconditions.checkNotNull(shortcut, "shortcut");
+ public int getShortcutIconResId(int launcherUserId, @NonNull String callingPackage,
+ @NonNull String packageName, @NonNull String shortcutId, int userId) {
+ Preconditions.checkNotNull(callingPackage, "callingPackage");
+ Preconditions.checkNotNull(packageName, "packageName");
+ Preconditions.checkNotNull(shortcutId, "shortcutId");
synchronized (mLock) {
getLauncherShortcutsLocked(callingPackage, userId, launcherUserId)
.attemptToRestoreIfNeededAndSave(ShortcutService.this);
final ShortcutInfo shortcutInfo = getPackageShortcutsLocked(
- shortcut.getPackageName(), userId).findShortcutById(shortcut.getId());
+ packageName, userId).findShortcutById(shortcutId);
return (shortcutInfo != null && shortcutInfo.hasIconResource())
? shortcutInfo.getIconResourceId() : 0;
}
@@ -1751,16 +1763,18 @@
@Override
public ParcelFileDescriptor getShortcutIconFd(int launcherUserId,
- @NonNull String callingPackage,
- @NonNull ShortcutInfo shortcutIn, int userId) {
- Preconditions.checkNotNull(shortcutIn, "shortcut");
+ @NonNull String callingPackage, @NonNull String packageName,
+ @NonNull String shortcutId, int userId) {
+ Preconditions.checkNotNull(callingPackage, "callingPackage");
+ Preconditions.checkNotNull(packageName, "packageName");
+ Preconditions.checkNotNull(shortcutId, "shortcutId");
synchronized (mLock) {
getLauncherShortcutsLocked(callingPackage, userId, launcherUserId)
.attemptToRestoreIfNeededAndSave(ShortcutService.this);
final ShortcutInfo shortcutInfo = getPackageShortcutsLocked(
- shortcutIn.getPackageName(), userId).findShortcutById(shortcutIn.getId());
+ packageName, userId).findShortcutById(shortcutId);
if (shortcutInfo == null || !shortcutInfo.hasIconFile()) {
return null;
}
@@ -1865,9 +1879,15 @@
Slog.d(TAG, String.format("handlePackageRemoved: %s user=%d", packageName,
packageUserId));
}
+ handlePackageRemovedInner(packageName, packageUserId, /* forceForCommandLine =*/ false);
+ }
+
+ private void handlePackageRemovedInner(String packageName, @UserIdInt int packageUserId,
+ boolean forceForCommandLine) {
synchronized (mLock) {
forEachLoadedUserLocked(user ->
- cleanUpPackageLocked(packageName, user.getUserId(), packageUserId));
+ cleanUpPackageLocked(packageName, user.getUserId(), packageUserId,
+ forceForCommandLine));
}
}
@@ -2048,17 +2068,26 @@
pw.print(formatTime(next));
pw.println();
- pw.print(" Max icon dim: ");
- pw.print(mMaxIconDimension);
- pw.print(" Icon format: ");
- pw.print(mIconPersistFormat);
- pw.print(" Icon quality: ");
+ pw.print(" Config:");
+ pw.print(" Max icon dim: ");
+ pw.println(mMaxIconDimension);
+ pw.print(" Icon format: ");
+ pw.println(mIconPersistFormat);
+ pw.print(" Icon quality: ");
pw.println(mIconPersistQuality);
+ pw.print(" saveDelayMillis:");
+ pw.println(mSaveDelayMillis);
+ pw.print(" resetInterval:");
+ pw.println(mResetInterval);
+ pw.print(" maxDailyUpdates:");
+ pw.println(mMaxDailyUpdates);
+ pw.print(" maxDynamicShortcuts:");
+ pw.println(mMaxDynamicShortcuts);
pw.println();
pw.println(" Stats:");
synchronized (mStatLock) {
- final String p = " ";
+ final String p = " ";
dumpStatLS(pw, p, Stats.GET_DEFAULT_HOME, "getHomeActivities()");
dumpStatLS(pw, p, Stats.LAUNCHER_PERMISSION_CHECK, "Launcher permission check");
@@ -2144,6 +2173,9 @@
case "reset-throttling":
handleResetThrottling();
break;
+ case "reset-all-throttling":
+ handleResetAllThrottling();
+ break;
case "override-config":
handleOverrideConfig();
break;
@@ -2162,6 +2194,9 @@
case "unload-user":
handleUnloadUser();
break;
+ case "clear-shortcuts":
+ handleClearShortcuts();
+ break;
default:
return handleDefaultCommands(cmd);
}
@@ -2181,9 +2216,12 @@
pw.println("cmd shortcut reset-package-throttling [--user USER_ID] PACKAGE");
pw.println(" Reset throttling for a package");
pw.println();
- pw.println("cmd shortcut reset-throttling");
+ pw.println("cmd shortcut reset-throttling [--user USER_ID]");
pw.println(" Reset throttling for all packages and users");
pw.println();
+ pw.println("cmd shortcut reset-all-throttling");
+ pw.println(" Reset the throttling state for all users");
+ pw.println();
pw.println("cmd shortcut override-config CONFIG");
pw.println(" Override the configuration for testing (will last until reboot)");
pw.println();
@@ -2203,13 +2241,23 @@
pw.println(" Unload a user from the memory");
pw.println(" (This should not affect any observable behavior)");
pw.println();
+ pw.println("cmd shortcut clear-shortcuts [--user USER_ID] PACKAGE");
+ pw.println(" Remove all shortcuts from a package, including pinned shortcuts");
+ pw.println();
}
- private int handleResetThrottling() throws CommandException {
+ private void handleResetThrottling() throws CommandException {
parseOptions(/* takeUser =*/ true);
+ Slog.i(TAG, "cmd: handleResetThrottling");
+
resetThrottlingInner(mUserId);
- return 0;
+ }
+
+ private void handleResetAllThrottling() {
+ Slog.i(TAG, "cmd: handleResetAllThrottling");
+
+ resetAllThrottlingInner();
}
private void handleResetPackageThrottling() throws CommandException {
@@ -2217,6 +2265,8 @@
final String packageName = getNextArgRequired();
+ Slog.i(TAG, "cmd: handleResetPackageThrottling: " + packageName);
+
synchronized (mLock) {
getPackageShortcutsLocked(packageName, mUserId).resetRateLimitingForCommandLine();
saveUserLocked(mUserId);
@@ -2226,6 +2276,8 @@
private void handleOverrideConfig() throws CommandException {
final String config = getNextArgRequired();
+ Slog.i(TAG, "cmd: handleOverrideConfig: " + config);
+
synchronized (mLock) {
if (!updateConfigurationLocked(config)) {
throw new CommandException("override-config failed. See logcat for details.");
@@ -2234,6 +2286,8 @@
}
private void handleResetConfig() {
+ Slog.i(TAG, "cmd: handleResetConfig");
+
synchronized (mLock) {
loadConfigurationLocked();
}
@@ -2278,8 +2332,20 @@
private void handleUnloadUser() throws CommandException {
parseOptions(/* takeUser =*/ true);
+ Slog.i(TAG, "cmd: handleUnloadUser: " + mUserId);
+
ShortcutService.this.handleCleanupUser(mUserId);
}
+
+ private void handleClearShortcuts() throws CommandException {
+ parseOptions(/* takeUser =*/ true);
+ final String packageName = getNextArgRequired();
+
+ Slog.i(TAG, "cmd: handleClearShortcuts: " + mUserId + ", " + packageName);
+
+ ShortcutService.this.handlePackageRemovedInner(packageName, mUserId,
+ /* forceForCommandLine= */ true);
+ }
}
// === Unit test support ===
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 60a0d62..60ea254 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -65,6 +65,7 @@
import android.system.Os;
import android.system.OsConstants;
import android.util.AtomicFile;
+import android.util.IntArray;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
@@ -483,13 +484,50 @@
}
}
+ @Override
+ public int[] getProfileIds(int userId, boolean enabledOnly) {
+ if (userId != UserHandle.getCallingUserId()) {
+ checkManageUsersPermission("getting profiles related to user " + userId);
+ }
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mUsersLock) {
+ return getProfileIdsLU(userId, enabledOnly).toArray();
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
/** Assume permissions already checked and caller's identity cleared */
private List<UserInfo> getProfilesLU(int userId, boolean enabledOnly, boolean fullInfo) {
+ IntArray profileIds = getProfileIdsLU(userId, enabledOnly);
+ ArrayList<UserInfo> users = new ArrayList<>(profileIds.size());
+ for (int i = 0; i < profileIds.size(); i++) {
+ int profileId = profileIds.get(i);
+ UserInfo userInfo = mUsers.get(profileId).info;
+ // If full info is not required - clear PII data to prevent 3P apps from reading it
+ if (!fullInfo) {
+ userInfo = new UserInfo(userInfo);
+ userInfo.name = null;
+ userInfo.iconPath = null;
+ } else {
+ userInfo = userWithName(userInfo);
+ }
+ users.add(userInfo);
+ }
+ return users;
+ }
+
+ /**
+ * Assume permissions already checked and caller's identity cleared
+ */
+ private IntArray getProfileIdsLU(int userId, boolean enabledOnly) {
UserInfo user = getUserInfoLU(userId);
- ArrayList<UserInfo> users = new ArrayList<UserInfo>(mUsers.size());
+ IntArray result = new IntArray(mUsers.size());
if (user == null) {
// Probably a dying user
- return users;
+ return result;
}
final int userSize = mUsers.size();
for (int i = 0; i < userSize; i++) {
@@ -506,16 +544,9 @@
if (profile.partial) {
continue;
}
- UserInfo userInfo = userWithName(profile);
- // If full info is not required - clear PII data to prevent 3P apps from reading it
- if (!fullInfo) {
- userInfo = new UserInfo(userInfo);
- userInfo.name = null;
- userInfo.iconPath = null;
- }
- users.add(userInfo);
+ result.add(profile.id);
}
- return users;
+ return result;
}
@Override
diff --git a/services/core/java/com/android/server/policy/ShortcutManager.java b/services/core/java/com/android/server/policy/ShortcutManager.java
index a14c614..ab404db 100644
--- a/services/core/java/com/android/server/policy/ShortcutManager.java
+++ b/services/core/java/com/android/server/policy/ShortcutManager.java
@@ -27,7 +27,9 @@
import android.util.SparseArray;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
+
import com.android.internal.util.XmlUtils;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
diff --git a/services/core/java/com/android/server/vr/EnabledComponentsObserver.java b/services/core/java/com/android/server/vr/EnabledComponentsObserver.java
index eb926c1..30194bf 100644
--- a/services/core/java/com/android/server/vr/EnabledComponentsObserver.java
+++ b/services/core/java/com/android/server/vr/EnabledComponentsObserver.java
@@ -24,7 +24,6 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
-import android.content.pm.UserInfo;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
@@ -213,18 +212,7 @@
if (userManager == null) {
return null;
}
- int currentUserId = ActivityManager.getCurrentUser();
- List<UserInfo> profiles = userManager.getProfiles(currentUserId);
- if (profiles == null) {
- return null;
- }
- final int s = profiles.size();
- int[] userIds = new int[s];
- int ctr = 0;
- for (UserInfo info : profiles) {
- userIds[ctr++] = info.id;
- }
- return userIds;
+ return userManager.getProfileIdsWithDisabled(ActivityManager.getCurrentUser());
}
public static ArraySet<ComponentName> loadComponentNames(PackageManager pm, int userId,
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index fb3c6ec..fe32104 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -49,6 +49,7 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapRegionDecoder;
+import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Binder;
@@ -265,70 +266,134 @@
*/
private void generateCrop(WallpaperData wallpaper) {
boolean success = false;
- boolean needCrop = false;
- boolean needScale = false;
+
+ Rect cropHint = new Rect(wallpaper.cropHint);
if (DEBUG) {
Slog.v(TAG, "Generating crop for new wallpaper(s): 0x"
+ Integer.toHexString(wallpaper.whichPending)
- + " to " + wallpaper.cropFile.getName());
+ + " to " + wallpaper.cropFile.getName()
+ + " crop=(" + cropHint.width() + 'x' + cropHint.height()
+ + ") dim=(" + wallpaper.width + 'x' + wallpaper.height + ')');
}
// Analyse the source; needed in multiple cases
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(wallpaper.wallpaperFile.getAbsolutePath(), options);
-
- // We'll need to scale if the crop is sufficiently bigger than the display
-
- // Legacy case uses an empty crop rect here, so we just preserve the
- // source image verbatim
- if (!wallpaper.cropHint.isEmpty()) {
- // ...clamp the crop rect to the measured bounds...
- wallpaper.cropHint.right = Math.min(wallpaper.cropHint.right, options.outWidth);
- wallpaper.cropHint.bottom = Math.min(wallpaper.cropHint.bottom, options.outHeight);
- // ...and don't bother cropping if what we're left with is identity
- needCrop = (options.outHeight >= wallpaper.cropHint.height()
- && options.outWidth >= wallpaper.cropHint.width());
- }
-
- if (!needCrop && !needScale) {
- // Simple case: the nominal crop is at least as big as the source image,
- // so we take the whole thing and just copy the image file directly.
- if (DEBUG) {
- Slog.v(TAG, "Null crop of new wallpaper; copying");
- }
- success = FileUtils.copyFile(wallpaper.wallpaperFile, wallpaper.cropFile);
- if (!success) {
- wallpaper.cropFile.delete();
- // TODO: fall back to default wallpaper in this case
- }
+ if (options.outWidth <= 0 || options.outHeight <= 0) {
+ Slog.e(TAG, "Invalid wallpaper data");
+ success = false;
} else {
- // Fancy case: crop and/or scale
- FileOutputStream f = null;
- BufferedOutputStream bos = null;
- try {
- BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(
- wallpaper.wallpaperFile.getAbsolutePath(), false);
- Bitmap cropped = decoder.decodeRegion(wallpaper.cropHint, null);
- decoder.recycle();
+ boolean needCrop = false;
+ boolean needScale = false;
- if (cropped == null) {
- Slog.e(TAG, "Could not decode new wallpaper");
- } else {
- f = new FileOutputStream(wallpaper.cropFile);
- bos = new BufferedOutputStream(f, 32*1024);
- cropped.compress(Bitmap.CompressFormat.PNG, 90, bos);
- bos.flush(); // don't rely on the implicit flush-at-close when noting success
- success = true;
- }
- } catch (IOException e) {
+ // Empty crop means use the full image
+ if (cropHint.isEmpty()) {
+ cropHint.left = cropHint.top = 0;
+ cropHint.right = options.outWidth;
+ cropHint.bottom = options.outHeight;
+ } else {
+ // force the crop rect to lie within the measured bounds
+ cropHint.offset(
+ (cropHint.right > options.outWidth ? options.outWidth - cropHint.right : 0),
+ (cropHint.bottom > options.outHeight ? options.outHeight - cropHint.bottom : 0));
+
+ // Don't bother cropping if what we're left with is identity
+ needCrop = (options.outHeight >= cropHint.height()
+ && options.outWidth >= cropHint.width());
+ }
+
+ // scale if the crop height winds up not matching the recommended metrics
+ needScale = (wallpaper.height != cropHint.height());
+
+ if (DEBUG) {
+ Slog.v(TAG, "crop: w=" + cropHint.width() + " h=" + cropHint.height());
+ Slog.v(TAG, "dims: w=" + wallpaper.width + " h=" + wallpaper.height);
+ Slog.v(TAG, "meas: w=" + options.outWidth + " h=" + options.outHeight);
+ Slog.v(TAG, "crop?=" + needCrop + " scale?=" + needScale);
+ }
+
+ if (!needCrop && !needScale) {
+ // Simple case: the nominal crop fits what we want, so we take
+ // the whole thing and just copy the image file directly.
if (DEBUG) {
- Slog.e(TAG, "I/O error decoding crop: " + e.getMessage());
+ Slog.v(TAG, "Null crop of new wallpaper; copying");
}
- } finally {
- IoUtils.closeQuietly(bos);
- IoUtils.closeQuietly(f);
+ success = FileUtils.copyFile(wallpaper.wallpaperFile, wallpaper.cropFile);
+ if (!success) {
+ wallpaper.cropFile.delete();
+ // TODO: fall back to default wallpaper in this case
+ }
+ } else {
+ // Fancy case: crop and scale. First, we decode and scale down if appropriate.
+ FileOutputStream f = null;
+ BufferedOutputStream bos = null;
+ try {
+ BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(
+ wallpaper.wallpaperFile.getAbsolutePath(), false);
+
+ // This actually downsamples only by powers of two, but that's okay; we do
+ // a proper scaling blit later. This is to minimize transient RAM use.
+ // We calculate the largest power-of-two under the actual ratio rather than
+ // just let the decode take care of it because we also want to remap where the
+ // cropHint rectangle lies in the decoded [super]rect.
+ final BitmapFactory.Options scaler;
+ final int actualScale = cropHint.height() / wallpaper.height;
+ int scale = 1;
+ while (2*scale < actualScale) {
+ scale *= 2;
+ }
+ if (scale > 1) {
+ scaler = new BitmapFactory.Options();
+ scaler.inSampleSize = scale;
+ if (DEBUG) {
+ Slog.v(TAG, "Downsampling cropped rect with scale " + scale);
+ }
+ } else {
+ scaler = null;
+ }
+ Bitmap cropped = decoder.decodeRegion(cropHint, scaler);
+ decoder.recycle();
+
+ if (cropped == null) {
+ Slog.e(TAG, "Could not decode new wallpaper");
+ } else {
+ // We've got the extracted crop; now we want to scale it properly to
+ // the desired rectangle. That's a height-biased operation: make it
+ // fit the hinted height, and accept whatever width we end up with.
+ cropHint.offsetTo(0, 0);
+ cropHint.right /= scale; // adjust by downsampling factor
+ cropHint.bottom /= scale;
+ final float heightR = ((float)wallpaper.height) / ((float)cropHint.height());
+ if (DEBUG) {
+ Slog.v(TAG, "scale " + heightR + ", extracting " + cropHint);
+ }
+ final int destWidth = (int)(cropHint.width() * heightR);
+ final Bitmap finalCrop = Bitmap.createScaledBitmap(cropped,
+ destWidth, wallpaper.height, true);
+ if (DEBUG) {
+ Slog.v(TAG, "Final extract:");
+ Slog.v(TAG, " dims: w=" + wallpaper.width
+ + " h=" + wallpaper.height);
+ Slog.v(TAG, " out: w=" + finalCrop.getWidth()
+ + " h=" + finalCrop.getHeight());
+ }
+
+ f = new FileOutputStream(wallpaper.cropFile);
+ bos = new BufferedOutputStream(f, 32*1024);
+ finalCrop.compress(Bitmap.CompressFormat.PNG, 90, bos);
+ bos.flush(); // don't rely on the implicit flush-at-close when noting success
+ success = true;
+ }
+ } catch (Exception e) {
+ if (DEBUG) {
+ Slog.e(TAG, "Error decoding crop", e);
+ }
+ } finally {
+ IoUtils.closeQuietly(bos);
+ IoUtils.closeQuietly(f);
+ }
}
}
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateService.java b/services/core/java/com/android/server/webkit/WebViewUpdateService.java
index 1f6fb2a..bbb4951 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdateService.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdateService.java
@@ -242,7 +242,12 @@
throw new SecurityException(msg);
}
- WebViewUpdateService.this.mImpl.enableFallbackLogic(enable);
+ long callingId = Binder.clearCallingIdentity();
+ try {
+ WebViewUpdateService.this.mImpl.enableFallbackLogic(enable);
+ } finally {
+ Binder.restoreCallingIdentity(callingId);
+ }
}
}
}
diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java
index eae7838..6bc633f 100644
--- a/services/core/java/com/android/server/wm/WindowAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowAnimator.java
@@ -670,7 +670,6 @@
if (SHOW_TRANSACTIONS) Slog.i(
TAG, ">>> OPEN TRANSACTION animateLocked");
SurfaceControl.openTransaction();
- SurfaceControl.setAnimationTransaction();
try {
final int numDisplays = mDisplayContentsAnimators.size();
for (int i = 0; i < numDisplays; i++) {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 72eebb5..d229633 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -21,8 +21,6 @@
import static android.app.admin.DevicePolicyManager.WIPE_EXTERNAL_STORAGE;
import static android.app.admin.DevicePolicyManager.WIPE_RESET_PROTECTION_DATA;
import static android.content.pm.PackageManager.GET_UNINSTALLED_PACKAGES;
-import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
-import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
@@ -57,7 +55,6 @@
import android.app.backup.IBackupManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -85,7 +82,6 @@
import android.os.AsyncTask;
import android.os.Binder;
import android.os.Build;
-import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Environment;
import android.os.FileUtils;
@@ -2065,10 +2061,9 @@
*/
private void sendAdminCommandToSelfAndProfilesLocked(String action, int reqPolicy,
int userHandle) {
- List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
- for (UserInfo ui : profiles) {
- int id = ui.id;
- sendAdminCommandLocked(action, reqPolicy, id);
+ int[] profileIds = mUserManager.getProfileIdsWithDisabled(userHandle);
+ for (int profileId : profileIds) {
+ sendAdminCommandLocked(action, reqPolicy, profileId);
}
}
@@ -3968,9 +3963,9 @@
// moment so we set the screen off timeout regardless of whether it affects the parent user
// or the profile challenge only.
long timeMs = Long.MAX_VALUE;
- List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
- for (UserInfo userInfo : profiles) {
- DevicePolicyData policy = getUserDataUnchecked(userInfo.id);
+ int[] profileIds = mUserManager.getProfileIdsWithDisabled(userHandle);
+ for (int profileId : profileIds) {
+ DevicePolicyData policy = getUserDataUnchecked(profileId);
final int N = policy.mAdminList.size();
for (int i = 0; i < N; i++) {
ActiveAdmin admin = policy.mAdminList.get(i);
@@ -6708,19 +6703,18 @@
// If we have multiple profiles we return the intersection of the
// permitted lists. This can happen in cases where we have a device
// and profile owner.
- List<UserInfo> profiles = mUserManager.getProfiles(userId);
- final int PROFILES_SIZE = profiles.size();
- for (int i = 0; i < PROFILES_SIZE; ++i) {
+ int[] profileIds = mUserManager.getProfileIdsWithDisabled(userId);
+ for (int profileId : profileIds) {
// Just loop though all admins, only device or profiles
// owners can have permitted lists set.
- DevicePolicyData policy = getUserDataUnchecked(profiles.get(i).id);
+ DevicePolicyData policy = getUserDataUnchecked(profileId);
final int N = policy.mAdminList.size();
for (int j = 0; j < N; j++) {
ActiveAdmin admin = policy.mAdminList.get(j);
List<String> fromAdmin = admin.permittedAccessiblityServices;
if (fromAdmin != null) {
if (result == null) {
- result = new ArrayList<String>(fromAdmin);
+ result = new ArrayList<>(fromAdmin);
} else {
result.retainAll(fromAdmin);
}
@@ -6888,12 +6882,11 @@
// If we have multiple profiles we return the intersection of the
// permitted lists. This can happen in cases where we have a device
// and profile owner.
- List<UserInfo> profiles = mUserManager.getProfiles(userId);
- final int PROFILES_SIZE = profiles.size();
- for (int i = 0; i < PROFILES_SIZE; ++i) {
+ int[] profileIds = mUserManager.getProfileIdsWithDisabled(userId);
+ for (int profileId : profileIds) {
// Just loop though all admins, only device or profiles
// owners can have permitted lists set.
- DevicePolicyData policy = getUserDataUnchecked(profiles.get(i).id);
+ DevicePolicyData policy = getUserDataUnchecked(profileId);
final int N = policy.mAdminList.size();
for (int j = 0; j < N; j++) {
ActiveAdmin admin = policy.mAdminList.get(j);
diff --git a/services/tests/servicestests/Android.mk b/services/tests/servicestests/Android.mk
index e6dd6a4..7ffdb35 100644
--- a/services/tests/servicestests/Android.mk
+++ b/services/tests/servicestests/Android.mk
@@ -19,7 +19,8 @@
easymocklib \
guava \
android-support-test \
- mockito-target
+ mockito-target \
+ ShortcutManagerTestUtils
LOCAL_JAVA_LIBRARIES := android.test.runner
diff --git a/services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java
index 5b4803b..4468857 100644
--- a/services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java
@@ -16,23 +16,34 @@
package com.android.server.accounts;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import android.accounts.Account;
import android.accounts.AuthenticatorDescription;
+import android.app.AppOpsManager;
import android.app.Notification;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.RegisteredServicesCache.ServiceInfo;
import android.content.pm.RegisteredServicesCacheListener;
+import android.content.pm.UserInfo;
+import android.database.DatabaseErrorHandler;
+import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
+import android.os.UserManager;
import android.test.AndroidTestCase;
-import android.test.IsolatedContext;
-import android.test.RenamingDelegatingContext;
-import android.test.mock.MockContentResolver;
import android.test.mock.MockContext;
import android.test.mock.MockPackageManager;
+import android.util.Log;
+import java.io.File;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -41,20 +52,28 @@
import java.util.Comparator;
public class AccountManagerServiceTest extends AndroidTestCase {
+ private static final String TAG = AccountManagerServiceTest.class.getSimpleName();
+
+ static final String PREN_DB = "pren.db";
+ static final String DE_DB = "de.db";
+ static final String CE_DB = "ce.db";
private AccountManagerService mAms;
@Override
protected void setUp() throws Exception {
- final String filenamePrefix = "test.";
- MockContentResolver resolver = new MockContentResolver();
- RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(
- new MyMockContext(), // The context that most methods are delegated to
- getContext(), // The context that file methods are delegated to
- filenamePrefix);
- Context context = new IsolatedContext(resolver, targetContextWrapper);
- setContext(context);
+ Context realTestContext = getContext();
+ Context mockContext = new MyMockContext(realTestContext);
+ setContext(mockContext);
mAms = new MyAccountManagerService(getContext(),
- new MyMockPackageManager(), new MockAccountAuthenticatorCache());
+ new MyMockPackageManager(), new MockAccountAuthenticatorCache(), realTestContext);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ new File(mAms.getCeDatabaseName(UserHandle.USER_SYSTEM)).delete();
+ new File(mAms.getDeDatabaseName(UserHandle.USER_SYSTEM)).delete();
+ new File(mAms.getPreNDatabaseName(UserHandle.USER_SYSTEM)).delete();
+ super.tearDown();
}
public class AccountSorter implements Comparator<Account> {
@@ -69,6 +88,7 @@
}
public void testCheckAddAccount() throws Exception {
+ unlockUser(UserHandle.USER_SYSTEM);
Account a11 = new Account("account1", "type1");
Account a21 = new Account("account2", "type1");
Account a31 = new Account("account3", "type1");
@@ -109,6 +129,7 @@
}
public void testPasswords() throws Exception {
+ unlockUser(UserHandle.USER_SYSTEM);
Account a11 = new Account("account1", "type1");
Account a12 = new Account("account1", "type2");
mAms.addAccountExplicitly(a11, "p11", null);
@@ -124,6 +145,7 @@
}
public void testUserdata() throws Exception {
+ unlockUser(UserHandle.USER_SYSTEM);
Account a11 = new Account("account1", "type1");
Bundle u11 = new Bundle();
u11.putString("a", "a_a11");
@@ -156,6 +178,7 @@
}
public void testAuthtokens() throws Exception {
+ unlockUser(UserHandle.USER_SYSTEM);
Account a11 = new Account("account1", "type1");
Account a12 = new Account("account1", "type2");
mAms.addAccountExplicitly(a11, "p11", null);
@@ -188,15 +211,21 @@
assertNull(mAms.peekAuthToken(a12, "att2"));
}
+ private void unlockUser(int userId) {
+ Intent intent = new Intent();
+ intent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
+ mAms.onUserUnlocked(intent);
+ }
+
static public class MockAccountAuthenticatorCache implements IAccountAuthenticatorCache {
private ArrayList<ServiceInfo<AuthenticatorDescription>> mServices;
public MockAccountAuthenticatorCache() {
- mServices = new ArrayList<ServiceInfo<AuthenticatorDescription>>();
+ mServices = new ArrayList<>();
AuthenticatorDescription d1 = new AuthenticatorDescription("type1", "p1", 0, 0, 0, 0);
AuthenticatorDescription d2 = new AuthenticatorDescription("type2", "p2", 0, 0, 0, 0);
- mServices.add(new ServiceInfo<AuthenticatorDescription>(d1, null, null));
- mServices.add(new ServiceInfo<AuthenticatorDescription>(d2, null, null));
+ mServices.add(new ServiceInfo<>(d1, null, null));
+ mServices.add(new ServiceInfo<>(d2, null, null));
}
@Override
@@ -232,10 +261,68 @@
}
static public class MyMockContext extends MockContext {
+ private Context mTestContext;
+ private AppOpsManager mAppOpsManager;
+ private UserManager mUserManager;
+
+ public MyMockContext(Context testContext) {
+ this.mTestContext = testContext;
+ this.mAppOpsManager = mock(AppOpsManager.class);
+ this.mUserManager = mock(UserManager.class);
+ final UserInfo ui = new UserInfo(UserHandle.USER_SYSTEM, "user0", 0);
+ when(mUserManager.getUserInfo(eq(ui.id))).thenReturn(ui);
+ }
+
@Override
public int checkCallingOrSelfPermission(final String permission) {
return PackageManager.PERMISSION_GRANTED;
}
+
+ @Override
+ public Object getSystemService(String name) {
+ if (Context.APP_OPS_SERVICE.equals(name)) {
+ return mAppOpsManager;
+ } else if( Context.USER_SERVICE.equals(name)) {
+ return mUserManager;
+ }
+ return null;
+ }
+
+ @Override
+ public String getSystemServiceName(Class<?> serviceClass) {
+ if (AppOpsManager.class.equals(serviceClass)) {
+ return Context.APP_OPS_SERVICE;
+ }
+ return null;
+ }
+
+ @Override
+ public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
+ return null;
+ }
+
+ @Override
+ public Intent registerReceiverAsUser(BroadcastReceiver receiver, UserHandle user,
+ IntentFilter filter, String broadcastPermission, Handler scheduler) {
+ return null;
+ }
+
+ @Override
+ public SQLiteDatabase openOrCreateDatabase(String file, int mode,
+ SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) {
+ Log.i(TAG, "openOrCreateDatabase " + file + " mode " + mode);
+ return mTestContext.openOrCreateDatabase(file, mode, factory,errorHandler);
+ }
+
+ @Override
+ public void sendBroadcastAsUser(Intent intent, UserHandle user) {
+ Log.i(TAG, "sendBroadcastAsUser " + intent + " " + user);
+ }
+
+ @Override
+ public String getOpPackageName() {
+ return null;
+ }
}
static public class MyMockPackageManager extends MockPackageManager {
@@ -246,9 +333,11 @@
}
static public class MyAccountManagerService extends AccountManagerService {
+ private Context mRealTestContext;
public MyAccountManagerService(Context context, PackageManager packageManager,
- IAccountAuthenticatorCache authenticatorCache) {
+ IAccountAuthenticatorCache authenticatorCache, Context realTestContext) {
super(context, packageManager, authenticatorCache);
+ this.mRealTestContext = realTestContext;
}
@Override
@@ -258,5 +347,20 @@
@Override
protected void cancelNotification(final int id, UserHandle user) {
}
+
+ @Override
+ protected String getCeDatabaseName(int userId) {
+ return new File(mRealTestContext.getCacheDir(), CE_DB).getPath();
+ }
+
+ @Override
+ protected String getDeDatabaseName(int userId) {
+ return new File(mRealTestContext.getCacheDir(), DE_DB).getPath();
+ }
+
+ @Override
+ String getPreNDatabaseName(int userId) {
+ return new File(mRealTestContext.getCacheDir(), PREN_DB).getPath();
+ }
}
}
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DpmMockContext.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DpmMockContext.java
index 60d7382..f6e35f5 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DpmMockContext.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DpmMockContext.java
@@ -39,7 +39,6 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManagerInternal;
-import android.os.storage.StorageManager;
import android.telephony.TelephonyManager;
import android.test.mock.MockContentResolver;
import android.test.mock.MockContext;
@@ -343,31 +342,25 @@
@Override
public List<UserInfo> answer(InvocationOnMock invocation) throws Throwable {
final int userId = (int) invocation.getArguments()[0];
- final ArrayList<UserInfo> ret = new ArrayList<UserInfo>();
- UserInfo parent = null;
- for (UserInfo ui : mUserInfos) {
- if (ui.id == userId) {
- parent = ui;
- break;
- }
- }
- if (parent == null) {
- return ret;
- }
- ret.add(parent);
- for (UserInfo ui : mUserInfos) {
- if (ui.id == userId) {
- continue;
- }
- if (ui.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID
- && ui.profileGroupId == parent.profileGroupId) {
- ret.add(ui);
- }
- }
- return ret;
+ return getProfiles(userId);
}
}
);
+ when(userManager.getProfileIdsWithDisabled(anyInt())).thenAnswer(
+ new Answer<int[]>() {
+ @Override
+ public int[] answer(InvocationOnMock invocation) throws Throwable {
+ final int userId = (int) invocation.getArguments()[0];
+ List<UserInfo> profiles = getProfiles(userId);
+ int[] results = new int[profiles.size()];
+ for (int i = 0; i < results.length; i++) {
+ results[i] = profiles.get(i).id;
+ }
+ return results;
+ }
+ }
+ );
+
// Create a data directory.
final File dir = new File(dataDir, "user" + userId);
@@ -377,6 +370,31 @@
return dir;
}
+ private List<UserInfo> getProfiles(int userId) {
+ final ArrayList<UserInfo> ret = new ArrayList<UserInfo>();
+ UserInfo parent = null;
+ for (UserInfo ui : mUserInfos) {
+ if (ui.id == userId) {
+ parent = ui;
+ break;
+ }
+ }
+ if (parent == null) {
+ return ret;
+ }
+ ret.add(parent);
+ for (UserInfo ui : mUserInfos) {
+ if (ui.id == userId) {
+ continue;
+ }
+ if (ui.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID
+ && ui.profileGroupId == parent.profileGroupId) {
+ ret.add(ui);
+ }
+ }
+ return ret;
+ }
+
/**
* Add multiple users at once. They'll all have flag 0.
*/
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest.java
index baa5d36..2fd11da 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest.java
@@ -27,6 +27,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.*;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -172,6 +173,11 @@
public String getPackageName() {
return mInjectedClientPackage;
}
+
+ @Override
+ public int getUserId() {
+ return getCallingUserId();
+ }
}
/** Context used in the service side */
@@ -190,6 +196,11 @@
public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options,
UserHandle userId) {
}
+
+ @Override
+ public int getUserId() {
+ return UserHandle.USER_SYSTEM;
+ }
}
/** ShortcutService with injection override methods. */
@@ -598,14 +609,6 @@
addPackage(packageName, uid, version, packageName);
}
- private <T> List<T> list(T... array) {
- return Arrays.asList(array);
- }
-
- private <T> Set<T> set(Set<T> in) {
- return new ArraySet<T>(in);
- }
-
private Signature[] genSignatures(String... signatures) {
final Signature[] sigs = new Signature[signatures.length];
for (int i = 0; i < signatures.length; i++){
@@ -789,33 +792,6 @@
runTestOnUiThread(() -> {});
}
- public static Bundle makeBundle(Object... keysAndValues) {
- Preconditions.checkState((keysAndValues.length % 2) == 0);
-
- if (keysAndValues.length == 0) {
- return null;
- }
- final Bundle ret = new Bundle();
-
- for (int i = keysAndValues.length - 2; i >= 0; i -= 2) {
- final String key = keysAndValues[i].toString();
- final Object value = keysAndValues[i + 1];
-
- if (value == null) {
- ret.putString(key, null);
- } else if (value instanceof Integer) {
- ret.putInt(key, (Integer) value);
- } else if (value instanceof String) {
- ret.putString(key, (String) value);
- } else if (value instanceof Bundle) {
- ret.putBundle(key, (Bundle) value);
- } else {
- fail("Type not supported yet: " + value.getClass().getName());
- }
- }
- return ret;
- }
-
/**
* Make a shortcut with an ID.
*/
@@ -913,20 +889,6 @@
return new ComponentName(mClientContext, clazz);
}
- private <T> Set<T> makeSet(T... values) {
- final HashSet<T> ret = new HashSet<>();
- for (T s : values) {
- ret.add(s);
- }
- return ret;
- }
-
- private static void resetAll(Collection<?> mocks) {
- for (Object o : mocks) {
- reset(o);
- }
- }
-
@NonNull
private ShortcutInfo findById(List<ShortcutInfo> list, String id) {
for (ShortcutInfo s : list) {
@@ -947,59 +909,8 @@
assertEquals(expectedNextResetTime, mService.getNextResetTimeLocked());
}
- @NonNull
- private List<ShortcutInfo> assertShortcutIds(@NonNull List<ShortcutInfo> actualShortcuts,
- String... expectedIds) {
- final HashSet<String> expected = new HashSet<>(list(expectedIds));
- final HashSet<String> actual = new HashSet<>();
- for (ShortcutInfo s : actualShortcuts) {
- actual.add(s.getId());
- }
-
- // Compare the sets.
- assertEquals(expected, actual);
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllHaveIntents(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertNotNull("ID " + s.getId(), s.getIntent());
- }
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllNotHaveIntents(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertNull("ID " + s.getId(), s.getIntent());
- }
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllHaveTitle(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertNotNull("ID " + s.getId(), s.getTitle());
- }
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllNotHaveTitle(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertNull("ID " + s.getId(), s.getTitle());
- }
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllNotHaveIcon(
- @NonNull List<ShortcutInfo> actualShortcuts) {
+ public static List<ShortcutInfo> assertAllNotHaveIcon(
+ List<ShortcutInfo> actualShortcuts) {
for (ShortcutInfo s : actualShortcuts) {
assertNull("ID " + s.getId(), s.getIcon());
}
@@ -1007,35 +918,6 @@
}
@NonNull
- private List<ShortcutInfo> assertAllHaveIconResId(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertTrue("ID " + s.getId() + " not have icon res ID", s.hasIconResource());
- assertFalse("ID " + s.getId() + " shouldn't have icon FD", s.hasIconFile());
- }
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllHaveIconFile(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertFalse("ID " + s.getId() + " shouldn't have icon res ID", s.hasIconResource());
- assertTrue("ID " + s.getId() + " not have icon FD", s.hasIconFile());
- }
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllHaveIcon(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertTrue("ID " + s.getId() + " has no icon ", s.hasIconFile() || s.hasIconResource());
- }
- return actualShortcuts;
- }
-
- @NonNull
private List<ShortcutInfo> assertAllHaveFlags(@NonNull List<ShortcutInfo> actualShortcuts,
int shortcutFlags) {
for (ShortcutInfo s : actualShortcuts) {
@@ -1045,87 +927,6 @@
return actualShortcuts;
}
- @NonNull
- private List<ShortcutInfo> assertAllKeyFieldsOnly(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertTrue("ID " + s.getId(), s.hasKeyFieldsOnly());
- }
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllNotKeyFieldsOnly(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertFalse("ID " + s.getId(), s.hasKeyFieldsOnly());
- }
- return actualShortcuts;
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllDynamic(@NonNull List<ShortcutInfo> actualShortcuts) {
- return assertAllHaveFlags(actualShortcuts, ShortcutInfo.FLAG_DYNAMIC);
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllPinned(@NonNull List<ShortcutInfo> actualShortcuts) {
- return assertAllHaveFlags(actualShortcuts, ShortcutInfo.FLAG_PINNED);
- }
-
- @NonNull
- private List<ShortcutInfo> assertAllDynamicOrPinned(
- @NonNull List<ShortcutInfo> actualShortcuts) {
- for (ShortcutInfo s : actualShortcuts) {
- assertTrue("ID " + s.getId(), s.isDynamic() || s.isPinned());
- }
- return actualShortcuts;
- }
-
- private void assertDynamicOnly(ShortcutInfo si) {
- assertTrue(si.isDynamic());
- assertFalse(si.isPinned());
- }
-
- private void assertPinnedOnly(ShortcutInfo si) {
- assertFalse(si.isDynamic());
- assertTrue(si.isPinned());
- }
-
- private void assertDynamicAndPinned(ShortcutInfo si) {
- assertTrue(si.isDynamic());
- assertTrue(si.isPinned());
- }
-
- private void assertBitmapSize(int expectedWidth, int expectedHeight, @NonNull Bitmap bitmap) {
- assertEquals("width", expectedWidth, bitmap.getWidth());
- assertEquals("height", expectedHeight, bitmap.getHeight());
- }
-
- private <T> void assertAllUnique(Collection<T> list) {
- final Set<Object> set = new HashSet<>();
- for (T item : list) {
- if (set.contains(item)) {
- fail("Duplicate item found: " + item + " (in the list: " + list + ")");
- }
- set.add(item);
- }
- }
-
- @NonNull
- private Bitmap pfdToBitmap(@NonNull ParcelFileDescriptor pfd) {
- Preconditions.checkNotNull(pfd);
- try {
- return BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor());
- } finally {
- IoUtils.closeQuietly(pfd);
- }
- }
-
- private void assertBundleEmpty(BaseBundle b) {
- assertTrue(b == null || b.size() == 0);
- }
-
private ShortcutInfo getPackageShortcut(String packageName, String shortcutId, int userId) {
return mService.getPackageShortcutForTest(packageName, shortcutId, userId);
}
@@ -1152,9 +953,25 @@
return intentCaptor.getValue();
}
+ private Intent launchShortcutAndGetIntent_withShortcutInfo(
+ @NonNull String packageName, @NonNull String shortcutId, int userId) {
+ reset(mServiceContext);
+
+ assertTrue(mLauncherApps.startShortcut(
+ getShortcutInfoAsLauncher(packageName, shortcutId, userId), null, null));
+
+ final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mServiceContext).startActivityAsUser(
+ intentCaptor.capture(),
+ any(Bundle.class),
+ eq(UserHandle.of(userId)));
+ return intentCaptor.getValue();
+ }
+
private void assertShortcutLaunchable(@NonNull String packageName, @NonNull String shortcutId,
int userId) {
assertNotNull(launchShortcutAndGetIntent(packageName, shortcutId, userId));
+ assertNotNull(launchShortcutAndGetIntent_withShortcutInfo(packageName, shortcutId, userId));
}
private void assertShortcutNotLaunchable(@NonNull String packageName,
@@ -1193,6 +1010,14 @@
return getLauncherShortcuts(launcher, userId, ShortcutQuery.FLAG_GET_PINNED);
}
+ private ShortcutInfo getShortcutInfoAsLauncher(String packageName, String shortcutId,
+ int userId) {
+ final List<ShortcutInfo> infoList =
+ mLauncherApps.getShortcutInfo(packageName, list(shortcutId),
+ UserHandle.of(userId));
+ assertEquals("No shortcutInfo found (or too many of them)", 1, infoList.size());
+ return infoList.get(0);
+ }
private Intent genPackageDeleteIntent(String pakcageName, int userId) {
Intent i = new Intent(Intent.ACTION_PACKAGE_REMOVED);
@@ -1684,7 +1509,7 @@
assertFalse(mManager.setDynamicShortcuts(list(si2)));
}
- public void testIcons() {
+ public void testIcons() throws IOException {
final Icon res32x32 = Icon.createWithResource(getTestContext(), R.drawable.black_32x32);
final Icon res64x64 = Icon.createWithResource(getTestContext(), R.drawable.black_64x64);
final Icon res512x512 = Icon.createWithResource(getTestContext(), R.drawable.black_512x512);
@@ -1728,6 +1553,16 @@
"res64x64",
"none");
+ // Different profile. Note the names and the contents don't match.
+ setCaller(CALLING_PACKAGE_1, USER_P0);
+ assertTrue(mManager.setDynamicShortcuts(list(
+ makeShortcutWithIcon("res32x32", res512x512),
+ makeShortcutWithIcon("bmp32x32", bmp512x512)
+ )));
+ assertShortcutIds(assertAllNotHaveIcon(mManager.getDynamicShortcuts()),
+ "res32x32",
+ "bmp32x32");
+
// Re-initialize and load from the files.
mService.saveDirtyInfo();
initService();
@@ -1737,61 +1572,90 @@
setCaller(LAUNCHER_1);
// Check hasIconResource()/hasIconFile().
- assertShortcutIds(assertAllHaveIconResId(mLauncherApps.getShortcutInfo(
- CALLING_PACKAGE_1, list("res32x32"),
- getCallingUser())), "res32x32");
+ assertShortcutIds(assertAllHaveIconResId(
+ list(getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "res32x32", USER_0))),
+ "res32x32");
- assertShortcutIds(assertAllHaveIconResId(mLauncherApps.getShortcutInfo(
- CALLING_PACKAGE_1, list("res64x64"), getCallingUser())),
+ assertShortcutIds(assertAllHaveIconResId(
+ list(getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "res64x64", USER_0))),
"res64x64");
- assertShortcutIds(assertAllHaveIconFile(mLauncherApps.getShortcutInfo(
- CALLING_PACKAGE_1, list("bmp32x32"), getCallingUser())),
+ assertShortcutIds(assertAllHaveIconFile(
+ list(getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp32x32", USER_0))),
"bmp32x32");
- assertShortcutIds(assertAllHaveIconFile(mLauncherApps.getShortcutInfo(
- CALLING_PACKAGE_1, list("bmp64x64"), getCallingUser())),
+ assertShortcutIds(assertAllHaveIconFile(
+ list(getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp64x64", USER_0))),
"bmp64x64");
- assertShortcutIds(assertAllHaveIconFile(mLauncherApps.getShortcutInfo(
- CALLING_PACKAGE_1, list("bmp512x512"), getCallingUser())),
+ assertShortcutIds(assertAllHaveIconFile(
+ list(getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp512x512", USER_0))),
"bmp512x512");
+ assertShortcutIds(assertAllHaveIconResId(
+ list(getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "res32x32", USER_P0))),
+ "res32x32");
+ assertShortcutIds(assertAllHaveIconFile(
+ list(getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp32x32", USER_P0))),
+ "bmp32x32");
+
// Check
assertEquals(
R.drawable.black_32x32,
mLauncherApps.getShortcutIconResId(
- makePackageShortcut(CALLING_PACKAGE_1, "res32x32"), getCallingUser()));
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "res32x32", USER_0)));
assertEquals(
R.drawable.black_64x64,
mLauncherApps.getShortcutIconResId(
-
- makePackageShortcut(CALLING_PACKAGE_1, "res64x64"), getCallingUser()));
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "res64x64", USER_0)));
assertEquals(
0, // because it's not a resource
mLauncherApps.getShortcutIconResId(
- makePackageShortcut(CALLING_PACKAGE_1, "bmp32x32"), getCallingUser()));
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp32x32", USER_0)));
assertEquals(
0, // because it's not a resource
mLauncherApps.getShortcutIconResId(
- makePackageShortcut(CALLING_PACKAGE_1, "bmp64x64"), getCallingUser()));
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp64x64", USER_0)));
assertEquals(
0, // because it's not a resource
mLauncherApps.getShortcutIconResId(
- makePackageShortcut(CALLING_PACKAGE_1, "bmp512x512"), getCallingUser()));
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp512x512", USER_0)));
bmp = pfdToBitmap(mLauncherApps.getShortcutIconFd(
- makePackageShortcut(CALLING_PACKAGE_1, "bmp32x32"), getCallingUser()));
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp32x32", USER_0)));
assertBitmapSize(32, 32, bmp);
bmp = pfdToBitmap(mLauncherApps.getShortcutIconFd(
- makePackageShortcut(CALLING_PACKAGE_1, "bmp64x64"), getCallingUser()));
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp64x64", USER_0)));
assertBitmapSize(64, 64, bmp);
bmp = pfdToBitmap(mLauncherApps.getShortcutIconFd(
- makePackageShortcut(CALLING_PACKAGE_1, "bmp512x512"), getCallingUser()));
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp512x512", USER_0)));
+ assertBitmapSize(128, 128, bmp);
+
+ assertEquals(
+ R.drawable.black_512x512,
+ mLauncherApps.getShortcutIconResId(
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "res32x32", USER_P0)));
+ // Should be 512x512, so shrunk.
+ bmp = pfdToBitmap(mLauncherApps.getShortcutIconFd(
+ getShortcutInfoAsLauncher(CALLING_PACKAGE_1, "bmp32x32", USER_P0)));
+ assertBitmapSize(128, 128, bmp);
+
+ // Also check the overload APIs too.
+ assertEquals(
+ R.drawable.black_32x32,
+ mLauncherApps.getShortcutIconResId(CALLING_PACKAGE_1, "res32x32", HANDLE_USER_0));
+ assertEquals(
+ R.drawable.black_64x64,
+ mLauncherApps.getShortcutIconResId(CALLING_PACKAGE_1, "res64x64", HANDLE_USER_0));
+ assertEquals(
+ R.drawable.black_512x512,
+ mLauncherApps.getShortcutIconResId(CALLING_PACKAGE_1, "res32x32", HANDLE_USER_P0));
+ bmp = pfdToBitmap(
+ mLauncherApps.getShortcutIconFd(CALLING_PACKAGE_1, "bmp32x32", HANDLE_USER_P0));
assertBitmapSize(128, 128, bmp);
// TODO Test the content URI case too.
@@ -2034,9 +1898,16 @@
private static ShortcutQuery buildQuery(long changedSince,
String packageName, ComponentName componentName,
/* @ShortcutQuery.QueryFlags */ int flags) {
+ return buildQuery(changedSince, packageName, null, componentName, flags);
+ }
+
+ private static ShortcutQuery buildQuery(long changedSince,
+ String packageName, List<String> shortcutIds, ComponentName componentName,
+ /* @ShortcutQuery.QueryFlags */ int flags) {
final ShortcutQuery q = new ShortcutQuery();
q.setChangedSince(changedSince);
q.setPackage(packageName);
+ q.setShortcutIds(shortcutIds);
q.setActivity(componentName);
q.setQueryFlags(flags);
return q;
@@ -2110,6 +1981,36 @@
getCallingUser())),
"s2", "s3"))));
+ // With ID.
+ assertAllDynamic(assertAllNotHaveTitle(assertAllNotHaveIntents(assertShortcutIds(
+ assertAllKeyFieldsOnly(mLauncherApps.getShortcuts(buildQuery(
+ /* time =*/ 1000, CALLING_PACKAGE_2, list("s3"),
+ /* activity =*/ null,
+ ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY),
+ getCallingUser())),
+ "s3"))));
+ assertAllDynamic(assertAllNotHaveTitle(assertAllNotHaveIntents(assertShortcutIds(
+ assertAllKeyFieldsOnly(mLauncherApps.getShortcuts(buildQuery(
+ /* time =*/ 1000, CALLING_PACKAGE_2, list("s3", "s2", "ss"),
+ /* activity =*/ null,
+ ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY),
+ getCallingUser())),
+ "s2", "s3"))));
+ assertAllDynamic(assertAllNotHaveTitle(assertAllNotHaveIntents(assertShortcutIds(
+ assertAllKeyFieldsOnly(mLauncherApps.getShortcuts(buildQuery(
+ /* time =*/ 1000, CALLING_PACKAGE_2, list("s3x", "s2x"),
+ /* activity =*/ null,
+ ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY),
+ getCallingUser()))
+ /* empty */))));
+ assertAllDynamic(assertAllNotHaveTitle(assertAllNotHaveIntents(assertShortcutIds(
+ assertAllKeyFieldsOnly(mLauncherApps.getShortcuts(buildQuery(
+ /* time =*/ 1000, CALLING_PACKAGE_2, list(),
+ /* activity =*/ null,
+ ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY),
+ getCallingUser()))
+ /* empty */))));
+
// Pin some shortcuts.
mLauncherApps.pinShortcuts(CALLING_PACKAGE_2,
list("s3", "s4"), getCallingUser());
@@ -2132,6 +2033,13 @@
getCallingUser())),
"s1", "s3");
+ assertExpectException(
+ IllegalArgumentException.class, "package name must also be set", () -> {
+ mLauncherApps.getShortcuts(buildQuery(
+ /* time =*/ 0, /* package= */ null, list("id"),
+ /* activity =*/ null, /* flags */ 0), getCallingUser());
+ });
+
// TODO More tests: pinned but dynamic, filter by activity
}
@@ -3224,20 +3132,6 @@
assertEquals(0, shortcuts.getValue().size());
}
- private void assertCallbackNotReceived(LauncherApps.Callback mock) {
- verify(mock, times(0)).onShortcutsChanged(anyString(), anyList(),
- any(UserHandle.class));
- }
-
- private void assertCallbackReceived(LauncherApps.Callback mock,
- UserHandle user, String packageName, String... ids) {
- ArgumentCaptor<List> shortcutsCaptor = ArgumentCaptor.forClass(List.class);
-
- verify(mock, times(1)).onShortcutsChanged(eq(packageName), shortcutsCaptor.capture(),
- eq(user));
- assertShortcutIds(shortcutsCaptor.getValue(), ids);
- }
-
public void testLauncherCallback_crossProfile() throws Throwable {
prepareCrossProfileDataSet();
@@ -3607,18 +3501,18 @@
// Check the registered packages.
dumpsysOnLogcat();
- assertEquals(makeSet(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
- set(user0.getAllPackages().keySet()));
- assertEquals(makeSet(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
- set(user10.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
+ hashSet(user0.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
+ hashSet(user10.getAllPackages().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_0, LAUNCHER_1),
+ set(PackageWithUser.of(USER_0, LAUNCHER_1),
PackageWithUser.of(USER_0, LAUNCHER_2)),
- set(user0.getAllLaunchers().keySet()));
+ hashSet(user0.getAllLaunchers().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_10, LAUNCHER_1),
+ set(PackageWithUser.of(USER_10, LAUNCHER_1),
PackageWithUser.of(USER_10, LAUNCHER_2)),
- set(user10.getAllLaunchers().keySet()));
+ hashSet(user10.getAllLaunchers().keySet()));
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_1, USER_0),
"s0_1", "s0_2");
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_2, USER_0),
@@ -3639,18 +3533,18 @@
mService.cleanUpPackageLocked("abc", USER_0, USER_0);
// No changes.
- assertEquals(makeSet(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
- set(user0.getAllPackages().keySet()));
- assertEquals(makeSet(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
- set(user10.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
+ hashSet(user0.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
+ hashSet(user10.getAllPackages().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_0, LAUNCHER_1),
+ set(PackageWithUser.of(USER_0, LAUNCHER_1),
PackageWithUser.of(USER_0, LAUNCHER_2)),
- set(user0.getAllLaunchers().keySet()));
+ hashSet(user0.getAllLaunchers().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_10, LAUNCHER_1),
+ set(PackageWithUser.of(USER_10, LAUNCHER_1),
PackageWithUser.of(USER_10, LAUNCHER_2)),
- set(user10.getAllLaunchers().keySet()));
+ hashSet(user10.getAllLaunchers().keySet()));
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_1, USER_0),
"s0_1", "s0_2");
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_2, USER_0),
@@ -3670,18 +3564,18 @@
uninstallPackage(USER_0, CALLING_PACKAGE_1);
mService.cleanUpPackageLocked(CALLING_PACKAGE_1, USER_0, USER_0);
- assertEquals(makeSet(CALLING_PACKAGE_2),
- set(user0.getAllPackages().keySet()));
- assertEquals(makeSet(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
- set(user10.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_2),
+ hashSet(user0.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
+ hashSet(user10.getAllPackages().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_0, LAUNCHER_1),
+ set(PackageWithUser.of(USER_0, LAUNCHER_1),
PackageWithUser.of(USER_0, LAUNCHER_2)),
- set(user0.getAllLaunchers().keySet()));
+ hashSet(user0.getAllLaunchers().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_10, LAUNCHER_1),
+ set(PackageWithUser.of(USER_10, LAUNCHER_1),
PackageWithUser.of(USER_10, LAUNCHER_2)),
- set(user10.getAllLaunchers().keySet()));
+ hashSet(user10.getAllLaunchers().keySet()));
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_1, USER_0),
"s0_2");
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_2, USER_0),
@@ -3701,17 +3595,17 @@
uninstallPackage(USER_10, LAUNCHER_1);
mService.cleanUpPackageLocked(LAUNCHER_1, USER_10, USER_10);
- assertEquals(makeSet(CALLING_PACKAGE_2),
- set(user0.getAllPackages().keySet()));
- assertEquals(makeSet(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
- set(user10.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_2),
+ hashSet(user0.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_1, CALLING_PACKAGE_2),
+ hashSet(user10.getAllPackages().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_0, LAUNCHER_1),
+ set(PackageWithUser.of(USER_0, LAUNCHER_1),
PackageWithUser.of(USER_0, LAUNCHER_2)),
- set(user0.getAllLaunchers().keySet()));
+ hashSet(user0.getAllLaunchers().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_10, LAUNCHER_2)),
- set(user10.getAllLaunchers().keySet()));
+ set(PackageWithUser.of(USER_10, LAUNCHER_2)),
+ hashSet(user10.getAllLaunchers().keySet()));
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_1, USER_0),
"s0_2");
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_2, USER_0),
@@ -3729,17 +3623,17 @@
uninstallPackage(USER_10, CALLING_PACKAGE_2);
mService.cleanUpPackageLocked(CALLING_PACKAGE_2, USER_10, USER_10);
- assertEquals(makeSet(CALLING_PACKAGE_2),
- set(user0.getAllPackages().keySet()));
- assertEquals(makeSet(CALLING_PACKAGE_1),
- set(user10.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_2),
+ hashSet(user0.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_1),
+ hashSet(user10.getAllPackages().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_0, LAUNCHER_1),
+ set(PackageWithUser.of(USER_0, LAUNCHER_1),
PackageWithUser.of(USER_0, LAUNCHER_2)),
- set(user0.getAllLaunchers().keySet()));
+ hashSet(user0.getAllLaunchers().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_10, LAUNCHER_2)),
- set(user10.getAllLaunchers().keySet()));
+ set(PackageWithUser.of(USER_10, LAUNCHER_2)),
+ hashSet(user10.getAllLaunchers().keySet()));
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_1, USER_0),
"s0_2");
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_2, USER_0),
@@ -3757,17 +3651,17 @@
uninstallPackage(USER_10, LAUNCHER_2);
mService.cleanUpPackageLocked(LAUNCHER_2, USER_10, USER_10);
- assertEquals(makeSet(CALLING_PACKAGE_2),
- set(user0.getAllPackages().keySet()));
- assertEquals(makeSet(CALLING_PACKAGE_1),
- set(user10.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_2),
+ hashSet(user0.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_1),
+ hashSet(user10.getAllPackages().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_0, LAUNCHER_1),
+ set(PackageWithUser.of(USER_0, LAUNCHER_1),
PackageWithUser.of(USER_0, LAUNCHER_2)),
- set(user0.getAllLaunchers().keySet()));
+ hashSet(user0.getAllLaunchers().keySet()));
assertEquals(
- makeSet(),
- set(user10.getAllLaunchers().keySet()));
+ set(),
+ hashSet(user10.getAllLaunchers().keySet()));
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_1, USER_0),
"s0_2");
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_2, USER_0),
@@ -3785,16 +3679,16 @@
uninstallPackage(USER_10, CALLING_PACKAGE_1);
mService.cleanUpPackageLocked(CALLING_PACKAGE_1, USER_10, USER_10);
- assertEquals(makeSet(CALLING_PACKAGE_2),
- set(user0.getAllPackages().keySet()));
- assertEquals(makeSet(),
- set(user10.getAllPackages().keySet()));
+ assertEquals(set(CALLING_PACKAGE_2),
+ hashSet(user0.getAllPackages().keySet()));
+ assertEquals(set(),
+ hashSet(user10.getAllPackages().keySet()));
assertEquals(
- makeSet(PackageWithUser.of(USER_0, LAUNCHER_1),
+ set(PackageWithUser.of(USER_0, LAUNCHER_1),
PackageWithUser.of(USER_0, LAUNCHER_2)),
- set(user0.getAllLaunchers().keySet()));
- assertEquals(makeSet(),
- set(user10.getAllLaunchers().keySet()));
+ hashSet(user0.getAllLaunchers().keySet()));
+ assertEquals(set(),
+ hashSet(user10.getAllLaunchers().keySet()));
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_1, USER_0),
"s0_2");
assertShortcutIds(getLauncherPinnedShortcuts(LAUNCHER_2, USER_0),
@@ -4935,7 +4829,7 @@
assertShortcutIds(
mLauncherApps.getShortcuts(buildPinnedQuery(CALLING_PACKAGE_2), HANDLE_USER_P0)
/* empty */);
- TestUtils.assertExpectException(
+ assertExpectException(
SecurityException.class, "", () -> {
mLauncherApps.getShortcuts(
buildAllQuery(CALLING_PACKAGE_1), HANDLE_USER_10);
@@ -5014,7 +4908,7 @@
assertShortcutIds(
mLauncherApps.getShortcuts(buildPinnedQuery(CALLING_PACKAGE_1), HANDLE_USER_P0),
"s1", "s4");
- TestUtils.assertExpectException(
+ assertExpectException(
SecurityException.class, "unrelated profile", () -> {
mLauncherApps.getShortcuts(
buildAllQuery(CALLING_PACKAGE_1), HANDLE_USER_10);
@@ -5030,12 +4924,12 @@
assertShortcutIds(
mLauncherApps.getShortcuts(buildPinnedQuery(CALLING_PACKAGE_3), HANDLE_USER_10)
/* empty */);
- TestUtils.assertExpectException(
+ assertExpectException(
SecurityException.class, "unrelated profile", () -> {
mLauncherApps.getShortcuts(
buildAllQuery(CALLING_PACKAGE_1), HANDLE_USER_0);
});
- TestUtils.assertExpectException(
+ assertExpectException(
SecurityException.class, "unrelated profile", () -> {
mLauncherApps.getShortcuts(
buildAllQuery(CALLING_PACKAGE_1), HANDLE_USER_P0);
@@ -5046,16 +4940,16 @@
// ShortcutInfo tests
public void testShortcutInfoMissingMandatoryFields() {
- TestUtils.assertExpectException(
+ assertExpectException(
IllegalArgumentException.class,
"ID must be provided",
() -> new ShortcutInfo.Builder(getTestContext()).build());
- TestUtils.assertExpectException(
+ assertExpectException(
IllegalArgumentException.class,
"title must be provided",
() -> new ShortcutInfo.Builder(getTestContext()).setId("id").build()
.enforceMandatoryFields());
- TestUtils.assertExpectException(
+ assertExpectException(
NullPointerException.class,
"Intent must be provided",
() -> new ShortcutInfo.Builder(getTestContext()).setId("id").setTitle("x").build()
@@ -5063,12 +4957,15 @@
}
public void testShortcutInfoParcel() {
- ShortcutInfo si = parceled(new ShortcutInfo.Builder(getTestContext())
+ setCaller(CALLING_PACKAGE_1, USER_10);
+ ShortcutInfo si = parceled(new ShortcutInfo.Builder(mClientContext)
.setId("id")
.setTitle("title")
.setIntent(makeIntent("action", ShortcutActivity.class))
.build());
- assertEquals(getTestContext().getPackageName(), si.getPackageName());
+ assertEquals(mClientContext.getPackageName(), si.getPackageName());
+ assertEquals(USER_10, si.getUserId());
+ assertEquals(HANDLE_USER_10, si.getUserHandle());
assertEquals("id", si.getId());
assertEquals("title", si.getTitle());
assertEquals("action", si.getIntent().getAction());
@@ -5109,9 +5006,11 @@
}
public void testShortcutInfoClone() {
+ setCaller(CALLING_PACKAGE_1, USER_11);
+
PersistableBundle pb = new PersistableBundle();
pb.putInt("k", 1);
- ShortcutInfo sorig = new ShortcutInfo.Builder(getTestContext())
+ ShortcutInfo sorig = new ShortcutInfo.Builder(mClientContext)
.setId("id")
.setActivityComponent(new ComponentName("a", "b"))
.setIcon(Icon.createWithContentUri("content://a.b.c/"))
@@ -5127,7 +5026,9 @@
ShortcutInfo si = sorig.clone(/* clone flags*/ 0);
- assertEquals(getTestContext().getPackageName(), si.getPackageName());
+ assertEquals(USER_11, si.getUserId());
+ assertEquals(HANDLE_USER_11, si.getUserHandle());
+ assertEquals(mClientContext.getPackageName(), si.getPackageName());
assertEquals("id", si.getId());
assertEquals(new ComponentName("a", "b"), si.getActivityComponent());
assertEquals("content://a.b.c/", si.getIcon().getUriString());
@@ -5144,7 +5045,7 @@
si = sorig.clone(ShortcutInfo.CLONE_REMOVE_FOR_CREATOR);
- assertEquals(getTestContext().getPackageName(), si.getPackageName());
+ assertEquals(mClientContext.getPackageName(), si.getPackageName());
assertEquals("id", si.getId());
assertEquals(new ComponentName("a", "b"), si.getActivityComponent());
assertEquals(null, si.getIcon());
@@ -5161,7 +5062,7 @@
si = sorig.clone(ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER);
- assertEquals(getTestContext().getPackageName(), si.getPackageName());
+ assertEquals(mClientContext.getPackageName(), si.getPackageName());
assertEquals("id", si.getId());
assertEquals(new ComponentName("a", "b"), si.getActivityComponent());
assertEquals(null, si.getIcon());
@@ -5177,7 +5078,7 @@
si = sorig.clone(ShortcutInfo.CLONE_REMOVE_NON_KEY_INFO);
- assertEquals(getTestContext().getPackageName(), si.getPackageName());
+ assertEquals(mClientContext.getPackageName(), si.getPackageName());
assertEquals("id", si.getId());
assertEquals(null, si.getActivityComponent());
assertEquals(null, si.getIcon());
@@ -5267,7 +5168,7 @@
}
public void testShortcutInfoSaveAndLoad() throws InterruptedException {
- setCaller(CALLING_PACKAGE_1, USER_0);
+ setCaller(CALLING_PACKAGE_1, USER_10);
final Icon bmp32x32 = Icon.createWithBitmap(BitmapFactory.decodeResource(
getTestContext().getResources(), R.drawable.black_32x32));
@@ -5293,11 +5194,13 @@
// Save and load.
mService.saveDirtyInfo();
initService();
- mService.handleUnlockUser(USER_0);
+ mService.handleUnlockUser(USER_10);
ShortcutInfo si;
- si = mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "id", USER_0);
+ si = mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "id", USER_10);
+ assertEquals(USER_10, si.getUserId());
+ assertEquals(HANDLE_USER_10, si.getUserHandle());
assertEquals(CALLING_PACKAGE_1, si.getPackageName());
assertEquals("id", si.getId());
assertEquals(ShortcutActivity2.class.getName(), si.getActivityComponent().getClassName());
@@ -5367,7 +5270,7 @@
dumpsysOnLogcat("test1", /* force= */ true);
}
- public void testDumpsys_withIcons() {
+ public void testDumpsys_withIcons() throws IOException {
testIcons();
// Dump after having some icons.
dumpsysOnLogcat("test1", /* force= */ true);
diff --git a/services/tests/shortcutmanagerutils/Android.mk b/services/tests/shortcutmanagerutils/Android.mk
new file mode 100644
index 0000000..701e058
--- /dev/null
+++ b/services/tests/shortcutmanagerutils/Android.mk
@@ -0,0 +1,31 @@
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, src)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ mockito-target
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE := ShortcutManagerTestUtils
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java b/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java
new file mode 100644
index 0000000..d09b62c
--- /dev/null
+++ b/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java
@@ -0,0 +1,506 @@
+/*
+ * 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.pm.shortcutmanagertest;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyList;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.pm.LauncherApps;
+import android.content.pm.ShortcutInfo;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.BaseBundle;
+import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
+import android.os.UserHandle;
+import android.test.MoreAsserts;
+import android.util.Log;
+
+import junit.framework.Assert;
+
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.mockito.Mockito;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.function.BooleanSupplier;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+public class ShortcutManagerTestUtils {
+ private static final String TAG = "ShortcutManagerUtils";
+
+ private static final boolean ENABLE_DUMPSYS = true; // DO NOT SUBMIT WITH true
+
+ private static final int STANDARD_TIMEOUT_SEC = 5;
+
+ private ShortcutManagerTestUtils() {
+ }
+
+ private static List<String> readAll(ParcelFileDescriptor pfd) {
+ try {
+ try {
+ final ArrayList<String> ret = new ArrayList<>();
+ try (BufferedReader r = new BufferedReader(
+ new FileReader(pfd.getFileDescriptor()))) {
+ String line;
+ while ((line = r.readLine()) != null) {
+ ret.add(line);
+ }
+ r.readLine();
+ }
+ return ret;
+ } finally {
+ pfd.close();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static String concatResult(List<String> result) {
+ final StringBuilder sb = new StringBuilder();
+ for (String s : result) {
+ sb.append(s);
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+ private static List<String> runCommand(Instrumentation instrumentation, String command) {
+ return runCommand(instrumentation, command, null);
+ }
+ private static List<String> runCommand(Instrumentation instrumentation, String command,
+ Predicate<List<String>> resultAsserter) {
+ Log.d(TAG, "Running command: " + command);
+ final List<String> result;
+ try {
+ result = readAll(
+ instrumentation.getUiAutomation().executeShellCommand(command));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ if (resultAsserter != null && !resultAsserter.test(result)) {
+ fail("Command '" + command + "' failed, output was:\n" + concatResult(result));
+ }
+ return result;
+ }
+
+ private static void runCommandForNoOutput(Instrumentation instrumentation, String command) {
+ runCommand(instrumentation, command, result -> result.size() == 0);
+ }
+
+ private static List<String> runShortcutCommand(Instrumentation instrumentation, String command,
+ Predicate<List<String>> resultAsserter) {
+ return runCommand(instrumentation, "cmd shortcut " + command, resultAsserter);
+ }
+
+ public static List<String> runShortcutCommandForSuccess(Instrumentation instrumentation,
+ String command) {
+ return runShortcutCommand(instrumentation, command, result -> result.contains("Success"));
+ }
+
+ public static String getDefaultLauncher(Instrumentation instrumentation) {
+ final String PREFIX = "Launcher: ComponentInfo{";
+ final String POSTFIX = "}";
+ final List<String> result = runShortcutCommandForSuccess(
+ instrumentation, "get-default-launcher");
+ for (String s : result) {
+ if (s.startsWith(PREFIX) && s.endsWith(POSTFIX)) {
+ return s.substring(PREFIX.length(), s.length() - POSTFIX.length());
+ }
+ }
+ fail("Default launcher not found");
+ return null;
+ }
+
+ public static void setDefaultLauncher(Instrumentation instrumentation, String component) {
+ runCommandForNoOutput(instrumentation, "cmd package set-home-activity " + component);
+ }
+
+ public static void setDefaultLauncher(Instrumentation instrumentation, Context packageContext) {
+ setDefaultLauncher(instrumentation, packageContext.getPackageName()
+ + "/android.content.pm.cts.shortcutmanager.packages.Launcher");
+ }
+
+ public static void overrideConfig(Instrumentation instrumentation, String config) {
+ runShortcutCommandForSuccess(instrumentation, "override-config " + config);
+ }
+
+ public static void resetConfig(Instrumentation instrumentation) {
+ runShortcutCommandForSuccess(instrumentation, "reset-config");
+ }
+
+ public static void resetThrottling(Instrumentation instrumentation) {
+ runShortcutCommandForSuccess(instrumentation, "reset-throttling");
+ }
+
+ public static void resetAllThrottling(Instrumentation instrumentation) {
+ runShortcutCommandForSuccess(instrumentation, "reset-all-throttling");
+ }
+
+ public static void clearShortcuts(Instrumentation instrumentation, int userId,
+ String packageName) {
+ runShortcutCommandForSuccess(instrumentation, "clear-shortcuts "
+ + " --user " + userId + " " + packageName);
+ }
+
+ public static void dumpsysShortcut(Instrumentation instrumentation) {
+ if (!ENABLE_DUMPSYS) {
+ return;
+ }
+ for (String s : runCommand(instrumentation, "dumpsys shortcut")) {
+ Log.e(TAG, s);
+ }
+ }
+
+ public static Bundle makeBundle(Object... keysAndValues) {
+ assertTrue((keysAndValues.length % 2) == 0);
+
+ if (keysAndValues.length == 0) {
+ return null;
+ }
+ final Bundle ret = new Bundle();
+
+ for (int i = keysAndValues.length - 2; i >= 0; i -= 2) {
+ final String key = keysAndValues[i].toString();
+ final Object value = keysAndValues[i + 1];
+
+ if (value == null) {
+ ret.putString(key, null);
+ } else if (value instanceof Integer) {
+ ret.putInt(key, (Integer) value);
+ } else if (value instanceof String) {
+ ret.putString(key, (String) value);
+ } else if (value instanceof Bundle) {
+ ret.putBundle(key, (Bundle) value);
+ } else {
+ fail("Type not supported yet: " + value.getClass().getName());
+ }
+ }
+ return ret;
+ }
+
+ public static <T> List<T> list(T... array) {
+ return Arrays.asList(array);
+ }
+
+ public static <T> Set<T> hashSet(Set<T> in) {
+ return new HashSet<T>(in);
+ }
+
+ public static <T> Set<T> set(T... values) {
+ return set(v -> v, values);
+ }
+
+ public static <T, V> Set<T> set(Function<V, T> converter, V... values) {
+ return set(converter, Arrays.asList(values));
+ }
+
+ public static <T, V> Set<T> set(Function<V, T> converter, List<V> values) {
+ final HashSet<T> ret = new HashSet<>();
+ for (V v : values) {
+ ret.add(converter.apply(v));
+ }
+ return ret;
+ }
+
+ public static void resetAll(Collection<?> mocks) {
+ for (Object o : mocks) {
+ reset(o);
+ }
+ }
+ public static void assertExpectException(Class<? extends Throwable> expectedExceptionType,
+ String expectedExceptionMessageRegex, Runnable r) {
+ assertExpectException("", expectedExceptionType, expectedExceptionMessageRegex, r);
+ }
+
+ public static void assertDynamicShortcutCountExceeded(Runnable r) {
+ assertExpectException(IllegalArgumentException.class,
+ "Max number of dynamic shortcuts exceeded", r);
+ }
+
+ public static void assertExpectException(String message,
+ Class<? extends Throwable> expectedExceptionType,
+ String expectedExceptionMessageRegex, Runnable r) {
+ try {
+ r.run();
+ Assert.fail("Expected exception type " + expectedExceptionType.getName()
+ + " was not thrown (message=" + message + ")");
+ } catch (Throwable e) {
+ Assert.assertTrue(
+ "Expected exception type was " + expectedExceptionType.getName()
+ + " but caught " + e + " (message=" + message + ")",
+ expectedExceptionType.isAssignableFrom(e.getClass()));
+ if (expectedExceptionMessageRegex != null) {
+ MoreAsserts.assertContainsRegex(expectedExceptionMessageRegex, e.getMessage());
+ }
+ }
+ }
+
+ public static List<ShortcutInfo> assertShortcutIds(List<ShortcutInfo> actualShortcuts,
+ String... expectedIds) {
+ final HashSet<String> expected = new HashSet<>(list(expectedIds));
+ final HashSet<String> actual = new HashSet<>();
+ for (ShortcutInfo s : actualShortcuts) {
+ actual.add(s.getId());
+ }
+
+ // Compare the sets.
+ assertEquals(expected, actual);
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllHaveIntents(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertNotNull("ID " + s.getId(), s.getIntent());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllNotHaveIntents(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertNull("ID " + s.getId(), s.getIntent());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllHaveTitle(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertNotNull("ID " + s.getId(), s.getTitle());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllNotHaveTitle(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertNull("ID " + s.getId(), s.getTitle());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllHaveIconResId(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertTrue("ID " + s.getId() + " not have icon res ID", s.hasIconResource());
+ assertFalse("ID " + s.getId() + " shouldn't have icon FD", s.hasIconFile());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllHaveIconFile(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertFalse("ID " + s.getId() + " shouldn't have icon res ID", s.hasIconResource());
+ assertTrue("ID " + s.getId() + " not have icon FD", s.hasIconFile());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllHaveIcon(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertTrue("ID " + s.getId() + " has no icon ", s.hasIconFile() || s.hasIconResource());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllKeyFieldsOnly(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertTrue("ID " + s.getId(), s.hasKeyFieldsOnly());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllNotKeyFieldsOnly(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertFalse("ID " + s.getId(), s.hasKeyFieldsOnly());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllDynamic(List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertTrue("ID " + s.getId(), s.isDynamic());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllPinned(List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertTrue("ID " + s.getId(), s.isPinned());
+ }
+ return actualShortcuts;
+ }
+
+ public static List<ShortcutInfo> assertAllDynamicOrPinned(
+ List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertTrue("ID " + s.getId(), s.isDynamic() || s.isPinned());
+ }
+ return actualShortcuts;
+ }
+
+ public static void assertDynamicOnly(ShortcutInfo si) {
+ assertTrue(si.isDynamic());
+ assertFalse(si.isPinned());
+ }
+
+ public static void assertPinnedOnly(ShortcutInfo si) {
+ assertFalse(si.isDynamic());
+ assertTrue(si.isPinned());
+ }
+
+ public static void assertDynamicAndPinned(ShortcutInfo si) {
+ assertTrue(si.isDynamic());
+ assertTrue(si.isPinned());
+ }
+
+ public static void assertBitmapSize(int expectedWidth, int expectedHeight, Bitmap bitmap) {
+ assertEquals("width", expectedWidth, bitmap.getWidth());
+ assertEquals("height", expectedHeight, bitmap.getHeight());
+ }
+
+ public static <T> void assertAllUnique(Collection<T> list) {
+ final Set<Object> set = new HashSet<>();
+ for (T item : list) {
+ if (set.contains(item)) {
+ fail("Duplicate item found: " + item + " (in the list: " + list + ")");
+ }
+ set.add(item);
+ }
+ }
+
+ public static Bitmap pfdToBitmap(ParcelFileDescriptor pfd) {
+ assertNotNull(pfd);
+ try {
+ try {
+ return BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor());
+ } finally {
+ pfd.close();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void assertBundleEmpty(BaseBundle b) {
+ assertTrue(b == null || b.size() == 0);
+ }
+
+ public static void assertCallbackNotReceived(LauncherApps.Callback mock) {
+ verify(mock, times(0)).onShortcutsChanged(anyString(), anyList(),
+ any(UserHandle.class));
+ }
+
+ public static void assertCallbackReceived(LauncherApps.Callback mock,
+ UserHandle user, String packageName, String... ids) {
+ verify(mock).onShortcutsChanged(eq(packageName), checkShortcutIds(ids),
+ eq(user));
+ }
+
+ public static boolean checkAssertSuccess(Runnable r) {
+ try {
+ r.run();
+ return true;
+ } catch (AssertionError e) {
+ return false;
+ }
+ }
+
+ public static <T> T checkArgument(Predicate<T> checker, String description,
+ List<T> matchedCaptor) {
+ final Matcher<T> m = new BaseMatcher<T>() {
+ @Override
+ public boolean matches(Object item) {
+ if (item == null) {
+ return false;
+ }
+ final T value = (T) item;
+ if (!checker.test(value)) {
+ return false;
+ }
+
+ if (matchedCaptor != null) {
+ matchedCaptor.add(value);
+ }
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description d) {
+ d.appendText(description);
+ }
+ };
+ return Mockito.argThat(m);
+ }
+
+ public static List<ShortcutInfo> checkShortcutIds(String... ids) {
+ return checkArgument((List<ShortcutInfo> list) -> {
+ final Set<String> actualSet = set(si -> si.getId(), list);
+ return actualSet.equals(set(ids));
+
+ }, "Shortcut IDs=[" + Arrays.toString(ids) + "]", null);
+ }
+
+ public static void waitUntil(String message, BooleanSupplier condition) {
+ waitUntil(message, condition, STANDARD_TIMEOUT_SEC);
+ }
+
+ public static void waitUntil(String message, BooleanSupplier condition, int timeoutSeconds) {
+ final long timeout = System.currentTimeMillis() + (timeoutSeconds * 1000L);
+ while (System.currentTimeMillis() < timeout) {
+ if (condition.getAsBoolean()) {
+ return;
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ fail("Timed out for: " + message);
+ }
+}
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index 0aeb96f..ecfeff9 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -152,6 +152,7 @@
private ArrayList<UsageStatsManagerInternal.AppIdleStateChangeListener>
mPackageAccessListeners = new ArrayList<>();
+ private boolean mHaveCarrierPrivilegedApps;
private List<String> mCarrierPrivilegedApps;
public UsageStatsService(Context context) {
@@ -931,11 +932,14 @@
private boolean isCarrierApp(String packageName) {
synchronized (mLock) {
- if (mCarrierPrivilegedApps == null) {
+ if (!mHaveCarrierPrivilegedApps) {
fetchCarrierPrivilegedAppsLocked();
}
+ if (mCarrierPrivilegedApps != null) {
+ return mCarrierPrivilegedApps.contains(packageName);
+ }
+ return false;
}
- return mCarrierPrivilegedApps.contains(packageName);
}
void clearCarrierPrivilegedApps() {
@@ -943,6 +947,7 @@
Slog.i(TAG, "Clearing carrier privileged apps list");
}
synchronized (mLock) {
+ mHaveCarrierPrivilegedApps = false;
mCarrierPrivilegedApps = null; // Need to be refetched.
}
}
@@ -951,6 +956,7 @@
TelephonyManager telephonyManager =
getContext().getSystemService(TelephonyManager.class);
mCarrierPrivilegedApps = telephonyManager.getPackagesWithCarrierPrivileges();
+ mHaveCarrierPrivilegedApps = true;
if (DEBUG) {
Slog.d(TAG, "apps with carrier privilege " + mCarrierPrivilegedApps);
}
@@ -1024,7 +1030,8 @@
}
pw.println();
- pw.println("Carrier privileged apps: " + mCarrierPrivilegedApps);
+ pw.println("Carrier privileged apps (have=" + mHaveCarrierPrivilegedApps
+ + "): " + mCarrierPrivilegedApps);
pw.println();
pw.println("Settings:");
diff --git a/telephony/java/com/android/internal/telephony/CarrierAppUtils.java b/telephony/java/com/android/internal/telephony/CarrierAppUtils.java
new file mode 100644
index 0000000..ca7354f
--- /dev/null
+++ b/telephony/java/com/android/internal/telephony/CarrierAppUtils.java
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2015 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.internal.telephony;
+
+import android.annotation.Nullable;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.os.RemoteException;
+import android.telephony.TelephonyManager;
+import android.util.Slog;
+
+import com.android.internal.annotations.VisibleForTesting;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utilities for handling carrier applications.
+ * @hide
+ */
+public final class CarrierAppUtils {
+ private static final String TAG = "CarrierAppUtils";
+
+ private static final boolean DEBUG = false; // STOPSHIP if true
+
+ private CarrierAppUtils() {}
+
+ /**
+ * Handle preinstalled carrier apps which should be disabled until a matching SIM is inserted.
+ *
+ * Evaluates the list of applications in config_disabledUntilUsedPreinstalledCarrierApps. We
+ * want to disable each such application which is present on the system image until the user
+ * inserts a SIM which causes that application to gain carrier privilege (indicating a "match"),
+ * without interfering with the user if they opt to enable/disable the app explicitly.
+ *
+ * So, for each such app, we either disable until used IFF the app is not carrier privileged AND
+ * in the default state (e.g. not explicitly DISABLED/DISABLED_BY_USER/ENABLED), or we enable if
+ * the app is carrier privileged and in either the default state or DISABLED_UNTIL_USED.
+ *
+ * When enabling a carrier app we also grant it default permissions.
+ *
+ * This method is idempotent and is safe to be called at any time; it should be called once at
+ * system startup prior to any application running, as well as any time the set of carrier
+ * privileged apps may have changed.
+ */
+ public synchronized static void disableCarrierAppsUntilPrivileged(String callingPackage,
+ IPackageManager packageManager, TelephonyManager telephonyManager, int userId) {
+ if (DEBUG) {
+ Slog.d(TAG, "disableCarrierAppsUntilPrivileged");
+ }
+ String[] systemCarrierAppsDisabledUntilUsed = Resources.getSystem().getStringArray(
+ com.android.internal.R.array.config_disabledUntilUsedPreinstalledCarrierApps);
+ disableCarrierAppsUntilPrivileged(callingPackage, packageManager, telephonyManager, userId,
+ systemCarrierAppsDisabledUntilUsed);
+ }
+
+ /**
+ * Like {@link #disableCarrierAppsUntilPrivileged(String, IPackageManager, TelephonyManager,
+ * int)}, but assumes that no carrier apps have carrier privileges.
+ *
+ * This prevents a potential race condition on first boot - since the app's default state is
+ * enabled, we will initially disable it when the telephony stack is first initialized as it has
+ * not yet read the carrier privilege rules. However, since telephony is initialized later on
+ * late in boot, the app being disabled may have already been started in response to certain
+ * broadcasts. The app will continue to run (briefly) after being disabled, before the Package
+ * Manager can kill it, and this can lead to crashes as the app is in an unexpected state.
+ */
+ public synchronized static void disableCarrierAppsUntilPrivileged(String callingPackage,
+ IPackageManager packageManager, int userId) {
+ if (DEBUG) {
+ Slog.d(TAG, "disableCarrierAppsUntilPrivileged");
+ }
+ String[] systemCarrierAppsDisabledUntilUsed = Resources.getSystem().getStringArray(
+ com.android.internal.R.array.config_disabledUntilUsedPreinstalledCarrierApps);
+ disableCarrierAppsUntilPrivileged(callingPackage, packageManager,
+ null /* telephonyManager */, userId, systemCarrierAppsDisabledUntilUsed);
+ }
+
+ // Must be public b/c framework unit tests can't access package-private methods.
+ @VisibleForTesting
+ public static void disableCarrierAppsUntilPrivileged(String callingPackage,
+ IPackageManager packageManager, @Nullable TelephonyManager telephonyManager, int userId,
+ String[] systemCarrierAppsDisabledUntilUsed) {
+ List<ApplicationInfo> candidates = getDefaultCarrierAppCandidatesHelper(packageManager,
+ userId, systemCarrierAppsDisabledUntilUsed);
+ if (candidates == null || candidates.isEmpty()) {
+ return;
+ }
+
+ List<String> enabledCarrierPackages = new ArrayList<>();
+
+ try {
+ for (ApplicationInfo ai : candidates) {
+ String packageName = ai.packageName;
+ boolean hasPrivileges = telephonyManager != null &&
+ telephonyManager.checkCarrierPrivilegesForPackageAnyPhone(packageName) ==
+ TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
+
+ // Only update enabled state for the app on /system. Once it has been updated we
+ // shouldn't touch it.
+ if (!ai.isUpdatedSystemApp()) {
+ if (hasPrivileges
+ && (ai.enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
+ || ai.enabledSetting ==
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED)) {
+ Slog.i(TAG, "Update state(" + packageName + "): ENABLED for user "
+ + userId);
+ packageManager.setApplicationEnabledSetting(packageName,
+ PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
+ PackageManager.DONT_KILL_APP, userId, callingPackage);
+ } else if (!hasPrivileges
+ && ai.enabledSetting ==
+ PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
+ Slog.i(TAG, "Update state(" + packageName
+ + "): DISABLED_UNTIL_USED for user " + userId);
+ packageManager.setApplicationEnabledSetting(packageName,
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED, 0,
+ userId, callingPackage);
+ }
+ }
+
+ // Always re-grant default permissions to carrier apps w/ privileges.
+ if (hasPrivileges) {
+ enabledCarrierPackages.add(ai.packageName);
+ }
+ }
+
+ if (!enabledCarrierPackages.isEmpty()) {
+ // Since we enabled at least one app, ensure we grant default permissions to those
+ // apps.
+ String[] packageNames = new String[enabledCarrierPackages.size()];
+ enabledCarrierPackages.toArray(packageNames);
+ packageManager.grantDefaultPermissionsToEnabledCarrierApps(packageNames, userId);
+ }
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Could not reach PackageManager", e);
+ }
+ }
+
+ /**
+ * Returns the list of "default" carrier apps.
+ *
+ * This is the subset of apps returned by
+ * {@link #getDefaultCarrierAppCandidates(IPackageManager, int)} which currently have carrier
+ * privileges per the SIM(s) inserted in the device.
+ */
+ public static List<ApplicationInfo> getDefaultCarrierApps(IPackageManager packageManager,
+ TelephonyManager telephonyManager, int userId) {
+ // Get all system apps from the default list.
+ List<ApplicationInfo> candidates = getDefaultCarrierAppCandidates(packageManager, userId);
+ if (candidates == null || candidates.isEmpty()) {
+ return null;
+ }
+
+ // Filter out apps without carrier privileges.
+ // Iterate from the end to avoid creating an Iterator object and because we will be removing
+ // elements from the list as we pass through it.
+ for (int i = candidates.size() - 1; i >= 0; i--) {
+ ApplicationInfo ai = candidates.get(i);
+ String packageName = ai.packageName;
+ boolean hasPrivileges =
+ telephonyManager.checkCarrierPrivilegesForPackageAnyPhone(packageName) ==
+ TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
+ if (!hasPrivileges) {
+ candidates.remove(i);
+ }
+ }
+
+ return candidates;
+ }
+
+ /**
+ * Returns the list of "default" carrier app candidates.
+ *
+ * These are the apps subject to the hiding/showing logic in
+ * {@link CarrierAppUtils#disableCarrierAppsUntilPrivileged(String, IPackageManager,
+ * TelephonyManager, int)}, as well as the apps which should have default permissions granted,
+ * when a matching SIM is inserted.
+ *
+ * Whether or not the app is actually considered a default app depends on whether the app has
+ * carrier privileges as determined by the SIMs in the device.
+ */
+ public static List<ApplicationInfo> getDefaultCarrierAppCandidates(
+ IPackageManager packageManager, int userId) {
+ String[] systemCarrierAppsDisabledUntilUsed = Resources.getSystem().getStringArray(
+ com.android.internal.R.array.config_disabledUntilUsedPreinstalledCarrierApps);
+ return getDefaultCarrierAppCandidatesHelper(packageManager, userId,
+ systemCarrierAppsDisabledUntilUsed);
+ }
+
+ private static List<ApplicationInfo> getDefaultCarrierAppCandidatesHelper(
+ IPackageManager packageManager, int userId,
+ String[] systemCarrierAppsDisabledUntilUsed) {
+ if (systemCarrierAppsDisabledUntilUsed == null
+ || systemCarrierAppsDisabledUntilUsed.length == 0) {
+ return null;
+ }
+ List<ApplicationInfo> apps = null;
+ try {
+ apps = new ArrayList<>(systemCarrierAppsDisabledUntilUsed.length);
+ for (String packageName : systemCarrierAppsDisabledUntilUsed) {
+ ApplicationInfo ai = packageManager.getApplicationInfo(packageName,
+ PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS, userId);
+ if (ai == null) {
+ // No app found for packageName
+ continue;
+ }
+ if (!ai.isSystemApp()) {
+ continue;
+ }
+ apps.add(ai);
+ }
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Could not reach PackageManager", e);
+ }
+ return apps;
+ }
+}
diff --git a/telephony/java/com/android/internal/telephony/DctConstants.java b/telephony/java/com/android/internal/telephony/DctConstants.java
index fcb967f..ccabace 100644
--- a/telephony/java/com/android/internal/telephony/DctConstants.java
+++ b/telephony/java/com/android/internal/telephony/DctConstants.java
@@ -102,6 +102,7 @@
public static final int CMD_NET_STAT_POLL = BASE + 40;
public static final int EVENT_DATA_RAT_CHANGED = BASE + 41;
public static final int CMD_CLEAR_PROVISIONING_SPINNER = BASE + 42;
+ public static final int EVENT_DEVICE_PROVISIONED_CHANGE = BASE + 43;
/***** Constants *****/
diff --git a/tests/SoundTriggerTestApp/res/layout/main.xml b/tests/SoundTriggerTestApp/res/layout/main.xml
index 702be49..06949a0 100644
--- a/tests/SoundTriggerTestApp/res/layout/main.xml
+++ b/tests/SoundTriggerTestApp/res/layout/main.xml
@@ -60,29 +60,22 @@
android:onClick="onUnEnrollButtonClicked"
android:padding="20dp" />
+ <Button
+ android:id="@+id/play_trigger_id"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/play_trigger"
+ android:onClick="onPlayTriggerButtonClicked"
+ android:padding="20dp" />
+
</LinearLayout>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/model_group_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="20dp"
- android:checkedButton="@+id/model_one"
android:orientation="vertical">
- <RadioButton android:id="@+id/model_one"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/model_one"
- android:onClick="onRadioButtonClicked"/>
- <RadioButton android:id="@+id/model_two"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/model_two"
- android:onClick="onRadioButtonClicked"/>
- <RadioButton android:id="@+id/model_three"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/model_three"
- android:onClick="onRadioButtonClicked"/>
</RadioGroup>
<ScrollView
@@ -93,7 +86,7 @@
android:fillViewport="true">
<TextView
- android:id="@+id/console"
+ android:id="@+id/console"
android:paddingTop="20pt"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
diff --git a/tests/SoundTriggerTestApp/res/values/strings.xml b/tests/SoundTriggerTestApp/res/values/strings.xml
index b4ca71b..7c1f649 100644
--- a/tests/SoundTriggerTestApp/res/values/strings.xml
+++ b/tests/SoundTriggerTestApp/res/values/strings.xml
@@ -21,8 +21,6 @@
<string name="unenroll">Un-load</string>
<string name="start_recog">Start</string>
<string name="stop_recog">Stop</string>
- <string name="model_one">Model One</string>
- <string name="model_two">Model Two</string>
- <string name="model_three">Model Three</string>
+ <string name="play_trigger">Play Trigger Audio</string>
<string name="none">Debug messages appear here:\n</string>
</resources>
diff --git a/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java b/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java
index 3ca96d2..5fd38e9 100644
--- a/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java
+++ b/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java
@@ -16,24 +16,36 @@
package com.android.test.soundtrigger;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
import java.util.Random;
import java.util.UUID;
import android.app.Activity;
-import android.hardware.soundtrigger.SoundTrigger;
import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel;
+import android.hardware.soundtrigger.SoundTrigger;
import android.media.AudioFormat;
+import android.media.AudioManager;
+import android.media.MediaPlayer;
import android.media.soundtrigger.SoundTriggerDetector;
import android.media.soundtrigger.SoundTriggerManager;
-import android.text.Editable;
-import android.text.method.ScrollingMovementMethod;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
import android.os.UserManager;
+import android.text.Editable;
+import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.View;
+import android.widget.Button;
import android.widget.RadioButton;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
@@ -44,20 +56,17 @@
private SoundTriggerUtil mSoundTriggerUtil;
private Random mRandom;
- private UUID mModelUuid1 = UUID.randomUUID();
- private UUID mModelUuid2 = UUID.randomUUID();
- private UUID mModelUuid3 = UUID.randomUUID();
- private UUID mVendorUuid = UUID.randomUUID();
- private SoundTriggerDetector mDetector1 = null;
- private SoundTriggerDetector mDetector2 = null;
- private SoundTriggerDetector mDetector3 = null;
+ private Map<Integer, ModelInfo> mModelInfoMap;
+ private Map<View, Integer> mModelIdMap;
private TextView mDebugView = null;
- private int mSelectedModelId = 1;
+ private int mSelectedModelId = -1;
private ScrollView mScrollView = null;
+ private Button mPlayTriggerButton = null;
private PowerManager.WakeLock mScreenWakelock;
private Handler mHandler;
+ private RadioGroup mRadioGroup;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -66,11 +75,108 @@
setContentView(R.layout.main);
mDebugView = (TextView) findViewById(R.id.console);
mScrollView = (ScrollView) findViewById(R.id.scroller_id);
+ mRadioGroup = (RadioGroup) findViewById(R.id.model_group_id);
+ mPlayTriggerButton = (Button) findViewById(R.id.play_trigger_id);
mDebugView.setText(mDebugView.getText(), TextView.BufferType.EDITABLE);
mDebugView.setMovementMethod(new ScrollingMovementMethod());
mSoundTriggerUtil = new SoundTriggerUtil(this);
mRandom = new Random();
mHandler = new Handler();
+
+ mModelInfoMap = new HashMap();
+ mModelIdMap = new HashMap();
+
+ setVolumeControlStream(AudioManager.STREAM_MUSIC);
+
+ // Load all the models in the data dir.
+ for (File file : getFilesDir().listFiles()) {
+ // Find meta-data in .properties files, ignore everything else.
+ if (!file.getName().endsWith(".properties")) {
+ continue;
+ }
+ try {
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(file));
+ createModelInfoAndWidget(properties);
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to load properties file " + file.getName());
+ }
+ }
+
+ // Create a few dummy models if we didn't load anything.
+ if (mModelIdMap.isEmpty()) {
+ Properties dummyModelProperties = new Properties();
+ for (String name : new String[]{"One", "Two", "Three"}) {
+ dummyModelProperties.setProperty("name", "Model " + name);
+ createModelInfoAndWidget(dummyModelProperties);
+ }
+ }
+ }
+
+ private void createModelInfoAndWidget(Properties properties) {
+ try {
+ ModelInfo modelInfo = new ModelInfo();
+
+ if (!properties.containsKey("name")) {
+ throw new RuntimeException("must have a 'name' property");
+ }
+ modelInfo.name = properties.getProperty("name");
+
+ if (properties.containsKey("modelUuid")) {
+ modelInfo.modelUuid = UUID.fromString(properties.getProperty("modelUuid"));
+ } else {
+ modelInfo.modelUuid = UUID.randomUUID();
+ }
+
+ if (properties.containsKey("vendorUuid")) {
+ modelInfo.vendorUuid = UUID.fromString(properties.getProperty("vendorUuid"));
+ } else {
+ modelInfo.vendorUuid = UUID.randomUUID();
+ }
+
+ if (properties.containsKey("triggerAudio")) {
+ modelInfo.triggerAudioPlayer = MediaPlayer.create(this, Uri.parse(
+ getFilesDir().getPath() + "/" + properties.getProperty("triggerAudio")));
+ }
+
+ if (properties.containsKey("dataFile")) {
+ File modelDataFile = new File(
+ getFilesDir().getPath() + "/" + properties.getProperty("dataFile"));
+ modelInfo.modelData = new byte[(int) modelDataFile.length()];
+ FileInputStream input = new FileInputStream(modelDataFile);
+ input.read(modelInfo.modelData, 0, modelInfo.modelData.length);
+ } else {
+ modelInfo.modelData = new byte[1024];
+ mRandom.nextBytes(modelInfo.modelData);
+ }
+
+ // TODO: Add property support for keyphrase models when they're exposed by the
+ // service. Also things like how much audio they should record with the capture session
+ // provided in the callback.
+
+ // Add a widget into the radio group.
+ RadioButton button = new RadioButton(this);
+ mRadioGroup.addView(button);
+ button.setText(modelInfo.name);
+ button.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ onRadioButtonClicked(v);
+ }
+ });
+
+ // Update our maps containing the button -> id and id -> modelInfo.
+ int newModelId = mModelIdMap.size() + 1;
+ mModelIdMap.put(button, newModelId);
+ mModelInfoMap.put(newModelId, modelInfo);
+
+ // If we don't have something selected, select this first thing.
+ if (mSelectedModelId < 0) {
+ button.setChecked(true);
+ onRadioButtonClicked(button);
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "Error parsing properties for " + properties.getProperty("name"), e);
+ }
}
private void postMessage(String msg) {
@@ -91,27 +197,15 @@
}
private synchronized UUID getSelectedUuid() {
- if (mSelectedModelId == 2) return mModelUuid2;
- if (mSelectedModelId == 3) return mModelUuid3;
- return mModelUuid1; // Default.
+ return mModelInfoMap.get(mSelectedModelId).modelUuid;
}
private synchronized void setDetector(SoundTriggerDetector detector) {
- if (mSelectedModelId == 2) {
- mDetector2 = detector;
- return;
- }
- if (mSelectedModelId == 3) {
- mDetector3 = detector;
- return;
- }
- mDetector1 = detector;
+ mModelInfoMap.get(mSelectedModelId).detector = detector;
}
private synchronized SoundTriggerDetector getDetector() {
- if (mSelectedModelId == 2) return mDetector2;
- if (mSelectedModelId == 3) return mDetector3;
- return mDetector1;
+ return mModelInfoMap.get(mSelectedModelId).detector;
}
private void screenWakeup() {
@@ -127,25 +221,29 @@
mScreenWakelock.release();
}
+ /** TODO: Should return the abstract sound model that can be then sent to the service. */
+ private GenericSoundModel createNewSoundModel() {
+ ModelInfo modelInfo = mModelInfoMap.get(mSelectedModelId);
+ return new GenericSoundModel(modelInfo.modelUuid, modelInfo.vendorUuid,
+ modelInfo.modelData);
+ }
+
/**
* Called when the user clicks the enroll button.
* Performs a fresh enrollment.
*/
public void onEnrollButtonClicked(View v) {
postMessage("Loading model: " + mSelectedModelId);
- // Generate a fake model to push.
- byte[] data = new byte[1024];
- mRandom.nextBytes(data);
- UUID modelUuid = getSelectedUuid();
- GenericSoundModel model = new GenericSoundModel(modelUuid, mVendorUuid, data);
+
+ GenericSoundModel model = createNewSoundModel();
boolean status = mSoundTriggerUtil.addOrUpdateSoundModel(model);
if (status) {
Toast.makeText(
- this, "Successfully created sound trigger model UUID=" + modelUuid,
+ this, "Successfully created sound trigger model UUID=" + model.uuid,
Toast.LENGTH_SHORT).show();
} else {
- Toast.makeText(this, "Failed to enroll!!!" + modelUuid, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, "Failed to enroll!!!" + model.uuid, Toast.LENGTH_SHORT).show();
}
// Test the SoundManager API.
@@ -185,11 +283,7 @@
Toast.makeText(this, "Sound model not found!!!", Toast.LENGTH_SHORT).show();
return;
}
- // Generate a fake model to push.
- byte[] data = new byte[2048];
- mRandom.nextBytes(data);
- GenericSoundModel updated = new GenericSoundModel(soundModel.uuid,
- soundModel.vendorUuid, data);
+ GenericSoundModel updated = createNewSoundModel();
boolean status = mSoundTriggerUtil.addOrUpdateSoundModel(updated);
if (status) {
Toast.makeText(this, "Successfully re-enrolled, model UUID=" + updated.uuid,
@@ -237,29 +331,32 @@
public synchronized void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
- // Check which radio button was clicked
- switch(view.getId()) {
- case R.id.model_one:
- if (checked) {
- mSelectedModelId = 1;
- postMessage("Selected model one.");
- }
- break;
- case R.id.model_two:
- if (checked) {
- mSelectedModelId = 2;
- postMessage("Selected model two.");
- }
- break;
- case R.id.model_three:
- if (checked) {
- mSelectedModelId = 3;
- postMessage("Selected model three.");
- }
- break;
+ if (checked) {
+ mSelectedModelId = mModelIdMap.get(view);
+ ModelInfo modelInfo = mModelInfoMap.get(mSelectedModelId);
+ postMessage("Selected " + modelInfo.name);
+
+ // Set the play trigger button to be enabled only if we actually have some audio.
+ mPlayTriggerButton.setEnabled(modelInfo.triggerAudioPlayer != null);
}
}
+ public synchronized void onPlayTriggerButtonClicked(View v) {
+ ModelInfo modelInfo = mModelInfoMap.get(mSelectedModelId);
+ modelInfo.triggerAudioPlayer.start();
+ postMessage("Playing trigger audio for " + modelInfo.name);
+ }
+
+ // Helper struct for holding information about a model.
+ private static class ModelInfo {
+ public String name;
+ public UUID modelUuid;
+ public UUID vendorUuid;
+ public MediaPlayer triggerAudioPlayer;
+ public SoundTriggerDetector detector;
+ public byte modelData[];
+ };
+
// Implementation of SoundTriggerDetector.Callback.
public class DetectorCallback extends SoundTriggerDetector.Callback {
public void onAvailabilityChanged(int status) {
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 0f84506..be5b8fc 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -149,7 +149,7 @@
void setAllowScansWithTraffic(int enabled);
int getAllowScansWithTraffic();
- boolean enableAutoJoinWhenAssociated(boolean enabled);
+ boolean setEnableAutoJoinWhenAssociated(boolean enabled);
boolean getEnableAutoJoinWhenAssociated();
void enableWifiConnectivityManager(boolean enabled);
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 6984fe2..1cd32b6 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -2700,9 +2700,9 @@
* @return true -- if set successful false -- if set failed
* @hide
*/
- public boolean enableAutoJoinWhenAssociated(boolean enabled) {
+ public boolean setEnableAutoJoinWhenAssociated(boolean enabled) {
try {
- return mService.enableAutoJoinWhenAssociated(enabled);
+ return mService.setEnableAutoJoinWhenAssociated(enabled);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}