Merge "Support more smaller scripts of Asia and Africa."
diff --git a/Android.mk b/Android.mk
index f4b9551..d7e8e4e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -209,6 +209,7 @@
core/java/android/security/IKeystoreService.aidl \
core/java/android/service/carrier/ICarrierMessagingCallback.aidl \
core/java/android/service/carrier/ICarrierMessagingService.aidl \
+ core/java/android/service/gatekeeper/IGateKeeperService.aidl \
core/java/android/service/notification/INotificationListener.aidl \
core/java/android/service/notification/IStatusBarNotificationHolder.aidl \
core/java/android/service/notification/IConditionListener.aidl \
@@ -1017,13 +1018,13 @@
LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
LOCAL_DROIDDOC_SOURCE_PATH:=$(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
-LOCAL_DROIDDOC_HTML_DIR:=$(framework_docs_LOCAL_DROIDDOC_HTML_DIR)
+LOCAL_DROIDDOC_HTML_DIR:=docs/html-ndk
LOCAL_ADDITIONAL_JAVA_DIR:=$(framework_docs_LOCAL_ADDITIONAL_JAVA_DIR)
LOCAL_ADDITIONAL_DEPENDENCIES:=$(framework_docs_LOCAL_ADDITIONAL_DEPENDENCIES)
# specify a second html input dir and an output path relative to OUT_DIR)
LOCAL_ADDITIONAL_HTML_DIR:=docs/html-intl/intl /
-LOCAL_MODULE := ndk
+LOCAL_MODULE := online-ndk
LOCAL_DROIDDOC_OPTIONS:= \
$(framework_docs_LOCAL_DROIDDOC_OPTIONS) \
diff --git a/api/current.txt b/api/current.txt
index 6de9a03..ea4aaf9 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4596,6 +4596,7 @@
method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult);
method public boolean inKeyguardRestrictedInputMode();
method public boolean isDeviceLocked();
+ method public boolean isDeviceSecure();
method public boolean isKeyguardLocked();
method public boolean isKeyguardSecure();
method public deprecated android.app.KeyguardManager.KeyguardLock newKeyguardLock(java.lang.String);
@@ -5653,6 +5654,7 @@
method public java.util.List<android.content.ComponentName> getActiveAdmins();
method public android.os.Bundle getApplicationRestrictions(android.content.ComponentName, java.lang.String);
method public boolean getAutoTimeRequired();
+ method public boolean getBluetoothContactSharingDisabled(android.content.ComponentName);
method public boolean getCameraDisabled(android.content.ComponentName);
method public java.lang.String getCertInstallerPackage(android.content.ComponentName) throws java.lang.SecurityException;
method public boolean getCrossProfileCallerIdDisabled(android.content.ComponentName);
@@ -5662,6 +5664,7 @@
method public int getKeyguardDisabledFeatures(android.content.ComponentName);
method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
method public long getMaximumTimeToLock(android.content.ComponentName);
+ method public android.app.admin.OtaPolicy getOtaPolicy();
method public long getPasswordExpiration(android.content.ComponentName);
method public long getPasswordExpirationTimeout(android.content.ComponentName);
method public int getPasswordHistoryLength(android.content.ComponentName);
@@ -5703,16 +5706,19 @@
method public boolean setApplicationHidden(android.content.ComponentName, java.lang.String, boolean);
method public void setApplicationRestrictions(android.content.ComponentName, java.lang.String, android.os.Bundle);
method public void setAutoTimeRequired(android.content.ComponentName, boolean);
+ method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
method public void setCameraDisabled(android.content.ComponentName, boolean);
method public void setCertInstallerPackage(android.content.ComponentName, java.lang.String) throws java.lang.SecurityException;
method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
+ method public boolean setKeyguardEnabledState(android.content.ComponentName, boolean);
method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
method public void setMaximumTimeToLock(android.content.ComponentName, long);
+ method public void setOtaPolicy(android.content.ComponentName, android.app.admin.OtaPolicy);
method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
method public void setPasswordHistoryLength(android.content.ComponentName, int);
method public void setPasswordMinimumLength(android.content.ComponentName, int);
@@ -5742,6 +5748,7 @@
method public void wipeData(int);
field public static final java.lang.String ACTION_ADD_DEVICE_ADMIN = "android.app.action.ADD_DEVICE_ADMIN";
field public static final java.lang.String ACTION_MANAGED_PROFILE_PROVISIONED = "android.app.action.MANAGED_PROFILE_PROVISIONED";
+ field public static final java.lang.String ACTION_OTA_POLICY_CHANGED = "android.app.action.OTA_POLICY_CHANGED";
field public static final java.lang.String ACTION_PROVISION_MANAGED_PROFILE = "android.app.action.PROVISION_MANAGED_PROFILE";
field public static final java.lang.String ACTION_SET_NEW_PASSWORD = "android.app.action.SET_NEW_PASSWORD";
field public static final java.lang.String ACTION_START_ENCRYPTION = "android.app.action.START_ENCRYPTION";
@@ -5809,6 +5816,23 @@
field public static final int WIPE_RESET_PROTECTION_DATA = 2; // 0x2
}
+ public class OtaPolicy {
+ ctor public OtaPolicy();
+ method public int getInstallWindowEnd();
+ method public int getInstallWindowStart();
+ method public int getPolicyType();
+ method public void setAutomaticInstallPolicy();
+ method public void setPostponeInstallPolicy();
+ method public void setWindowedInstallPolicy(int, int) throws android.app.admin.OtaPolicy.InvalidWindowException;
+ field public static final int TYPE_INSTALL_AUTOMATIC = 1; // 0x1
+ field public static final int TYPE_INSTALL_WINDOWED = 2; // 0x2
+ field public static final int TYPE_POSTPONE = 3; // 0x3
+ }
+
+ public static class OtaPolicy.InvalidWindowException extends java.lang.Exception {
+ ctor public OtaPolicy.InvalidWindowException(java.lang.String);
+ }
+
}
package android.app.backup {
@@ -8157,6 +8181,7 @@
field public static final java.lang.String EXTRA_CHANGED_COMPONENT_NAME_LIST = "android.intent.extra.changed_component_name_list";
field public static final java.lang.String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list";
field public static final java.lang.String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list";
+ field public static final java.lang.String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
@@ -14799,7 +14824,7 @@
method public static float getMaxVolume();
method public static int getMinBufferSize(int, int, int);
method public static float getMinVolume();
- method protected deprecated int getNativeFrameCount();
+ method public int getNativeFrameCount() throws java.lang.IllegalStateException;
method public static int getNativeOutputSampleRate(int);
method public int getNotificationMarkerPosition();
method public int getPlayState();
@@ -15184,6 +15209,7 @@
method public android.media.MediaCodecInfo.AudioCapabilities getAudioCapabilities();
method public android.media.MediaFormat getDefaultFormat();
method public android.media.MediaCodecInfo.EncoderCapabilities getEncoderCapabilities();
+ method public int getMaxSupportedInstances();
method public java.lang.String getMimeType();
method public android.media.MediaCodecInfo.VideoCapabilities getVideoCapabilities();
method public final boolean isFeatureRequired(java.lang.String);
@@ -18053,6 +18079,7 @@
}
public final class IpPrefix implements android.os.Parcelable {
+ method public boolean contains(java.net.InetAddress);
method public int describeContents();
method public java.net.InetAddress getAddress();
method public int getPrefixLength();
@@ -28383,8 +28410,10 @@
public final class ChooserTarget implements android.os.Parcelable {
ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.app.PendingIntent);
ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.content.IntentSender);
+ ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.content.Intent);
method public int describeContents();
method public android.graphics.Bitmap getIcon();
+ method public android.content.Intent getIntent();
method public android.content.IntentSender getIntentSender();
method public float getScore();
method public java.lang.CharSequence getTitle();
@@ -28397,6 +28426,8 @@
ctor public ChooserTargetService();
method public android.os.IBinder onBind(android.content.Intent);
method public abstract java.util.List<android.service.chooser.ChooserTarget> onGetChooserTargets(android.content.ComponentName, android.content.IntentFilter);
+ field public static final java.lang.String BIND_PERMISSION = "android.permission.BIND_CHOOSER_TARGET_SERVICE";
+ field public static final java.lang.String META_DATA_NAME = "android.service.chooser.chooser_target_service";
field public static final java.lang.String SERVICE_INTERFACE = "android.service.chooser.ChooserTargetService";
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 708394c..1a28546 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4687,6 +4687,7 @@
method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult);
method public boolean inKeyguardRestrictedInputMode();
method public boolean isDeviceLocked();
+ method public boolean isDeviceSecure();
method public boolean isKeyguardLocked();
method public boolean isKeyguardSecure();
method public deprecated android.app.KeyguardManager.KeyguardLock newKeyguardLock(java.lang.String);
@@ -5749,6 +5750,7 @@
method public java.util.List<android.content.ComponentName> getActiveAdmins();
method public android.os.Bundle getApplicationRestrictions(android.content.ComponentName, java.lang.String);
method public boolean getAutoTimeRequired();
+ method public boolean getBluetoothContactSharingDisabled(android.content.ComponentName);
method public boolean getCameraDisabled(android.content.ComponentName);
method public java.lang.String getCertInstallerPackage(android.content.ComponentName) throws java.lang.SecurityException;
method public boolean getCrossProfileCallerIdDisabled(android.content.ComponentName);
@@ -5761,6 +5763,7 @@
method public int getKeyguardDisabledFeatures(android.content.ComponentName);
method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
method public long getMaximumTimeToLock(android.content.ComponentName);
+ method public android.app.admin.OtaPolicy getOtaPolicy();
method public long getPasswordExpiration(android.content.ComponentName);
method public long getPasswordExpirationTimeout(android.content.ComponentName);
method public int getPasswordHistoryLength(android.content.ComponentName);
@@ -5807,16 +5810,19 @@
method public boolean setApplicationHidden(android.content.ComponentName, java.lang.String, boolean);
method public void setApplicationRestrictions(android.content.ComponentName, java.lang.String, android.os.Bundle);
method public void setAutoTimeRequired(android.content.ComponentName, boolean);
+ method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
method public void setCameraDisabled(android.content.ComponentName, boolean);
method public void setCertInstallerPackage(android.content.ComponentName, java.lang.String) throws java.lang.SecurityException;
method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
+ method public boolean setKeyguardEnabledState(android.content.ComponentName, boolean);
method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
method public void setMaximumTimeToLock(android.content.ComponentName, long);
+ method public void setOtaPolicy(android.content.ComponentName, android.app.admin.OtaPolicy);
method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
method public void setPasswordHistoryLength(android.content.ComponentName, int);
method public void setPasswordMinimumLength(android.content.ComponentName, int);
@@ -5846,6 +5852,7 @@
method public void wipeData(int);
field public static final java.lang.String ACTION_ADD_DEVICE_ADMIN = "android.app.action.ADD_DEVICE_ADMIN";
field public static final java.lang.String ACTION_MANAGED_PROFILE_PROVISIONED = "android.app.action.MANAGED_PROFILE_PROVISIONED";
+ field public static final java.lang.String ACTION_OTA_POLICY_CHANGED = "android.app.action.OTA_POLICY_CHANGED";
field public static final java.lang.String ACTION_PROVISION_MANAGED_PROFILE = "android.app.action.PROVISION_MANAGED_PROFILE";
field public static final java.lang.String ACTION_SEND_DEVICE_INITIALIZER_STATUS = "android.app.action.SEND_DEVICE_INITIALIZER_STATUS";
field public static final java.lang.String ACTION_SET_NEW_PASSWORD = "android.app.action.SET_NEW_PASSWORD";
@@ -5918,6 +5925,23 @@
field public static final int WIPE_RESET_PROTECTION_DATA = 2; // 0x2
}
+ public class OtaPolicy {
+ ctor public OtaPolicy();
+ method public int getInstallWindowEnd();
+ method public int getInstallWindowStart();
+ method public int getPolicyType();
+ method public void setAutomaticInstallPolicy();
+ method public void setPostponeInstallPolicy();
+ method public void setWindowedInstallPolicy(int, int) throws android.app.admin.OtaPolicy.InvalidWindowException;
+ field public static final int TYPE_INSTALL_AUTOMATIC = 1; // 0x1
+ field public static final int TYPE_INSTALL_WINDOWED = 2; // 0x2
+ field public static final int TYPE_POSTPONE = 3; // 0x3
+ }
+
+ public static class OtaPolicy.InvalidWindowException extends java.lang.Exception {
+ ctor public OtaPolicy.InvalidWindowException(java.lang.String);
+ }
+
}
package android.app.backup {
@@ -8383,6 +8407,7 @@
field public static final java.lang.String EXTRA_CHANGED_COMPONENT_NAME_LIST = "android.intent.extra.changed_component_name_list";
field public static final java.lang.String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list";
field public static final java.lang.String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list";
+ field public static final java.lang.String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
field public static final java.lang.String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
@@ -16011,7 +16036,7 @@
method public static float getMaxVolume();
method public static int getMinBufferSize(int, int, int);
method public static float getMinVolume();
- method protected deprecated int getNativeFrameCount();
+ method public int getNativeFrameCount() throws java.lang.IllegalStateException;
method public static int getNativeOutputSampleRate(int);
method public int getNotificationMarkerPosition();
method public int getPlayState();
@@ -16396,6 +16421,7 @@
method public android.media.MediaCodecInfo.AudioCapabilities getAudioCapabilities();
method public android.media.MediaFormat getDefaultFormat();
method public android.media.MediaCodecInfo.EncoderCapabilities getEncoderCapabilities();
+ method public int getMaxSupportedInstances();
method public java.lang.String getMimeType();
method public android.media.MediaCodecInfo.VideoCapabilities getVideoCapabilities();
method public final boolean isFeatureRequired(java.lang.String);
@@ -19507,6 +19533,7 @@
}
public final class IpPrefix implements android.os.Parcelable {
+ method public boolean contains(java.net.InetAddress);
method public int describeContents();
method public java.net.InetAddress getAddress();
method public int getPrefixLength();
@@ -30382,8 +30409,10 @@
public final class ChooserTarget implements android.os.Parcelable {
ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.app.PendingIntent);
ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.content.IntentSender);
+ ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.content.Intent);
method public int describeContents();
method public android.graphics.Bitmap getIcon();
+ method public android.content.Intent getIntent();
method public android.content.IntentSender getIntentSender();
method public float getScore();
method public java.lang.CharSequence getTitle();
@@ -30396,6 +30425,8 @@
ctor public ChooserTargetService();
method public android.os.IBinder onBind(android.content.Intent);
method public abstract java.util.List<android.service.chooser.ChooserTarget> onGetChooserTargets(android.content.ComponentName, android.content.IntentFilter);
+ field public static final java.lang.String BIND_PERMISSION = "android.permission.BIND_CHOOSER_TARGET_SERVICE";
+ field public static final java.lang.String META_DATA_NAME = "android.service.chooser.chooser_target_service";
field public static final java.lang.String SERVICE_INTERFACE = "android.service.chooser.ChooserTargetService";
}
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java
index ddd21e6..56cd53e 100644
--- a/core/java/android/app/KeyguardManager.java
+++ b/core/java/android/app/KeyguardManager.java
@@ -253,6 +253,32 @@
}
/**
+ * Returns whether the device is secured with a PIN, pattern or
+ * password.
+ *
+ * @return true if a PIN, pattern or password was set.
+ */
+ public boolean isDeviceSecure() {
+ return isDeviceSecure(UserHandle.getCallingUserId());
+ }
+
+ /**
+ * Returns whether the device is secured with a PIN, pattern or
+ * password.
+ *
+ * @param userId the user for which the secure state should be reported.
+ * @return true if a PIN, pattern or password was set.
+ * @hide
+ */
+ public boolean isDeviceSecure(int userId) {
+ try {
+ return mTrustManager.isDeviceSecure(userId);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
* @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD}
* and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED}
* instead; this allows you to seamlessly hide the keyguard as your application
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 26b1b36..a0a6c4c 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -754,6 +754,14 @@
public static final int FLAG_MANAGED_CAN_ACCESS_PARENT = 0x0002;
/**
+ * Broadcast action: notify that a new local OTA policy has been set by the device owner.
+ * The new policy can be retrieved by {@link #getOtaPolicy()}.
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_OTA_POLICY_CHANGED = "android.app.action.OTA_POLICY_CHANGED";
+
+
+ /**
* Return true if the given administrator component is currently
* active (enabled) in the system.
*/
@@ -2209,7 +2217,8 @@
* Called by a device or profile owner to install a certificate and private key pair. The
* keypair will be visible to all apps within the profile.
*
- * @param who Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param who Which {@link DeviceAdminReceiver} this request is associated with. Use
+ * <code>null</code> if calling from a delegated certificate installer.
* @param privKey The private key to install.
* @param cert The certificate to install.
* @param alias The private key alias under which to install the certificate. If a certificate
@@ -2246,9 +2255,9 @@
/**
* Called by a profile owner or device owner to grant access to privileged certificate
- * manipulation APIs to a third-party CA certificate installer app. Granted APIs include
+ * manipulation APIs to a third-party certificate installer app. Granted APIs include
* {@link #getInstalledCaCerts}, {@link #hasCaCertInstalled}, {@link #installCaCert},
- * {@link #uninstallCaCert} and {@link #uninstallAllUserCaCerts}.
+ * {@link #uninstallCaCert}, {@link #uninstallAllUserCaCerts} and {@link #installKeyPair}.
* <p>
* Delegated certificate installer is a per-user state. The delegated access is persistent until
* it is later cleared by calling this method with a null value or uninstallling the certificate
@@ -3253,6 +3262,73 @@
}
/**
+ * Called by a profile owner of a managed profile to set whether bluetooth
+ * devices can access enterprise contacts.
+ * <p>
+ * The calling device admin must be a profile owner. If it is not, a
+ * security exception will be thrown.
+ * <p>
+ * This API works on managed profile only.
+ *
+ * @param who Which {@link DeviceAdminReceiver} this request is associated
+ * with.
+ * @param disabled If true, bluetooth devices cannot access enterprise
+ * contacts.
+ */
+ public void setBluetoothContactSharingDisabled(ComponentName who, boolean disabled) {
+ if (mService != null) {
+ try {
+ mService.setBluetoothContactSharingDisabled(who, disabled);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ }
+
+ /**
+ * Called by a profile owner of a managed profile to determine whether or
+ * not Bluetooth devices cannot access enterprise contacts.
+ * <p>
+ * The calling device admin must be a profile owner. If it is not, a
+ * security exception will be thrown.
+ * <p>
+ * This API works on managed profile only.
+ *
+ * @param who Which {@link DeviceAdminReceiver} this request is associated
+ * with.
+ */
+ public boolean getBluetoothContactSharingDisabled(ComponentName who) {
+ if (mService != null) {
+ try {
+ return mService.getBluetoothContactSharingDisabled(who);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Determine whether or not Bluetooth devices cannot access contacts.
+ * <p>
+ * This API works on managed profile UserHandle only.
+ *
+ * @param userHandle The user for whom to check the caller-id permission
+ * @hide
+ */
+ public boolean getBluetoothContactSharingDisabled(UserHandle userHandle) {
+ if (mService != null) {
+ try {
+ return mService.getBluetoothContactSharingDisabledForUser(userHandle
+ .getIdentifier());
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ return true;
+ }
+
+ /**
* Called by the profile owner of a managed profile so that some intents sent in the managed
* profile can also be resolved in the parent, or vice versa.
* Only activity intents are supported.
@@ -4066,4 +4142,72 @@
Log.w(TAG, "Could not send device initializer status", re);
}
}
+
+ /*
+ * Called by device owners to set a local OTA update policy. When a new OTA policy is set,
+ * {@link #ACTION_OTA_POLICY_CHANGED} is broadcasted.
+ *
+ * @param who Which {@link DeviceAdminReceiver} this request is associated with. All components
+ * in the device owner package can set OTA policies and the most recent policy takes effect.
+ * @param policy the new OTA policy, or null to clear the current policy.
+ * @see OtaPolicy
+ */
+ public void setOtaPolicy(ComponentName who, OtaPolicy policy) {
+ if (mService != null) {
+ try {
+ if (policy != null) {
+ mService.setOtaPolicy(who, policy.getPolicyBundle());
+ } else {
+ mService.setOtaPolicy(who, null);
+ }
+ } catch (RemoteException re) {
+ Log.w(TAG, "Error calling setOtaPolicy", re);
+ }
+ }
+ }
+
+ /**
+ * Retrieve a local OTA update policy set previously by {@link #setOtaPolicy}.
+ *
+ * @return The current OTA policy object, or null if no policy is set or the system does not
+ * support managed OTA.
+ */
+ public OtaPolicy getOtaPolicy() {
+ if (mService != null) {
+ try {
+ PersistableBundle bundle = mService.getOtaPolicy();
+ if (bundle != null) {
+ return new OtaPolicy(bundle);
+ } else {
+ return null;
+ }
+ } catch (RemoteException re) {
+ Log.w(TAG, "Error calling getOtaPolicy", re);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Called by a device owner to disable the keyguard altogether.
+ *
+ * <p>Setting the keyguard to disabled has the same effect as choosing "None" as the screen
+ * lock type. However, this call has no effect if a password, pin or pattern is currently set.
+ * If a password, pin or pattern is set after the keyguard was disabled, the keyguard stops
+ * being disabled.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param enabled New state of the keyguard.
+ *
+ * @return {@code false} if attempting to disable the keyguard while a lock password was in
+ * place. {@code true} otherwise."
+ */
+ public boolean setKeyguardEnabledState(ComponentName admin, boolean enabled) {
+ try {
+ return mService.setKeyguardEnabledState(admin, enabled);
+ } catch (RemoteException re) {
+ Log.w(TAG, "Failed talking with device policy service", re);
+ return false;
+ }
+ }
}
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 75b97a8..131b99c 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -191,6 +191,10 @@
boolean getCrossProfileCallerIdDisabledForUser(int userId);
void startManagedQuickContact(String lookupKey, long contactId, in Intent originalIntent);
+ void setBluetoothContactSharingDisabled(in ComponentName who, boolean disabled);
+ boolean getBluetoothContactSharingDisabled(in ComponentName who);
+ boolean getBluetoothContactSharingDisabledForUser(int userId);
+
void setTrustAgentConfiguration(in ComponentName admin, in ComponentName agent,
in PersistableBundle args);
List<PersistableBundle> getTrustAgentConfiguration(in ComponentName admin,
@@ -215,4 +219,8 @@
void setUserIcon(in ComponentName admin, in Bitmap icon);
void sendDeviceInitializerStatus(int statusCode, String description);
+ void setOtaPolicy(in ComponentName who, in PersistableBundle policy);
+ PersistableBundle getOtaPolicy();
+
+ boolean setKeyguardEnabledState(in ComponentName admin, boolean enabled);
}
diff --git a/core/java/android/app/admin/OtaPolicy.java b/core/java/android/app/admin/OtaPolicy.java
new file mode 100644
index 0000000..98581a7
--- /dev/null
+++ b/core/java/android/app/admin/OtaPolicy.java
@@ -0,0 +1,179 @@
+/*
+ * 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 android.app.admin;
+
+import android.annotation.IntDef;
+import android.os.PersistableBundle;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A class that represents a local OTA policy set by the device owner.
+ *
+ * @see DevicePolicyManager#setOtaPolicy
+ * @see DevicePolicyManager#getOtaPolicy
+ */
+public class OtaPolicy {
+
+ /** @hide */
+ @IntDef({
+ TYPE_INSTALL_AUTOMATIC,
+ TYPE_INSTALL_WINDOWED,
+ TYPE_POSTPONE})
+ @Retention(RetentionPolicy.SOURCE)
+ @interface OtaPolicyType {}
+
+ /**
+ * Install OTA update automatically as soon as one is available.
+ */
+ public static final int TYPE_INSTALL_AUTOMATIC = 1;
+
+ /**
+ * Install OTA update automatically within a daily maintenance window, for a maximum of two-week
+ * period. After that period the OTA will be installed automatically.
+ */
+ public static final int TYPE_INSTALL_WINDOWED = 2;
+
+ /**
+ * Incoming OTA will be blocked for a maximum of two weeks, after which it will be installed
+ * automatically.
+ */
+ public static final int TYPE_POSTPONE = 3;
+
+ private static final String KEY_POLICY_TYPE = "policy_type";
+ private static final String KEY_INSTALL_WINDOW_START = "install_window_start";
+ private static final String KEY_INSTALL_WINDOW_END = "install_window_end";
+
+ private PersistableBundle mPolicy;
+
+ public OtaPolicy() {
+ mPolicy = new PersistableBundle();
+ }
+
+ /**
+ * Construct an OtaPolicy object from a bundle.
+ * @hide
+ */
+ public OtaPolicy(PersistableBundle in) {
+ mPolicy = new PersistableBundle(in);
+ }
+
+ /**
+ * Retrieve the underlying bundle where the policy is stored.
+ * @hide
+ */
+ public PersistableBundle getPolicyBundle() {
+ return new PersistableBundle(mPolicy);
+ }
+
+ /**
+ * Set the OTA policy to: install OTA update automatically as soon as one is available.
+ */
+ public void setAutomaticInstallPolicy() {
+ mPolicy.clear();
+ mPolicy.putInt(KEY_POLICY_TYPE, TYPE_INSTALL_AUTOMATIC);
+ }
+
+ /**
+ * Set the OTA policy to: new OTA update will only be installed automatically when the system
+ * clock is inside a daily maintenance window. If the start and end times are the same, the
+ * window is considered to include the WHOLE 24 hours, that is, OTAs can install at any time. If
+ * the given window in invalid, a {@link OtaPolicy.InvalidWindowException} will be thrown. If
+ * start time is later than end time, the window is considered spanning midnight, i.e. end time
+ * donates a time on the next day. The maintenance window will last for two weeks, after which
+ * the OTA will be installed automatically.
+ *
+ * @param startTime the start of the maintenance window, measured as the number of minutes from
+ * midnight in the device's local time. Must be in the range of [0, 1440).
+ * @param endTime the end of the maintenance window, measured as the number of minutes from
+ * midnight in the device's local time. Must be in the range of [0, 1440).
+ */
+ public void setWindowedInstallPolicy(int startTime, int endTime) throws InvalidWindowException{
+ if (startTime < 0 || startTime >= 1440 || endTime < 0 || endTime >= 1440) {
+ throw new InvalidWindowException("startTime and endTime must be inside [0, 1440)");
+ }
+ mPolicy.clear();
+ mPolicy.putInt(KEY_POLICY_TYPE, TYPE_INSTALL_WINDOWED);
+ mPolicy.putInt(KEY_INSTALL_WINDOW_START, startTime);
+ mPolicy.putInt(KEY_INSTALL_WINDOW_END, endTime);
+ }
+
+ /**
+ * Set the OTA policy to: block installation for a maximum period of two weeks. After the
+ * block expires the OTA will be installed automatically.
+ */
+ public void setPostponeInstallPolicy() {
+ mPolicy.clear();
+ mPolicy.putInt(KEY_POLICY_TYPE, TYPE_POSTPONE);
+ }
+
+ /**
+ * Returns the type of OTA policy.
+ *
+ * @return an integer, either one of {@link #TYPE_INSTALL_AUTOMATIC},
+ * {@link #TYPE_INSTALL_WINDOWED} and {@link #TYPE_POSTPONE}, or -1 if no policy has been set.
+ */
+ @OtaPolicyType
+ public int getPolicyType() {
+ return mPolicy.getInt(KEY_POLICY_TYPE, -1);
+ }
+
+ /**
+ * Get the start of the maintenance window.
+ *
+ * @return the start of the maintenance window measured as the number of minutes from midnight,
+ * or -1 if the policy does not have a maintenance window.
+ */
+ public int getInstallWindowStart() {
+ if (getPolicyType() == TYPE_INSTALL_WINDOWED) {
+ return mPolicy.getInt(KEY_INSTALL_WINDOW_START, -1);
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * Get the end of the maintenance window.
+ *
+ * @return the end of the maintenance window measured as the number of minutes from midnight,
+ * or -1 if the policy does not have a maintenance window.
+ */
+ public int getInstallWindowEnd() {
+ if (getPolicyType() == TYPE_INSTALL_WINDOWED) {
+ return mPolicy.getInt(KEY_INSTALL_WINDOW_END, -1);
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return mPolicy.toString();
+ }
+
+ /**
+ * Exception thrown by {@link OtaPolicy#setWindowedInstallPolicy(int, int)} in case the
+ * specified window is invalid.
+ */
+ public static class InvalidWindowException extends Exception {
+ public InvalidWindowException(String reason) {
+ super(reason);
+ }
+ }
+}
+
diff --git a/core/java/android/app/backup/BackupTransport.java b/core/java/android/app/backup/BackupTransport.java
index 1131ff9..9540eb1 100644
--- a/core/java/android/app/backup/BackupTransport.java
+++ b/core/java/android/app/backup/BackupTransport.java
@@ -399,6 +399,13 @@
* operation will be skipped (and {@link #finishBackup() invoked} with no data for that
* package being passed to {@link #sendBackupData}.
*
+ * <p class="note">The platform does no size-based rejection of full backup attempts on
+ * its own: it is always the responsibility of the transport to implement its own policy.
+ * In particular, even if the preflighted payload size is zero, the platform will still call
+ * this method and will proceed to back up an archive metadata header with no file content
+ * if this method returns TRANSPORT_OK. To avoid storing such payloads the transport
+ * must recognize this case and return TRANSPORT_PACKAGE_REJECTED.
+ *
* Added in MNC (API 23).
*
* @param size The estimated size of the full-data payload for this app. This includes
diff --git a/core/java/android/app/trust/ITrustManager.aidl b/core/java/android/app/trust/ITrustManager.aidl
index 68ea0aa..17cff5c 100644
--- a/core/java/android/app/trust/ITrustManager.aidl
+++ b/core/java/android/app/trust/ITrustManager.aidl
@@ -31,4 +31,5 @@
void unregisterTrustListener(in ITrustListener trustListener);
void reportKeyguardShowingChanged();
boolean isDeviceLocked(int userId);
+ boolean isDeviceSecure(int userId);
}
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index eea47b7..54fe786 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -3311,6 +3311,14 @@
public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
/**
+ * A Parcelable[] of {@link android.service.chooser.ChooserTarget ChooserTarget} objects
+ * as set with {@link #putExtra(String, Parcelable[])} representing additional app-specific
+ * targets to place at the front of the list of choices. Shown to the user with
+ * {@link #ACTION_CHOOSER}.
+ */
+ public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
+
+ /**
* A Bundle forming a mapping of potential target package names to different extras Bundles
* to add to the default intent extras in {@link #EXTRA_INTENT} when used with
* {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
diff --git a/core/java/android/hardware/location/GeofenceHardwareImpl.java b/core/java/android/hardware/location/GeofenceHardwareImpl.java
index 4696b2a..5d40e94 100644
--- a/core/java/android/hardware/location/GeofenceHardwareImpl.java
+++ b/core/java/android/hardware/location/GeofenceHardwareImpl.java
@@ -53,6 +53,7 @@
private IFusedGeofenceHardware mFusedService;
private IGpsGeofenceHardware mGpsService;
+ private int mCapabilities;
private int[] mSupportedMonitorTypes = new int[GeofenceHardware.NUM_MONITORS];
@@ -89,6 +90,9 @@
private static final int RESOLUTION_LEVEL_COARSE = 2;
private static final int RESOLUTION_LEVEL_FINE = 3;
+ // Capability constant corresponding to fused_location.h entry when geofencing supports GNNS.
+ private static final int CAPABILITY_GNSS = 1;
+
public synchronized static GeofenceHardwareImpl getInstance(Context context) {
if (sInstance == null) {
sInstance = new GeofenceHardwareImpl(context);
@@ -141,7 +145,9 @@
private void updateFusedHardwareAvailability() {
boolean fusedSupported;
try {
- fusedSupported = (mFusedService != null ? mFusedService.isSupported() : false);
+ fusedSupported = (mFusedService != null
+ ? mFusedService.isSupported() && (mCapabilities & CAPABILITY_GNSS) != 0
+ : false);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException calling LocationManagerService");
fusedSupported = false;
@@ -166,6 +172,11 @@
}
}
+ public void onCapabilities(int capabilities) {
+ mCapabilities = capabilities;
+ updateFusedHardwareAvailability();
+ }
+
public void setFusedGeofenceHardware(IFusedGeofenceHardware service) {
if(mFusedService == null) {
mFusedService = service;
@@ -212,6 +223,20 @@
}
}
+ public int getCapabilitiesForMonitoringType(int monitoringType) {
+ switch (mSupportedMonitorTypes[monitoringType]) {
+ case GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE:
+ switch (monitoringType) {
+ case GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE:
+ return CAPABILITY_GNSS;
+ case GeofenceHardware.MONITORING_TYPE_FUSED_HARDWARE:
+ return mCapabilities;
+ }
+ break;
+ }
+ return 0;
+ }
+
public boolean addCircularFence(
int monitoringType,
GeofenceHardwareRequestParcelable request,
diff --git a/core/java/android/hardware/location/GeofenceHardwareService.java b/core/java/android/hardware/location/GeofenceHardwareService.java
index 4816c5f..c0bcb27 100644
--- a/core/java/android/hardware/location/GeofenceHardwareService.java
+++ b/core/java/android/hardware/location/GeofenceHardwareService.java
@@ -65,14 +65,17 @@
}
private IBinder mBinder = new IGeofenceHardware.Stub() {
+ @Override
public void setGpsGeofenceHardware(IGpsGeofenceHardware service) {
mGeofenceHardwareImpl.setGpsHardwareGeofence(service);
}
+ @Override
public void setFusedGeofenceHardware(IFusedGeofenceHardware service) {
mGeofenceHardwareImpl.setFusedGeofenceHardware(service);
}
+ @Override
public int[] getMonitoringTypes() {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
@@ -80,12 +83,15 @@
return mGeofenceHardwareImpl.getMonitoringTypes();
}
+ @Override
public int getStatusOfMonitoringType(int monitoringType) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
return mGeofenceHardwareImpl.getStatusOfMonitoringType(monitoringType);
}
+
+ @Override
public boolean addCircularFence(
int monitoringType,
GeofenceHardwareRequestParcelable request,
@@ -96,6 +102,7 @@
return mGeofenceHardwareImpl.addCircularFence(monitoringType, request, callback);
}
+ @Override
public boolean removeGeofence(int id, int monitoringType) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
@@ -104,6 +111,7 @@
return mGeofenceHardwareImpl.removeGeofence(id, monitoringType);
}
+ @Override
public boolean pauseGeofence(int id, int monitoringType) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
@@ -112,6 +120,7 @@
return mGeofenceHardwareImpl.pauseGeofence(id, monitoringType);
}
+ @Override
public boolean resumeGeofence(int id, int monitoringType, int monitorTransitions) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
@@ -120,6 +129,7 @@
return mGeofenceHardwareImpl.resumeGeofence(id, monitoringType, monitorTransitions);
}
+ @Override
public boolean registerForMonitorStateChangeCallback(int monitoringType,
IGeofenceHardwareMonitorCallback callback) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
@@ -130,6 +140,7 @@
callback);
}
+ @Override
public boolean unregisterForMonitorStateChangeCallback(int monitoringType,
IGeofenceHardwareMonitorCallback callback) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
diff --git a/core/java/android/hardware/location/IFusedLocationHardware.aidl b/core/java/android/hardware/location/IFusedLocationHardware.aidl
index 382c12c..3de766a 100644
--- a/core/java/android/hardware/location/IFusedLocationHardware.aidl
+++ b/core/java/android/hardware/location/IFusedLocationHardware.aidl
@@ -32,21 +32,21 @@
*
* @param eventSink The sink to register.
*/
- void registerSink(in IFusedLocationHardwareSink eventSink);
+ void registerSink(in IFusedLocationHardwareSink eventSink) = 0;
/**
* Unregisters a sink with the Location Hardware object.
*
* @param eventSink The sink to unregister.
*/
- void unregisterSink(in IFusedLocationHardwareSink eventSink);
+ void unregisterSink(in IFusedLocationHardwareSink eventSink) = 1;
/**
* Provides access to the batch size available in Hardware.
*
* @return The batch size the hardware supports.
*/
- int getSupportedBatchSize();
+ int getSupportedBatchSize() = 2;
/**
* Requests the Hardware to start batching locations.
@@ -56,7 +56,7 @@
*
* @throws RuntimeException if the request Id exists.
*/
- void startBatching(in int id, in FusedBatchOptions batchOptions);
+ void startBatching(in int id, in FusedBatchOptions batchOptions) = 3;
/**
* Requests the Hardware to stop batching for the given Id.
@@ -64,7 +64,7 @@
* @param id The request that needs to be stopped.
* @throws RuntimeException if the request Id is unknown.
*/
- void stopBatching(in int id);
+ void stopBatching(in int id) = 4;
/**
* Updates a batching operation in progress.
@@ -74,7 +74,7 @@
*
* @throws RuntimeException if the Id of the request is unknown.
*/
- void updateBatchingOptions(in int id, in FusedBatchOptions batchOptions);
+ void updateBatchingOptions(in int id, in FusedBatchOptions batchOptions) = 5;
/**
* Requests the most recent locations available in Hardware.
@@ -83,14 +83,14 @@
*
* @param batchSizeRequested The number of locations requested.
*/
- void requestBatchOfLocations(in int batchSizeRequested);
+ void requestBatchOfLocations(in int batchSizeRequested) = 6;
/**
* Flags if the Hardware supports injection of diagnostic data.
*
* @return True if data injection is supported, false otherwise.
*/
- boolean supportsDiagnosticDataInjection();
+ boolean supportsDiagnosticDataInjection() = 7;
/**
* Injects diagnostic data into the Hardware subsystem.
@@ -98,14 +98,14 @@
* @param data The data to inject.
* @throws RuntimeException if injection is not supported.
*/
- void injectDiagnosticData(in String data);
+ void injectDiagnosticData(in String data) = 8;
/**
* Flags if the Hardware supports injection of device context information.
*
* @return True if device context injection is supported, false otherwise.
*/
- boolean supportsDeviceContextInjection();
+ boolean supportsDeviceContextInjection() = 9;
/**
* Injects device context information into the Hardware subsystem.
@@ -113,5 +113,12 @@
* @param deviceEnabledContext The context to inject.
* @throws RuntimeException if injection is not supported.
*/
- void injectDeviceContext(in int deviceEnabledContext);
+ void injectDeviceContext(in int deviceEnabledContext) = 10;
+
+ /**
+ * Requests all batched locations currently available in Hardware
+ * and clears the buffer. Any subsequent calls will not return any
+ * of the locations returned in this call.
+ */
+ void flushBatchedLocations() = 11;
}
diff --git a/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl b/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl
index a11d8ab..c99cb0c 100644
--- a/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl
+++ b/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl
@@ -30,12 +30,24 @@
*
* @param locations The batch of location information available.
*/
- void onLocationAvailable(in Location[] locations);
+ void onLocationAvailable(in Location[] locations) = 0;
/**
* Event generated from FLP HAL to provide diagnostic data to the platform.
*
* @param data The diagnostic data provided by FLP HAL.
*/
- void onDiagnosticDataAvailable(in String data);
+ void onDiagnosticDataAvailable(in String data) = 1;
+
+ /**
+ * Event generated from FLP HAL to provide a mask of supported
+ * capabilities. Should be called immediatly after init.
+ */
+ void onCapabilities(int capabilities) = 2;
+
+ /**
+ * Event generated from FLP HAL when the status of location batching
+ * changes (location is successful/unsuccessful).
+ */
+ void onStatusChanged(int status) = 3;
}
\ No newline at end of file
diff --git a/core/java/android/net/IpPrefix.java b/core/java/android/net/IpPrefix.java
index b268986..6b4f2d5 100644
--- a/core/java/android/net/IpPrefix.java
+++ b/core/java/android/net/IpPrefix.java
@@ -170,6 +170,21 @@
}
/**
+ * Determines whether the prefix contains the specified address.
+ *
+ * @param address An {@link InetAddress} to test.
+ * @return {@code true} if the prefix covers the given address.
+ */
+ public boolean contains(InetAddress address) {
+ byte[] addrBytes = (address == null) ? null : address.getAddress();
+ if (addrBytes == null || addrBytes.length != this.address.length) {
+ return false;
+ }
+ NetworkUtils.maskRawAddress(addrBytes, prefixLength);
+ return Arrays.equals(this.address, addrBytes);
+ }
+
+ /**
* Returns a string representation of this {@code IpPrefix}.
*
* @return a string such as {@code "192.0.2.0/24"} or {@code "2001:db8:1:2::/64"}.
diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java
index cfd20a0..90a2460 100644
--- a/core/java/android/net/RouteInfo.java
+++ b/core/java/android/net/RouteInfo.java
@@ -367,13 +367,7 @@
* @return {@code true} if the destination and prefix length cover the given address.
*/
public boolean matches(InetAddress destination) {
- if (destination == null) return false;
-
- // match the route destination and destination with prefix length
- InetAddress dstNet = NetworkUtils.getNetworkPart(destination,
- mDestination.getPrefixLength());
-
- return mDestination.getAddress().equals(dstNet);
+ return mDestination.contains(destination);
}
/**
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 3087e1d..9edf6ad 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -889,6 +889,15 @@
= "android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS";
/**
+ * Activity Action: Show Zen Mode external rule configuration settings.
+ *
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS
+ = "android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS";
+
+ /**
* Activity Action: Show the regulatory information screen for the device.
* <p>
* In some cases, a matching Activity may not exist, so ensure you safeguard
diff --git a/core/java/android/service/chooser/ChooserTarget.java b/core/java/android/service/chooser/ChooserTarget.java
index 7fd1d10..d21cc3c 100644
--- a/core/java/android/service/chooser/ChooserTarget.java
+++ b/core/java/android/service/chooser/ChooserTarget.java
@@ -17,6 +17,7 @@
package android.service.chooser;
+import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -24,8 +25,10 @@
import android.content.IntentFilter;
import android.content.IntentSender;
import android.graphics.Bitmap;
+import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.UserHandle;
import android.util.Log;
/**
@@ -55,6 +58,12 @@
private IntentSender mIntentSender;
/**
+ * A raw intent provided in lieu of an IntentSender. Will be filled in and sent
+ * by {@link #sendIntent(Context, Intent)}.
+ */
+ private Intent mIntent;
+
+ /**
* The score given to this item. It can be normalized.
*/
private float mScore;
@@ -135,6 +144,17 @@
mIntentSender = intentSender;
}
+ public ChooserTarget(CharSequence title, Bitmap icon, float score, Intent intent) {
+ mTitle = title;
+ mIcon = icon;
+ if (score > 1.f || score < 0.f) {
+ throw new IllegalArgumentException("Score " + score + " out of range; "
+ + "must be between 0.0f and 1.0f");
+ }
+ mScore = score;
+ mIntent = intent;
+ }
+
ChooserTarget(Parcel in) {
mTitle = in.readCharSequence();
if (in.readInt() != 0) {
@@ -144,6 +164,9 @@
}
mScore = in.readFloat();
mIntentSender = IntentSender.readIntentSenderOrNullFromParcel(in);
+ if (in.readInt() != 0) {
+ mIntent = Intent.CREATOR.createFromParcel(in);
+ }
}
/**
@@ -179,6 +202,7 @@
/**
* Returns the raw IntentSender supplied by the ChooserTarget's creator.
+ * This may be null if the creator specified a regular Intent instead.
*
* <p>To fill in and send the intent, see {@link #sendIntent(Context, Intent)}.</p>
*
@@ -189,6 +213,18 @@
}
/**
+ * Returns the Intent supplied by the ChooserTarget's creator.
+ * This may be null if the creator specified an IntentSender or PendingIntent instead.
+ *
+ * <p>To fill in and send the intent, see {@link #sendIntent(Context, Intent)}.</p>
+ *
+ * @return the Intent supplied by the ChooserTarget's creator
+ */
+ public Intent getIntent() {
+ return mIntent;
+ }
+
+ /**
* Fill in the IntentSender supplied by the ChooserTarget's creator and send it.
*
* @param context the sending Context; generally the Activity presenting the chooser UI
@@ -200,18 +236,109 @@
fillInIntent.migrateExtraStreamToClipData();
fillInIntent.prepareToLeaveProcess();
}
- try {
- mIntentSender.sendIntent(context, 0, fillInIntent, null, null);
- return true;
- } catch (IntentSender.SendIntentException e) {
- Log.e(TAG, "sendIntent " + this + " failed", e);
+ if (mIntentSender != null) {
+ try {
+ mIntentSender.sendIntent(context, 0, fillInIntent, null, null);
+ return true;
+ } catch (IntentSender.SendIntentException e) {
+ Log.e(TAG, "sendIntent " + this + " failed", e);
+ return false;
+ }
+ } else if (mIntent != null) {
+ try {
+ final Intent toSend = new Intent(mIntent);
+ toSend.fillIn(fillInIntent, 0);
+ context.startActivity(toSend);
+ return true;
+ } catch (Exception e) {
+ Log.e(TAG, "sendIntent " + this + " failed", e);
+ return false;
+ }
+ } else {
+ Log.e(TAG, "sendIntent " + this + " failed - no IntentSender or Intent to send");
+ return false;
+ }
+ }
+
+ /**
+ * Same as {@link #sendIntent(Context, Intent)}, but offers a userId field to use
+ * for launching the {@link #getIntent() intent} using
+ * {@link Activity#startActivityAsCaller(Intent, Bundle, int)} if the
+ * {@link #getIntentSender() IntentSender} is not present. If the IntentSender is present,
+ * it will be invoked as usual with its own calling identity.
+ *
+ * @hide internal use only.
+ */
+ public boolean sendIntentAsCaller(Activity context, Intent fillInIntent, int userId) {
+ if (fillInIntent != null) {
+ fillInIntent.migrateExtraStreamToClipData();
+ fillInIntent.prepareToLeaveProcess();
+ }
+ if (mIntentSender != null) {
+ try {
+ mIntentSender.sendIntent(context, 0, fillInIntent, null, null);
+ return true;
+ } catch (IntentSender.SendIntentException e) {
+ Log.e(TAG, "sendIntent " + this + " failed", e);
+ return false;
+ }
+ } else if (mIntent != null) {
+ try {
+ final Intent toSend = new Intent(mIntent);
+ toSend.fillIn(fillInIntent, 0);
+ context.startActivityAsCaller(toSend, null, userId);
+ return true;
+ } catch (Exception e) {
+ Log.e(TAG, "sendIntent " + this + " failed", e);
+ return false;
+ }
+ } else {
+ Log.e(TAG, "sendIntent " + this + " failed - no IntentSender or Intent to send");
+ return false;
+ }
+ }
+
+ /**
+ * The UserHandle is only used if we're launching a raw intent. The IntentSender will be
+ * launched with its associated identity.
+ *
+ * @hide Internal use only
+ */
+ public boolean sendIntentAsUser(Activity context, Intent fillInIntent, UserHandle user) {
+ if (fillInIntent != null) {
+ fillInIntent.migrateExtraStreamToClipData();
+ fillInIntent.prepareToLeaveProcess();
+ }
+ if (mIntentSender != null) {
+ try {
+ mIntentSender.sendIntent(context, 0, fillInIntent, null, null);
+ return true;
+ } catch (IntentSender.SendIntentException e) {
+ Log.e(TAG, "sendIntent " + this + " failed", e);
+ return false;
+ }
+ } else if (mIntent != null) {
+ try {
+ final Intent toSend = new Intent(mIntent);
+ toSend.fillIn(fillInIntent, 0);
+ context.startActivityAsUser(toSend, user);
+ return true;
+ } catch (Exception e) {
+ Log.e(TAG, "sendIntent " + this + " failed", e);
+ return false;
+ }
+ } else {
+ Log.e(TAG, "sendIntent " + this + " failed - no IntentSender or Intent to send");
return false;
}
}
@Override
public String toString() {
- return "ChooserTarget{" + mIntentSender.getCreatorPackage() + "'" + mTitle
+ return "ChooserTarget{"
+ + (mIntentSender != null ? mIntentSender.getCreatorPackage() : mIntent)
+ + ", "
+ + "'" + mTitle
+ "', " + mScore + "}";
}
diff --git a/core/java/android/service/chooser/ChooserTargetService.java b/core/java/android/service/chooser/ChooserTargetService.java
index 9188806..699bd0a 100644
--- a/core/java/android/service/chooser/ChooserTargetService.java
+++ b/core/java/android/service/chooser/ChooserTargetService.java
@@ -24,6 +24,7 @@
import android.content.IntentFilter;
import android.os.IBinder;
import android.os.RemoteException;
+import android.util.Log;
import java.util.List;
@@ -77,9 +78,26 @@
private final String TAG = ChooserTargetService.class.getSimpleName()
+ '[' + getClass().getSimpleName() + ']';
+ private static final boolean DEBUG = false;
+
+ /**
+ * The Intent action that a ChooserTargetService must respond to
+ */
@SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
public static final String SERVICE_INTERFACE = "android.service.chooser.ChooserTargetService";
+ /**
+ * The name of the <code>meta-data</code> element that must be present on an
+ * <code>activity</code> element in a manifest to link it to a ChooserTargetService
+ */
+ public static final String META_DATA_NAME = "android.service.chooser.chooser_target_service";
+
+ /**
+ * The permission that a ChooserTargetService must require in order to bind to it.
+ * If this permission is not enforced the system will skip that ChooserTargetService.
+ */
+ public static final String BIND_PERMISSION = "android.permission.BIND_CHOOSER_TARGET_SERVICE";
+
private IChooserTargetServiceWrapper mWrapper = null;
/**
@@ -105,7 +123,9 @@
@Override
public IBinder onBind(Intent intent) {
+ if (DEBUG) Log.d(TAG, "onBind " + intent);
if (!SERVICE_INTERFACE.equals(intent.getAction())) {
+ if (DEBUG) Log.d(TAG, "bad intent action " + intent.getAction() + "; returning null");
return null;
}
@@ -121,9 +141,14 @@
IntentFilter matchedFilter, IChooserTargetResult result) throws RemoteException {
List<ChooserTarget> targets = null;
try {
+ if (DEBUG) {
+ Log.d(TAG, "getChooserTargets calling onGetChooserTargets; "
+ + targetComponentName + " filter: " + matchedFilter);
+ }
targets = onGetChooserTargets(targetComponentName, matchedFilter);
} finally {
result.sendResult(targets);
+ if (DEBUG) Log.d(TAG, "Sent results");
}
}
}
diff --git a/core/java/android/service/gatekeeper/IGateKeeperService.aidl b/core/java/android/service/gatekeeper/IGateKeeperService.aidl
new file mode 100644
index 0000000..2f3e296
--- /dev/null
+++ b/core/java/android/service/gatekeeper/IGateKeeperService.aidl
@@ -0,0 +1,65 @@
+/*
+ * 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 android.service.gatekeeper;
+
+/**
+ * Interface for communication with GateKeeper, the
+ * secure password storage daemon.
+ *
+ * This must be kept manually in sync with system/core/gatekeeperd
+ * until AIDL can generate both C++ and Java bindings.
+ *
+ * @hide
+ */
+interface IGateKeeperService {
+ /**
+ * Enrolls a password, returning the handle to the enrollment to be stored locally.
+ * @param uid The Android user ID associated to this enrollment
+ * @param currentPasswordHandle The previously enrolled handle, or null if none
+ * @param currentPassword The previously enrolled plaintext password, or null if none.
+ * If provided, must verify against the currentPasswordHandle.
+ * @param desiredPassword The new desired password, for which a handle will be returned
+ * upon success.
+ * @return the handle corresponding to desiredPassword, or null
+ */
+ byte[] enroll(int uid, in byte[] currentPasswordHandle, in byte[] currentPassword,
+ in byte[] desiredPassword);
+
+ /**
+ * Verifies an enrolled handle against a provided, plaintext blob.
+ * @param uid The Android user ID associated to this enrollment
+ * @param enrolledPasswordHandle The handle against which the provided password will be
+ * verified.
+ * @param The plaintext blob to verify against enrolledPassword.
+ * @return True if the authentication was successful
+ */
+ boolean verify(int uid, in byte[] enrolledPasswordHandle,
+ in byte[] providedPassword);
+ /**
+ * Verifies an enrolled handle against a provided, plaintext blob.
+ * @param uid The Android user ID associated to this enrollment
+ * @param challenge a challenge to authenticate agaisnt the device credential. If successful
+ * authentication occurs, this value will be written to the returned
+ * authentication attestation.
+ * @param enrolledPasswordHandle The handle against which the provided password will be
+ * verified.
+ * @param The plaintext blob to verify against enrolledPassword.
+ * @return an opaque attestation of authentication on success, or null.
+ */
+ byte[] verifyChallenge(int uid, long challenge, in byte[] enrolledPasswordHandle,
+ in byte[] providedPassword);
+}
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 56eb510..1ed4779 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -654,8 +654,7 @@
}
String summary = "";
for (ZenRule automaticRule : config.automaticRules.values()) {
- if (automaticRule.enabled && !automaticRule.snoozing
- && automaticRule.isTrueOrUnknown()) {
+ if (automaticRule.isAutomaticActive()) {
if (summary.isEmpty()) {
summary = automaticRule.name;
} else {
@@ -745,9 +744,13 @@
component);
}
+ public boolean isAutomaticActive() {
+ return enabled && !snoozing && component != null && isTrueOrUnknown();
+ }
+
public boolean isTrueOrUnknown() {
- return condition == null || condition.state == Condition.STATE_TRUE
- || condition.state == Condition.STATE_UNKNOWN;
+ return condition != null && (condition.state == Condition.STATE_TRUE
+ || condition.state == Condition.STATE_UNKNOWN);
}
public static final Parcelable.Creator<ZenRule> CREATOR
diff --git a/core/java/android/widget/ActionMenuPresenter.java b/core/java/android/widget/ActionMenuPresenter.java
index f951dc2..e0b0e1f 100644
--- a/core/java/android/widget/ActionMenuPresenter.java
+++ b/core/java/android/widget/ActionMenuPresenter.java
@@ -40,7 +40,6 @@
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ListPopupWindow.ForwardingListener;
-import com.android.internal.transition.ActionBarTransition;
import com.android.internal.view.ActionBarPolicy;
import com.android.internal.view.menu.ActionMenuItemView;
import com.android.internal.view.menu.BaseMenuPresenter;
@@ -99,7 +98,30 @@
// The list of currently running animations on menu items.
private List<ItemAnimationInfo> mRunningItemAnimations = new ArrayList<ItemAnimationInfo>();
+ private ViewTreeObserver.OnPreDrawListener mItemAnimationPreDrawListener =
+ new ViewTreeObserver.OnPreDrawListener() {
+ @Override
+ public boolean onPreDraw() {
+ computeMenuItemAnimationInfo(false);
+ ((View) mMenuView).getViewTreeObserver().removeOnPreDrawListener(this);
+ runItemAnimations();
+ return true;
+ }
+ };
+ private View.OnAttachStateChangeListener mAttachStateChangeListener =
+ new View.OnAttachStateChangeListener() {
+ @Override
+ public void onViewAttachedToWindow(View v) {
+ }
+ @Override
+ public void onViewDetachedFromWindow(View v) {
+ ((View) mMenuView).getViewTreeObserver().removeOnPreDrawListener(
+ mItemAnimationPreDrawListener);
+ mPreLayoutItems.clear();
+ mPostLayoutItems.clear();
+ }
+ };
public ActionMenuPresenter(Context context) {
@@ -177,8 +199,15 @@
@Override
public MenuView getMenuView(ViewGroup root) {
+ MenuView oldMenuView = mMenuView;
MenuView result = super.getMenuView(root);
- ((ActionMenuView) result).setPresenter(this);
+ if (oldMenuView != result) {
+ ((ActionMenuView) result).setPresenter(this);
+ if (oldMenuView != null) {
+ ((View) oldMenuView).removeOnAttachStateChangeListener(mAttachStateChangeListener);
+ }
+ ((View) result).addOnAttachStateChangeListener(mAttachStateChangeListener);
+ }
return result;
}
@@ -226,11 +255,11 @@
* into the MenuItemLayoutInfo structure to store the appropriate position values.
*/
private void computeMenuItemAnimationInfo(boolean preLayout) {
- final ViewGroup menuViewParent = (ViewGroup) mMenuView;
- final int count = menuViewParent.getChildCount();
+ final ViewGroup menuView = (ViewGroup) mMenuView;
+ final int count = menuView.getChildCount();
SparseArray items = preLayout ? mPreLayoutItems : mPostLayoutItems;
for (int i = 0; i < count; ++i) {
- View child = menuViewParent.getChildAt(i);
+ View child = menuView.getChildAt(i);
final int id = child.getId();
if (id > 0 && child.getWidth() != 0 && child.getHeight() != 0) {
MenuItemLayoutInfo info = new MenuItemLayoutInfo(child, preLayout);
@@ -377,28 +406,16 @@
* which is then fed into runItemAnimations()
*/
private void setupItemAnimations() {
- final ViewGroup menuViewParent = (ViewGroup) mMenuView;
computeMenuItemAnimationInfo(true);
- final ViewTreeObserver observer = menuViewParent.getViewTreeObserver();
- if (observer != null) {
- observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
- @Override
- public boolean onPreDraw() {
- computeMenuItemAnimationInfo(false);
- observer.removeOnPreDrawListener(this);
- runItemAnimations();
- return true;
- }
- });
- }
+ ((View) mMenuView).getViewTreeObserver().
+ addOnPreDrawListener(mItemAnimationPreDrawListener);
}
@Override
public void updateMenuView(boolean cleared) {
final ViewGroup menuViewParent = (ViewGroup) ((View) mMenuView).getParent();
if (menuViewParent != null) {
-// setupItemAnimations();
- ActionBarTransition.beginDelayedTransition(menuViewParent);
+ setupItemAnimations();
}
super.updateMenuView(cleared);
@@ -736,8 +753,14 @@
}
public void setMenuView(ActionMenuView menuView) {
- mMenuView = menuView;
- menuView.initialize(mMenu);
+ if (menuView != mMenuView) {
+ if (mMenuView != null) {
+ ((View) mMenuView).removeOnAttachStateChangeListener(mAttachStateChangeListener);
+ }
+ mMenuView = menuView;
+ menuView.initialize(mMenu);
+ menuView.addOnAttachStateChangeListener(mAttachStateChangeListener);
+ }
}
public void setOverflowTintList(ColorStateList tint) {
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 29073be..1be05f3 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -3370,7 +3370,7 @@
// Parent's (TextView) previous position in window
private int mLastParentX, mLastParentY;
// Previous text character offset
- private int mPreviousOffset = -1;
+ protected int mPreviousOffset = -1;
// Previous text character offset
private boolean mPositionHasChanged = true;
// Minimum touch target size for handles
@@ -3830,8 +3830,6 @@
}
private class SelectionStartHandleView extends HandleView {
- // The previous offset this handle was at.
- private int mPrevOffset;
// Indicates whether the cursor is making adjustments within a word.
private boolean mInWord = false;
// Offset to track difference between touch and word boundary.
@@ -3879,7 +3877,7 @@
int end = getWordEnd(offset, true);
int start = getWordStart(offset);
- if (offset < mPrevOffset) {
+ if (offset < mPreviousOffset) {
// User is increasing the selection.
if (!mInWord || currLine < mPrevLine) {
// We're not in a word, or we're on a different line so we'll expand by
@@ -3888,21 +3886,19 @@
if (offset <= end - offsetToWord || currLine < mPrevLine) {
offset = start;
} else {
- offset = mPrevOffset;
+ offset = mPreviousOffset;
}
}
- mPrevOffset = offset;
mTouchWordOffset = Math.max(trueOffset - offset, 0);
mInWord = !isStartBoundary(offset);
positionCursor = true;
- } else if (offset - mTouchWordOffset > mPrevOffset) {
+ } else if (offset - mTouchWordOffset > mPreviousOffset) {
// User is shrinking the selection.
if (currLine > mPrevLine) {
// We're on a different line, so we'll snap to word boundaries.
offset = end;
}
offset -= mTouchWordOffset;
- mPrevOffset = offset;
mInWord = !isEndBoundary(offset);
positionCursor = true;
}
@@ -3936,8 +3932,6 @@
}
private class SelectionEndHandleView extends HandleView {
- // The previous offset this handle was at.
- private int mPrevOffset;
// Indicates whether the cursor is making adjustments within a word.
private boolean mInWord = false;
// Offset to track difference between touch and word boundary.
@@ -3986,7 +3980,7 @@
int end = getWordEnd(offset, true);
int start = getWordStart(offset);
- if (offset > mPrevOffset) {
+ if (offset > mPreviousOffset) {
// User is increasing the selection.
if (!mInWord || currLine > mPrevLine) {
// We're not in a word, or we're on a different line so we'll expand by
@@ -3995,21 +3989,19 @@
if (offset >= start + midPoint || currLine > mPrevLine) {
offset = end;
} else {
- offset = mPrevOffset;
+ offset = mPreviousOffset;
}
}
- mPrevOffset = offset;
mTouchWordOffset = Math.max(offset - trueOffset, 0);
mInWord = !isEndBoundary(offset);
positionCursor = true;
- } else if (offset + mTouchWordOffset < mPrevOffset) {
+ } else if (offset + mTouchWordOffset < mPreviousOffset) {
// User is shrinking the selection.
if (currLine > mPrevLine) {
// We're on a different line, so we'll snap to word boundaries.
offset = getWordStart(offset);
}
offset += mTouchWordOffset;
- mPrevOffset = offset;
positionCursor = true;
mInWord = !isStartBoundary(offset);
}
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 64bd6b6..8403e77 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -18,20 +18,87 @@
import android.app.Activity;
import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
import android.os.Parcelable;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.service.chooser.ChooserTarget;
+import android.service.chooser.ChooserTargetService;
+import android.service.chooser.IChooserTargetResult;
+import android.service.chooser.IChooserTargetService;
+import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+import java.util.List;
public class ChooserActivity extends ResolverActivity {
private static final String TAG = "ChooserActivity";
+ private static final boolean DEBUG = false;
+
+ private static final int QUERY_TARGET_LIMIT = 5;
+ private static final int WATCHDOG_TIMEOUT_MILLIS = 5000;
+
private Bundle mReplacementExtras;
private IntentSender mChosenComponentSender;
+ private ChooserTarget[] mCallerChooserTargets;
+
+ private final List<ChooserTargetServiceConnection> mServiceConnections = new ArrayList<>();
+
+ private static final int CHOOSER_TARGET_SERVICE_RESULT = 1;
+ private static final int CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT = 2;
+
+ private Handler mTargetResultHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case CHOOSER_TARGET_SERVICE_RESULT:
+ if (DEBUG) Log.d(TAG, "CHOOSER_TARGET_SERVICE_RESULT");
+ if (isDestroyed()) break;
+ final ServiceResultInfo sri = (ServiceResultInfo) msg.obj;
+ if (!mServiceConnections.contains(sri.connection)) {
+ Log.w(TAG, "ChooserTargetServiceConnection " + sri.connection
+ + " returned after being removed from active connections."
+ + " Have you considered returning results faster?");
+ break;
+ }
+ final ChooserListAdapter cla = (ChooserListAdapter) getAdapter();
+ cla.addServiceResults(sri.originalTarget, sri.resultTargets);
+ unbindService(sri.connection);
+ mServiceConnections.remove(sri.connection);
+ break;
+
+ case CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT:
+ if (DEBUG) {
+ Log.d(TAG, "CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT; unbinding services");
+ }
+ unbindRemainingServices();
+ break;
+
+ default:
+ super.handleMessage(msg);
+ }
+ }
+ };
+
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
@@ -42,7 +109,7 @@
super.onCreate(null);
return;
}
- Intent target = (Intent)targetParcelable;
+ Intent target = (Intent) targetParcelable;
if (target != null) {
modifyTargetIntent(target);
}
@@ -68,6 +135,22 @@
initialIntents[i] = in;
}
}
+
+ pa = intent.getParcelableArrayExtra(Intent.EXTRA_CHOOSER_TARGETS);
+ if (pa != null) {
+ final ChooserTarget[] targets = new ChooserTarget[pa.length];
+ for (int i = 0; i < pa.length; i++) {
+ if (!(pa[i] instanceof ChooserTarget)) {
+ Log.w("ChooserActivity", "Chooser target #" + i + " is not a ChooserTarget: " +
+ pa[i]);
+ finish();
+ super.onCreate(null);
+ return;
+ }
+ targets[i] = (ChooserTarget) pa[i];
+ }
+ mCallerChooserTargets = targets;
+ }
mChosenComponentSender = intent.getParcelableExtra(
Intent.EXTRA_CHOSEN_COMPONENT_INTENT_SENDER);
setSafeForwardingMode(true);
@@ -94,9 +177,9 @@
}
@Override
- public void onActivityStarted(Intent intent) {
+ void onActivityStarted(TargetInfo cti) {
if (mChosenComponentSender != null) {
- final ComponentName target = intent.getComponent();
+ final ComponentName target = cti.getResolvedComponentName();
if (target != null) {
final Intent fillIn = new Intent().putExtra(Intent.EXTRA_CHOSEN_COMPONENT, target);
try {
@@ -109,6 +192,16 @@
}
}
+ @Override
+ int getLayoutResource() {
+ return com.android.internal.R.layout.chooser_grid;
+ }
+
+ @Override
+ boolean shouldGetActivityMetadata() {
+ return true;
+ }
+
private void modifyTargetIntent(Intent in) {
final String action = in.getAction();
if (Intent.ACTION_SEND.equals(action) ||
@@ -117,4 +210,297 @@
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
}
}
+
+ void queryTargetServices(ChooserListAdapter adapter) {
+ final PackageManager pm = getPackageManager();
+ int targetsToQuery = 0;
+ for (int i = 0, N = adapter.getDisplayResolveInfoCount(); i < N; i++) {
+ final DisplayResolveInfo dri = adapter.getDisplayResolveInfo(i);
+ final ActivityInfo ai = dri.getResolveInfo().activityInfo;
+ final Bundle md = ai.metaData;
+ final String serviceName = md != null ? convertServiceName(ai.packageName,
+ md.getString(ChooserTargetService.META_DATA_NAME)) : null;
+ if (serviceName != null) {
+ final ComponentName serviceComponent = new ComponentName(
+ ai.packageName, serviceName);
+ final Intent serviceIntent = new Intent(ChooserTargetService.SERVICE_INTERFACE)
+ .setComponent(serviceComponent);
+
+ if (DEBUG) {
+ Log.d(TAG, "queryTargets found target with service " + serviceComponent);
+ }
+
+ try {
+ final String perm = pm.getServiceInfo(serviceComponent, 0).permission;
+ if (!ChooserTargetService.BIND_PERMISSION.equals(perm)) {
+ Log.w(TAG, "ChooserTargetService " + serviceComponent + " does not require"
+ + " permission " + ChooserTargetService.BIND_PERMISSION
+ + " - this service will not be queried for ChooserTargets."
+ + " add android:permission=\""
+ + ChooserTargetService.BIND_PERMISSION + "\""
+ + " to the <service> tag for " + serviceComponent
+ + " in the manifest.");
+ continue;
+ }
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Could not look up service " + serviceComponent, e);
+ continue;
+ }
+
+ final ChooserTargetServiceConnection conn = new ChooserTargetServiceConnection(dri);
+ if (bindServiceAsUser(serviceIntent, conn, BIND_AUTO_CREATE | BIND_NOT_FOREGROUND,
+ UserHandle.CURRENT)) {
+ if (DEBUG) {
+ Log.d(TAG, "Binding service connection for target " + dri
+ + " intent " + serviceIntent);
+ }
+ mServiceConnections.add(conn);
+ targetsToQuery++;
+ }
+ }
+ if (targetsToQuery >= QUERY_TARGET_LIMIT) {
+ if (DEBUG) Log.d(TAG, "queryTargets hit query target limit " + QUERY_TARGET_LIMIT);
+ break;
+ }
+ }
+
+ if (!mServiceConnections.isEmpty()) {
+ if (DEBUG) Log.d(TAG, "queryTargets setting watchdog timer for "
+ + WATCHDOG_TIMEOUT_MILLIS + "ms");
+ mTargetResultHandler.sendEmptyMessageDelayed(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT,
+ WATCHDOG_TIMEOUT_MILLIS);
+ }
+ }
+
+ private String convertServiceName(String packageName, String serviceName) {
+ if (TextUtils.isEmpty(serviceName)) {
+ return null;
+ }
+
+ final String fullName;
+ if (serviceName.startsWith(".")) {
+ // Relative to the app package. Prepend the app package name.
+ fullName = packageName + serviceName;
+ } else if (serviceName.indexOf('.') >= 0) {
+ // Fully qualified package name.
+ fullName = serviceName;
+ } else {
+ fullName = null;
+ }
+ return fullName;
+ }
+
+ void unbindRemainingServices() {
+ if (DEBUG) {
+ Log.d(TAG, "unbindRemainingServices, " + mServiceConnections.size() + " left");
+ }
+ for (int i = 0, N = mServiceConnections.size(); i < N; i++) {
+ final ChooserTargetServiceConnection conn = mServiceConnections.get(i);
+ if (DEBUG) Log.d(TAG, "unbinding " + conn);
+ unbindService(conn);
+ }
+ mServiceConnections.clear();
+ mTargetResultHandler.removeMessages(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT);
+ }
+
+ @Override
+ ResolveListAdapter createAdapter(Context context, Intent[] initialIntents,
+ List<ResolveInfo> rList, int launchedFromUid, boolean filterLastUsed) {
+ final ChooserListAdapter adapter = new ChooserListAdapter(context, initialIntents, rList,
+ launchedFromUid, filterLastUsed);
+ if (DEBUG) Log.d(TAG, "Adapter created; querying services");
+ queryTargetServices(adapter);
+ return adapter;
+ }
+
+ class ChooserTargetInfo implements TargetInfo {
+ private final TargetInfo mSourceInfo;
+ private final ChooserTarget mChooserTarget;
+ private final Drawable mDisplayIcon;
+
+ public ChooserTargetInfo(TargetInfo sourceInfo, ChooserTarget chooserTarget) {
+ mSourceInfo = sourceInfo;
+ mChooserTarget = chooserTarget;
+ mDisplayIcon = new BitmapDrawable(getResources(), chooserTarget.getIcon());
+ }
+
+ @Override
+ public Intent getResolvedIntent() {
+ final Intent targetIntent = mChooserTarget.getIntent();
+ return targetIntent != null ? targetIntent : mSourceInfo.getResolvedIntent();
+ }
+
+ @Override
+ public ComponentName getResolvedComponentName() {
+ return mSourceInfo.getResolvedComponentName();
+ }
+
+ @Override
+ public boolean start(Activity activity, Bundle options) {
+ return mChooserTarget.sendIntent(activity, mSourceInfo.getResolvedIntent());
+ }
+
+ @Override
+ public boolean startAsCaller(Activity activity, Bundle options, int userId) {
+ return mChooserTarget.sendIntentAsCaller(activity, mSourceInfo.getResolvedIntent(),
+ userId);
+ }
+
+ @Override
+ public boolean startAsUser(Activity activity, Bundle options, UserHandle user) {
+ return mChooserTarget.sendIntentAsUser(activity, mSourceInfo.getResolvedIntent(), user);
+ }
+
+ @Override
+ public ResolveInfo getResolveInfo() {
+ return mSourceInfo.getResolveInfo();
+ }
+
+ @Override
+ public CharSequence getDisplayLabel() {
+ return mChooserTarget.getTitle();
+ }
+
+ @Override
+ public CharSequence getExtendedInfo() {
+ return mSourceInfo.getExtendedInfo();
+ }
+
+ @Override
+ public Drawable getDisplayIcon() {
+ return mDisplayIcon;
+ }
+ }
+
+ public class ChooserListAdapter extends ResolveListAdapter {
+ private final List<ChooserTargetInfo> mServiceTargets = new ArrayList<>();
+
+ public ChooserListAdapter(Context context, Intent[] initialIntents, List<ResolveInfo> rList,
+ int launchedFromUid, boolean filterLastUsed) {
+ super(context, initialIntents, rList, launchedFromUid, filterLastUsed);
+ }
+
+ @Override
+ public boolean showsExtendedInfo(TargetInfo info) {
+ // Reserve space to show extended info if any one of the items in the adapter has
+ // extended info. This keeps grid item sizes uniform.
+ return hasExtendedInfo();
+ }
+
+ @Override
+ public View createView(ViewGroup parent) {
+ return mInflater.inflate(
+ com.android.internal.R.layout.resolve_grid_item, parent, false);
+ }
+
+ @Override
+ public void onListRebuilt() {
+ if (mServiceTargets != null) {
+ pruneServiceTargets();
+ }
+ }
+
+ @Override
+ public int getCount() {
+ int count = super.getCount();
+ if (mServiceTargets != null) {
+ count += mServiceTargets.size();
+ }
+ return count;
+ }
+
+ @Override
+ public TargetInfo getItem(int position) {
+ int offset = 0;
+ if (mServiceTargets != null) {
+ final int serviceTargetCount = mServiceTargets.size();
+ if (position < serviceTargetCount) {
+ return mServiceTargets.get(position);
+ }
+ offset += serviceTargetCount;
+ }
+ return super.getItem(position - offset);
+ }
+
+ public void addServiceResults(DisplayResolveInfo origTarget, List<ChooserTarget> targets) {
+ if (DEBUG) Log.d(TAG, "addServiceResults " + origTarget + ", " + targets.size()
+ + " targets");
+ for (int i = 0, N = targets.size(); i < N; i++) {
+ mServiceTargets.add(new ChooserTargetInfo(origTarget, targets.get(i)));
+ }
+
+ // TODO: Maintain sort by ranking scores.
+
+ notifyDataSetChanged();
+ }
+
+ private void pruneServiceTargets() {
+ if (DEBUG) Log.d(TAG, "pruneServiceTargets");
+ for (int i = mServiceTargets.size() - 1; i >= 0; i--) {
+ final ChooserTargetInfo cti = mServiceTargets.get(i);
+ if (!hasResolvedTarget(cti.getResolveInfo())) {
+ if (DEBUG) Log.d(TAG, " => " + i + " " + cti);
+ mServiceTargets.remove(i);
+ }
+ }
+ }
+ }
+
+ class ChooserTargetServiceConnection implements ServiceConnection {
+ private final DisplayResolveInfo mOriginalTarget;
+
+ private final IChooserTargetResult mChooserTargetResult = new IChooserTargetResult.Stub() {
+ @Override
+ public void sendResult(List<ChooserTarget> targets) throws RemoteException {
+ final Message msg = Message.obtain();
+ msg.what = CHOOSER_TARGET_SERVICE_RESULT;
+ msg.obj = new ServiceResultInfo(mOriginalTarget, targets,
+ ChooserTargetServiceConnection.this);
+ mTargetResultHandler.sendMessage(msg);
+ }
+ };
+
+ public ChooserTargetServiceConnection(DisplayResolveInfo dri) {
+ mOriginalTarget = dri;
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ if (DEBUG) Log.d(TAG, "onServiceConnected: " + name);
+ final IChooserTargetService icts = IChooserTargetService.Stub.asInterface(service);
+ try {
+ icts.getChooserTargets(mOriginalTarget.getResolvedComponentName(),
+ mOriginalTarget.getResolveInfo().filter, mChooserTargetResult);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Querying ChooserTargetService " + name + " failed.", e);
+ unbindService(this);
+ mServiceConnections.remove(this);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ if (DEBUG) Log.d(TAG, "onServiceDisconnected: " + name);
+ unbindService(this);
+ mServiceConnections.remove(this);
+ }
+
+ @Override
+ public String toString() {
+ return mOriginalTarget.getResolveInfo().activityInfo.toString();
+ }
+ }
+
+ static class ServiceResultInfo {
+ public final DisplayResolveInfo originalTarget;
+ public final List<ChooserTarget> resultTargets;
+ public final ChooserTargetServiceConnection connection;
+
+ public ServiceResultInfo(DisplayResolveInfo ot, List<ChooserTarget> rt,
+ ChooserTargetServiceConnection c) {
+ originalTarget = ot;
+ resultTargets = rt;
+ connection = c;
+ }
+ }
}
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 6b35f3f..3cd69a1 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -25,6 +25,7 @@
import android.text.TextUtils;
import android.util.Slog;
import android.widget.AbsListView;
+import android.widget.GridView;
import com.android.internal.R;
import com.android.internal.content.PackageMonitor;
@@ -91,15 +92,14 @@
private PackageManager mPm;
private boolean mSafeForwardingMode;
private boolean mAlwaysUseOption;
- private boolean mShowExtended;
+ private AbsListView mAdapterView;
private ListView mListView;
+ private GridView mGridView;
private Button mAlwaysButton;
private Button mOnceButton;
private View mProfileView;
private int mIconDpi;
- private int mIconSize;
- private int mMaxColumns;
- private int mLastSelected = ListView.INVALID_POSITION;
+ private int mLastSelected = AbsListView.INVALID_POSITION;
private boolean mResolvingHome = false;
private int mProfileSwitchMessageId = -1;
private Intent mIntent;
@@ -192,7 +192,7 @@
}
/**
- * Compatibility version for other bundled services that use this ocerload without
+ * Compatibility version for other bundled services that use this overload without
* a default title resource
*/
protected void onCreate(Bundle savedInstanceState, Intent intent,
@@ -223,18 +223,14 @@
final long sinceTime = System.currentTimeMillis() - USAGE_STATS_PERIOD;
mStats = mUsm.queryAndAggregateUsageStats(sinceTime, System.currentTimeMillis());
- mMaxColumns = getResources().getInteger(R.integer.config_maxResolverActivityColumns);
-
mPackageMonitor.register(this, getMainLooper(), false);
mRegistered = true;
final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
mIconDpi = am.getLauncherLargeIconDensity();
- mIconSize = am.getLauncherLargeIconSize();
mIntent = new Intent(intent);
- mAdapter = new ResolveListAdapter(this, initialIntents, rList,
- mLaunchedFromUid, alwaysUseOption);
+ mAdapter = createAdapter(this, initialIntents, rList, mLaunchedFromUid, alwaysUseOption);
final int layoutId;
final boolean useHeader;
@@ -244,7 +240,7 @@
useHeader = true;
} else {
useHeader = false;
- layoutId = R.layout.resolver_list;
+ layoutId = getLayoutResource();
}
mAlwaysUseOption = alwaysUseOption;
@@ -257,21 +253,30 @@
int count = mAdapter.mList.size();
if (count > 1 || (count == 1 && mAdapter.getOtherProfile() != null)) {
setContentView(layoutId);
- mListView = (ListView) findViewById(R.id.resolver_list);
- mListView.setAdapter(mAdapter);
- mListView.setOnItemClickListener(this);
- mListView.setOnItemLongClickListener(new ItemLongClickListener());
+ mAdapterView = (AbsListView) findViewById(R.id.resolver_list);
+ mAdapterView.setAdapter(mAdapter);
+ mAdapterView.setOnItemClickListener(this);
+ mAdapterView.setOnItemLongClickListener(new ItemLongClickListener());
- if (alwaysUseOption) {
- mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
+ // Initialize the different types of collection views we may have. Depending
+ // on which ones are initialized later we'll configure different properties.
+ if (mAdapterView instanceof ListView) {
+ mListView = (ListView) mAdapterView;
+ }
+ if (mAdapterView instanceof GridView) {
+ mGridView = (GridView) mAdapterView;
}
- if (useHeader) {
+ if (alwaysUseOption) {
+ mAdapterView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
+ }
+
+ if (useHeader && mListView != null) {
mListView.addHeaderView(LayoutInflater.from(this).inflate(
R.layout.resolver_different_item_header, mListView, false));
}
} else if (count == 1) {
- safelyStartActivity(mAdapter.intentForPosition(0, false));
+ safelyStartActivity(mAdapter.targetInfoForPosition(0, false));
mPackageMonitor.unregister();
mRegistered = false;
finish();
@@ -282,8 +287,8 @@
final TextView empty = (TextView) findViewById(R.id.empty);
empty.setVisibility(View.VISIBLE);
- mListView = (ListView) findViewById(R.id.resolver_list);
- mListView.setVisibility(View.GONE);
+ mAdapterView = (AbsListView) findViewById(R.id.resolver_list);
+ mAdapterView.setVisibility(View.GONE);
}
// Prevent the Resolver window from becoming the top fullscreen window and thus from taking
// control of the system bars.
@@ -308,12 +313,30 @@
titleView.setText(title);
}
setTitle(title);
+
+ // Try to initialize the title icon if we have a view for it and a title to match
+ final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon);
+ if (titleIcon != null) {
+ final String referrerPackage = getReferrerPackageName();
+ ApplicationInfo ai = null;
+ try {
+ if (!TextUtils.isEmpty(referrerPackage)) {
+ ai = mPm.getApplicationInfo(referrerPackage, 0);
+ }
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Could not find referrer package " + referrerPackage);
+ }
+
+ if (ai != null) {
+ titleIcon.setImageDrawable(ai.loadIcon(mPm));
+ }
+ }
}
final ImageView iconView = (ImageView) findViewById(R.id.icon);
final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem();
if (iconView != null && iconInfo != null) {
- new LoadIconIntoViewTask(iconView).execute(iconInfo);
+ new LoadIconIntoViewTask(iconInfo, iconView).execute();
}
if (alwaysUseOption || mAdapter.hasFilteredItem()) {
@@ -345,8 +368,7 @@
// Do not show the profile switch message anymore.
mProfileSwitchMessageId = -1;
- final Intent intent = intentForDisplayResolveInfo(dri);
- onIntentSelected(dri.ri, intent, false);
+ onTargetSelected(dri, false);
finish();
}
});
@@ -354,17 +376,29 @@
}
}
+ private String getReferrerPackageName() {
+ final Uri referrer = getReferrer();
+ if (referrer != null && "android-app".equals(referrer.getScheme())) {
+ return referrer.getHost();
+ }
+ return null;
+ }
+
+ int getLayoutResource() {
+ return R.layout.resolver_list;
+ }
+
void bindProfileView() {
final DisplayResolveInfo dri = mAdapter.getOtherProfile();
if (dri != null) {
mProfileView.setVisibility(View.VISIBLE);
final ImageView icon = (ImageView) mProfileView.findViewById(R.id.icon);
final TextView text = (TextView) mProfileView.findViewById(R.id.text1);
- if (dri.displayIcon == null) {
- new LoadIconTask().execute(dri);
+ if (!dri.hasDisplayIcon()) {
+ new LoadIconIntoViewTask(dri, icon).execute();
}
- icon.setImageDrawable(dri.displayIcon);
- text.setText(dri.displayLabel);
+ icon.setImageDrawable(dri.getDisplayIcon());
+ text.setText(dri.getDisplayLabel());
} else {
mProfileView.setVisibility(View.GONE);
}
@@ -408,8 +442,9 @@
if (title == ActionTitle.DEFAULT && defaultTitleRes != 0) {
return getString(defaultTitleRes);
} else {
- return named ? getString(title.namedTitleRes, mAdapter.getFilteredItem().displayLabel) :
- getString(title.titleRes);
+ return named
+ ? getString(title.namedTitleRes, mAdapter.getFilteredItem().getDisplayLabel())
+ : getString(title.titleRes);
}
}
@@ -490,31 +525,33 @@
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
if (mAlwaysUseOption) {
- final int checkedPos = mListView.getCheckedItemPosition();
+ final int checkedPos = mAdapterView.getCheckedItemPosition();
final boolean hasValidSelection = checkedPos != ListView.INVALID_POSITION;
mLastSelected = checkedPos;
setAlwaysButtonEnabled(hasValidSelection, checkedPos, true);
mOnceButton.setEnabled(hasValidSelection);
if (hasValidSelection) {
- mListView.setSelection(checkedPos);
+ mAdapterView.setSelection(checkedPos);
}
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- position -= mListView.getHeaderViewsCount();
+ if (mListView != null) {
+ position -= mListView.getHeaderViewsCount();
+ }
if (position < 0) {
// Header views don't count.
return;
}
- final int checkedPos = mListView.getCheckedItemPosition();
+ final int checkedPos = mAdapterView.getCheckedItemPosition();
final boolean hasValidSelection = checkedPos != ListView.INVALID_POSITION;
if (mAlwaysUseOption && (!hasValidSelection || mLastSelected != checkedPos)) {
setAlwaysButtonEnabled(hasValidSelection, checkedPos, true);
mOnceButton.setEnabled(hasValidSelection);
if (hasValidSelection) {
- mListView.smoothScrollToPosition(checkedPos);
+ mAdapterView.smoothScrollToPosition(checkedPos);
}
mLastSelected = checkedPos;
} else {
@@ -570,7 +607,7 @@
public void onButtonClick(View v) {
final int id = v.getId();
startSelected(mAlwaysUseOption ?
- mListView.getCheckedItemPosition() : mAdapter.getFilteredPosition(),
+ mAdapterView.getCheckedItemPosition() : mAdapter.getFilteredPosition(),
id == R.id.button_always,
mAlwaysUseOption);
}
@@ -588,8 +625,8 @@
return;
}
- Intent intent = mAdapter.intentForPosition(which, filtered);
- onIntentSelected(ri, intent, always);
+ TargetInfo target = mAdapter.targetInfoForPosition(which, filtered);
+ onTargetSelected(target, always);
finish();
}
@@ -600,8 +637,12 @@
return defIntent;
}
- protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) {
- if ((mAlwaysUseOption || mAdapter.hasFilteredItem()) && mAdapter.mOrigResolveList != null) {
+ protected void onTargetSelected(TargetInfo target, boolean alwaysCheck) {
+ final ResolveInfo ri = target.getResolveInfo();
+ final Intent intent = target != null ? target.getResolvedIntent() : null;
+
+ if (intent != null && (mAlwaysUseOption || mAdapter.hasFilteredItem())
+ && mAdapter.mOrigResolveList != null) {
// Build a reasonable intent filter, based on what matched.
IntentFilter filter = new IntentFilter();
String action = intent.getAction();
@@ -617,7 +658,7 @@
}
filter.addCategory(Intent.CATEGORY_DEFAULT);
- int cat = ri.match&IntentFilter.MATCH_CATEGORY_MASK;
+ int cat = ri.match & IntentFilter.MATCH_CATEGORY_MASK;
Uri data = intent.getData();
if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
String mimeType = intent.resolveType(this);
@@ -726,25 +767,27 @@
}
}
- if (intent != null) {
- safelyStartActivity(intent);
+ if (target != null) {
+ safelyStartActivity(target);
}
}
- public void safelyStartActivity(Intent intent) {
+ void safelyStartActivity(TargetInfo cti) {
// If needed, show that intent is forwarded
// from managed profile to owner or other way around.
if (mProfileSwitchMessageId != -1) {
Toast.makeText(this, getString(mProfileSwitchMessageId), Toast.LENGTH_LONG).show();
}
if (!mSafeForwardingMode) {
- startActivity(intent);
- onActivityStarted(intent);
+ if (cti.start(this, null)) {
+ onActivityStarted(cti);
+ }
return;
}
try {
- startActivityAsCaller(intent, null, UserHandle.USER_NULL);
- onActivityStarted(intent);
+ if (cti.startAsCaller(this, null, UserHandle.USER_NULL)) {
+ onActivityStarted(cti);
+ }
} catch (RuntimeException e) {
String launchedFromPackage;
try {
@@ -759,51 +802,197 @@
}
}
- public void onActivityStarted(Intent intent) {
+ void onActivityStarted(TargetInfo cti) {
// Do nothing
}
+ boolean shouldGetActivityMetadata() {
+ return false;
+ }
+
void showAppDetails(ResolveInfo ri) {
Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
.setData(Uri.fromParts("package", ri.activityInfo.packageName, null))
- .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
startActivity(in);
}
- Intent intentForDisplayResolveInfo(DisplayResolveInfo dri) {
- Intent intent = new Intent(dri.origIntent != null ? dri.origIntent :
- getReplacementIntent(dri.ri.activityInfo, mIntent));
- intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
- |Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
- ActivityInfo ai = dri.ri.activityInfo;
- intent.setComponent(new ComponentName(
- ai.applicationInfo.packageName, ai.name));
- return intent;
+ ResolveListAdapter createAdapter(Context context, Intent[] initialIntents,
+ List<ResolveInfo> rList, int launchedFromUid, boolean filterLastUsed) {
+ return new ResolveListAdapter(context, initialIntents, rList, launchedFromUid,
+ filterLastUsed);
}
- private final class DisplayResolveInfo {
- ResolveInfo ri;
- CharSequence displayLabel;
- Drawable displayIcon;
- CharSequence extendedInfo;
- Intent origIntent;
+ ResolveListAdapter getAdapter() {
+ return mAdapter;
+ }
+
+ final class DisplayResolveInfo implements TargetInfo {
+ private final ResolveInfo mResolveInfo;
+ private final CharSequence mDisplayLabel;
+ private Drawable mDisplayIcon;
+ private final CharSequence mExtendedInfo;
+ private final Intent mResolvedIntent;
DisplayResolveInfo(ResolveInfo pri, CharSequence pLabel,
CharSequence pInfo, Intent pOrigIntent) {
- ri = pri;
- displayLabel = pLabel;
- extendedInfo = pInfo;
- origIntent = pOrigIntent;
+ mResolveInfo = pri;
+ mDisplayLabel = pLabel;
+ mExtendedInfo = pInfo;
+
+ final Intent intent = new Intent(pOrigIntent != null ? pOrigIntent :
+ getReplacementIntent(pri.activityInfo, mIntent));
+ intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
+ | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
+ final ActivityInfo ai = mResolveInfo.activityInfo;
+ intent.setComponent(new ComponentName(ai.applicationInfo.packageName, ai.name));
+
+ mResolvedIntent = intent;
+ }
+
+ public ResolveInfo getResolveInfo() {
+ return mResolveInfo;
+ }
+
+ public CharSequence getDisplayLabel() {
+ return mDisplayLabel;
+ }
+
+ public Drawable getDisplayIcon() {
+ return mDisplayIcon;
+ }
+
+ public void setDisplayIcon(Drawable icon) {
+ mDisplayIcon = icon;
+ }
+
+ public boolean hasDisplayIcon() {
+ return mDisplayIcon != null;
+ }
+
+ public CharSequence getExtendedInfo() {
+ return mExtendedInfo;
+ }
+
+ public Intent getResolvedIntent() {
+ return mResolvedIntent;
+ }
+
+ @Override
+ public ComponentName getResolvedComponentName() {
+ return new ComponentName(mResolveInfo.activityInfo.packageName,
+ mResolveInfo.activityInfo.name);
+ }
+
+ @Override
+ public boolean start(Activity activity, Bundle options) {
+ activity.startActivity(mResolvedIntent, options);
+ return true;
+ }
+
+ @Override
+ public boolean startAsCaller(Activity activity, Bundle options, int userId) {
+ activity.startActivityAsCaller(mResolvedIntent, options, userId);
+ return true;
+ }
+
+ @Override
+ public boolean startAsUser(Activity activity, Bundle options, UserHandle user) {
+ activity.startActivityAsUser(mResolvedIntent, options, user);
+ return false;
}
}
- private final class ResolveListAdapter extends BaseAdapter {
+ /**
+ * A single target as represented in the chooser.
+ */
+ public interface TargetInfo {
+ /**
+ * Get the resolved intent that represents this target. Note that this may not be the
+ * intent that will be launched by calling one of the <code>start</code> methods provided;
+ * this is the intent that will be credited with the launch.
+ *
+ * @return the resolved intent for this target
+ */
+ public Intent getResolvedIntent();
+
+ /**
+ * Get the resolved component name that represents this target. Note that this may not
+ * be the component that will be directly launched by calling one of the <code>start</code>
+ * methods provided; this is the component that will be credited with the launch.
+ *
+ * @return the resolved ComponentName for this target
+ */
+ public ComponentName getResolvedComponentName();
+
+ /**
+ * Start the activity referenced by this target.
+ *
+ * @param activity calling Activity performing the launch
+ * @param options ActivityOptions bundle
+ * @return true if the start completed successfully
+ */
+ public boolean start(Activity activity, Bundle options);
+
+ /**
+ * Start the activity referenced by this target as if the ResolverActivity's caller
+ * was performing the start operation.
+ *
+ * @param activity calling Activity (actually) performing the launch
+ * @param options ActivityOptions bundle
+ * @param userId userId to start as or {@link UserHandle#USER_NULL} for activity's caller
+ * @return true if the start completed successfully
+ */
+ public boolean startAsCaller(Activity activity, Bundle options, int userId);
+
+ /**
+ * Start the activity referenced by this target as a given user.
+ *
+ * @param activity calling activity performing the launch
+ * @param options ActivityOptions bundle
+ * @param user handle for the user to start the activity as
+ * @return true if the start completed successfully
+ */
+ public boolean startAsUser(Activity activity, Bundle options, UserHandle user);
+
+ /**
+ * Return the ResolveInfo about how and why this target matched the original query
+ * for available targets.
+ *
+ * @return ResolveInfo representing this target's match
+ */
+ public ResolveInfo getResolveInfo();
+
+ /**
+ * Return the human-readable text label for this target.
+ *
+ * @return user-visible target label
+ */
+ public CharSequence getDisplayLabel();
+
+ /**
+ * Return any extended info for this target. This may be used to disambiguate
+ * otherwise identical targets.
+ *
+ * @return human-readable disambig string or null if none present
+ */
+ public CharSequence getExtendedInfo();
+
+ /**
+ * @return The drawable that should be used to represent this target
+ */
+ public Drawable getDisplayIcon();
+ }
+
+ class ResolveListAdapter extends BaseAdapter {
private final Intent[] mInitialIntents;
private final List<ResolveInfo> mBaseResolveList;
private ResolveInfo mLastChosen;
private DisplayResolveInfo mOtherProfile;
private final int mLaunchedFromUid;
- private final LayoutInflater mInflater;
+ private boolean mHasExtendedInfo;
+
+ protected final LayoutInflater mInflater;
List<DisplayResolveInfo> mList;
List<ResolveInfo> mOrigResolveList;
@@ -817,7 +1006,7 @@
mBaseResolveList = rList;
mLaunchedFromUid = launchedFromUid;
mInflater = LayoutInflater.from(context);
- mList = new ArrayList<DisplayResolveInfo>();
+ mList = new ArrayList<>();
mFilterLastUsed = filterLastUsed;
rebuildList();
}
@@ -871,9 +1060,11 @@
if (mBaseResolveList != null) {
currentResolveList = mOrigResolveList = mBaseResolveList;
} else {
- currentResolveList = mOrigResolveList = mPm.queryIntentActivities(
- mIntent, PackageManager.MATCH_DEFAULT_ONLY
- | (mFilterLastUsed ? PackageManager.GET_RESOLVED_FILTER : 0));
+ currentResolveList = mOrigResolveList = mPm.queryIntentActivities(mIntent,
+ PackageManager.MATCH_DEFAULT_ONLY
+ | (mFilterLastUsed ? PackageManager.GET_RESOLVED_FILTER : 0)
+ | (shouldGetActivityMetadata() ? PackageManager.GET_META_DATA : 0)
+ );
// Filter out any activities that the launched uid does not
// have permission for. We don't do this when we have an explicit
// list of resolved activities, because that only happens when
@@ -961,7 +1152,7 @@
r0 = currentResolveList.get(0);
int start = 0;
CharSequence r0Label = r0.loadLabel(mPm);
- mShowExtended = false;
+ mHasExtendedInfo = false;
for (int i = 1; i < N; i++) {
if (r0Label == null) {
r0Label = r0.activityInfo.packageName;
@@ -989,6 +1180,12 @@
mLastChosenPosition = -1;
mFilterLastUsed = false;
}
+
+ onListRebuilt();
+ }
+
+ public void onListRebuilt() {
+ // This space for rent
}
private void processGroup(List<ResolveInfo> rList, int start, int end, ResolveInfo ro,
@@ -1000,7 +1197,7 @@
addResolveInfo(new DisplayResolveInfo(ro, roLabel, null, null));
updateLastChosenPosition(ro);
} else {
- mShowExtended = true;
+ mHasExtendedInfo = true;
boolean usePkg = false;
CharSequence startApp = ro.activityInfo.applicationInfo.loadLabel(mPm);
if (startApp == null) {
@@ -1049,7 +1246,7 @@
}
private void addResolveInfo(DisplayResolveInfo dri) {
- if (dri.ri.targetUserId != UserHandle.USER_CURRENT && mOtherProfile == null) {
+ if (dri.mResolveInfo.targetUserId != UserHandle.USER_CURRENT && mOtherProfile == null) {
// So far we only support a single other profile at a time.
// The first one we see gets special treatment.
mOtherProfile = dri;
@@ -1059,12 +1256,11 @@
}
public ResolveInfo resolveInfoForPosition(int position, boolean filtered) {
- return (filtered ? getItem(position) : mList.get(position)).ri;
+ return (filtered ? getItem(position) : mList.get(position)).getResolveInfo();
}
- public Intent intentForPosition(int position, boolean filtered) {
- DisplayResolveInfo dri = filtered ? getItem(position) : mList.get(position);
- return intentForDisplayResolveInfo(dri);
+ public TargetInfo targetInfoForPosition(int position, boolean filtered) {
+ return filtered ? getItem(position) : mList.get(position);
}
public int getCount() {
@@ -1075,7 +1271,7 @@
return result;
}
- public DisplayResolveInfo getItem(int position) {
+ public TargetInfo getItem(int position) {
if (mFilterLastUsed && mLastChosenPosition >= 0 && position >= mLastChosenPosition) {
position++;
}
@@ -1086,11 +1282,31 @@
return position;
}
- public View getView(int position, View convertView, ViewGroup parent) {
+ public boolean hasExtendedInfo() {
+ return mHasExtendedInfo;
+ }
+
+ public boolean hasResolvedTarget(ResolveInfo info) {
+ for (int i = 0, N = mList.size(); i < N; i++) {
+ if (info.equals(mList.get(i).getResolveInfo())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected int getDisplayResolveInfoCount() {
+ return mList.size();
+ }
+
+ protected DisplayResolveInfo getDisplayResolveInfo(int index) {
+ return mList.get(index);
+ }
+
+ public final View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
- view = mInflater.inflate(
- com.android.internal.R.layout.resolve_list_item, parent, false);
+ view = createView(parent);
final ViewHolder holder = new ViewHolder(view);
view.setTag(holder);
@@ -1099,19 +1315,29 @@
return view;
}
- private final void bindView(View view, DisplayResolveInfo info) {
+ public View createView(ViewGroup parent) {
+ return mInflater.inflate(
+ com.android.internal.R.layout.resolve_list_item, parent, false);
+ }
+
+ public boolean showsExtendedInfo(TargetInfo info) {
+ return !TextUtils.isEmpty(info.getExtendedInfo());
+ }
+
+ private final void bindView(View view, TargetInfo info) {
final ViewHolder holder = (ViewHolder) view.getTag();
- holder.text.setText(info.displayLabel);
- if (mShowExtended) {
+ holder.text.setText(info.getDisplayLabel());
+ if (showsExtendedInfo(info)) {
holder.text2.setVisibility(View.VISIBLE);
- holder.text2.setText(info.extendedInfo);
+ holder.text2.setText(info.getExtendedInfo());
} else {
holder.text2.setVisibility(View.GONE);
}
- if (info.displayIcon == null) {
- new LoadIconTask().execute(info);
+ if (info instanceof DisplayResolveInfo
+ && !((DisplayResolveInfo) info).hasDisplayIcon()) {
+ new LoadAdapterIconTask((DisplayResolveInfo) info).execute();
}
- holder.icon.setImageDrawable(info.displayIcon);
+ holder.icon.setImageDrawable(info.getDisplayIcon());
}
}
@@ -1131,7 +1357,9 @@
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
- position -= mListView.getHeaderViewsCount();
+ if (mListView != null) {
+ position -= mListView.getHeaderViewsCount();
+ }
if (position < 0) {
// Header views don't count.
return false;
@@ -1143,44 +1371,53 @@
}
- class LoadIconTask extends AsyncTask<DisplayResolveInfo, Void, DisplayResolveInfo> {
- @Override
- protected DisplayResolveInfo doInBackground(DisplayResolveInfo... params) {
- final DisplayResolveInfo info = params[0];
- if (info.displayIcon == null) {
- info.displayIcon = loadIconForResolveInfo(info.ri);
- }
- return info;
+ abstract class LoadIconTask extends AsyncTask<Void, Void, Drawable> {
+ protected final DisplayResolveInfo mDisplayResolveInfo;
+ private final ResolveInfo mResolveInfo;
+
+ public LoadIconTask(DisplayResolveInfo dri) {
+ mDisplayResolveInfo = dri;
+ mResolveInfo = dri.getResolveInfo();
}
@Override
- protected void onPostExecute(DisplayResolveInfo info) {
- if (mProfileView != null && mAdapter.getOtherProfile() == info) {
+ protected Drawable doInBackground(Void... params) {
+ return loadIconForResolveInfo(mResolveInfo);
+ }
+
+ @Override
+ protected void onPostExecute(Drawable d) {
+ mDisplayResolveInfo.setDisplayIcon(d);
+ }
+ }
+
+ class LoadAdapterIconTask extends LoadIconTask {
+ public LoadAdapterIconTask(DisplayResolveInfo dri) {
+ super(dri);
+ }
+
+ @Override
+ protected void onPostExecute(Drawable d) {
+ super.onPostExecute(d);
+ if (mProfileView != null && mAdapter.getOtherProfile() == mDisplayResolveInfo) {
bindProfileView();
}
mAdapter.notifyDataSetChanged();
}
}
- class LoadIconIntoViewTask extends AsyncTask<DisplayResolveInfo, Void, DisplayResolveInfo> {
- final ImageView mTargetView;
+ class LoadIconIntoViewTask extends LoadIconTask {
+ private final ImageView mTargetView;
- public LoadIconIntoViewTask(ImageView target) {
+ public LoadIconIntoViewTask(DisplayResolveInfo dri, ImageView target) {
+ super(dri);
mTargetView = target;
}
@Override
- protected DisplayResolveInfo doInBackground(DisplayResolveInfo... params) {
- final DisplayResolveInfo info = params[0];
- if (info.displayIcon == null) {
- info.displayIcon = loadIconForResolveInfo(info.ri);
- }
- return info;
- }
-
- @Override
- protected void onPostExecute(DisplayResolveInfo info) {
- mTargetView.setImageDrawable(info.displayIcon);
+ protected void onPostExecute(Drawable d) {
+ super.onPostExecute(d);
+ mTargetView.setImageDrawable(d);
}
}
diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java
index e32a3a2..22d35f2 100644
--- a/core/java/com/android/internal/backup/LocalTransport.java
+++ b/core/java/com/android/internal/backup/LocalTransport.java
@@ -45,8 +45,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
-import static android.system.OsConstants.*;
+import static android.system.OsConstants.SEEK_CUR;
/**
* Backup transport for stashing stuff into a known location on disk, and
@@ -284,8 +283,10 @@
private int tearDownFullBackup() {
if (mSocket != null) {
try {
- mFullBackupOutputStream.flush();
- mFullBackupOutputStream.close();
+ if (mFullBackupOutputStream != null) {
+ mFullBackupOutputStream.flush();
+ mFullBackupOutputStream.close();
+ }
mSocketInputStream = null;
mFullTargetPackage = null;
mSocket.close();
@@ -296,6 +297,7 @@
return TRANSPORT_ERROR;
} finally {
mSocket = null;
+ mFullBackupOutputStream = null;
}
}
return TRANSPORT_OK;
@@ -311,6 +313,18 @@
}
@Override
+ public int checkFullBackupSize(long size) {
+ // Decline zero-size "backups"
+ final int result = (size > 0) ? TRANSPORT_OK : TRANSPORT_PACKAGE_REJECTED;
+ if (result != TRANSPORT_OK) {
+ if (DEBUG) {
+ Log.v(TAG, "Declining backup of size " + size);
+ }
+ }
+ return result;
+ }
+
+ @Override
public int performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket) {
if (mSocket != null) {
Log.e(TAG, "Attempt to initiate full backup while one is in progress");
@@ -333,22 +347,14 @@
}
mFullTargetPackage = targetPackage.packageName;
- FileOutputStream tarstream;
- try {
- File tarball = tarballFile(mFullTargetPackage);
- tarstream = new FileOutputStream(tarball);
- } catch (FileNotFoundException e) {
- return TRANSPORT_ERROR;
- }
- mFullBackupOutputStream = new BufferedOutputStream(tarstream);
mFullBackupBuffer = new byte[4096];
return TRANSPORT_OK;
}
@Override
- public int sendBackupData(int numBytes) {
- if (mFullBackupBuffer == null) {
+ public int sendBackupData(final int numBytes) {
+ if (mSocket == null) {
Log.w(TAG, "Attempted sendBackupData before performFullBackup");
return TRANSPORT_ERROR;
}
@@ -356,16 +362,29 @@
if (numBytes > mFullBackupBuffer.length) {
mFullBackupBuffer = new byte[numBytes];
}
- while (numBytes > 0) {
+
+ if (mFullBackupOutputStream == null) {
+ FileOutputStream tarstream;
try {
- int nRead = mSocketInputStream.read(mFullBackupBuffer, 0, numBytes);
+ File tarball = tarballFile(mFullTargetPackage);
+ tarstream = new FileOutputStream(tarball);
+ } catch (FileNotFoundException e) {
+ return TRANSPORT_ERROR;
+ }
+ mFullBackupOutputStream = new BufferedOutputStream(tarstream);
+ }
+
+ int bytesLeft = numBytes;
+ while (bytesLeft > 0) {
+ try {
+ int nRead = mSocketInputStream.read(mFullBackupBuffer, 0, bytesLeft);
if (nRead < 0) {
// Something went wrong if we expect data but saw EOD
Log.w(TAG, "Unexpected EOD; failing backup");
return TRANSPORT_ERROR;
}
mFullBackupOutputStream.write(mFullBackupBuffer, 0, nRead);
- numBytes -= nRead;
+ bytesLeft -= nRead;
} catch (IOException e) {
Log.e(TAG, "Error handling backup data for " + mFullTargetPackage);
return TRANSPORT_ERROR;
diff --git a/core/java/com/android/internal/logging/MetricsLogger.java b/core/java/com/android/internal/logging/MetricsLogger.java
index 6be6389..24b5d0d 100644
--- a/core/java/com/android/internal/logging/MetricsLogger.java
+++ b/core/java/com/android/internal/logging/MetricsLogger.java
@@ -26,9 +26,10 @@
*/
public class MetricsLogger implements MetricsConstants {
// These constants are temporary, they should migrate to MetricsConstants.
- // next value is 145;
+ // next value is 146;
public static final int NOTIFICATION_ZEN_MODE_SCHEDULE_RULE = 144;
+ public static final int NOTIFICATION_ZEN_MODE_EXTERNAL_RULE = 145;
public static void visible(Context context, int category) throws IllegalArgumentException {
if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
diff --git a/core/java/com/android/internal/os/PowerProfile.java b/core/java/com/android/internal/os/PowerProfile.java
index 7e6706c..1efa5651 100644
--- a/core/java/com/android/internal/os/PowerProfile.java
+++ b/core/java/com/android/internal/os/PowerProfile.java
@@ -316,7 +316,7 @@
final Double[] values = (Double[]) data;
if (values.length > level && level >= 0) {
return values[level];
- } else if (level < 0) {
+ } else if (level < 0 || values.length == 0) {
return 0;
} else {
return values[values.length - 1];
diff --git a/core/java/com/android/internal/transition/ActionBarTransition.java b/core/java/com/android/internal/transition/ActionBarTransition.java
deleted file mode 100644
index c1065e7..0000000
--- a/core/java/com/android/internal/transition/ActionBarTransition.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2013 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.transition;
-
-import android.transition.ChangeBounds;
-import android.transition.Fade;
-import android.transition.ChangeText;
-import android.transition.Transition;
-import android.transition.TransitionManager;
-import android.transition.TransitionSet;
-import android.view.ViewGroup;
-
-public class ActionBarTransition {
-
- private static boolean TRANSITIONS_ENABLED = false;
-
- private static final int TRANSITION_DURATION = 120; // ms
-
- private static final Transition sTransition;
-
- static {
- if (TRANSITIONS_ENABLED) {
- final ChangeText tc = new ChangeText();
- tc.setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT_IN);
- final TransitionSet inner = new TransitionSet();
- inner.addTransition(tc).addTransition(new ChangeBounds());
- final TransitionSet tg = new TransitionSet();
- tg.addTransition(new Fade(Fade.OUT)).addTransition(inner).
- addTransition(new Fade(Fade.IN));
- tg.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
- tg.setDuration(TRANSITION_DURATION);
- sTransition = tg;
- } else {
- sTransition = null;
- }
- }
-
- public static void beginDelayedTransition(ViewGroup sceneRoot) {
- if (TRANSITIONS_ENABLED) {
- TransitionManager.beginDelayedTransition(sceneRoot, sTransition);
- }
- }
-}
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 88436f8..6b781c3 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -49,7 +49,6 @@
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import com.android.internal.R;
-import com.android.internal.transition.ActionBarTransition;
import com.android.internal.view.menu.ActionMenuItem;
import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.view.menu.MenuItemImpl;
@@ -459,9 +458,6 @@
public void setCustomView(View view) {
final boolean showCustom = (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0;
- if (showCustom) {
- ActionBarTransition.beginDelayedTransition(this);
- }
if (mCustomNavView != null && showCustom) {
removeView(mCustomNavView);
}
@@ -499,7 +495,6 @@
}
private void setTitleImpl(CharSequence title) {
- ActionBarTransition.beginDelayedTransition(this);
mTitle = title;
if (mTitleView != null) {
mTitleView.setText(title);
@@ -519,7 +514,6 @@
}
public void setSubtitle(CharSequence subtitle) {
- ActionBarTransition.beginDelayedTransition(this);
mSubtitle = subtitle;
if (mSubtitleView != null) {
mSubtitleView.setText(subtitle);
@@ -604,7 +598,6 @@
mDisplayOptions = options;
if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
- ActionBarTransition.beginDelayedTransition(this);
if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
@@ -706,7 +699,6 @@
public void setNavigationMode(int mode) {
final int oldMode = mNavigationMode;
if (mode != oldMode) {
- ActionBarTransition.beginDelayedTransition(this);
switch (oldMode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mListNavLayout != null) {
@@ -836,7 +828,6 @@
}
}
- ActionBarTransition.beginDelayedTransition(this);
mUpGoerFive.addView(mTitleLayout);
if (mExpandedActionView != null ||
(TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
@@ -1659,7 +1650,6 @@
@Override
public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
- ActionBarTransition.beginDelayedTransition(ActionBarView.this);
mExpandedActionView = item.getActionView();
mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(getResources()));
@@ -1688,7 +1678,6 @@
@Override
public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
- ActionBarTransition.beginDelayedTransition(ActionBarView.this);
// Do this before detaching the actionview from the hierarchy, in case
// it needs to dismiss the soft keyboard, etc.
diff --git a/core/java/com/android/internal/widget/ILockSettings.aidl b/core/java/com/android/internal/widget/ILockSettings.aidl
index 0cb1f38..bfafff6 100644
--- a/core/java/com/android/internal/widget/ILockSettings.aidl
+++ b/core/java/com/android/internal/widget/ILockSettings.aidl
@@ -24,10 +24,12 @@
boolean getBoolean(in String key, in boolean defaultValue, in int userId);
long getLong(in String key, in long defaultValue, in int userId);
String getString(in String key, in String defaultValue, in int userId);
- void setLockPattern(in String pattern, int userId);
+ void setLockPattern(in String pattern, in String savedPattern, int userId);
boolean checkPattern(in String pattern, int userId);
- void setLockPassword(in String password, int userId);
+ byte[] verifyPattern(in String pattern, long challenge, int userId);
+ void setLockPassword(in String password, in String savedPassword, int userId);
boolean checkPassword(in String password, int userId);
+ byte[] verifyPassword(in String password, long challenge, int userId);
boolean checkVoldPassword(int userId);
boolean havePattern(int userId);
boolean havePassword(int userId);
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 2967876..123d1ac 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -280,6 +280,24 @@
}
/**
+ * Check to see if a pattern matches the saved pattern.
+ * If pattern matches, return an opaque attestation that the challenge
+ * was verified.
+ *
+ * @param pattern The pattern to check.
+ * @param challenge The challenge to verify against the pattern
+ * @return the attestation that the challenge was verified, or null.
+ */
+ public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge) {
+ final int userId = getCurrentOrCallingUserId();
+ try {
+ return getLockSettings().verifyPattern(patternToString(pattern), challenge, userId);
+ } catch (RemoteException re) {
+ return null;
+ }
+ }
+
+ /**
* Check to see if a pattern matches the saved pattern. If no pattern exists,
* always returns true.
* @param pattern The pattern to check.
@@ -295,6 +313,24 @@
}
/**
+ * Check to see if a password matches the saved password.
+ * If password matches, return an opaque attestation that the challenge
+ * was verified.
+ *
+ * @param password The password to check.
+ * @param challenge The challenge to verify against the password
+ * @return the attestation that the challenge was verified, or null.
+ */
+ public byte[] verifyPassword(String password, long challenge) {
+ final int userId = getCurrentOrCallingUserId();
+ try {
+ return getLockSettings().verifyPassword(password, challenge, userId);
+ } catch (RemoteException re) {
+ return null;
+ }
+ }
+
+ /**
* Check to see if a password matches the saved password. If no password exists,
* always returns true.
* @param password The password to check.
@@ -425,8 +461,8 @@
setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, userHandle);
try {
- getLockSettings().setLockPassword(null, userHandle);
- getLockSettings().setLockPattern(null, userHandle);
+ getLockSettings().setLockPassword(null, null, userHandle);
+ getLockSettings().setLockPattern(null, null, userHandle);
} catch (RemoteException e) {
// well, we tried...
}
@@ -477,24 +513,30 @@
/**
* Save a lock pattern.
* @param pattern The new pattern to save.
+ * @param savedPattern The previously saved pattern, or null if none
*/
- public void saveLockPattern(List<LockPatternView.Cell> pattern) {
- this.saveLockPattern(pattern, getCurrentOrCallingUserId());
+ public void saveLockPattern(List<LockPatternView.Cell> pattern,
+ String savedPattern) {
+ this.saveLockPattern(pattern, savedPattern, getCurrentOrCallingUserId());
}
+ public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId) {
+ this.saveLockPattern(pattern, null, userId);
+ }
/**
* Save a lock pattern.
* @param pattern The new pattern to save.
+ * @param savedPattern The previously saved pattern, converted to String format
* @param userId the user whose pattern is to be saved.
*/
- public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId) {
+ public void saveLockPattern(List<LockPatternView.Cell> pattern, String savedPattern, int userId) {
try {
if (pattern == null || pattern.size() < MIN_LOCK_PATTERN_SIZE) {
throw new IllegalArgumentException("pattern must not be null and at least "
+ MIN_LOCK_PATTERN_SIZE + " dots long.");
}
- getLockSettings().setLockPattern(patternToString(pattern), userId);
+ getLockSettings().setLockPattern(patternToString(pattern), savedPattern, userId);
DevicePolicyManager dpm = getDevicePolicyManager();
// Update the device encryption password.
@@ -685,10 +727,11 @@
* as the requested mode, but will adjust the mode to be as good as the
* pattern.
* @param password The password to save
+ * @param savedPassword The previously saved lock password, or null if none
* @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
*/
- public void saveLockPassword(String password, int quality) {
- saveLockPassword(password, quality, getCurrentOrCallingUserId());
+ public void saveLockPassword(String password, String savedPassword, int quality) {
+ saveLockPassword(password, savedPassword, quality, getCurrentOrCallingUserId());
}
/**
@@ -699,7 +742,8 @@
* @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
* @param userHandle The userId of the user to change the password for
*/
- public void saveLockPassword(String password, int quality, int userHandle) {
+ public void saveLockPassword(String password, String savedPassword, int quality,
+ int userHandle) {
try {
DevicePolicyManager dpm = getDevicePolicyManager();
if (password == null || password.length() < MIN_LOCK_PASSWORD_SIZE) {
@@ -707,7 +751,7 @@
+ "of length " + MIN_LOCK_PASSWORD_SIZE);
}
- getLockSettings().setLockPassword(password, userHandle);
+ getLockSettings().setLockPassword(password, savedPassword, userHandle);
int computedQuality = computePasswordQuality(password);
// Update the device encryption password.
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 4a1be2d..3d22e52 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -311,6 +311,7 @@
<protected-broadcast android:name="android.internal.policy.action.BURN_IN_PROTECTION" />
<protected-broadcast android:name="android.service.persistentdata.action.WIPE_IF_ALLOWED" />
+ <protected-broadcast android:name="android.app.action.OTA_POLICY_CHANGED" />
<!-- ====================================================================== -->
<!-- RUNTIME PERMISSIONS -->
<!-- ====================================================================== -->
diff --git a/core/res/res/layout/chooser_grid.xml b/core/res/res/layout/chooser_grid.xml
new file mode 100644
index 0000000..0fa82eb
--- /dev/null
+++ b/core/res/res/layout/chooser_grid.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+* Copyright 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.
+*/
+-->
+<com.android.internal.widget.ResolverDrawerLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:maxWidth="@dimen/resolver_max_width"
+ android:maxCollapsedHeight="256dp"
+ android:maxCollapsedHeightSmall="56dp"
+ android:id="@id/contentPanel">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alwaysShow="true"
+ android:elevation="8dp"
+ android:paddingStart="?attr/dialogPreferredPadding"
+ android:background="@color/white" >
+ <ImageView android:id="@+id/title_icon"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="start|center_vertical"
+ android:layout_marginEnd="16dp"
+ android:scaleType="fitCenter" />
+ <TextView android:id="@+id/title"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:minHeight="56dp"
+ android:textAppearance="?attr/textAppearanceMedium"
+ android:gravity="start|center_vertical"
+ android:paddingEnd="?attr/dialogPreferredPadding"
+ android:paddingTop="8dp"
+ android:paddingBottom="8dp" />
+ <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_marginStart="4dp"
+ android:layout_marginEnd="16dp"
+ 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="16dp"
+ android:textAppearance="?attr/textAppearanceButton"
+ android:textColor="?attr/textColorPrimary"
+ android:minLines="1"
+ android:maxLines="1"
+ android:ellipsize="marquee" />
+ </LinearLayout>
+ </LinearLayout>
+
+ <GridView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/resolver_list"
+ android:clipToPadding="false"
+ android:paddingStart="@dimen/chooser_grid_padding"
+ android:paddingEnd="@dimen/chooser_grid_padding"
+ android:scrollbarStyle="outsideOverlay"
+ android:background="@color/white"
+ android:elevation="8dp"
+ android:numColumns="4"
+ android:nestedScrollingEnabled="true" />
+
+ <TextView android:id="@+id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alwaysShow="true"
+ android:text="@string/noApplications"
+ android:padding="32dp"
+ android:gravity="center"
+ android:visibility="gone" />
+
+</com.android.internal.widget.ResolverDrawerLayout>
diff --git a/core/res/res/layout/resolve_grid_item.xml b/core/res/res/layout/resolve_grid_item.xml
new file mode 100644
index 0000000..664b02f
--- /dev/null
+++ b/core/res/res/layout/resolve_grid_item.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2006, 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.
+*/
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:minWidth="80dp"
+ android:gravity="center"
+ android:paddingTop="8dp"
+ android:paddingBottom="8dp"
+ android:background="?attr/activatedBackgroundIndicator">
+
+ <!-- Activity icon when presenting dialog -->
+ <ImageView android:id="@+id/icon"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:scaleType="fitCenter" />
+
+ <!-- Activity name -->
+ <TextView android:id="@android:id/text1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginLeft="4dp"
+ android:layout_marginRight="4dp"
+ android:textAppearance="?attr/textAppearanceSmall"
+ android:textColor="?attr/textColorPrimary"
+ android:fontFamily="sans-serif-condensed"
+ android:gravity="center"
+ android:minLines="2"
+ android:maxLines="2"
+ android:ellipsize="marquee" />
+ <!-- Extended activity info to distinguish between duplicate activity names -->
+ <TextView android:id="@android:id/text2"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="4dp"
+ android:layout_marginRight="4dp"
+ android:minLines="2"
+ android:maxLines="2"
+ android:gravity="center"
+ android:ellipsize="marquee" />
+</LinearLayout>
+
diff --git a/core/res/res/values-sw360dp/dimens.xml b/core/res/res/values-sw360dp/dimens.xml
new file mode 100644
index 0000000..4c74264
--- /dev/null
+++ b/core/res/res/values-sw360dp/dimens.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 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.
+ */
+-->
+<resources>
+ <dimen name="chooser_grid_padding">16dp</dimen>
+</resources>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 0f50502..04e40a7 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5988,11 +5988,11 @@
<enum name="noScale" value="0"/>
<!-- This should be used when the animation's moving distance is proportional to screen,
as the scaling is based on screen size. -->
- <enum name="screen" value="1"/>
+ <enum name="screenBased" value="1"/>
<!-- This is for animations that have a distance defined in dp, which will be the same
across different devices. In this case, scaling is based on the physical distance
per dp on the current device. -->
- <enum name="dp" value="2"/>
+ <enum name="dpBased" value="2"/>
</attr>
</declare-styleable>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 6d9bbae..8c78e74 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -23,6 +23,7 @@
<!-- Do not translate. Defines the slots for the right-hand side icons. That is to say, the
icons in the status bar that are not notifications. -->
<string-array name="config_statusBarIcons">
+ <item><xliff:g id="id">managed_profile</xliff:g></item>
<item><xliff:g id="id">ime</xliff:g></item>
<item><xliff:g id="id">sync_failing</xliff:g></item>
<item><xliff:g id="id">sync_active</xliff:g></item>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 2654a25..100b161 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -394,4 +394,5 @@
<dimen name="floating_toolbar_minimum_overflow_height">192dp</dimen>
<dimen name="floating_toolbar_overflow_width">130dp</dimen>
<dimen name="floating_toolbar_margin">2dp</dimen>
+ <dimen name="chooser_grid_padding">0dp</dimen>
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 326a1db..2dbba8e 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1655,8 +1655,8 @@
<!-- On the unlock pattern screen, shown at the top of the unlock screen to tell the user what to do. Below this text is the place for theu ser to draw the pattern. -->
<string name="lockscreen_pattern_instructions">Draw pattern to unlock</string>
- <!-- Button at the bottom of the unlock screen to make an emergency call. -->
- <string name="lockscreen_emergency_call">Emergency call</string>
+ <!-- Button at the bottom of the unlock screen to make an emergency call or access other emergency assistance functions. -->
+ <string name="lockscreen_emergency_call">Emergency</string>
<!-- Button at the bottom of the unlock screen that lets the user return to a call -->
<string name="lockscreen_return_to_call">Return to call</string>
<!-- Shown to confirm that the user entered their lock pattern correctly. -->
@@ -3438,8 +3438,6 @@
<string name="display_manager_overlay_display_secure_suffix">, secure</string>
<!-- Keyguard strings -->
- <!-- Label shown on emergency call button in keyguard -->
- <string name="kg_emergency_call_label">Emergency call</string>
<!-- Message shown in pattern unlock after some number of unsuccessful attempts -->
<string name="kg_forgot_pattern_button_text">Forgot Pattern</string>
<!-- Message shown when user enters wrong pattern -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 42d187d..36a736a 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2232,4 +2232,7 @@
<java-symbol type="layout" name="date_picker_month_item_material" />
<java-symbol type="id" name="month_view" />
<java-symbol type="integer" name="config_zen_repeat_callers_threshold" />
+ <java-symbol type="layout" name="chooser_grid" />
+ <java-symbol type="layout" name="resolve_grid_item" />
+ <java-symbol type="id" name="title_icon" />
</resources>
diff --git a/core/tests/coretests/src/android/net/IpPrefixTest.java b/core/tests/coretests/src/android/net/IpPrefixTest.java
index cf278fb..fcc6389 100644
--- a/core/tests/coretests/src/android/net/IpPrefixTest.java
+++ b/core/tests/coretests/src/android/net/IpPrefixTest.java
@@ -29,6 +29,10 @@
public class IpPrefixTest extends TestCase {
+ private static InetAddress Address(String addr) {
+ return InetAddress.parseNumericAddress(addr);
+ }
+
// Explicitly cast everything to byte because "error: possible loss of precision".
private static final byte[] IPV4_BYTES = { (byte) 192, (byte) 0, (byte) 2, (byte) 4};
private static final byte[] IPV6_BYTES = {
@@ -209,6 +213,34 @@
}
@SmallTest
+ public void testContains() {
+ IpPrefix p = new IpPrefix("2001:db8:f00::ace:d00d/127");
+ assertTrue(p.contains(Address("2001:db8:f00::ace:d00c")));
+ assertTrue(p.contains(Address("2001:db8:f00::ace:d00d")));
+ assertFalse(p.contains(Address("2001:db8:f00::ace:d00e")));
+ assertFalse(p.contains(Address("2001:db8:f00::bad:d00d")));
+ assertFalse(p.contains(Address("2001:4868:4860::8888")));
+ assertFalse(p.contains(null));
+ assertFalse(p.contains(Address("8.8.8.8")));
+
+ p = new IpPrefix("192.0.2.0/23");
+ assertTrue(p.contains(Address("192.0.2.43")));
+ assertTrue(p.contains(Address("192.0.3.21")));
+ assertFalse(p.contains(Address("192.0.0.21")));
+ assertFalse(p.contains(Address("8.8.8.8")));
+ assertFalse(p.contains(Address("2001:4868:4860::8888")));
+
+ IpPrefix ipv6Default = new IpPrefix("::/0");
+ assertTrue(ipv6Default.contains(Address("2001:db8::f00")));
+ assertFalse(ipv6Default.contains(Address("192.0.2.1")));
+
+ IpPrefix ipv4Default = new IpPrefix("0.0.0.0/0");
+ assertTrue(ipv4Default.contains(Address("255.255.255.255")));
+ assertTrue(ipv4Default.contains(Address("192.0.2.1")));
+ assertFalse(ipv4Default.contains(Address("2001:db8::f00")));
+ }
+
+ @SmallTest
public void testHashCode() {
IpPrefix p;
int oldCode = -1;
diff --git a/core/tests/coretests/src/android/net/RouteInfoTest.java b/core/tests/coretests/src/android/net/RouteInfoTest.java
index 0b88bc7..831fefd 100644
--- a/core/tests/coretests/src/android/net/RouteInfoTest.java
+++ b/core/tests/coretests/src/android/net/RouteInfoTest.java
@@ -90,6 +90,7 @@
assertFalse(r.matches(Address("2001:db8:f00::ace:d00e")));
assertFalse(r.matches(Address("2001:db8:f00::bad:d00d")));
assertFalse(r.matches(Address("2001:4868:4860::8888")));
+ assertFalse(r.matches(Address("8.8.8.8")));
r = new PatchedRouteInfo(Prefix("192.0.2.0/23"), null, "wlan0");
assertTrue(r.matches(Address("192.0.2.43")));
diff --git a/docs/html-ndk/ndk/downloads/downloads_toc.cs b/docs/html-ndk/ndk/downloads/downloads_toc.cs
new file mode 100644
index 0000000..66d0007
--- /dev/null
+++ b/docs/html-ndk/ndk/downloads/downloads_toc.cs
@@ -0,0 +1,21 @@
+<?cs # Table of contents for Dev Guide.
+
+ For each document available in translation, add an localized title to this TOC.
+ Do not add localized title for docs not available in translation.
+ Below are template spans for adding localized doc titles. Please ensure that
+ localized titles are added in the language order specified below.
+?>
+
+
+<ul id="nav">
+ <li><a href="/ndk/downloads/index.html"><span class="en">NDK Download</span></a></li>
+</ul>
+
+
+<script type="text/javascript">
+<!--
+ buildToggleLists();
+ changeNavLang(getLangPref());
+//-->
+</script>
+
diff --git a/docs/html-ndk/ndk/downloads/index.jd b/docs/html-ndk/ndk/downloads/index.jd
new file mode 100644
index 0000000..ef00069
--- /dev/null
+++ b/docs/html-ndk/ndk/downloads/index.jd
@@ -0,0 +1,4 @@
+page.title=NDK Downloads
+@jd:body
+
+<p>downloads
\ No newline at end of file
diff --git a/docs/html-ndk/ndk/guides/guides_toc.cs b/docs/html-ndk/ndk/guides/guides_toc.cs
new file mode 100644
index 0000000..e6bc199
--- /dev/null
+++ b/docs/html-ndk/ndk/guides/guides_toc.cs
@@ -0,0 +1,22 @@
+<?cs # Table of contents for Dev Guide.
+
+ For each document available in translation, add an localized title to this TOC.
+ Do not add localized title for docs not available in translation.
+ Below are template spans for adding localized doc titles. Please ensure that
+ localized titles are added in the language order specified below.
+?>
+
+
+<ul id="nav">
+ <li><a href="/ndk/guides/index.html"><span class="en">Getting Started</span></a></li>
+ <li><a href="/ndk/guides/pg_html/md_1__concepts__concepts.html">Concepts</a></li>
+</ul>
+
+
+<script type="text/javascript">
+<!--
+ buildToggleLists();
+ changeNavLang(getLangPref());
+//-->
+</script>
+
diff --git a/docs/html-ndk/ndk/guides/index.jd b/docs/html-ndk/ndk/guides/index.jd
new file mode 100644
index 0000000..8c3ecab
--- /dev/null
+++ b/docs/html-ndk/ndk/guides/index.jd
@@ -0,0 +1,4 @@
+page.title=Concepts
+@jd:body
+
+<p>To use the NDK, you must download it and install it separately from the SDK. To do so, follow these directions.
\ No newline at end of file
diff --git a/docs/html-ndk/ndk/guides/md_1__concepts__concepts.html b/docs/html-ndk/ndk/guides/md_1__concepts__concepts.html
new file mode 100644
index 0000000..2dcf6ae
--- /dev/null
+++ b/docs/html-ndk/ndk/guides/md_1__concepts__concepts.html
@@ -0,0 +1,4 @@
+page.title=Concepts
+@jd:body
+
+<p>This section provides a high-level explanation of how the NDK works. The Android NDK is a set of tools allowing you to embed C or C++ (“native code”) into your Android apps. The ability to use native code in Android apps can be particularly useful to developers who wish to do one or more of the following:
\ No newline at end of file
diff --git a/docs/html-ndk/ndk/index.jd b/docs/html-ndk/ndk/index.jd
new file mode 100644
index 0000000..f1c5ce6
--- /dev/null
+++ b/docs/html-ndk/ndk/index.jd
@@ -0,0 +1,15 @@
+fullpage=true
+page.viewport_width=970
+excludeFromSuggestions=true
+page.metaDescription=The official Android NDK developer web site.
+page.customHeadTag=<meta name="google-site-verification" content="sa-bIAI6GKvct3f61-WpRguHq-aNjtF7xJjMTSi79as" />
+
+@jd:body
+
+
+<h1>SUPER FANCY NDK LANDING PAGE<h1>
+
+<p>Welcome to the placeholder text for the NDK. Here, you'll find all of the details you need to
+combine the power of native code with Android flexibility and compatibility. The documents here
+help you get started, introduce some key concepts that you should know when using the NDK, and then
+provide a variety of other information that you'll find helpful while developing your app.</p>
diff --git a/docs/html-ndk/ndk/reference/index.jd b/docs/html-ndk/ndk/reference/index.jd
new file mode 100644
index 0000000..a496f19
--- /dev/null
+++ b/docs/html-ndk/ndk/reference/index.jd
@@ -0,0 +1,4 @@
+page.title=Reference
+@jd:body
+
+<p>NDK reference docs
\ No newline at end of file
diff --git a/docs/html-ndk/ndk/reference/reference_toc.cs b/docs/html-ndk/ndk/reference/reference_toc.cs
new file mode 100644
index 0000000..01364a6
--- /dev/null
+++ b/docs/html-ndk/ndk/reference/reference_toc.cs
@@ -0,0 +1,21 @@
+<?cs # Table of contents for Dev Guide.
+
+ For each document available in translation, add an localized title to this TOC.
+ Do not add localized title for docs not available in translation.
+ Below are template spans for adding localized doc titles. Please ensure that
+ localized titles are added in the language order specified below.
+?>
+
+
+<ul id="nav">
+ <li><a href="/ndk/reference/index.html"><span class="en">foo.h</span></a></li>
+</ul>
+
+
+<script type="text/javascript">
+<!--
+ buildToggleLists();
+ changeNavLang(getLangPref());
+//-->
+</script>
+
diff --git a/docs/html-ndk/ndk/samples/index.jd b/docs/html-ndk/ndk/samples/index.jd
new file mode 100644
index 0000000..b333aa7
--- /dev/null
+++ b/docs/html-ndk/ndk/samples/index.jd
@@ -0,0 +1,4 @@
+page.title=Samples
+@jd:body
+
+<p>NDK samples
\ No newline at end of file
diff --git a/docs/html-ndk/ndk/samples/samples_toc.cs b/docs/html-ndk/ndk/samples/samples_toc.cs
new file mode 100644
index 0000000..9fb036e
--- /dev/null
+++ b/docs/html-ndk/ndk/samples/samples_toc.cs
@@ -0,0 +1,21 @@
+<?cs # Table of contents for Dev Guide.
+
+ For each document available in translation, add an localized title to this TOC.
+ Do not add localized title for docs not available in translation.
+ Below are template spans for adding localized doc titles. Please ensure that
+ localized titles are added in the language order specified below.
+?>
+
+
+<ul id="nav">
+ <li><a href="/ndk/samples/index.html"><span class="en">Stuff</span></a></li>
+</ul>
+
+
+<script type="text/javascript">
+<!--
+ buildToggleLists();
+ changeNavLang(getLangPref());
+//-->
+</script>
+
diff --git a/docs/html/distribute/googleplay/families/about.jd b/docs/html/distribute/googleplay/families/about.jd
new file mode 100644
index 0000000..c542e0f
--- /dev/null
+++ b/docs/html/distribute/googleplay/families/about.jd
@@ -0,0 +1,67 @@
+page.title=Designed for Families
+page.metaDescription=Designed for Families helps you make your apps and games more discoverable to families.
+page.image=/distribute/images/about-dff-sm.jpg
+meta.tags="families, googleplay, distribution"
+page.tags="families"
+
+@jd:body
+
+<p>
+ In several weeks, a new family-focused experience on Google Play will give
+ users new ways to browse, search, and discover high quality apps and games
+ for their families.
+</p>
+
+<p>
+ To support a more family-friendly store, developers are invited to opt-in
+ family-focused apps and games to the new Designed for Families program. Apps
+ that meet the <a href=
+ "https://support.google.com/googleplay/android-developer/answer/6184502">program
+ requirements</a> will be shown in the new family experience so that
+ parents can find suitable, trusted, high-quality apps and games more easily.
+</p>
+
+<img src="{@docRoot}distribute/images/about-dff-sm.jpg">
+
+<p>
+ Opt-in your apps and games today using the tools and processes you currently
+ use to manage your apps in the Developer Console. Your apps in the program
+ can benefit from enhanced discoverability in addition to maintaining their
+ existing categories, rankings, and reviews elsewhere on the Google Play
+ store.
+</p>
+
+<h2 id="elibibility">Eligibility</h2>
+
+<p>
+ Apps in the family-friendly experience on Google Play will be more
+ discoverable by parents and families, who expect the apps to be age
+ appropriate. The Designed for Families program is designed to be inclusive of
+ apps that are made for kids as well as those that can be enjoyed by the
+ entire family. To address this audience, there are specific guidelines and
+ policies your apps need to meet, which will be assessed in an app content
+ review.
+</p>
+
+<p>
+ Make sure that you're familiar with the policies that your app must comply
+ with. These include <a href=
+ "http://play.google.com/about/developer-content-policy.html">content
+ policies</a>, the <a href=
+ "http://play.google.com/about/developer-distribution-agreement.html">Developer
+ Distribution Agreement</a>, and the <a href=
+ "https://play.google.com/intl/ALL_us/about/families/developer-distribution-agreement-addendum.html">
+ Designed for Families DDA Addendum</a>.
+</p>
+
+<p>
+ Your app must also meet the <a href=
+ "https://support.google.com/googleplay/android-developer/answer/6184502">Designed
+ for Families program requirements</a> listed in the Google Play Developer
+ Help Center.
+</p>
+
+<div class="paging-links" style="padding-top:.75em;">
+ <a href="{@docRoot}distribute/googleplay/families/start.html" class=
+ "next-class-link">Next: Opt-In</a>
+</div>
diff --git a/docs/html/distribute/googleplay/families/faq.jd b/docs/html/distribute/googleplay/families/faq.jd
new file mode 100644
index 0000000..c6fbf86
--- /dev/null
+++ b/docs/html/distribute/googleplay/families/faq.jd
@@ -0,0 +1,336 @@
+page.title=Frequently Asked Questions
+meta.tags="families", "guidelines", "quality"
+page.tags="families", "addendum"
+page.metaDescription=Questions and answers about Designed for Families
+
+@jd:body
+
+ <style>
+ dt {
+ font-weight:bold;
+ }
+ </style>
+
+<div id="qv-wrapper">
+<ol id="qv">
+<h2>In this document</h2>
+<ol>
+ <li><a href="#review">App Review and Opt-In</a></li>
+ <li><a href="#monetization">Monetization</a></li>
+ <li><a href="#other">Other Questions</a></li>
+</ol>
+</div>
+
+<p>
+ The sections below provide more information about Designed for Families
+ and answer common questions that you might have about it.
+</p>
+
+
+<h2 id="review">App Review and Opt-In</h2>
+
+<dl>
+<dt>How do I opt-in my app(s)?</dt>
+
+<dl>
+ <dd>
+ You can opt-in to Designed for Families on the Pricing and Distribution tab
+ for your app on the Google Play Developer Console. Here's a <a href=
+ "{@docRoot}distribute/googleplay/families/start.html">step-by-step
+ walkthrough</a>.
+ </dd>
+
+ <dt>
+ Where do I disclose my app’s interactive features? Why are you collecting
+ this information?
+ </dt>
+
+ <dd>
+ Interactive feature disclosures are part of the content rating
+ questionnaire. You have an opportunity to review your disclosures as
+ part of the Designed for Families program opt-in flow. We collect this
+ information so that users can make informed choices when evaluating your
+ app.
+ </dd>
+
+ <dt>
+ What is COPPA?
+ </dt>
+
+ <dd>
+ COPPA is the Federal Trade Commission’s (FTC) Child Online Privacy
+ Protection Rule. More details are available on the <a
+ href="http://www.ftc.gov/tips-advice/business-center/guidance/complying-coppa-frequently-asked-questions">
+ FTC's FAQ about COPPA</a>. Note that Google Play cannot provide legal guidance to developers
+ on how to comply with COPPA or other child statutes.
+ </dd>
+
+ <dt>
+ Do I need to provide an up-to-date privacy policy and where do I do that?
+ </dt>
+
+ <dd>
+ Yes, you need to provide a link to a persistent privacy policy on your
+ app’s store listing and confirm your compliance with local privacy statutes
+ in the Developer Console. To add or review your privacy policy, choose your
+ app in the Developer Console and then scroll to the bottom of the
+ <strong>Store Listing</strong> section.
+ </dd>
+
+ <dt>
+ How many age groups can I select?
+ </dt>
+
+ <dd>
+ You can select up to two adjacent age groups. Age groups are: Ages 5 &
+ Under, Ages 6-8, and Ages 9-12. However, if your app targets audiences
+ comprised of children and older audiences, you must select the <em>General
+ Audience</em> category.
+ </dd>
+
+ <dt>
+ How many content categories can I select in the Designed for Families
+ program?
+ </dt>
+
+ <dd>
+ You can select one category as part of the Designed for Families program
+ and another category for the general Google Play store.
+ </dd>
+
+ <dt>
+ What are the Designed for Families categories?
+ </dt>
+
+<ul>
+<li><strong>Action & Adventure</strong>: These are action-oriented apps/games and include everything
+ from racing games, fairy tale adventures, and more.
+ </li>
+
+ <li style="list-style: none"><strong>Brain Games</strong>: This category includes games that
+ make the user think and includes puzzles, matching games, and similar
+ games.
+ </li>
+
+ <li><strong>Creativity</strong>: These are apps/games that spur creativity.
+ Example types of apps/games we expect in this category include drawing,
+ painting, and other games where you can build things.
+ </li>
+
+ <li><strong>Education</strong>: These are apps/games that have educational value and include
+ math, science, learning the alphabet, learning to count, and many more types of
+ educational content like geography and history.
+ </li>
+
+ <li><strong>Music and Video</strong>: These are apps/games that contain a musical element or
+ video component and include everything from playing the
+ piano to watching videos and more.
+ </li>
+
+ <li><strong>Pretend Play</strong>: These are apps/games where one can pretend to take on a
+ role, like pretending to be a cook or a doctor.
+ </li>
+</ul>
+
+<dl>
+ <dt>
+ Will it take longer for my app to get published if I opt-in to the Designed
+ for Families program?
+ </dt>
+
+ <dd>
+ When you opt-in to Designed for Families, Google Play reviews your app to
+ confirm that it is appropriate for families. Assuming your app complies with all program
+ requirements, we expect that publishing time should not take any longer
+ than normal; however, there may be a delay in publishing the app if it is
+ rejected during the Designed for Families review.
+ </dd>
+
+ <dt>
+ What happens if my app is rejected from the Designed for Families program?
+ </dt>
+
+ <dd>
+ If your app is rejected from the Designed for Families program, we’ll
+ indicate why in the Developer Console and in a detailed email. You’ll have
+ an opportunity to correct the issues and resubmit your app to the program,
+ or change your opt-in response. Note that if you have an existing app that
+ is live on Google Play, only your app update will be rejected (your app
+ will remain live on the Play store). If you’ve submitted a new app to the
+ Designed for Families program that does not meet the requirements, your
+ entire app submission will be rejected and the app will not be published on
+ Play. You can then address the identified issue(s) and resubmit the app for
+ the Designed for Families program or opt-out of the program.
+ </dd>
+
+ <dt>
+ What happens if my app is found to be non-compliant with Designed for
+ Families program requirements after it has been published?
+ </dt>
+
+ <dd>
+ Your app may be removed or suspended from the Google Play Store, not only
+ the Designed for Families program. Removed apps can follow the same
+ remedies as rejected apps. Suspended apps can be appealed using the
+ developer appeal process.
+ </dd>
+
+ <dt>
+ If I opt-in to the Designed for Families program, can I opt-out later on?
+ </dt>
+
+ <dd>
+ Yes, you may opt-out of the program at any time. Please note that by opting
+ out you would lose your placement in the new family-friendly experience as
+ well as the other benefits of the program.
+ </dd>
+
+ <dt>
+ What happens when I update my app after it has been accepted into the
+ program?
+ </dt>
+
+ <dd>
+ Apps that are part of the Designed for Families program need to maintain
+ compliance with the eligibility requirements at all times. If you need to
+ edit the Designed for Families metadata associated with your app, please go
+ to the Pricing & Distribution section of the Google Play Developer Console
+ to edit this information. If updating your app results in you changing your
+ target audience, we recommend that you alert the users who already
+ have your app installed.
+ </dd>
+
+ <dt>
+ Can apps and games that use Google sign-in or Google Play Game
+ services opt-into the Designed for Families program?
+ </dt>
+
+ <dd>
+ Apps that participate in Designed for Families that are wholly
+ child-focused, i.e. that target the following age groups: Ages 5 & Under,
+ Ages 6 to 8, or Ages 9 to 12 <strong>may not</strong> use Google+ Sign-in
+ or Google Play Game services as the login experience for their
+ application.
+
+ <p>
+ Apps that participate in Designed for Families that target both children and
+ older audiences, can use Google+ Sign-in or Google Play Game services as an
+ <strong>optional</strong> feature. Child users must be able to access the app
+ or game in its entirety without signing into Google+ or Google Play Game services.
+ </p>
+ </dd>
+
+ <dt>
+ My app is opted-in to Google Play for Education and has Google sign-in integration
+ so that students can login with their school accounts. Do I need to change the way
+ Google sign-in works in my app?
+ </dt>
+
+ <dd>
+ Apps that participate in Google Play for Education may use Google sign-in for
+ student accounts as long as it is not a blocking requirement for all users of the app.
+ </dd>
+</dl>
+
+<h2 id="monetization">
+ Designed for Families Program Monetization
+</h2>
+
+<dl>
+ <dt>
+ Can you give me more details on the advertising policies for Designed for
+ Families?
+ </dt>
+
+ <dd>
+ Read the <a href=
+ "https://support.google.com/googleplay/android-developer/answer/6184502#ads">
+ ads policy for Designed for Families</a>.
+ </dd>
+
+ <dt>
+ Can my app serve interstitial advertisements?
+ </dt>
+
+ <dd>
+ Interstitial ads may be appropriate for some apps. However, a user must be
+ able to navigate to the main activity before any ads are served.
+ </dd>
+
+ <dt>
+ How do I know that my ad network complies with the advertising
+ policies for Designed for Families?
+ </dt>
+
+ <dd>
+ Please contact your advertising network to ask them about their content policies
+ and advertising practices. If you use AdMob, then please refer to the <a href=
+ "https://support.google.com/admob/answer/3248194">AdMob help center</a> for
+ details on how to tag your app or a specific ad unit for child-directed
+ treatment. It is the developer’s responsibility to ensure that the overall
+ user experience with in-app advertising meets the <a href=
+ "https://support.google.com/googleplay/android-developer/answer/6184502">Designed
+ for Families program requirements</a>.
+ </dd>
+
+ <dt>
+ Can I have in-app purchases in my app?
+ </dt>
+
+ <dd>
+ There are no specific restrictions relating to in-app purchases (IAP) in
+ apps participating in the Designed for Families program other than
+ compliance with the <a href=
+ "https://play.google.com/intl/ALL_us/about/families/developer-distribution-agreement-addendum.html">
+ Designed for Families DDA</a> and other applicable legal requirements, but
+ Play reserves the right to reject apps for overly aggressive commercial
+ tactics. Google Play will enforce IAP password protection on all apps
+ participating in the Designed for Families program that primarily target
+ child audiences to ensure that parents, not children, are approving
+ purchases. Please note that this treatment does not extend to apps
+ targeting general audiences.
+ </dd>
+</dl>
+
+<h2 id="other">
+ Other Questions
+</h2>
+
+<dl>
+ <dt>
+ Who is the intended target audience for participating Designed for Families
+ apps?
+ </dt>
+
+ <dd>
+ Our goal is to provide a great experience on the Google Play store for
+ parents and guardians to discover delightful apps designed for kids and
+ families from trusted brands and developers.
+ </dd>
+
+ <dt>
+ Is the Designed for Families Program only available to developers in
+ certain countries?
+ </dt>
+
+ <dd>
+ Designed for Families is a global program.
+ </dd>
+
+ <dt>
+ What happens to apps that are published in the current Family Games
+ category?
+ </dt>
+
+ <dd>
+ The current Family Games category will be deprecated in May 2015. Apps
+ currently in the Family Games category will have to select
+ a different category in the Play store. Apps that have not selected another
+ category will be assigned to the Casual Games category.
+ </dd>
+</dl>
+
+<div class="paging-links" style="padding-top:.75em;">
+ <a href="https://docs.google.com/forms/d/1EtvUWqlkxS6RxHJjeI-3-7uzdbIZx6n9Cocy2D369B8/viewform" class=
+ "next-class-link">Next: Stay in Touch</a>
+</div>
\ No newline at end of file
diff --git a/docs/html/distribute/googleplay/families/start.jd b/docs/html/distribute/googleplay/families/start.jd
new file mode 100644
index 0000000..af4eb3a
--- /dev/null
+++ b/docs/html/distribute/googleplay/families/start.jd
@@ -0,0 +1,114 @@
+page.title=Opt-In to Designed for Families
+meta.tags="families", "guidelines", "quality"
+page.tags="families", "addendum"
+page.metaDescription=Join Designed for Families in just a few simple steps.
+
+@jd:body
+
+<p>
+ If you're building an app designed for kids and families, there are a few
+ things you need to do <em>before</em> you’ll be ready to opt-in to the Designed for
+ Families program:
+</p>
+
+<ul>
+ <li>Complete the content rating questionnaire for your app and meet an ESRB
+ rating of Everyone or Everyone 10+ rating
+ </li>
+
+ <li>Add a privacy policy link to your app’s <strong>Store Listing</strong>
+ page.
+ </li>
+
+ <li>Make sure your app meets all the <a href=
+ "https://support.google.com/googleplay/android-developer/answer/6184502">Designed
+ for Families program requirements.</a>
+ </li>
+</ul>
+
+<p>
+ Now that your app is ready to publish, you can opt-in to Designed for
+ Families directly from the <a href=
+ "https://play.google.com/apps/publish/">Developer Console</a>. Opt-in means
+ that you want your app to be made available on the new family-friendly
+ experience on Google Play in addition to the category you’ve selected on
+ the Google Play Store.
+</p>
+
+<p>
+ Opt-in also confirms that your app complies with <a href=
+ "http://play.google.com/about/developer-content-policy.html">Google Play
+ Developer Program Policies</a> and the <a href=
+ "http://play.google.com/about/developer-distribution-agreement.html">Developer
+ Distribution Agreement</a>, including the <a href=
+ "https://play.google.com/intl/ALL_us/about/families/developer-distribution-agreement-addendum.html">
+ Designed for Families DDA Addendum</a>. If you are not familiar with these
+ policy documents or the Addendum, make sure to read them before opting-in.
+</p>
+
+<p>
+ Once you're ready, here's how to opt-in to Designed for Families for a specific app:
+</p>
+
+<ol>
+<li>In the Developer Console <strong>All Applications</strong> page, click the app you want to
+ opt-in. Under Pricing and Distribution, scroll down to find <strong>Designed for
+ Families</strong> and the opt-in checkbox.<img src="/images/gp-dff-optin.png" style=
+ "border:2px solid #ddd;margin:1em 0;">
+ </li>
+
+ <li>Start the opt-in flow and confirm that your app meets the eligibility
+ requirements.</li>
+ <li>If your app has ads, confirm that it meets the ads policy.
+ <img src="/images/gp-dff-appinfo.png"
+ style="border:2px solid #ddd;margin:1em 0;"></li>
+ <li>Choose your target age groups from: Ages 5 & Under, Ages 6 to 8, Ages 9
+ to 12, or General Audience (for apps which target children and older
+ audiences). If your app targets more than one age group, you can choose up to
+ two adjacent age groups. Apps with an ESRB 10+ rating can only choose an
+ age target of 9-12 or General Audience.
+ </li>
+
+ <li>Choose a category for your app for the new family-focused experience on
+ Google Play. Your app will also be discoverable in its existing category in
+ Google Play.</li>
+ <li>Review and agree to the linked documents and then click
+ <strong>Opt-In</strong>. Finally, click <strong>Submit update</strong> on the
+ Pricing & Distribution page to publish or update your app.
+ </li>
+</ol>
+
+<p>
+ Once you opt-in your app, it will be thoroughly reviewed before being
+ accepted into the Designed for Families program.
+</p>
+
+<p class="note">
+ <strong>Note</strong>: Published apps in the Designed for Families program
+ are also available to all users on Google Play.
+</p>
+
+<p>
+ If you opt-in an app that you're publishing for the first time and it doesn't
+ meet the Designed for Families program requirements, it won't be made available
+ on Google Play until <strong>either</strong> you update the app to meet the
+ program requirements <strong>or</strong> you uncheck the opt-in box and pass
+ Google Play's standard review process.
+</p>
+
+<p>
+ If you opt-in an app that's already published on Google Play and it doesn't
+ meet the program requirements, it will remain available to all users but won't
+ be added to the new family experience until you update the app to meet the
+ program requirements.
+</p>
+
+<p>
+ If you publish an update to an app that's opted-in to Designed for Families,
+ the app update needs to pass the Designed for Families review before it will
+ become available to all users on Google Play.</p>
+
+<div class="paging-links" style="padding-top:.75em;">
+ <a href="{@docRoot}distribute/googleplay/families/faq.html" class=
+ "next-class-link">Next: Frequently Asked Questions</a>
+</div>
diff --git a/docs/html/distribute/googleplay/googleplay_toc.cs b/docs/html/distribute/googleplay/googleplay_toc.cs
index 594d6d6..78a3731 100644
--- a/docs/html/distribute/googleplay/googleplay_toc.cs
+++ b/docs/html/distribute/googleplay/googleplay_toc.cs
@@ -24,8 +24,8 @@
</div>
</li>
<li class="nav-section">
- <div class="nav-section-header empty" style="font-weight:normal"><a href="<?cs var:toroot?>distribute/googleplay/auto.html">
- <span class="en">Distributing to <span style="white-space:nowrap">Android Auto</span></span>
+ <div class="nav-section-header empty" style="font-weight:normal"><a href="<?cs var:toroot?>distribute/googleplay/wear.html">
+ <span class="en">Distributing to <span style="white-space:nowrap">Android Wear</span></span>
</a>
</div>
</li>
@@ -36,12 +36,29 @@
</div>
</li>
<li class="nav-section">
- <div class="nav-section-header empty" style="font-weight:normal"><a href="<?cs var:toroot?>distribute/googleplay/wear.html">
- <span class="en">Distributing to <span style="white-space:nowrap">Android Wear</span></span>
+ <div class="nav-section-header empty" style="font-weight:normal"><a href="<?cs var:toroot?>distribute/googleplay/auto.html">
+ <span class="en">Distributing to <span style="white-space:nowrap">Android Auto</span></span>
</a>
</div>
</li>
<li class="nav-section">
+ <div class="nav-section-header" style="font-weight:normal"><a href="<?cs var:toroot?>distribute/googleplay/families/about.html">
+ <span class="en">Designed for Families</span>
+ </a>
+ </div>
+ <ul>
+ <li><a href="<?cs var:toroot?>distribute/googleplay/families/start.html">
+ <span class="en">Opt-In</span>
+ </a></li>
+ <li><a href="<?cs var:toroot?>distribute/googleplay/families/faq.html">
+ <span class="en">FAQ</span>
+ </a></li>
+ <li><a href="https://docs.google.com/forms/d/1EtvUWqlkxS6RxHJjeI-3-7uzdbIZx6n9Cocy2D369B8/viewform">
+ <span class="en">Stay in Touch »</span>
+ </a></li>
+ </ul>
+ </li>
+ <li class="nav-section">
<div class="nav-section-header" style="font-weight:normal"><a href="<?cs var:toroot?>distribute/googleplay/edu/about.html">
<span class="en">Google Play for Education</span>
</a>
@@ -56,7 +73,6 @@
</ul>
</li>
</ul>
-
<script type="text/javascript">
<!--
buildToggleLists();
diff --git a/docs/html/distribute/googleplay/index.jd b/docs/html/distribute/googleplay/index.jd
index 20f07fa..b25f6b75 100644
--- a/docs/html/distribute/googleplay/index.jd
+++ b/docs/html/distribute/googleplay/index.jd
@@ -26,7 +26,7 @@
<div class="resource-widget resource-flow-layout landing col-16"
data-query="collection:distribute/gp/gpfelanding"
data-cardSizes="6x6"
- data-maxResults="3">
+ data-maxResults="5">
</div>
<h3>Related resources</h3>
diff --git a/docs/html/distribute/images/about-dff-sm.jpg b/docs/html/distribute/images/about-dff-sm.jpg
new file mode 100644
index 0000000..10cc5fa
--- /dev/null
+++ b/docs/html/distribute/images/about-dff-sm.jpg
Binary files differ
diff --git a/docs/html/images/gp-dff-appinfo.png b/docs/html/images/gp-dff-appinfo.png
new file mode 100644
index 0000000..30f58b8
--- /dev/null
+++ b/docs/html/images/gp-dff-appinfo.png
Binary files differ
diff --git a/docs/html/images/gp-dff-optin.png b/docs/html/images/gp-dff-optin.png
new file mode 100644
index 0000000..9f97d2d
--- /dev/null
+++ b/docs/html/images/gp-dff-optin.png
Binary files differ
diff --git a/docs/html/jd_collections.js b/docs/html/jd_collections.js
index 05a8a3e..99b9dd1 100644
--- a/docs/html/jd_collections.js
+++ b/docs/html/jd_collections.js
@@ -87,7 +87,8 @@
"distribute/googleplay/auto.html",
"distribute/googleplay/tv.html",
"distribute/googleplay/wear.html",
- "distribute/googleplay/edu/about.html"
+ "distribute/googleplay/edu/about.html",
+ "distribute/googleplay/families/about.html"
]
},
"distribute/essentials": {
diff --git a/docs/html/tools/debugging/debugging-memory.jd b/docs/html/tools/debugging/debugging-memory.jd
index ae67b3c..5893ad1 100644
--- a/docs/html/tools/debugging/debugging-memory.jd
+++ b/docs/html/tools/debugging/debugging-memory.jd
@@ -24,63 +24,72 @@
<p>Because Android is designed for mobile devices, you should always be careful about how much
-random-access memory (RAM) your app uses. Although Android’s Dalvik virtual machine performs
-routine garbage collection, this doesn’t mean you can ignore when and where your app allocates and
+random-access memory (RAM) your application uses. Although Dalvik and ART perform
+routine garbage collection (GC), this doesn’t mean you can ignore when and where your application allocates and
releases memory. In order to provide a stable user experience that allows the system to quickly
-switch between apps, it’s important that your app does not needlessly consume memory when the user
+switch between apps, it is important that your application does not needlessly consume memory when the user
is not interacting with it.</p>
<p>Even if you follow all the best practices for <a href="{@docRoot}training/articles/memory.html"
>Managing Your App Memory</a> during
development (which you should), you still might leak objects or introduce other memory bugs. The
-only way to be certain your app is using as little memory as possible is to analyze your app’s
+only way to be certain your application is using as little memory as possible is to analyze your app’s
memory usage with tools. This guide shows you how to do that.</p>
<h2 id="LogMessages">Interpreting Log Messages</h2>
-<p>The simplest place to begin investigating your apps memory usage is the Dalvik log messages. You'll
-find these log messages in <a href="{@docRoot}tools/help/logcat.html">logcat</a> (the output is
-available in the Device Monitor or directly in IDEs such as Eclipse and Android Studio).</p>
+<p>The simplest place to begin investigating your application’s memory usage is the runtime log messages.
+Sometimes when a GC occurs, a message is printed to
+<a href="{@docRoot}tools/help/logcat.html">logcat</a>. The logcat output is also available in the
+Device Monitor or directly in IDEs such as Eclipse and Android Studio.</p>
-<p>Every time a garbage collection occurs, logcat prints a message with the following information:</p>
+<h3 id="DalvikLogMessages">Dalvik Log Messages</h3>
+
+<p>In Dalvik (but not ART), every GC prints the following information to logcat:</p>
<pre class="no-pretty-print">
D/dalvikvm: <GC_Reason> <Amount_freed>, <Heap_stats>, <External_memory_stats>, <Pause_time>
</pre>
+<p>Example:</p>
+
+<pre class="no-pretty-print">
+D/dalvikvm( 9050): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external 4703K/5261K, paused 2ms+2ms
+</pre>
+
<dl>
<dt>GC Reason</dt>
<dd>
-What triggered the garbage collection and what kind of collection it is. Reasons that may appear
+What triggered the GC and what kind of collection it is. Reasons that may appear
include:
<dl>
<dt><code>GC_CONCURRENT</code></dt>
-<dd>A concurrent garbage collection that frees up memory as your heap begins to fill up.</dd>
+<dd>A concurrent GC that frees up memory as your heap begins to fill up.</dd>
<dt><code>GC_FOR_MALLOC</code></dt>
-<dd>A garbage collection caused because your app attempted to allocate memory when your heap was
-already full, so the system had to stop your app and reclaim memory.</dd>
+<dd>A GC caused because your application attempted to allocate memory when your heap was
+already full, so the system had to stop your application and reclaim memory.</dd>
<dt><code>GC_HPROF_DUMP_HEAP</code></dt>
-<dd>A garbage collection that occurs when you create an HPROF file to analyze your heap.</dd>
+<dd>A GC that occurs when you request to create an HPROF file to analyze your heap.</dd>
<dt><code>GC_EXPLICIT</code>
-<dd>An explicit garbage collection, such as when you call {@link java.lang.System#gc()} (which you
-should avoid calling and instead trust the garbage collector to run when needed).</dd>
+<dd>An explicit GC, such as when you call {@link java.lang.System#gc()} (which you
+should avoid calling and instead trust the GC to run when needed).</dd>
<dt><code>GC_EXTERNAL_ALLOC</code></dt>
<dd>This happens only on API level 10 and lower (newer versions allocate everything in the Dalvik
-heap). A garbage collection for externally allocated memory (such as the pixel data stored in
+heap). A GC for externally allocated memory (such as the pixel data stored in
native memory or NIO byte buffers).</dd>
</dl>
</dd>
<dt>Amount freed</dt>
-<dd>The amount of memory reclaimed from this garbage collection.</dd>
+<dd>The amount of memory reclaimed from this GC.</dd>
<dt>Heap stats</dt>
-<dd>Percentage free and (number of live objects)/(total heap size).</dd>
+<dd>Percentage free of the heap and (number of live objects)/(total heap size).</dd>
<dt>External memory stats</dt>
<dd>Externally allocated memory on API level 10 and lower (amount of allocated memory) / (limit at
@@ -91,20 +100,141 @@
beginning of the collection and another near the end.</dd>
</dl>
-<p>For example:</p>
+<p>As these log messages accumulate, look out for increases in the heap stats (the
+{@code 3571K/9991K} value in the above example). If this value continues to increase, you may have
+a memory leak.</p>
+
+
+<h3 id="ARTLogMessages">ART Log Messages</h3>
+
+<p>Unlike Dalvik, ART doesn't log messqages for GCs that were not explicity requested. GCs are only
+printed when they are they are deemed slow. More precisely, if the GC pause exceeds than 5ms or
+the GC duration exceeds 100ms. If the application is not in a pause perceptible process state,
+then none of its GCs are deemed slow. Explicit GCs are always logged.</p>
+
+<p>ART includes the following information in its garbage collection log messages:</p>
<pre class="no-pretty-print">
-D/dalvikvm( 9050): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external 4703K/5261K, paused 2ms+2ms
+I/art: <GC_Reason> <GC_Name> <Objects_freed>(<Size_freed>) AllocSpace Objects, <Large_objects_freed>(<Large_object_size_freed>) <Heap_stats> LOS objects, <Pause_time(s)>
</pre>
-<p>As these log messages stack up, look out for increases in the heap stats (the
-{@code 3571K/9991K} value in the above example). If this value
-continues to increase and doesn't ever seem to get smaller, you could have a memory leak.</p>
+<p>Example:</p>
+<pre class="no-pretty-print">
+I/art : Explicit concurrent mark sweep GC freed 104710(7MB) AllocSpace objects, 21(416KB) LOS objects, 33% free, 25MB/38MB, paused 1.230ms total 67.216ms
+</pre>
+
+<dl>
+<dt>GC Reason</dt>
+<dd>
+What triggered the GC and what kind of collection it is. Reasons that may appear
+include:
+<dl>
+<dt><code>Concurrent</code></dt>
+<dd>A concurrent GC which does not suspend application threads. This GC runs in a background thread
+and does not prevent allocations.</dd>
+
+<dt><code>Alloc</code></dt>
+<dd>The GC was initiated because your application attempted to allocate memory when your heap
+was already full. In this case, the garbage collection occurred in the allocating thread.</dd>
+
+<dt><code>Explicit</code>
+<dd>The garbage collection was explicitly requested by an application, for instance, by
+calling {@link java.lang.System#gc()} or {@link java.lang.Runtime#gc()}. As with Dalvik, in ART it is
+recommended that you trust the GC and avoid requesting explicit GCs if possible. Explicit GCs are
+discouraged since they block the allocating thread and unnecessarily was CPU cycles. Explicit GCs
+could also cause jank if they cause other threads to get preempted.</dd>
+
+<dt><code>NativeAlloc</code></dt>
+<dd>The collection was caused by native memory pressure from native allocations such as Bitmaps or
+RenderScript allocation objects.</dd>
+
+<dt><code>CollectorTransition</code></dt>
+<dd>The collection was caused by a heap transition; this is caused by switching the GC at run time.
+Collector transitions consist of copying all the objects from a free-list backed
+space to a bump pointer space (or visa versa). Currently collector transitions only occur when an
+application changes process states from a pause perceptible state to a non pause perceptible state
+(or visa versa) on low RAM devices.
+</dd>
+
+<dt><code>HomogeneousSpaceCompact</code></dt>
+<dd>Homogeneous space compaction is free-list space to free-list space compaction which usually
+occurs when an application is moved to a pause imperceptible process state. The main reasons for doing
+this are reducing RAM usage and defragmenting the heap.
+</dd>
+
+<dt><code>DisableMovingGc</code></dt>
+<dd>This is not a real GC reason, but a note that collection was blocked due to use of
+GetPrimitiveArrayCritical. while concurrent heap compaction is occuring. In general, the use of
+GetPrimitiveArrayCritical is strongly discouraged due to its restrictions on moving collectors.
+</dd>
+
+<dt><code>HeapTrim</code></dt>
+<dd>This is not a GC reason, but a note that collection was blocked until a heap trim finished.
+</dd>
+
+</dl>
+</dd>
+
+
+<dl>
+<dt>GC Name</dt>
+<dd>
+ART has various different GCs which can get run.
+<dl>
+<dt><code>Concurrent mark sweep (CMS)</code></dt>
+<dd>A whole heap collector which frees collects all spaces other than the image space.</dd>
+
+<dt><code>Concurrent partial mark sweep</code></dt>
+<dd>A mostly whole heap collector which collects all spaces other than the image and zygote spaces.
+</dd>
+
+<dt><code>Concurrent sticky mark sweep</code></dt>
+<dd>A generational collector which can only free objects allocated since the last GC. This garbage
+collection is run more often than a full or partial mark sweep since it is faster and has lower pauses.
+</dd>
+
+<dt><code>Marksweep + semispace</code></dt>
+<dd>A non concurrent, copying GC used for heap transitions as well as homogeneous space
+compaction (to defragement the heap).</dd>
+
+</dl>
+</dd>
+
+<dt>Objects freed</dt>
+<dd>The number of objects which were reclaimed from this GC from the non large
+object space.</dd>
+
+<dt>Size freed</dt>
+<dd>The number of bytes which were reclaimed from this GC from the non large object
+space.</dd>
+
+<dt>Large objects freed</dt>
+<dd>The number of object in the large object space which were reclaimed from this garbage
+collection.</dd>
+
+<dt>Large object size freed</dt>
+<dd>The number of bytes in the large object space which were reclaimed from this garbage
+collection.</dd>
+
+<dt>Heap stats</dt>
+<dd>Percentage free and (number of live objects)/(total heap size).</dd>
+
+<dt>Pause times</dt>
+<dd>In general pause times are proportional to the number of object references which were modified
+while the GC was running. Currently, the ART CMS GCs only has one pause, near the end of the GC.
+The moving GCs have a long pause which lasts for the majority of the GC duration.</dd>
+</dl>
+
+<p>If you are seeing a large amount of GCs in logcat, look for increases in the heap stats (the
+{@code 25MB/38MB} value in the above example). If this value continues to increase and doesn't
+ever seem to get smaller, you could have a memory leak. Alternatively, if you are seeing GC which
+are for the reason "Alloc", then you are already operating near your heap capacity and can expect
+OOM exceptios in the near future. </p>
<h2 id="ViewHeap">Viewing Heap Updates</h2>
-<p>To get a little information about what kind of memory your app is using and when, you can view
+<p>To get a little information about what kind of memory your application is using and when, you can view
real-time updates to your app's heap in the Device Monitor:</p>
<ol>
@@ -117,15 +247,15 @@
</ol>
<p>The Heap view shows some basic stats about your heap memory usage, updated after every
-garbage collection. To see the first update, click the <strong>Cause GC</strong> button.</p>
+GC. To see the first update, click the <strong>Cause GC</strong> button.</p>
<img src="{@docRoot}images/tools/monitor-vmheap@2x.png" width="760" alt="" />
<p class="img-caption"><strong>Figure 1.</strong> The Device Monitor tool,
showing the <strong>[1] Update Heap</strong> and <strong>[2] Cause GC</strong> buttons.
The Heap tab on the right shows the heap results.</p>
-<p>Continue interacting with your app to watch your heap allocation update with each garbage
-collection. This can help you identify which actions in your app are likely causing too much
+<p>Continue interacting with your application to watch your heap allocation update with each garbage
+collection. This can help you identify which actions in your application are likely causing too much
allocation and where you should try to reduce allocations and release
resources.</p>
@@ -136,9 +266,9 @@
<p>As you start narrowing down memory issues, you should also use the Allocation Tracker to
get a better understanding of where your memory-hogging objects are allocated. The Allocation
Tracker can be useful not only for looking at specific uses of memory, but also to analyze critical
-code paths in an app such as scrolling.</p>
+code paths in an application such as scrolling.</p>
-<p>For example, tracking allocations when flinging a list in your app allows you to see all the
+<p>For example, tracking allocations when flinging a list in your application allows you to see all the
allocations that need to be done for that behavior, what thread they are on, and where they came
from. This is extremely valuable for tightening up these paths to reduce the work they need and
improve the overall smoothness of the UI.</p>
@@ -151,7 +281,7 @@
<li>In the DDMS window, select your app's process in the left-side panel.</li>
<li>In the right-side panel, select the <strong>Allocation Tracker</strong> tab.</li>
<li>Click <strong>Start Tracking</strong>.</li>
-<li>Interact with your app to execute the code paths you want to analyze.</li>
+<li>Interact with your application to execute the code paths you want to analyze.</li>
<li>Click <strong>Get Allocations</strong> every time you want to update the
list of allocations.</li>
</ol>
@@ -163,7 +293,7 @@
<img src="{@docRoot}images/tools/monitor-tracker@2x.png" width="760" alt="" />
<p class="img-caption"><strong>Figure 2.</strong> The Device Monitor tool,
-showing recent app allocations and stack traces in the Allocation Tracker.</p>
+showing recent application allocations and stack traces in the Allocation Tracker.</p>
<p class="note"><strong>Note:</strong> You will always see some allocations from {@code
@@ -186,9 +316,11 @@
following <a href="{@docRoot}tools/help/adb.html">adb</a> command:</p>
<pre class="no-pretty-print">
-adb shell dumpsys meminfo <package_name>
+adb shell dumpsys meminfo <package_name|pid> [-d]
</pre>
+<p>The -d flag prints more info related to Dalvik and ART memory usage.</p>
+
<p>The output lists all of your app's current allocations, measured in kilobytes.</p>
<p>When inspecting this information, you should be familiar with the
@@ -218,13 +350,57 @@
total available RAM.</p>
-<p>For example, below is the the output for Gmail’s process on a tablet device. There is a lot of
+<p>For example, below is the the output for Map’s process on a Nexus 5 device. There is a lot of
information here, but key points for discussion are listed below.</p>
+<code>adb shell dumpsys meminfo com.google.android.apps.maps -d</code>
<p class="note"><strong>Note:</strong> The information you see may vary slightly from what is shown
here, as some details of the output differ across platform versions.</p>
<pre class="no-pretty-print">
+** MEMINFO in pid 18227 [com.google.android.apps.maps] **
+ Pss Private Private Swapped Heap Heap Heap
+ Total Dirty Clean Dirty Size Alloc Free
+ ------ ------ ------ ------ ------ ------ ------
+ Native Heap 10468 10408 0 0 20480 14462 6017
+ Dalvik Heap 34340 33816 0 0 62436 53883 8553
+ Dalvik Other 972 972 0 0
+ Stack 1144 1144 0 0
+ Gfx dev 35300 35300 0 0
+ Other dev 5 0 4 0
+ .so mmap 1943 504 188 0
+ .apk mmap 598 0 136 0
+ .ttf mmap 134 0 68 0
+ .dex mmap 3908 0 3904 0
+ .oat mmap 1344 0 56 0
+ .art mmap 2037 1784 28 0
+ Other mmap 30 4 0 0
+ EGL mtrack 73072 73072 0 0
+ GL mtrack 51044 51044 0 0
+ Unknown 185 184 0 0
+ TOTAL 216524 208232 4384 0 82916 68345 14570
+
+ Dalvik Details
+ .Heap 6568 6568 0 0
+ .LOS 24771 24404 0 0
+ .GC 500 500 0 0
+ .JITCache 428 428 0 0
+ .Zygote 1093 936 0 0
+ .NonMoving 1908 1908 0 0
+ .IndirectRef 44 44 0 0
+
+ Objects
+ Views: 90 ViewRootImpl: 1
+ AppContexts: 4 Activities: 1
+ Assets: 2 AssetManagers: 2
+ Local Binders: 21 Proxy Binders: 28
+ Parcel memory: 18 Parcel count: 74
+ Death Recipients: 2 OpenSSL Sockets: 2
+</pre>
+
+<p>Here is an older dumpsys on Dalvik of the gmail app:</p>
+
+<pre class="no-pretty-print">
** MEMINFO in pid 9953 [com.google.android.gm] **
Pss Pss Shared Private Shared Private Heap Heap Heap
Total Clean Dirty Dirty Clean Clean Size Alloc Free
@@ -272,7 +448,7 @@
<p class="note"><strong>Note:</strong> On newer platform versions that have the <code>Dalvik
Other</code> section, the <code>Pss Total</code> and <code>Private Dirty</code> numbers for Dalvik Heap do
-not include Dalvik overhead such as the just-in-time compilation (JIT) and garbage collection (GC)
+not include Dalvik overhead such as the just-in-time compilation (JIT) and GC
bookkeeping, whereas older versions list it all combined under <code>Dalvik</code>.</p>
<p>The <code>Heap Alloc</code> is the amount of memory that the Dalvik and native heap allocators keep
@@ -282,12 +458,62 @@
</dd>
<dt><code>.so mmap</code> and <code>.dex mmap</code></dt>
-<dd>The RAM being used for mmapped <code>.so</code> (native) and <code>.dex</code> (Dalvik) code. The
-<code>Pss Total</code> number includes platform code shared across apps; the <code>Private Clean</code> is
-your app’s own code. Generally, the actual mapped size will be much larger—the RAM here is only
-what currently needs to be in RAM for code that has been executed by the app. However, the .so mmap
-has a large private dirty, which is due to fix-ups to the native code when it was loaded into its
-final address.
+<dd>The RAM being used for mmapped <code>.so</code> (native) and <code>.dex</code> (Dalvik or ART)
+code. The <code>Pss Total</code> number includes platform code shared across apps; the
+<code>Private Clean</code> is your app’s own code. Generally, the actual mapped size will be much
+larger—the RAM here is only what currently needs to be in RAM for code that has been executed by
+the app. However, the .so mmap has a large private dirty, which is due to fix-ups to the native
+code when it was loaded into its final address.
+</dd>
+
+<dt><code>.oat mmap</code></dt>
+<dd>This is the amount of RAM used by the code image which is based off of the preloaded classes
+which are commonly used by multiple apps. This image is shared across all apps and is unaffected
+by particular apps.
+</dd>
+
+<dt><code>.art mmap</code></dt>
+<dd>This is the amount of RAM used by the heap image which is based off of the preloaded classes
+which are commonly used by multiple apps. This image is shared across all apps and is unaffected
+by particular apps. Even though the ART image contains {@link java.lang.Object} instances, it does not
+count towards your heap size.
+</dd>
+
+<dt><code>.Heap</code> (only with -d flag)</dt>
+<dd>This is the amount of heap memory for your app. This excludes objects in the image and large
+object spaces, but includes the zygote space and non-moving space.
+</dd>
+
+<dt><code>.LOS</code> (only with -d flag)</dt>
+<dd>This is the amount of RAM used by the ART large object space. This includes zygote large
+objects. Large objects are all primitive array allocations larger than 12KB.
+</dd>
+
+<dt><code>.GC</code> (only with -d flag)</dt>
+<dd>This is the amount of internal GC accounting overhead for your app. There is not really any way
+to reduce this overhead.
+</dd>
+
+<dt><code>.JITCache</code> (only with -d flag)</dt>
+<dd>This is the amount of memory used by the JIT data and code caches. Typically, this is zero
+since all of the apps will be compiled at installed time.
+</dd>
+
+<dt><code>.Zygote</code> (only with -d flag)</dt>
+<dd>This is the amount of memory used by the zygote space. The zygote space is created during
+device startup and is never allocated into.
+</dd>
+
+<dt><code>.NonMoving</code> (only with -d flag)</dt>
+<dd>This is the amount of RAM used by the ART non-moving space. The non-moving space contains
+special non-movable objects such as fields and methods. You can reduce this section by using fewer
+fields and methods in your app.
+</dd>
+
+<dt><code>.IndirectRef</code> (only with -d flag)</dt>
+<dd>This is the amount of RAM used by the ART indirect reference tables. Usually this amount is
+small, but if it is too high, it may be possible to reduce it by reducing the number of local and
+global JNI references used.
</dd>
<dt><code>Unknown</code></dt>
@@ -318,7 +544,7 @@
</dd>
<dt><code>AppContexts</code> and <code>Activities</code></dt>
-<dd>The number of app {@link android.content.Context} and {@link android.app.Activity} objects that
+<dd>The number of application {@link android.content.Context} and {@link android.app.Activity} objects that
currently live in your process. This can be useful to quickly identify leaked {@link
android.app.Activity} objects that can’t be garbage collected due to static references on them,
which is common. These objects often have a lot of other allocations associated with them and so
@@ -327,7 +553,7 @@
<p class="note"><strong>Note:</strong> A {@link android.view.View} or {@link
android.graphics.drawable.Drawable} object also holds a reference to the {@link
android.app.Activity} that it's from, so holding a {@link android.view.View} or {@link
-android.graphics.drawable.Drawable} object can also lead to your app leaking an {@link
+android.graphics.drawable.Drawable} object can also lead to your application leaking an {@link
android.app.Activity}.</p>
</dd>
@@ -363,13 +589,13 @@
showing the <strong>[1] Dump HPROF file</strong> button.</p>
<p>If you need to be more precise about when the dump is created, you can also create a heap dump
-at the critical point in your app code by calling {@link android.os.Debug#dumpHprofData
+at the critical point in your application code by calling {@link android.os.Debug#dumpHprofData
dumpHprofData()}.</p>
<p>The heap dump is provided in a format that's similar to, but not identical to one from the Java
HPROF tool. The major difference in an Android heap dump is due to the fact that there are a large
number of allocations in the Zygote process. But because the Zygote allocations are shared across
-all app processes, they don’t matter very much to your own heap analysis.</p>
+all application processes, they don’t matter very much to your own heap analysis.</p>
<p>To analyze your heap dump, you can use a standard tool like jhat or the <a href=
"http://www.eclipse.org/mat/downloads.php">Eclipse Memory Analyzer Tool</a> (MAT). However, first
@@ -434,7 +660,7 @@
<p class="note"><strong>Note:</strong> Most apps will show an instance of
{@link android.content.res.Resources} near the top with a good chunk of heap, but this is
- usually expected when your app uses lots of resources from your {@code res/} directory.</p>
+ usually expected when your application uses lots of resources from your {@code res/} directory.</p>
</li>
</ul>
@@ -473,19 +699,19 @@
<h2 id="TriggerLeaks">Triggering Memory Leaks</h2>
-<p>While using the tools described above, you should aggressively stress your app code and try
-forcing memory leaks. One way to provoke memory leaks in your app is to let it
+<p>While using the tools described above, you should aggressively stress your application code and try
+forcing memory leaks. One way to provoke memory leaks in your application is to let it
run for a while before inspecting the heap. Leaks will trickle up to the top of the allocations in
-the heap. However, the smaller the leak, the longer you need to run the app in order to see it.</p>
+the heap. However, the smaller the leak, the longer you need to run the application in order to see it.</p>
<p>You can also trigger a memory leak in one of the following ways:</p>
<ol>
<li>Rotate the device from portrait to landscape and back again multiple times while in different
-activity states. Rotating the device can often cause an app to leak an {@link android.app.Activity},
+activity states. Rotating the device can often cause an application to leak an {@link android.app.Activity},
{@link android.content.Context}, or {@link android.view.View} object because the system
-recreates the {@link android.app.Activity} and if your app holds a reference
+recreates the {@link android.app.Activity} and if your application holds a reference
to one of those objects somewhere else, the system can't garbage collect it.</li>
-<li>Switch between your app and another app while in different activity states (navigate to
+<li>Switch between your application and another application while in different activity states (navigate to
the Home screen, then return to your app).</li>
</ol>
diff --git a/docs/html/tools/extras/oem-usb.jd b/docs/html/tools/extras/oem-usb.jd
index b25b41e..6d449ee 100644
--- a/docs/html/tools/extras/oem-usb.jd
+++ b/docs/html/tools/extras/oem-usb.jd
@@ -32,12 +32,13 @@
To start developing with your device, read <a
href="{@docRoot}tools/device.html">Using Hardware Devices</a>.</p>
-<p class="note"><strong>Note:</strong> If your device is one of the Android Developer Phones
-(ADP), a Nexus One, or a Nexus S, then you need
-the <a href="{@docRoot}sdk/win-usb.html">Google USB Driver</a>, instead of an OEM driver. The Galaxy
-Nexus driver, however, is distributed by <a
-href="http://www.samsung.com/us/support/downloads/verizon-wireless/SCH-I515MSAVZW">Samsung</a>
-(listed as model SCH-I515).</p>
+<p>The Google USB Driver is <strong>required for Windows only</strong> in order to perform
+<a href="{@docRoot}tools/help/adb.html">adb</a> debugging with any of
+the <strong>Google Nexus devices</strong>. The one exception is the
+Galaxy Nexus: the driver for Galaxy Nexus is distributed by <a
+href="http://www.samsung.com/us/support/owners/product/GT-I9250TSGGEN">Samsung</a>
+(listed as model GT-I9250TSGGEN).</p>
+
<h2 id="InstallingDriver">Installing a USB Driver</h2>
@@ -99,7 +100,7 @@
<li>Select <strong>Device Manager</strong> in the left pane of the Computer Management
window.</li>
<li>Locate and expand <em>Android Phone</em> in the right pane.</li>
- <li>Right-click <em>Android Composite ADB Interface</em> and select <strong>Update
+ <li>Right-click on <em>Android Composite ADB Interface</em> and select <strong>Update
Driver</strong>.
This will launch the Hardware Update Wizard.</li>
<li>Select <strong>Install from a list or specific location</strong> and click
@@ -145,14 +146,14 @@
and select <strong>Manage</strong>.</li>
<li>Select <strong>Device Manager</strong> in the left pane.</li>
<li>Locate and expand <em>ADB Interface</em> in the right pane.</li>
- <li>Right-click on <em>HTC Dream Composite ADB Interface</em>, and select <strong>Update
+ <li>Right-click on <em>Android Composite ADB Interface</em>, and select <strong>Update
Driver Software</strong>.</li>
<li>When Vista starts updating the driver, a prompt will ask how you want to
search for the driver
software. Select <strong>Browse my computer for driver software</strong>.</li>
<li>Click <strong>Browse</strong> and locate the USB driver folder. (The Google USB
Driver is located in {@code <sdk>\extras\google\usb_driver\}.) As long as you specified the
-exact location of the
+exact location of the
installation package, you may leave <strong>Include subfolders</strong> checked or
unchecked—it doesn't matter.</li>
<li>Click <strong>Next</strong>. Vista might prompt you to confirm the privilege elevation
@@ -164,13 +165,6 @@
<h2 id="Drivers">OEM Drivers</h2>
-<p class="note"><strong>Note:</strong> If your device is one of the Android Developer Phones
-(purchased from the Google Play Developer Console), a Nexus One, or a Nexus S, then you need
-the <a href="{@docRoot}sdk/win-usb.html">Google USB Driver</a>, instead of an OEM driver. The Galaxy
-Nexus driver, however, is distributed by <a
-href="http://www.samsung.com/us/support/downloads/verizon-wireless/SCH-I515MSAVZW">Samsung</a>
-(listed as model SCH-I515).</p>
-
<table><tr>
<th>OEM</th>
diff --git a/docs/html/tools/help/adb.jd b/docs/html/tools/help/adb.jd
index e2dd196..41c6686 100644
--- a/docs/html/tools/help/adb.jd
+++ b/docs/html/tools/help/adb.jd
@@ -962,7 +962,6 @@
</code></td>
<td>Installs a package (specified by {@code <PATH>}) to the system. <p>Options:
<ul>
- <li>{@code -l}: Install the package with forward lock.
<li>{@code -r}: Reinstall an exisiting app, keeping its data.
<li>{@code -t}: Allow test APKs to be installed.
<li>{@code -i <INSTALLER_PACKAGE_NAME>}: Specify the installer package name.
diff --git a/docs/html/tools/help/systrace.jd b/docs/html/tools/help/systrace.jd
index d6fc05e..4461da9 100644
--- a/docs/html/tools/help/systrace.jd
+++ b/docs/html/tools/help/systrace.jd
@@ -68,7 +68,8 @@
<ol>
<li>In <a href="{@docRoot}sdk/installing/studio.html">Android Studio</a>, open an
Android application project.</li>
- <li>Open the Device Monitor by selecting <strong>Tools > Android > Monitor</strong>.</li>
+ <li>Open the Device Monitor by selecting <strong>Tools > Android > Android Device
+ Monitor</strong>.</li>
<li>In the <strong>Devices</strong> tab, select the device on which to run a trace. If no
devices are listed, make sure your device is connected via USB cable and that debugging is
enabled on the device.</li>
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index 71088b7..8b11757 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -709,7 +709,7 @@
void SkiaCanvas::drawTextOnPath(const uint16_t* glyphs, int count, const SkPath& path,
float hOffset, float vOffset, const SkPaint& paint) {
- mCanvas->drawTextOnPathHV(glyphs, count, path, hOffset, vOffset, paint);
+ mCanvas->drawTextOnPathHV(glyphs, count << 1, path, hOffset, vOffset, paint);
}
} // namespace android
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardware.java b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
index bc5a8a1..480a18c 100644
--- a/location/lib/java/com/android/location/provider/FusedLocationHardware.java
+++ b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
@@ -34,7 +34,7 @@
* Class that exposes IFusedLocationHardware functionality to unbundled services.
*/
public final class FusedLocationHardware {
- private final String TAG = "FusedLocationHardware";
+ private static final String TAG = "FusedLocationHardware";
private IFusedLocationHardware mLocationHardware;
@@ -52,6 +52,16 @@
public void onDiagnosticDataAvailable(String data) {
dispatchDiagnosticData(data);
}
+
+ @Override
+ public void onCapabilities(int capabilities) {
+ dispatchCapabilities(capabilities);
+ }
+
+ @Override
+ public void onStatusChanged(int status) {
+ dispatchStatus(status);
+ }
};
/**
@@ -164,6 +174,14 @@
}
}
+ public void flushBatchedLocations() {
+ try {
+ mLocationHardware.flushBatchedLocations();
+ } catch(RemoteException e) {
+ Log.e(TAG, "RemoteException at flushBatchedLocations");
+ }
+ }
+
public boolean supportsDiagnosticDataInjection() {
try {
return mLocationHardware.supportsDiagnosticDataInjection();
@@ -204,6 +222,8 @@
private class DispatcherHandler extends Handler {
public static final int DISPATCH_LOCATION = 1;
public static final int DISPATCH_DIAGNOSTIC_DATA = 2;
+ public static final int DISPATCH_CAPABILITIES = 3;
+ public static final int DISPATCH_STATUS = 4;
public DispatcherHandler(Looper looper) {
super(looper, null /*callback*/ , true /*async*/);
@@ -218,6 +238,13 @@
break;
case DISPATCH_DIAGNOSTIC_DATA:
command.dispatchDiagnosticData();
+ break;
+ case DISPATCH_CAPABILITIES:
+ command.dispatchCapabilities();
+ break;
+ case DISPATCH_STATUS:
+ command.dispatchStatus();
+ break;
default:
Log.e(TAG, "Invalid dispatch message");
break;
@@ -229,14 +256,20 @@
private final FusedLocationHardwareSink mSink;
private final Location[] mLocations;
private final String mData;
+ private final int mCapabilities;
+ private final int mStatus;
public MessageCommand(
FusedLocationHardwareSink sink,
Location[] locations,
- String data) {
+ String data,
+ int capabilities,
+ int status) {
mSink = sink;
mLocations = locations;
mData = data;
+ mCapabilities = capabilities;
+ mStatus = status;
}
public void dispatchLocation() {
@@ -246,6 +279,14 @@
public void dispatchDiagnosticData() {
mSink.onDiagnosticDataAvailable(mData);
}
+
+ public void dispatchCapabilities() {
+ mSink.onCapabilities(mCapabilities);
+ }
+
+ public void dispatchStatus() {
+ mSink.onStatusChanged(mStatus);
+ }
}
private void dispatchLocations(Location[] locations) {
@@ -258,7 +299,7 @@
Message message = Message.obtain(
entry.getValue(),
DispatcherHandler.DISPATCH_LOCATION,
- new MessageCommand(entry.getKey(), locations, null /*data*/));
+ new MessageCommand(entry.getKey(), locations, null /*data*/, 0, 0));
message.sendToTarget();
}
}
@@ -273,7 +314,37 @@
Message message = Message.obtain(
entry.getValue(),
DispatcherHandler.DISPATCH_DIAGNOSTIC_DATA,
- new MessageCommand(entry.getKey(), null /*locations*/, data));
+ new MessageCommand(entry.getKey(), null /*locations*/, data, 0, 0));
+ message.sendToTarget();
+ }
+ }
+
+ private void dispatchCapabilities(int capabilities) {
+ HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
+ synchronized(mSinkList) {
+ sinks = mSinkList;
+ }
+
+ for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
+ Message message = Message.obtain(
+ entry.getValue(),
+ DispatcherHandler.DISPATCH_CAPABILITIES,
+ new MessageCommand(entry.getKey(), null /*locations*/, null, capabilities, 0));
+ message.sendToTarget();
+ }
+ }
+
+ private void dispatchStatus(int status) {
+ HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
+ synchronized(mSinkList) {
+ sinks = mSinkList;
+ }
+
+ for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
+ Message message = Message.obtain(
+ entry.getValue(),
+ DispatcherHandler.DISPATCH_STATUS,
+ new MessageCommand(entry.getKey(), null /*locations*/, null, 0, status));
message.sendToTarget();
}
}
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
index 2c39fa8..618d5d6 100644
--- a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
+++ b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
@@ -20,11 +20,47 @@
/**
* Base class for sinks to interact with FusedLocationHardware.
+ *
+ * <p>Default implementations allow new methods to be added without crashing
+ * clients compiled against an old library version.
*/
-public abstract class FusedLocationHardwareSink {
- /*
- * Methods to provide a facade for IFusedLocationHardware
+public class FusedLocationHardwareSink {
+ /**
+ * Called when one or more locations are available from the FLP
+ * HAL.
*/
- public abstract void onLocationAvailable(Location[] locations);
- public abstract void onDiagnosticDataAvailable(String data);
+ public void onLocationAvailable(Location[] locations) {
+ // default do nothing
+ }
+
+ /**
+ * Called when diagnostic data is available from the FLP HAL.
+ */
+ public void onDiagnosticDataAvailable(String data) {
+ // default do nothing
+ }
+
+ /**
+ * Called when capabilities are available from the FLP HAL.
+ * Should be called once right after initialization.
+ *
+ * @param capabilities A bitmask of capabilities defined in
+ * fused_location.h.
+ */
+ public void onCapabilities(int capabilities) {
+ // default do nothing
+ }
+
+ /**
+ * Called when the status changes in the underlying FLP HAL
+ * implementation (the ability to compute location). This
+ * callback will only be made on API 23 or later.
+ *
+ * @param status One of FLP_STATUS_LOCATION_AVAILABLE or
+ * FLP_STATUS_LOCATION_UNAVAILABLE as defined in
+ * fused_location.h.
+ */
+ public void onStatusChanged(int status) {
+ // default do nothing
+ }
}
\ No newline at end of file
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index 9c6d640..fac69ea 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -214,6 +214,8 @@
private final Object mPlayStateLock = new Object();
/**
* Sizes of the native audio buffer.
+ * These values are set during construction and can be stale.
+ * To obtain the current native audio buffer frame count use {@link #getNativeFrameCount()}.
*/
private int mNativeBufferSizeInBytes = 0;
private int mNativeBufferSizeInFrames = 0;
@@ -312,15 +314,20 @@
* {@link AudioFormat#ENCODING_PCM_8BIT},
* and {@link AudioFormat#ENCODING_PCM_FLOAT}.
* @param bufferSizeInBytes the total size (in bytes) of the internal buffer where audio data is
- * read from for playback.
- * If track's creation mode is {@link #MODE_STREAM}, you can write data into
- * this buffer in chunks less than or equal to this size, and it is typical to use
- * chunks of 1/2 of the total size to permit double-buffering.
- * If the track's creation mode is {@link #MODE_STATIC},
+ * read from for playback. This should be a multiple of the frame size in bytes.
+ * <p> If the track's creation mode is {@link #MODE_STATIC},
* this is the maximum length sample, or audio clip, that can be played by this instance.
- * See {@link #getMinBufferSize(int, int, int)} to determine the minimum required buffer size
- * for the successful creation of an AudioTrack instance in streaming mode. Using values
- * smaller than getMinBufferSize() will result in an initialization failure.
+ * <p> If the track's creation mode is {@link #MODE_STREAM},
+ * this should be the desired buffer size
+ * for the <code>AudioTrack</code> to satisfy the application's
+ * natural latency requirements.
+ * If <code>bufferSizeInBytes</code> is less than the
+ * minimum buffer size for the output sink, it is automatically increased to the minimum
+ * buffer size.
+ * The method {@link #getNativeFrameCount()} returns the
+ * actual size in frames of the native buffer created, which
+ * determines the frequency to write
+ * to the streaming <code>AudioTrack</code> to avoid underrun.
* @param mode streaming or static buffer. See {@link #MODE_STATIC} and {@link #MODE_STREAM}
* @throws java.lang.IllegalArgumentException
*/
@@ -512,8 +519,10 @@
* {@link AudioManager#PROPERTY_OUTPUT_SAMPLE_RATE}), its channel configuration will be
* {@link AudioFormat#CHANNEL_OUT_STEREO} and the encoding will be
* {@link AudioFormat#ENCODING_PCM_16BIT}.
+ * <br>If the buffer size is not specified with {@link #setBufferSizeInBytes(int)},
+ * and the mode is {@link AudioTrack#MODE_STREAM}, the minimum buffer size is used.
* <br>If the transfer mode is not specified with {@link #setTransferMode(int)},
- * {@link AudioTrack#MODE_STREAM} will be used.
+ * <code>MODE_STREAM</code> will be used.
* <br>If the session ID is not specified with {@link #setSessionId(int)}, a new one will
* be generated.
*/
@@ -648,6 +657,13 @@
.build();
}
try {
+ // If the buffer size is not specified in streaming mode,
+ // use a single frame for the buffer size and let the
+ // native code figure out the minimum buffer size.
+ if (mMode == MODE_STREAM && mBufferSizeInBytes == 0) {
+ mBufferSizeInBytes = mFormat.getChannelCount()
+ * mFormat.getBytesPerSample(mFormat.getEncoding());
+ }
return new AudioTrack(mAttributes, mFormat, mBufferSizeInBytes, mMode, mSessionId);
} catch (IllegalArgumentException e) {
throw new UnsupportedOperationException(e.getMessage());
@@ -986,19 +1002,22 @@
}
/**
- * Returns the "native frame count", derived from the bufferSizeInBytes specified at
- * creation time and converted to frame units.
- * If track's creation mode is {@link #MODE_STATIC},
- * it is equal to the specified bufferSizeInBytes converted to frame units.
- * If track's creation mode is {@link #MODE_STREAM},
- * it is typically greater than or equal to the specified bufferSizeInBytes converted to frame
- * units; it may be rounded up to a larger value if needed by the target device implementation.
- * @deprecated Only accessible by subclasses, which are not recommended for AudioTrack.
- * See {@link AudioManager#getProperty(String)} for key
+ * Returns the "native frame count" of the <code>AudioTrack</code> buffer.
+ * <p> If the track's creation mode is {@link #MODE_STATIC},
+ * it is equal to the specified bufferSizeInBytes on construction, converted to frame units.
+ * A static track's native frame count will not change.
+ * <p> If the track's creation mode is {@link #MODE_STREAM},
+ * it is greater than or equal to the specified bufferSizeInBytes converted to frame units.
+ * For streaming tracks, this value may be rounded up to a larger value if needed by
+ * the target output sink, and
+ * if the track is subsequently routed to a different output sink, the native
+ * frame count may enlarge to accommodate.
+ * See also {@link AudioManager#getProperty(String)} for key
* {@link AudioManager#PROPERTY_OUTPUT_FRAMES_PER_BUFFER}.
+ * @return current size in frames of the audio track buffer.
+ * @throws IllegalStateException
*/
- @Deprecated
- protected int getNativeFrameCount() {
+ public int getNativeFrameCount() throws IllegalStateException {
return native_get_native_frame_count();
}
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index ebf73da..ce06e65 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -124,6 +124,8 @@
private static final Range<Integer> SIZE_RANGE = Range.create(1, 32768);
private static final Range<Integer> FRAME_RATE_RANGE = Range.create(0, 960);
private static final Range<Integer> BITRATE_RANGE = Range.create(0, 500000000);
+ private static final int DEFAULT_MAX_SUPPORTED_INSTANCES = 32;
+ private static final int MAX_SUPPORTED_INSTANCES_LIMIT = 256;
// found stuff that is not supported by framework (=> this should not happen)
private static final int ERROR_UNRECOGNIZED = (1 << 0);
@@ -147,6 +149,7 @@
// CLASSIFICATION
private String mMime;
+ private int mMaxSupportedInstances;
// LEGACY FIELDS
@@ -366,6 +369,18 @@
return mMime;
}
+ /**
+ * Returns the max number of the supported concurrent codec instances.
+ * <p>
+ * This is a hint for an upper bound. Applications should not expect to successfully
+ * operate more instances than the returned value, but the actual number of
+ * concurrently operable instances may be less as it depends on the available
+ * resources at time of use.
+ */
+ public int getMaxSupportedInstances() {
+ return mMaxSupportedInstances;
+ }
+
private boolean isAudio() {
return mAudioCaps != null;
}
@@ -467,6 +482,15 @@
mEncoderCaps.setDefaultFormat(mDefaultFormat);
}
+ final Map<String, Object> global = MediaCodecList.getGlobalSettings();
+ mMaxSupportedInstances = Utils.parseIntSafely(
+ global.get("max-supported-instances"), DEFAULT_MAX_SUPPORTED_INSTANCES);
+
+ int maxInstances = Utils.parseIntSafely(
+ map.get("max-supported-instances"), mMaxSupportedInstances);
+ mMaxSupportedInstances =
+ Range.create(1, MAX_SUPPORTED_INSTANCES_LIMIT).clamp(maxInstances);
+
for (Feature feat: getValidFeatures()) {
String key = MediaFormat.KEY_FEATURE_ + feat.mName;
Integer yesNo = (Integer)map.get(key);
diff --git a/media/java/android/media/MediaCodecList.java b/media/java/android/media/MediaCodecList.java
index 7fd0186..f44e048 100644
--- a/media/java/android/media/MediaCodecList.java
+++ b/media/java/android/media/MediaCodecList.java
@@ -21,6 +21,7 @@
import android.media.MediaCodecInfo;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Map;
/**
* Allows you to enumerate available codecs, each specified as a {@link MediaCodecInfo} object,
@@ -61,13 +62,19 @@
return sRegularCodecInfos[index];
}
+ /* package private */ static final Map<String, Object> getGlobalSettings() {
+ return sGlobalSettings;
+ }
+
private static Object sInitLock = new Object();
private static MediaCodecInfo[] sAllCodecInfos;
private static MediaCodecInfo[] sRegularCodecInfos;
+ private static Map<String, Object> sGlobalSettings;
private static final void initCodecList() {
synchronized (sInitLock) {
if (sRegularCodecInfos == null) {
+ sGlobalSettings = native_getGlobalSettings();
int count = native_getCodecCount();
ArrayList<MediaCodecInfo> regulars = new ArrayList<MediaCodecInfo>();
ArrayList<MediaCodecInfo> all = new ArrayList<MediaCodecInfo>();
@@ -112,6 +119,8 @@
/* package private */ static native final MediaCodecInfo.CodecCapabilities
getCodecCapabilities(int index, String type);
+ /* package private */ static native final Map<String, Object> native_getGlobalSettings();
+
/* package private */ static native final int findCodecByName(String codec);
/** @hide */
diff --git a/media/jni/android_media_MediaCodecList.cpp b/media/jni/android_media_MediaCodecList.cpp
index f8c349b..82dd48d 100644
--- a/media/jni/android_media_MediaCodecList.cpp
+++ b/media/jni/android_media_MediaCodecList.cpp
@@ -262,6 +262,27 @@
return caps;
}
+static jobject android_media_MediaCodecList_getGlobalSettings(JNIEnv *env, jobject /* thiz */) {
+ sp<IMediaCodecList> mcl = getCodecList(env);
+ if (mcl == NULL) {
+ // Runtime exception already pending.
+ return NULL;
+ }
+
+ const sp<AMessage> settings = mcl->getGlobalSettings();
+ if (settings == NULL) {
+ jniThrowException(env, "java/lang/RuntimeException", "cannot get global settings");
+ return NULL;
+ }
+
+ jobject settingsObj = NULL;
+ if (ConvertMessageToMap(env, settings, &settingsObj)) {
+ return NULL;
+ }
+
+ return settingsObj;
+}
+
static void android_media_MediaCodecList_native_init(JNIEnv* /* env */) {
}
@@ -277,6 +298,10 @@
"(ILjava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;",
(void *)android_media_MediaCodecList_getCodecCapabilities },
+ { "native_getGlobalSettings",
+ "()Ljava/util/Map;",
+ (void *)android_media_MediaCodecList_getGlobalSettings },
+
{ "findCodecByName", "(Ljava/lang/String;)I",
(void *)android_media_MediaCodecList_findCodecByName },
diff --git a/packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml b/packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml
index 7e09a5b..9b55e5b 100644
--- a/packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml
+++ b/packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml
@@ -46,7 +46,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="@dimen/eca_overlap"
- android:text="@string/kg_emergency_call_label"
+ android:text="@*android:string/lockscreen_emergency_call"
style="?android:attr/buttonBarButtonStyle"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/kg_status_line_font_size"
diff --git a/packages/Keyguard/res/values/strings.xml b/packages/Keyguard/res/values/strings.xml
index df221fa..e060b4a 100644
--- a/packages/Keyguard/res/values/strings.xml
+++ b/packages/Keyguard/res/values/strings.xml
@@ -122,8 +122,6 @@
<!-- Description of the Enter button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_enter">Enter</string>
- <!-- Label shown on emergency call button in keyguard -->
- <string name="kg_emergency_call_label">Emergency</string>
<!-- Message shown in pattern unlock after some number of unsuccessful attempts -->
<string name="kg_forgot_pattern_button_text">Forgot Pattern</string>
<!-- Message shown when user enters wrong pattern -->
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 0b6ab99..870f043 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2066,7 +2066,7 @@
LockPatternUtils lpu = new LockPatternUtils(mContext);
List<LockPatternView.Cell> cellPattern =
LockPatternUtils.stringToPattern(lockPattern);
- lpu.saveLockPattern(cellPattern);
+ lpu.saveLockPattern(cellPattern, null);
} catch (IllegalArgumentException e) {
// Don't want corrupted lock pattern to hang the reboot process
}
diff --git a/packages/SystemUI/res/drawable/stat_sys_managed_profile_status.xml b/packages/SystemUI/res/drawable/stat_sys_managed_profile_status.xml
new file mode 100644
index 0000000..3c4c646
--- /dev/null
+++ b/packages/SystemUI/res/drawable/stat_sys_managed_profile_status.xml
@@ -0,0 +1,29 @@
+<!--
+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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="23.0dp"
+ android:height="18.0dp"
+ android:viewportWidth="21.0"
+ android:viewportHeight="17.0">
+ <group android:translateX="2.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M9.9,11.6H7v-1.1H2.1v2.8c0,0.8,0.6,1.4,1.4,1.4h9.9c0.8,0,1.4,-0.6,1.4,-1.4v-2.8H9.9V11.6z"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M14.1,4.2h-2.5V3.2l-1.1,-1.1H6.3L5.3,3.2v1H2.8C2,4.2,1.4,4.9,1.4,5.6v2.8c0,0.8,0.6,1.4,1.4,1.4H7V8.8h2.8v1.1h4.2 c0.8,0,1.4,-0.6,1.4,-1.4V5.6C15.5,4.9,14.8,4.2,14.1,4.2z M10.6,4.2H6.3V3.2h4.2V4.2z"/>
+ </group>
+</vector>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 779b55e..fe974be 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -982,4 +982,7 @@
<!-- Volume dialog zen toggle switch title -->
<string name="volume_zen_switch_text">@*android:string/zen_mode_feature_name</string>
+
+ <!-- Toast shown when user unlocks screen and managed profile activity is in the foreground -->
+ <string name="managed_profile_foreground_toast">You are in the Work profile</string>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index d2837b7..ee607a7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -80,6 +80,7 @@
import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.TextView;
+import android.widget.Toast;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.StatusBarIcon;
@@ -378,6 +379,23 @@
userSwitched(mCurrentUserId);
} else if (Intent.ACTION_USER_ADDED.equals(action)) {
updateCurrentProfilesCache();
+ } else if (Intent.ACTION_USER_PRESENT.equals(action)) {
+ List<ActivityManager.RecentTaskInfo> recentTask = null;
+ try {
+ recentTask = ActivityManagerNative.getDefault().getRecentTasks(1,
+ ActivityManager.RECENT_WITH_EXCLUDED
+ | ActivityManager.RECENT_INCLUDE_PROFILES,
+ mCurrentUserId);
+ } catch (RemoteException e) {
+ // Abandon hope activity manager not running.
+ }
+ if (recentTask != null && recentTask.size() > 0) {
+ UserInfo user = mUserManager.getUserInfo(recentTask.get(0).userId);
+ if (user != null && user.isManagedProfile()) {
+ Toast.makeText(mContext, R.string.managed_profile_foreground_toast,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
} else if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(
action)) {
mUsersAllowingPrivateNotifications.clear();
@@ -612,6 +630,7 @@
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
filter.addAction(Intent.ACTION_USER_ADDED);
+ filter.addAction(Intent.ACTION_USER_PRESENT);
filter.addAction(BANNER_ACTION_CANCEL);
filter.addAction(BANNER_ACTION_SETUP);
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 7c199cd..b0d6178 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -3288,8 +3288,10 @@
}
if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) {
mScrimController.setKeyguardShowing(true);
+ mIconPolicy.setKeyguardShowing(true);
} else {
mScrimController.setKeyguardShowing(false);
+ mIconPolicy.setKeyguardShowing(false);
}
mNotificationPanel.setBarState(mState, mKeyguardFadingAway, goingToFullShade);
updateDozingState();
@@ -3724,6 +3726,9 @@
if (!mKeyguardFadingAway) {
mIconController.appTransitionStarting(startTime, duration);
}
+ if (mIconPolicy != null) {
+ mIconPolicy.appTransitionStarting(startTime, duration);
+ }
}
private final class ShadeUpdates {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index ac93ced..fb42ba1d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -16,16 +16,22 @@
package com.android.systemui.statusbar.phone;
+import android.app.ActivityManagerNative;
import android.app.AlarmManager;
+import android.app.IUserSwitchObserver;
import android.app.StatusBarManager;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.UserInfo;
import android.media.AudioManager;
import android.os.Handler;
+import android.os.IRemoteCallback;
+import android.os.RemoteException;
import android.os.UserHandle;
+import android.os.UserManager;
import android.provider.Settings.Global;
import android.telecom.TelecomManager;
import android.util.Log;
@@ -54,6 +60,7 @@
private static final String SLOT_ZEN = "zen";
private static final String SLOT_VOLUME = "volume";
private static final String SLOT_ALARM_CLOCK = "alarm_clock";
+ private static final String SLOT_MANAGED_PROFILE = "managed_profile";
private final Context mContext;
private final StatusBarManager mService;
@@ -72,6 +79,10 @@
private boolean mBluetoothEnabled = false;
+ private boolean mManagedProfileFocused = false;
+ private boolean mManagedProfileIconVisible = true;
+
+ private boolean mKeyguardVisible = true;
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
@@ -94,9 +105,6 @@
else if (action.equals(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED)) {
updateTTY(intent);
}
- else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
- updateAlarm();
- }
}
};
@@ -115,9 +123,15 @@
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
- filter.addAction(Intent.ACTION_USER_SWITCHED);
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
+ // listen for user / profile change.
+ try {
+ ActivityManagerNative.getDefault().registerUserSwitchObserver(mUserSwitchListener);
+ } catch (RemoteException e) {
+ // Ignore
+ }
+
// TTY status
mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0, null);
mService.setIconVisibility(SLOT_TTY, false);
@@ -147,6 +161,10 @@
mService.setIcon(SLOT_HOTSPOT, R.drawable.stat_sys_hotspot, 0, null);
mService.setIconVisibility(SLOT_HOTSPOT, mHotspot.isHotspotEnabled());
mHotspot.addCallback(mHotspotCallback);
+
+ // managed profile
+ mService.setIcon(SLOT_MANAGED_PROFILE, R.drawable.stat_sys_managed_profile_status, 0, null);
+ mService.setIconVisibility(SLOT_MANAGED_PROFILE, false);
}
public void setZenMode(int zen) {
@@ -298,6 +316,53 @@
mService.setIconVisibility(SLOT_CAST, isCasting);
}
+ private void profileChanged(int userId) {
+ UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ UserInfo user = null;
+ if (userId == UserHandle.USER_CURRENT) {
+ try {
+ user = ActivityManagerNative.getDefault().getCurrentUser();
+ } catch (RemoteException e) {
+ // Ignore
+ }
+ } else {
+ user = userManager.getUserInfo(userId);
+ }
+
+ mManagedProfileFocused = user != null && user.isManagedProfile();
+ if (DEBUG) Log.v(TAG, "profileChanged: mManagedProfileFocused: " + mManagedProfileFocused);
+ // Actually update the icon later when transition starts.
+ }
+
+ private void updateManagedProfile() {
+ if (DEBUG) Log.v(TAG, "updateManagedProfile: mManagedProfileFocused: "
+ + mManagedProfileFocused
+ + " mKeyguardVisible: " + mKeyguardVisible);
+ boolean showIcon = mManagedProfileFocused && !mKeyguardVisible;
+ if (mManagedProfileIconVisible != showIcon) {
+ mService.setIconVisibility(SLOT_MANAGED_PROFILE, showIcon);
+ mManagedProfileIconVisible = showIcon;
+ }
+ }
+
+ private final IUserSwitchObserver.Stub mUserSwitchListener =
+ new IUserSwitchObserver.Stub() {
+ @Override
+ public void onUserSwitching(int newUserId, IRemoteCallback reply) {
+ }
+
+ @Override
+ public void onUserSwitchComplete(int newUserId) throws RemoteException {
+ updateAlarm();
+ profileChanged(newUserId);
+ }
+
+ @Override
+ public void onForegroundProfileSwitch(int newProfileId) {
+ profileChanged(newProfileId);
+ }
+ };
+
private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() {
@Override
public void onHotspotChanged(boolean enabled) {
@@ -311,4 +376,13 @@
updateCast();
}
};
+
+ public void appTransitionStarting(long startTime, long duration) {
+ updateManagedProfile();
+ }
+
+ public void setKeyguardShowing(boolean visible) {
+ mKeyguardVisible = visible;
+ updateManagedProfile();
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java
index 9928f7f..23a65e8 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java
@@ -93,7 +93,8 @@
}
@Override
- protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) {
+ protected void onTargetSelected(TargetInfo target, boolean alwaysCheck) {
+ final ResolveInfo ri = target.getResolveInfo();
try {
IBinder b = ServiceManager.getService(USB_SERVICE);
IUsbManager service = IUsbManager.Stub.asInterface(b);
@@ -121,7 +122,7 @@
}
try {
- startActivityAsUser(intent, new UserHandle(userId));
+ target.startAsUser(this, null, new UserHandle(userId));
} catch (ActivityNotFoundException e) {
Log.e(TAG, "startActivity failed", e);
}
diff --git a/preloaded-classes b/preloaded-classes
index 151766f..86bd5c9 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -1791,7 +1791,6 @@
com.android.internal.telephony.ITelephonyRegistry$Stub
com.android.internal.telephony.ITelephonyRegistry$Stub$Proxy
com.android.internal.telephony.PhoneConstants$State
-com.android.internal.transition.ActionBarTransition
com.android.internal.util.ArrayUtils
com.android.internal.util.FastPrintWriter
com.android.internal.util.FastPrintWriter$1
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 5fc1f93..7c927fd 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -332,10 +332,12 @@
rsnClosureSetGlobal(mContext, closureID, fieldID, value, size);
}
- native long rsnScriptGroup2Create(long con, String cachePath, long[] closures);
- synchronized long nScriptGroup2Create(String cachePath, long[] closures) {
+ native long rsnScriptGroup2Create(long con, String name, String cachePath,
+ long[] closures);
+ synchronized long nScriptGroup2Create(String name, String cachePath,
+ long[] closures) {
validate();
- return rsnScriptGroup2Create(mContext, cachePath, closures);
+ return rsnScriptGroup2Create(mContext, name, cachePath, closures);
}
native void rsnScriptGroup2Execute(long con, long groupID);
diff --git a/rs/java/android/renderscript/ScriptGroup2.java b/rs/java/android/renderscript/ScriptGroup2.java
index 858a957..96bb6e2 100644
--- a/rs/java/android/renderscript/ScriptGroup2.java
+++ b/rs/java/android/renderscript/ScriptGroup2.java
@@ -323,6 +323,7 @@
}
}
+ String mName;
List<Closure> mClosures;
List<UnboundValue> mInputs;
Future[] mOutputs;
@@ -333,9 +334,10 @@
super(id, rs);
}
- ScriptGroup2(RenderScript rs, List<Closure> closures,
+ ScriptGroup2(RenderScript rs, String name, List<Closure> closures,
List<UnboundValue> inputs, Future[] outputs) {
super(0, rs);
+ mName = name;
mClosures = closures;
mInputs = inputs;
mOutputs = outputs;
@@ -344,7 +346,7 @@
for (int i = 0; i < closureIDs.length; i++) {
closureIDs[i] = closures.get(i).getID(rs);
}
- long id = rs.nScriptGroup2Create(ScriptC.mCachePath, closureIDs);
+ long id = rs.nScriptGroup2Create(name, ScriptC.mCachePath, closureIDs);
setID(id);
}
@@ -560,7 +562,7 @@
!name.equals(name.replaceAll("[^a-zA-Z0-9-]", "_"))) {
throw new RSIllegalArgumentException("invalid script group name");
}
- ScriptGroup2 ret = new ScriptGroup2(mRS, mClosures, mInputs, outputs);
+ ScriptGroup2 ret = new ScriptGroup2(mRS, name, mClosures, mInputs, outputs);
return ret;
}
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index 783df68..49afa6d 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -418,8 +418,9 @@
}
static long
-nScriptGroup2Create(JNIEnv *_env, jobject _this, jlong con,
+nScriptGroup2Create(JNIEnv *_env, jobject _this, jlong con, jstring name,
jstring cacheDir, jlongArray closureArray) {
+ AutoJavaStringToUTF8 nameUTF(_env, name);
AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir);
jlong* jClosures = _env->GetLongArrayElements(closureArray, nullptr);
@@ -430,7 +431,8 @@
}
return (jlong)(uintptr_t)rsScriptGroup2Create(
- (RsContext)con, cacheDirUTF.c_str(), cacheDirUTF.length(),
+ (RsContext)con, nameUTF.c_str(), nameUTF.length(),
+ cacheDirUTF.c_str(), cacheDirUTF.length(),
closures, numClosures);
}
@@ -2404,7 +2406,7 @@
{"rsnScriptInvokeIDCreate", "(JJI)J", (void*)nScriptInvokeIDCreate },
{"rsnScriptFieldIDCreate", "(JJI)J", (void*)nScriptFieldIDCreate },
{"rsnScriptGroupCreate", "(J[J[J[J[J[J)J", (void*)nScriptGroupCreate },
-{"rsnScriptGroup2Create", "(JLjava/lang/String;[J)J", (void*)nScriptGroup2Create },
+{"rsnScriptGroup2Create", "(JLjava/lang/String;Ljava/lang/String;[J)J", (void*)nScriptGroup2Create },
{"rsnScriptGroupSetInput", "(JJJJ)V", (void*)nScriptGroupSetInput },
{"rsnScriptGroupSetOutput", "(JJJJ)V", (void*)nScriptGroupSetOutput },
{"rsnScriptGroupExecute", "(JJ)V", (void*)nScriptGroupExecute },
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index 53c87a2..ee73b1a 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -44,12 +44,14 @@
import android.provider.Settings.Secure;
import android.provider.Settings.SettingNotFoundException;
import android.security.KeyStore;
+import android.service.gatekeeper.IGateKeeperService;
import android.text.TextUtils;
import android.util.Slog;
import com.android.internal.util.ArrayUtils;
import com.android.internal.widget.ILockSettings;
import com.android.internal.widget.LockPatternUtils;
+import com.android.server.LockSettingsStorage.CredentialHash;
import java.util.Arrays;
import java.util.List;
@@ -72,6 +74,7 @@
private LockPatternUtils mLockPatternUtils;
private boolean mFirstCallToVold;
+ private IGateKeeperService mGateKeeperService;
public LockSettingsService(Context context) {
mContext = context;
@@ -131,6 +134,7 @@
public void systemReady() {
migrateOldData();
+ getGateKeeperService();
mStorage.prefetchUser(UserHandle.USER_OWNER);
}
@@ -277,7 +281,6 @@
@Override
public boolean getBoolean(String key, boolean defaultValue, int userId) throws RemoteException {
checkReadPermission(key, userId);
-
String value = getStringUnchecked(key, null, userId);
return TextUtils.isEmpty(value) ?
defaultValue : (value.equals("1") || value.equals("true"));
@@ -345,62 +348,252 @@
}
}
- @Override
- public void setLockPattern(String pattern, int userId) throws RemoteException {
- checkWritePermission(userId);
- maybeUpdateKeystore(pattern, userId);
+ private byte[] getCurrentHandle(int userId) {
+ CredentialHash credential;
+ byte[] currentHandle;
- final byte[] hash = LockPatternUtils.patternToHash(
- LockPatternUtils.stringToPattern(pattern));
- mStorage.writePatternHash(hash, userId);
+ int currentHandleType = mStorage.getStoredCredentialType(userId);
+ switch (currentHandleType) {
+ case CredentialHash.TYPE_PATTERN:
+ credential = mStorage.readPatternHash(userId);
+ currentHandle = credential != null
+ ? credential.hash
+ : null;
+ break;
+ case CredentialHash.TYPE_PASSWORD:
+ credential = mStorage.readPasswordHash(userId);
+ currentHandle = credential != null
+ ? credential.hash
+ : null;
+ break;
+ case CredentialHash.TYPE_NONE:
+ default:
+ currentHandle = null;
+ break;
+ }
+
+ // sanity check
+ if (currentHandleType != CredentialHash.TYPE_NONE && currentHandle == null) {
+ Slog.e(TAG, "Stored handle type [" + currentHandleType + "] but no handle available");
+ }
+
+ return currentHandle;
}
+
@Override
- public void setLockPassword(String password, int userId) throws RemoteException {
+ public void setLockPattern(String pattern, String savedCredential, int userId)
+ throws RemoteException {
+ byte[] currentHandle = getCurrentHandle(userId);
+
+ if (pattern == null) {
+ mStorage.writePatternHash(null, userId);
+ return;
+ }
+
+ if (currentHandle == null) {
+ if (savedCredential != null) {
+ Slog.w(TAG, "Saved credential provided, but none stored");
+ }
+ savedCredential = null;
+ }
+
+ byte[] enrolledHandle = enrollCredential(currentHandle, savedCredential, pattern, userId);
+ if (enrolledHandle != null) {
+ mStorage.writePatternHash(enrolledHandle, userId);
+ } else {
+ Slog.e(TAG, "Failed to enroll pattern");
+ }
+ }
+
+
+ @Override
+ public void setLockPassword(String password, String savedCredential, int userId)
+ throws RemoteException {
+ byte[] currentHandle = getCurrentHandle(userId);
+
+ if (password == null) {
+ mStorage.writePasswordHash(null, userId);
+ return;
+ }
+
+ if (currentHandle == null) {
+ if (savedCredential != null) {
+ Slog.w(TAG, "Saved credential provided, but none stored");
+ }
+ savedCredential = null;
+ }
+
+ byte[] enrolledHandle = enrollCredential(currentHandle, savedCredential, password, userId);
+ if (enrolledHandle != null) {
+ mStorage.writePasswordHash(enrolledHandle, userId);
+ } else {
+ Slog.e(TAG, "Failed to enroll password");
+ }
+ }
+
+ private byte[] enrollCredential(byte[] enrolledHandle,
+ String enrolledCredential, String toEnroll, int userId)
+ throws RemoteException {
checkWritePermission(userId);
+ byte[] enrolledCredentialBytes = enrolledCredential == null
+ ? null
+ : enrolledCredential.getBytes();
+ byte[] toEnrollBytes = toEnroll == null
+ ? null
+ : toEnroll.getBytes();
+ byte[] hash = getGateKeeperService().enroll(userId, enrolledHandle, enrolledCredentialBytes,
+ toEnrollBytes);
- maybeUpdateKeystore(password, userId);
+ if (hash != null) {
+ maybeUpdateKeystore(toEnroll, userId);
+ }
- mStorage.writePasswordHash(mLockPatternUtils.passwordToHash(password, userId), userId);
+ return hash;
}
@Override
public boolean checkPattern(String pattern, int userId) throws RemoteException {
- checkPasswordReadPermission(userId);
- byte[] hash = LockPatternUtils.patternToHash(LockPatternUtils.stringToPattern(pattern));
- byte[] storedHash = mStorage.readPatternHash(userId);
-
- if (storedHash == null) {
- return true;
+ try {
+ doVerifyPattern(pattern, false, 0, userId);
+ } catch (VerificationFailedException ex) {
+ return false;
}
- boolean matched = Arrays.equals(hash, storedHash);
- if (matched && !TextUtils.isEmpty(pattern)) {
- maybeUpdateKeystore(pattern, userId);
+ return true;
+ }
+
+ @Override
+ public byte[] verifyPattern(String pattern, long challenge, int userId)
+ throws RemoteException {
+ try {
+ return doVerifyPattern(pattern, true, challenge, userId);
+ } catch (VerificationFailedException ex) {
+ return null;
}
- return matched;
+ }
+
+ private byte[] doVerifyPattern(String pattern, boolean hasChallenge, long challenge,
+ int userId) throws VerificationFailedException, RemoteException {
+ checkPasswordReadPermission(userId);
+
+ CredentialHash storedHash = mStorage.readPatternHash(userId);
+
+ if ((storedHash == null || storedHash.hash.length == 0) && TextUtils.isEmpty(pattern)) {
+ // don't need to pass empty passwords to GateKeeper
+ return null;
+ }
+
+ if (TextUtils.isEmpty(pattern)) {
+ throw new VerificationFailedException();
+ }
+
+ if (storedHash.version == CredentialHash.VERSION_LEGACY) {
+ byte[] hash = mLockPatternUtils.patternToHash(
+ mLockPatternUtils.stringToPattern(pattern));
+ if (Arrays.equals(hash, storedHash.hash)) {
+ maybeUpdateKeystore(pattern, userId);
+ // migrate password to GateKeeper
+ setLockPattern(pattern, null, userId);
+ if (!hasChallenge) {
+ return null;
+ }
+ // Fall through to get the auth token. Technically this should never happen,
+ // as a user that had a legacy pattern would have to unlock their device
+ // before getting to a flow with a challenge, but supporting for consistency.
+ } else {
+ throw new VerificationFailedException();
+ }
+ }
+
+ byte[] token = null;
+ if (hasChallenge) {
+ token = getGateKeeperService()
+ .verifyChallenge(userId, challenge, storedHash.hash, pattern.getBytes());
+ if (token == null) {
+ throw new VerificationFailedException();
+ }
+ } else if (!getGateKeeperService().verify(userId, storedHash.hash, pattern.getBytes())) {
+ throw new VerificationFailedException();
+ }
+
+ // pattern has matched
+ maybeUpdateKeystore(pattern, userId);
+ return token;
+
}
@Override
public boolean checkPassword(String password, int userId) throws RemoteException {
- checkPasswordReadPermission(userId);
-
- byte[] hash = mLockPatternUtils.passwordToHash(password, userId);
- byte[] storedHash = mStorage.readPasswordHash(userId);
-
- if (storedHash == null) {
- return true;
+ try {
+ doVerifyPassword(password, false, 0, userId);
+ } catch (VerificationFailedException ex) {
+ return false;
}
-
- boolean matched = Arrays.equals(hash, storedHash);
- if (matched && !TextUtils.isEmpty(password)) {
- maybeUpdateKeystore(password, userId);
- }
- return matched;
+ return true;
}
@Override
+ public byte[] verifyPassword(String password, long challenge, int userId)
+ throws RemoteException {
+ try {
+ return doVerifyPassword(password, true, challenge, userId);
+ } catch (VerificationFailedException ex) {
+ return null;
+ }
+ }
+
+ private byte[] doVerifyPassword(String password, boolean hasChallenge, long challenge,
+ int userId) throws VerificationFailedException, RemoteException {
+ checkPasswordReadPermission(userId);
+
+ CredentialHash storedHash = mStorage.readPasswordHash(userId);
+
+ if ((storedHash == null || storedHash.hash.length == 0) && TextUtils.isEmpty(password)) {
+ // don't need to pass empty passwords to GateKeeper
+ return null;
+ }
+
+ if (TextUtils.isEmpty(password)) {
+ throw new VerificationFailedException();
+ }
+
+ if (storedHash.version == CredentialHash.VERSION_LEGACY) {
+ byte[] hash = mLockPatternUtils.passwordToHash(password, userId);
+ if (Arrays.equals(hash, storedHash.hash)) {
+ maybeUpdateKeystore(password, userId);
+ // migrate password to GateKeeper
+ setLockPassword(password, null, userId);
+ if (!hasChallenge) {
+ return null;
+ }
+ // Fall through to get the auth token. Technically this should never happen,
+ // as a user that had a legacy password would have to unlock their device
+ // before getting to a flow with a challenge, but supporting for consistency.
+ } else {
+ throw new VerificationFailedException();
+ }
+ }
+
+ byte[] token = null;
+ if (hasChallenge) {
+ token = getGateKeeperService()
+ .verifyChallenge(userId, challenge, storedHash.hash, password.getBytes());
+ if (token == null) {
+ throw new VerificationFailedException();
+ }
+ } else if (!getGateKeeperService().verify(userId, storedHash.hash, password.getBytes())) {
+ throw new VerificationFailedException();
+ }
+
+ // password has matched
+ maybeUpdateKeystore(password, userId);
+ return token;
+ }
+
+
+ @Override
public boolean checkVoldPassword(int userId) throws RemoteException {
if (!mFirstCallToVold) {
return false;
@@ -482,6 +675,7 @@
private static final String[] READ_PASSWORD_PROTECTED_SETTINGS = new String[] {
LockPatternUtils.LOCK_PASSWORD_SALT_KEY,
LockPatternUtils.PASSWORD_HISTORY_KEY,
+ LockPatternUtils.PASSWORD_TYPE_KEY,
};
private static final String[] SETTINGS_TO_BACKUP = new String[] {
@@ -496,4 +690,23 @@
}
return null;
}
+
+ private synchronized IGateKeeperService getGateKeeperService() {
+ if (mGateKeeperService != null) {
+ return mGateKeeperService;
+ }
+
+ final IBinder service =
+ ServiceManager.getService("android.service.gatekeeper.IGateKeeperService");
+ if (service != null) {
+ mGateKeeperService = IGateKeeperService.Stub.asInterface(service);
+ return mGateKeeperService;
+ }
+
+ Slog.e(TAG, "Unable to acquire GateKeeperService");
+ return null;
+ }
+
+ private class VerificationFailedException extends Exception {}
+
}
diff --git a/services/core/java/com/android/server/LockSettingsStorage.java b/services/core/java/com/android/server/LockSettingsStorage.java
index d81daa9..f202c36 100644
--- a/services/core/java/com/android/server/LockSettingsStorage.java
+++ b/services/core/java/com/android/server/LockSettingsStorage.java
@@ -56,8 +56,10 @@
};
private static final String SYSTEM_DIRECTORY = "/system/";
- private static final String LOCK_PATTERN_FILE = "gesture.key";
- private static final String LOCK_PASSWORD_FILE = "password.key";
+ private static final String LOCK_PATTERN_FILE = "gatekeeper.gesture.key";
+ private static final String LEGACY_LOCK_PATTERN_FILE = "gesture.key";
+ private static final String LOCK_PASSWORD_FILE = "gatekeeper.password.key";
+ private static final String LEGACY_LOCK_PASSWORD_FILE = "password.key";
private static final Object DEFAULT = new Object();
@@ -66,6 +68,25 @@
private final Cache mCache = new Cache();
private final Object mFileWriteLock = new Object();
+ private int mStoredCredentialType;
+
+ class CredentialHash {
+ static final int TYPE_NONE = -1;
+ static final int TYPE_PATTERN = 1;
+ static final int TYPE_PASSWORD = 2;
+
+ static final int VERSION_LEGACY = 0;
+ static final int VERSION_GATEKEEPER = 1;
+
+ CredentialHash(byte[] hash, int version) {
+ this.hash = hash;
+ this.version = version;
+ }
+
+ byte[] hash;
+ int version;
+ }
+
public LockSettingsStorage(Context context, Callback callback) {
mContext = context;
mOpenHelper = new DatabaseHelper(context, callback);
@@ -148,28 +169,72 @@
readPatternHash(userId);
}
- public byte[] readPasswordHash(int userId) {
- final byte[] stored = readFile(getLockPasswordFilename(userId));
- if (stored != null && stored.length > 0) {
- return stored;
+ public int getStoredCredentialType(int userId) {
+ if (mStoredCredentialType != 0) {
+ return mStoredCredentialType;
}
+
+ CredentialHash pattern = readPatternHash(userId);
+ if (pattern == null) {
+ if (readPasswordHash(userId) != null) {
+ mStoredCredentialType = CredentialHash.TYPE_PASSWORD;
+ } else {
+ mStoredCredentialType = CredentialHash.TYPE_NONE;
+ }
+ } else {
+ CredentialHash password = readPasswordHash(userId);
+ if (password != null) {
+ // Both will never be GateKeeper
+ if (password.version == CredentialHash.VERSION_GATEKEEPER) {
+ mStoredCredentialType = CredentialHash.TYPE_PASSWORD;
+ } else {
+ mStoredCredentialType = CredentialHash.TYPE_PATTERN;
+ }
+ } else {
+ mStoredCredentialType = CredentialHash.TYPE_PATTERN;
+ }
+ }
+
+ return mStoredCredentialType;
+ }
+
+
+ public CredentialHash readPasswordHash(int userId) {
+ byte[] stored = readFile(getLockPasswordFilename(userId));
+ if (stored != null && stored.length > 0) {
+ return new CredentialHash(stored, CredentialHash.VERSION_GATEKEEPER);
+ }
+
+ stored = readFile(getLegacyLockPasswordFilename(userId));
+ if (stored != null && stored.length > 0) {
+ return new CredentialHash(stored, CredentialHash.VERSION_LEGACY);
+ }
+
return null;
}
- public byte[] readPatternHash(int userId) {
- final byte[] stored = readFile(getLockPatternFilename(userId));
+ public CredentialHash readPatternHash(int userId) {
+ byte[] stored = readFile(getLockPatternFilename(userId));
if (stored != null && stored.length > 0) {
- return stored;
+ return new CredentialHash(stored, CredentialHash.VERSION_GATEKEEPER);
}
+
+ stored = readFile(getLegacyLockPatternFilename(userId));
+ if (stored != null && stored.length > 0) {
+ return new CredentialHash(stored, CredentialHash.VERSION_LEGACY);
+ }
+
return null;
}
public boolean hasPassword(int userId) {
- return hasFile(getLockPasswordFilename(userId));
+ return hasFile(getLockPasswordFilename(userId)) ||
+ hasFile(getLegacyLockPasswordFilename(userId));
}
public boolean hasPattern(int userId) {
- return hasFile(getLockPatternFilename(userId));
+ return hasFile(getLockPatternFilename(userId)) ||
+ hasFile(getLegacyLockPatternFilename(userId));
}
private boolean hasFile(String name) {
@@ -237,6 +302,9 @@
}
public void writePatternHash(byte[] hash, int userId) {
+ mStoredCredentialType = hash == null
+ ? CredentialHash.TYPE_NONE
+ : CredentialHash.TYPE_PATTERN;
writeFile(getLockPatternFilename(userId), hash);
clearPasswordHash(userId);
}
@@ -246,6 +314,9 @@
}
public void writePasswordHash(byte[] hash, int userId) {
+ mStoredCredentialType = hash == null
+ ? CredentialHash.TYPE_NONE
+ : CredentialHash.TYPE_PASSWORD;
writeFile(getLockPasswordFilename(userId), hash);
clearPatternHash(userId);
}
@@ -264,6 +335,16 @@
return getLockCredentialFilePathForUser(userId, LOCK_PASSWORD_FILE);
}
+ @VisibleForTesting
+ String getLegacyLockPatternFilename(int userId) {
+ return getLockCredentialFilePathForUser(userId, LEGACY_LOCK_PATTERN_FILE);
+ }
+
+ @VisibleForTesting
+ String getLegacyLockPasswordFilename(int userId) {
+ return getLockCredentialFilePathForUser(userId, LEGACY_LOCK_PASSWORD_FILE);
+ }
+
private String getLockCredentialFilePathForUser(int userId, String basename) {
userId = getUserParentOrSelfId(userId);
String dataSystemDirectory =
diff --git a/services/core/java/com/android/server/content/AppIdleMonitor.java b/services/core/java/com/android/server/content/AppIdleMonitor.java
new file mode 100644
index 0000000..9598de8
--- /dev/null
+++ b/services/core/java/com/android/server/content/AppIdleMonitor.java
@@ -0,0 +1,89 @@
+/*
+ * 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.server.content;
+
+import android.app.usage.UsageStatsManagerInternal;
+import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.BatteryManager;
+import android.os.UserHandle;
+
+import com.android.server.LocalServices;
+
+/**
+ * Helper to listen for app idle and charging status changes and restart backed off
+ * sync operations.
+ */
+class AppIdleMonitor implements AppIdleStateChangeListener {
+
+ private final SyncManager mSyncManager;
+ private final UsageStatsManagerInternal mUsageStats;
+ final BatteryManager mBatteryManager;
+ /** Is the device currently plugged into power. */
+ private boolean mPluggedIn;
+
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ onPluggedIn(mBatteryManager.isCharging());
+ }
+ };
+
+ AppIdleMonitor(SyncManager syncManager, Context context) {
+ mSyncManager = syncManager;
+ mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
+ mUsageStats.addAppIdleStateChangeListener(this);
+ mBatteryManager = context.getSystemService(BatteryManager.class);
+ mPluggedIn = isPowered();
+ registerReceivers(context);
+ }
+
+ private void registerReceivers(Context context) {
+ // Monitor battery charging state
+ IntentFilter filter = new IntentFilter(BatteryManager.ACTION_CHARGING);
+ filter.addAction(BatteryManager.ACTION_DISCHARGING);
+ context.registerReceiver(mReceiver, filter);
+ }
+
+ private boolean isPowered() {
+ return mBatteryManager.isCharging();
+ }
+
+ void onPluggedIn(boolean pluggedIn) {
+ if (mPluggedIn == pluggedIn) {
+ return;
+ }
+ mPluggedIn = pluggedIn;
+ if (mPluggedIn) {
+ mSyncManager.onAppNotIdle(null, UserHandle.USER_ALL);
+ }
+ }
+
+ boolean isAppIdle(String packageName, int userId) {
+ return !mPluggedIn && mUsageStats.isAppIdle(packageName, userId);
+ }
+
+ @Override
+ public void onAppIdleStateChanged(String packageName, int userId, boolean idle) {
+ // Don't care if the app is becoming idle
+ if (idle) return;
+ mSyncManager.onAppNotIdle(packageName, userId);
+ }
+}
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java
index 7866ddc..4173b78 100644
--- a/services/core/java/com/android/server/content/SyncManager.java
+++ b/services/core/java/com/android/server/content/SyncManager.java
@@ -83,6 +83,7 @@
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.accounts.AccountManagerService;
import com.android.server.content.SyncStorageEngine.AuthorityInfo;
+import com.android.server.content.SyncStorageEngine.EndPoint;
import com.android.server.content.SyncStorageEngine.OnSyncRequestListener;
import com.google.android.collect.Lists;
import com.google.android.collect.Maps;
@@ -107,7 +108,7 @@
* @hide
*/
public class SyncManager {
- private static final String TAG = "SyncManager";
+ static final String TAG = "SyncManager";
/** Delay a sync due to local changes this long. In milliseconds */
private static final long LOCAL_SYNC_DELAY;
@@ -199,6 +200,8 @@
protected SyncAdaptersCache mSyncAdapters;
+ private final AppIdleMonitor mAppIdleMonitor;
+
private BroadcastReceiver mStorageIntentReceiver =
new BroadcastReceiver() {
@Override
@@ -427,6 +430,8 @@
mSyncAlarmIntent = PendingIntent.getBroadcast(
mContext, 0 /* ignored */, new Intent(ACTION_SYNC_ALARM), 0);
+ mAppIdleMonitor = new AppIdleMonitor(this, mContext);
+
IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
context.registerReceiver(mConnectivityIntentReceiver, intentFilter);
@@ -1169,6 +1174,36 @@
}
/**
+ * Clear backoff on operations in the sync queue that match the packageName and userId.
+ * @param packageName The package that just became active. Can be null to indicate that all
+ * packages are now considered active due to being plugged in.
+ * @param userId The user for which the package has become active. Can be USER_ALL if
+ * the device just plugged in.
+ */
+ void onAppNotIdle(String packageName, int userId) {
+ synchronized (mSyncQueue) {
+ // For all sync operations in sync queue, if marked as idle, compare with package name
+ // and unmark. And clear backoff for the operation.
+ final Iterator<SyncOperation> operationIterator =
+ mSyncQueue.getOperations().iterator();
+ boolean changed = false;
+ while (operationIterator.hasNext()) {
+ final SyncOperation op = operationIterator.next();
+ if (op.appIdle
+ && getPackageName(op.target).equals(packageName)
+ && (userId == UserHandle.USER_ALL || op.target.userId == userId)) {
+ op.appIdle = false;
+ clearBackoffSetting(op);
+ changed = true;
+ }
+ }
+ if (changed) {
+ sendCheckAlarmsMessage();
+ }
+ }
+ }
+
+ /**
* @hide
*/
class ActiveSyncContext extends ISyncContext.Stub
@@ -2447,6 +2482,19 @@
}
continue;
}
+ String packageName = getPackageName(op.target);
+ // If app is considered idle, then skip for now and backoff
+ if (packageName != null
+ && mAppIdleMonitor.isAppIdle(packageName, op.target.userId)) {
+ increaseBackoffSetting(op);
+ op.appIdle = true;
+ if (isLoggable) {
+ Log.v(TAG, "Sync backing off idle app " + packageName);
+ }
+ continue;
+ } else {
+ op.appIdle = false;
+ }
// Add this sync to be run.
operations.add(op);
}
@@ -3194,6 +3242,21 @@
}
}
+ String getPackageName(EndPoint endpoint) {
+ if (endpoint.target_service) {
+ return endpoint.service.getPackageName();
+ } else {
+ SyncAdapterType syncAdapterType =
+ SyncAdapterType.newKey(endpoint.provider, endpoint.account.type);
+ final RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo;
+ syncAdapterInfo = mSyncAdapters.getServiceInfo(syncAdapterType, endpoint.userId);
+ if (syncAdapterInfo == null) {
+ return null;
+ }
+ return syncAdapterInfo.componentName.getPackageName();
+ }
+ }
+
private boolean isSyncStillActive(ActiveSyncContext activeSyncContext) {
for (ActiveSyncContext sync : mActiveSyncContexts) {
if (sync == activeSyncContext) {
diff --git a/services/core/java/com/android/server/content/SyncOperation.java b/services/core/java/com/android/server/content/SyncOperation.java
index 35827cc..10efe81 100644
--- a/services/core/java/com/android/server/content/SyncOperation.java
+++ b/services/core/java/com/android/server/content/SyncOperation.java
@@ -90,6 +90,9 @@
/** Descriptive string key for this operation */
public String wakeLockName;
+ /** Whether this sync op was recently skipped due to the app being idle */
+ public boolean appIdle;
+
public SyncOperation(Account account, int userId, int reason, int source, String provider,
Bundle extras, long runTimeFromNow, long flexTime, long backoff,
long delayUntil, boolean allowParallelSyncs) {
diff --git a/services/core/java/com/android/server/location/FlpHardwareProvider.java b/services/core/java/com/android/server/location/FlpHardwareProvider.java
index 530ad4b..834dff2 100644
--- a/services/core/java/com/android/server/location/FlpHardwareProvider.java
+++ b/services/core/java/com/android/server/location/FlpHardwareProvider.java
@@ -44,6 +44,9 @@
public class FlpHardwareProvider {
private GeofenceHardwareImpl mGeofenceHardwareSink = null;
private IFusedLocationHardwareSink mLocationSink = null;
+ // Capabilities provided by FlpCallbacks
+ private boolean mHaveBatchingCapabilities;
+ private int mBatchingCapabilities;
private static FlpHardwareProvider sSingletonInstance = null;
@@ -124,6 +127,47 @@
}
}
+ private void onBatchingCapabilities(int capabilities) {
+ synchronized (mLocationSinkLock) {
+ mHaveBatchingCapabilities = true;
+ mBatchingCapabilities = capabilities;
+ }
+
+ maybeSendCapabilities();
+ }
+
+ private void onBatchingStatus(int status) {
+ IFusedLocationHardwareSink sink;
+ synchronized (mLocationSinkLock) {
+ sink = mLocationSink;
+ }
+ try {
+ if (sink != null) {
+ sink.onStatusChanged(status);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "RemoteException calling onBatchingStatus");
+ }
+ }
+
+ private void maybeSendCapabilities() {
+ IFusedLocationHardwareSink sink;
+ boolean haveBatchingCapabilities;
+ int batchingCapabilities;
+ synchronized (mLocationSinkLock) {
+ sink = mLocationSink;
+ haveBatchingCapabilities = mHaveBatchingCapabilities;
+ batchingCapabilities = mBatchingCapabilities;
+ }
+ try {
+ if (sink != null && haveBatchingCapabilities) {
+ sink.onCapabilities(batchingCapabilities);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "RemoteException calling onLocationAvailable");
+ }
+ }
+
// FlpDiagnosticCallbacks members
private void onDataReport(String data) {
IFusedLocationHardwareSink sink;
@@ -209,6 +253,10 @@
translateToGeofenceHardwareStatus(result));
}
+ private void onGeofencingCapabilities(int capabilities) {
+ getGeofenceHardwareSink().onCapabilities(capabilities);
+ }
+
/**
* Private native methods accessing FLP HAL.
*/
@@ -225,6 +273,7 @@
private native void nativeUpdateBatchingOptions(int requestId, FusedBatchOptions optionsObject);
private native void nativeStopBatching(int id);
private native void nativeRequestBatchedLocation(int lastNLocations);
+ private native void nativeFlushBatchedLocations();
private native void nativeInjectLocation(Location location);
// TODO [Fix] sort out the lifetime of the instance
private native void nativeCleanup();
@@ -277,6 +326,7 @@
mLocationSink = eventSink;
}
+ maybeSendCapabilities();
}
@Override
@@ -315,6 +365,11 @@
}
@Override
+ public void flushBatchedLocations() {
+ nativeFlushBatchedLocations();
+ }
+
+ @Override
public boolean supportsDiagnosticDataInjection() {
return nativeIsDiagnosticSupported();
}
diff --git a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java b/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java
index 389bd24..e49c411 100644
--- a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java
+++ b/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java
@@ -116,4 +116,10 @@
checkPermissions();
mLocationHardware.injectDeviceContext(deviceEnabledContext);
}
+
+ @Override
+ public void flushBatchedLocations() throws RemoteException {
+ checkPermissions();
+ mLocationHardware.flushBatchedLocations();
+ }
}
diff --git a/services/core/java/com/android/server/notification/ConditionProviders.java b/services/core/java/com/android/server/notification/ConditionProviders.java
index fc2eced..b36fcd2 100644
--- a/services/core/java/com/android/server/notification/ConditionProviders.java
+++ b/services/core/java/com/android/server/notification/ConditionProviders.java
@@ -142,6 +142,9 @@
} catch (RemoteException e) {
// we tried
}
+ if (mCallback != null) {
+ mCallback.onServiceAdded(info.component);
+ }
}
@Override
@@ -246,6 +249,16 @@
}
}
+ public IConditionProvider findConditionProvider(ComponentName component) {
+ if (component == null) return null;
+ for (ManagedServiceInfo service : mServices) {
+ if (component.equals(service.component)) {
+ return provider(service);
+ }
+ }
+ return null;
+ }
+
public void ensureRecordExists(ComponentName component, Uri conditionId,
IConditionProvider provider) {
// constructed by convention, make sure the record exists...
@@ -378,6 +391,7 @@
public interface Callback {
void onBootComplete();
+ void onServiceAdded(ComponentName component);
void onConditionChanged(Uri id, Condition condition);
void onUserSwitched();
}
diff --git a/services/core/java/com/android/server/notification/CountdownConditionProvider.java b/services/core/java/com/android/server/notification/CountdownConditionProvider.java
index d223353..6a04688c 100644
--- a/services/core/java/com/android/server/notification/CountdownConditionProvider.java
+++ b/services/core/java/com/android/server/notification/CountdownConditionProvider.java
@@ -38,7 +38,7 @@
/** Built-in zen condition provider for simple time-based conditions */
public class CountdownConditionProvider extends SystemConditionProviderService {
- private static final String TAG = "CountdownConditions";
+ private static final String TAG = "ConditionProviders";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
public static final ComponentName COMPONENT =
diff --git a/services/core/java/com/android/server/notification/ScheduleConditionProvider.java b/services/core/java/com/android/server/notification/ScheduleConditionProvider.java
index c997e45..383d56c 100644
--- a/services/core/java/com/android/server/notification/ScheduleConditionProvider.java
+++ b/services/core/java/com/android/server/notification/ScheduleConditionProvider.java
@@ -43,7 +43,7 @@
* Built-in zen condition provider for daily scheduled time-based conditions.
*/
public class ScheduleConditionProvider extends SystemConditionProviderService {
- private static final String TAG = "ScheduleConditions";
+ private static final String TAG = "ConditionProviders";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
public static final ComponentName COMPONENT =
diff --git a/services/core/java/com/android/server/notification/ZenModeConditions.java b/services/core/java/com/android/server/notification/ZenModeConditions.java
index 67a2a54..766d6c5 100644
--- a/services/core/java/com/android/server/notification/ZenModeConditions.java
+++ b/services/core/java/com/android/server/notification/ZenModeConditions.java
@@ -20,6 +20,7 @@
import android.net.Uri;
import android.service.notification.Condition;
import android.service.notification.IConditionListener;
+import android.service.notification.IConditionProvider;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ZenRule;
import android.util.ArrayMap;
@@ -39,6 +40,7 @@
private CountdownConditionProvider mCountdown;
private ScheduleConditionProvider mSchedule;
+ private boolean mFirstEvaluation = true;
public ZenModeConditions(ZenModeHelper helper, ConditionProviders conditionProviders) {
mHelper = helper;
@@ -64,7 +66,8 @@
public void evaluateConfig(ZenModeConfig config) {
if (config == null) return;
- if (config.manualRule != null && !config.manualRule.isTrueOrUnknown()) {
+ if (config.manualRule != null && config.manualRule.condition != null
+ && !config.manualRule.isTrueOrUnknown()) {
if (DEBUG) Log.d(TAG, "evaluateConfig: clearing manual rule");
config.manualRule = null;
}
@@ -72,6 +75,7 @@
evaluateRule(config.manualRule, current);
for (ZenRule automaticRule : config.automaticRules.values()) {
evaluateRule(automaticRule, current);
+ updateSnoozing(automaticRule);
}
final int N = mSubscriptions.size();
for (int i = N - 1; i >= 0; i--) {
@@ -82,21 +86,7 @@
mSubscriptions.removeAt(i);
}
}
- }
-
- private void evaluateRule(ZenRule rule, ArraySet<Uri> current) {
- if (rule == null || rule.conditionId == null) return;
- final Uri id = rule.conditionId;
- for (SystemConditionProviderService sp : mConditionProviders.getSystemProviders()) {
- if (sp.isValidConditionid(id)) {
- mConditionProviders.ensureRecordExists(sp.getComponent(), id, sp.asInterface());
- rule.component = sp.getComponent();
- }
- }
- current.add(id);
- if (mConditionProviders.subscribeIfNecessary(rule.component, rule.conditionId)) {
- mSubscriptions.put(rule.conditionId, rule.component);
- }
+ mFirstEvaluation = false;
}
@Override
@@ -110,6 +100,14 @@
}
@Override
+ public void onServiceAdded(ComponentName component) {
+ if (DEBUG) Log.d(TAG, "onServiceAdded " + component);
+ if (isAutomaticActive(component)) {
+ mHelper.setConfig(mHelper.getConfig(), "zmc.onServiceAdded");
+ }
+ }
+
+ @Override
public void onConditionChanged(Uri id, Condition condition) {
if (DEBUG) Log.d(TAG, "onConditionChanged " + id + " " + condition);
ZenModeConfig config = mHelper.getConfig();
@@ -125,8 +123,53 @@
}
}
+ private void evaluateRule(ZenRule rule, ArraySet<Uri> current) {
+ if (rule == null || rule.conditionId == null) return;
+ final Uri id = rule.conditionId;
+ boolean isSystemCondition = false;
+ for (SystemConditionProviderService sp : mConditionProviders.getSystemProviders()) {
+ if (sp.isValidConditionid(id)) {
+ mConditionProviders.ensureRecordExists(sp.getComponent(), id, sp.asInterface());
+ rule.component = sp.getComponent();
+ isSystemCondition = true;
+ }
+ }
+ if (!isSystemCondition) {
+ final IConditionProvider cp = mConditionProviders.findConditionProvider(rule.component);
+ if (DEBUG) Log.d(TAG, "Ensure external rule exists: " + (cp != null) + " for " + id);
+ if (cp != null) {
+ mConditionProviders.ensureRecordExists(rule.component, id, cp);
+ }
+ }
+ if (rule.component == null) {
+ Log.w(TAG, "No component found for automatic rule: " + rule.conditionId);
+ rule.enabled = false;
+ return;
+ }
+ if (current != null) {
+ current.add(id);
+ }
+ if (mConditionProviders.subscribeIfNecessary(rule.component, rule.conditionId)) {
+ mSubscriptions.put(rule.conditionId, rule.component);
+ } else {
+ if (DEBUG) Log.d(TAG, "zmc failed to subscribe");
+ }
+ }
+
+ private boolean isAutomaticActive(ComponentName component) {
+ if (component == null) return false;
+ final ZenModeConfig config = mHelper.getConfig();
+ if (config == null) return false;
+ for (ZenRule rule : config.automaticRules.values()) {
+ if (component.equals(rule.component) && rule.isAutomaticActive()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private boolean updateSnoozing(ZenRule rule) {
- if (rule != null && rule.snoozing && !rule.isTrueOrUnknown()) {
+ if (rule != null && rule.snoozing && (mFirstEvaluation || !rule.isTrueOrUnknown())) {
rule.snoozing = false;
if (DEBUG) Log.d(TAG, "Snoozing reset for " + rule.conditionId);
return true;
@@ -141,4 +184,5 @@
rule.condition = condition;
return true;
}
+
}
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index e5925fe..683d1fd 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -175,7 +175,7 @@
if (zenMode == Global.ZEN_MODE_OFF) {
newConfig.manualRule = null;
for (ZenRule automaticRule : newConfig.automaticRules.values()) {
- if (automaticRule.isTrueOrUnknown()) {
+ if (automaticRule.isAutomaticActive()) {
automaticRule.snoozing = true;
}
}
@@ -286,8 +286,7 @@
if (mConfig.manualRule != null) return mConfig.manualRule.zenMode;
int zen = Global.ZEN_MODE_OFF;
for (ZenRule automaticRule : mConfig.automaticRules.values()) {
- if (automaticRule.enabled && !automaticRule.snoozing
- && automaticRule.isTrueOrUnknown()) {
+ if (automaticRule.isAutomaticActive()) {
if (zenSeverity(automaticRule.zenMode) > zenSeverity(zen)) {
zen = automaticRule.zenMode;
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 8c2dab0..a260b0e 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -6645,86 +6645,94 @@
r = null;
for (i=0; i<N; i++) {
PackageParser.Permission p = pkg.permissions.get(i);
+
+ // Now that permission groups have a special meaning, we ignore permission
+ // groups for legacy apps to prevent unexpected behavior. In particular,
+ // permissions for one app being granted to someone just becuase they happen
+ // to be in a group defined by another app (before this had no implications).
+ if (pkg.applicationInfo.targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1) {
+ p.group = mPermissionGroups.get(p.info.group);
+ // Warn for a permission in an unknown group.
+ if (p.info.group != null && p.group == null) {
+ Slog.w(TAG, "Permission " + p.info.name + " from package "
+ + p.info.packageName + " in an unknown group " + p.info.group);
+ }
+ }
+
ArrayMap<String, BasePermission> permissionMap =
p.tree ? mSettings.mPermissionTrees
- : mSettings.mPermissions;
- p.group = mPermissionGroups.get(p.info.group);
- if (p.info.group == null || p.group != null) {
- BasePermission bp = permissionMap.get(p.info.name);
+ : mSettings.mPermissions;
+ BasePermission bp = permissionMap.get(p.info.name);
- // Allow system apps to redefine non-system permissions
- if (bp != null && !Objects.equals(bp.sourcePackage, p.info.packageName)) {
- final boolean currentOwnerIsSystem = (bp.perm != null
- && isSystemApp(bp.perm.owner));
- if (isSystemApp(p.owner)) {
- if (bp.type == BasePermission.TYPE_BUILTIN && bp.perm == null) {
- // It's a built-in permission and no owner, take ownership now
- bp.packageSetting = pkgSetting;
- bp.perm = p;
- bp.uid = pkg.applicationInfo.uid;
- bp.sourcePackage = p.info.packageName;
- } else if (!currentOwnerIsSystem) {
- String msg = "New decl " + p.owner + " of permission "
- + p.info.name + " is system; overriding " + bp.sourcePackage;
- reportSettingsProblem(Log.WARN, msg);
- bp = null;
- }
+ // Allow system apps to redefine non-system permissions
+ if (bp != null && !Objects.equals(bp.sourcePackage, p.info.packageName)) {
+ final boolean currentOwnerIsSystem = (bp.perm != null
+ && isSystemApp(bp.perm.owner));
+ if (isSystemApp(p.owner)) {
+ if (bp.type == BasePermission.TYPE_BUILTIN && bp.perm == null) {
+ // It's a built-in permission and no owner, take ownership now
+ bp.packageSetting = pkgSetting;
+ bp.perm = p;
+ bp.uid = pkg.applicationInfo.uid;
+ bp.sourcePackage = p.info.packageName;
+ } else if (!currentOwnerIsSystem) {
+ String msg = "New decl " + p.owner + " of permission "
+ + p.info.name + " is system; overriding " + bp.sourcePackage;
+ reportSettingsProblem(Log.WARN, msg);
+ bp = null;
}
}
+ }
- if (bp == null) {
- bp = new BasePermission(p.info.name, p.info.packageName,
- BasePermission.TYPE_NORMAL);
- permissionMap.put(p.info.name, bp);
- }
+ if (bp == null) {
+ bp = new BasePermission(p.info.name, p.info.packageName,
+ BasePermission.TYPE_NORMAL);
+ permissionMap.put(p.info.name, bp);
+ }
- if (bp.perm == null) {
- if (bp.sourcePackage == null
- || bp.sourcePackage.equals(p.info.packageName)) {
- BasePermission tree = findPermissionTreeLP(p.info.name);
- if (tree == null
- || tree.sourcePackage.equals(p.info.packageName)) {
- bp.packageSetting = pkgSetting;
- bp.perm = p;
- bp.uid = pkg.applicationInfo.uid;
- bp.sourcePackage = p.info.packageName;
- if ((parseFlags&PackageParser.PARSE_CHATTY) != 0) {
- if (r == null) {
- r = new StringBuilder(256);
- } else {
- r.append(' ');
- }
- r.append(p.info.name);
+ if (bp.perm == null) {
+ if (bp.sourcePackage == null
+ || bp.sourcePackage.equals(p.info.packageName)) {
+ BasePermission tree = findPermissionTreeLP(p.info.name);
+ if (tree == null
+ || tree.sourcePackage.equals(p.info.packageName)) {
+ bp.packageSetting = pkgSetting;
+ bp.perm = p;
+ bp.uid = pkg.applicationInfo.uid;
+ bp.sourcePackage = p.info.packageName;
+ if ((parseFlags&PackageParser.PARSE_CHATTY) != 0) {
+ if (r == null) {
+ r = new StringBuilder(256);
+ } else {
+ r.append(' ');
}
- } else {
- Slog.w(TAG, "Permission " + p.info.name + " from package "
- + p.info.packageName + " ignored: base tree "
- + tree.name + " is from package "
- + tree.sourcePackage);
+ r.append(p.info.name);
}
} else {
Slog.w(TAG, "Permission " + p.info.name + " from package "
- + p.info.packageName + " ignored: original from "
- + bp.sourcePackage);
+ + p.info.packageName + " ignored: base tree "
+ + tree.name + " is from package "
+ + tree.sourcePackage);
}
- } else if ((parseFlags&PackageParser.PARSE_CHATTY) != 0) {
- if (r == null) {
- r = new StringBuilder(256);
- } else {
- r.append(' ');
- }
- r.append("DUP:");
- r.append(p.info.name);
+ } else {
+ Slog.w(TAG, "Permission " + p.info.name + " from package "
+ + p.info.packageName + " ignored: original from "
+ + bp.sourcePackage);
}
- if (bp.perm == p) {
- bp.protectionLevel = p.info.protectionLevel;
+ } else if ((parseFlags&PackageParser.PARSE_CHATTY) != 0) {
+ if (r == null) {
+ r = new StringBuilder(256);
+ } else {
+ r.append(' ');
}
- } else {
- Slog.w(TAG, "Permission " + p.info.name + " from package "
- + p.info.packageName + " ignored: no group "
- + p.group);
+ r.append("DUP:");
+ r.append(p.info.name);
+ }
+ if (bp.perm == p) {
+ bp.protectionLevel = p.info.protectionLevel;
}
}
+
if (r != null) {
if (DEBUG_PACKAGE_SCANNING) Log.d(TAG, " Permissions: " + r);
}
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index cd1c9a5..b38d33d 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -691,6 +691,20 @@
return isDeviceLockedInner(userId);
}
+ @Override
+ public boolean isDeviceSecure(int userId) throws RemoteException {
+ userId = ActivityManager.handleIncomingUser(getCallingPid(), getCallingUid(), userId,
+ false /* allowAll */, true /* requireFull */, "isDeviceSecure", null);
+ userId = resolveProfileParent(userId);
+
+ long token = Binder.clearCallingIdentity();
+ try {
+ return new LockPatternUtils(mContext).isSecure(userId);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
private void enforceReportPermission() {
mContext.enforceCallingOrSelfPermission(
Manifest.permission.ACCESS_KEYGUARD_SECURE_STORAGE, "reporting trust events");
diff --git a/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp b/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
index d5508bc..852b5e9 100644
--- a/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
+++ b/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
@@ -33,12 +33,15 @@
static jmethodID sOnLocationReport = NULL;
static jmethodID sOnDataReport = NULL;
+static jmethodID sOnBatchingCapabilities = NULL;
+static jmethodID sOnBatchingStatus = NULL;
static jmethodID sOnGeofenceTransition = NULL;
static jmethodID sOnGeofenceMonitorStatus = NULL;
static jmethodID sOnGeofenceAdd = NULL;
static jmethodID sOnGeofenceRemove = NULL;
static jmethodID sOnGeofencePause = NULL;
static jmethodID sOnGeofenceResume = NULL;
+static jmethodID sOnGeofencingCapabilities = NULL;
static const FlpLocationInterface* sFlpInterface = NULL;
static const FlpDiagnosticInterface* sFlpDiagnosticInterface = NULL;
@@ -85,6 +88,32 @@
return true;
}
+static void BatchingCapabilitiesCallback(int32_t capabilities) {
+ if(!IsValidCallbackThread()) {
+ return;
+ }
+
+ sCallbackEnv->CallVoidMethod(
+ sCallbacksObj,
+ sOnBatchingCapabilities,
+ capabilities
+ );
+ CheckExceptions(sCallbackEnv, __FUNCTION__);
+}
+
+static void BatchingStatusCallback(int32_t status) {
+ if(!IsValidCallbackThread()) {
+ return;
+ }
+
+ sCallbackEnv->CallVoidMethod(
+ sCallbacksObj,
+ sOnBatchingStatus,
+ status
+ );
+ CheckExceptions(sCallbackEnv, __FUNCTION__);
+}
+
static int SetThreadEvent(ThreadEvent event) {
JavaVM* javaVm = AndroidRuntime::getJavaVM();
@@ -156,6 +185,18 @@
"onDataReport",
"(Ljava/lang/String;)V"
);
+ sOnBatchingCapabilities = env->GetMethodID(
+ clazz,
+ "onBatchingCapabilities",
+ "(I)V");
+ sOnBatchingStatus = env->GetMethodID(
+ clazz,
+ "onBatchingStatus",
+ "(I)V");
+ sOnGeofencingCapabilities = env->GetMethodID(
+ clazz,
+ "onGeofencingCapabilities",
+ "(I)V");
sOnGeofenceTransition = env->GetMethodID(
clazz,
"onGeofenceTransition",
@@ -534,7 +575,9 @@
LocationCallback,
AcquireWakelock,
ReleaseWakelock,
- SetThreadEvent
+ SetThreadEvent,
+ BatchingCapabilitiesCallback,
+ BatchingStatusCallback
};
static void ReportData(char* data, int length) {
@@ -670,6 +713,19 @@
CheckExceptions(sCallbackEnv, __FUNCTION__);
}
+static void GeofencingCapabilitiesCallback(int32_t capabilities) {
+ if(!IsValidCallbackThread()) {
+ return;
+ }
+
+ sCallbackEnv->CallVoidMethod(
+ sCallbacksObj,
+ sOnGeofencingCapabilities,
+ capabilities
+ );
+ CheckExceptions(sCallbackEnv, __FUNCTION__);
+}
+
FlpGeofenceCallbacks sFlpGeofenceCallbacks = {
sizeof(FlpGeofenceCallbacks),
GeofenceTransitionCallback,
@@ -678,7 +734,8 @@
GeofenceRemoveCallback,
GeofencePauseCallback,
GeofenceResumeCallback,
- SetThreadEvent
+ SetThreadEvent,
+ GeofencingCapabilitiesCallback
};
/*
@@ -790,6 +847,14 @@
sFlpInterface->get_batched_location(lastNLocations);
}
+static void FlushBatchedLocations(JNIEnv* env, jobject /* object */) {
+ if(sFlpInterface == NULL) {
+ ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
+ }
+
+ sFlpInterface->flush_batched_locations();
+}
+
static void InjectLocation(JNIEnv* env, jobject /* object */, jobject locationObject) {
if(locationObject == NULL) {
ALOGE("Invalid location for injection: %p", locationObject);
@@ -972,6 +1037,9 @@
{"nativeRequestBatchedLocation",
"(I)V",
reinterpret_cast<void*>(GetBatchedLocation)},
+ {"nativeFlushBatchedLocations",
+ "()V",
+ reinterpret_cast<void*>(FlushBatchedLocations)},
{"nativeInjectLocation",
"(Landroid/location/Location;)V",
reinterpret_cast<void*>(InjectLocation)},
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java b/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java
index c766183..2661643 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java
@@ -22,6 +22,7 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Environment;
+import android.os.PersistableBundle;
import android.os.RemoteException;
import android.util.AtomicFile;
import android.util.Slog;
@@ -59,6 +60,7 @@
private static final String ATTR_PACKAGE = "package";
private static final String ATTR_COMPONENT_NAME = "component";
private static final String ATTR_USERID = "userId";
+ private static final String TAG_OTA_POLICY = "ota-policy";
private AtomicFile fileForWriting;
@@ -75,6 +77,9 @@
// Internal state for the profile owner packages.
private final HashMap<Integer, OwnerInfo> mProfileOwners = new HashMap<Integer, OwnerInfo>();
+ // Local OTA policy controllable by device owner.
+ private PersistableBundle mOtaPolicy;
+
// Private default constructor.
private DeviceOwner() {
}
@@ -187,6 +192,18 @@
return mProfileOwners.keySet();
}
+ PersistableBundle getOtaPolicy() {
+ return mOtaPolicy;
+ }
+
+ void setOtaPolicy(PersistableBundle otaPolicy) {
+ mOtaPolicy = otaPolicy;
+ }
+
+ void clearOtaPolicy() {
+ mOtaPolicy = null;
+ }
+
boolean hasDeviceOwner() {
return mDeviceOwner != null;
}
@@ -273,6 +290,8 @@
profileOwnerInfo = new OwnerInfo(profileOwnerName, profileOwnerPackageName);
}
mProfileOwners.put(userId, profileOwnerInfo);
+ } else if (TAG_OTA_POLICY.equals(tag)) {
+ mOtaPolicy = PersistableBundle.restoreFromXml(parser);
} else {
throw new XmlPullParserException(
"Unexpected tag in device owner file: " + tag);
@@ -338,6 +357,17 @@
out.endTag(null, TAG_PROFILE_OWNER);
}
}
+
+ // Write OTA policy tag
+ if (mOtaPolicy != null) {
+ out.startTag(null, TAG_OTA_POLICY);
+ try {
+ mOtaPolicy.saveToXml(out);
+ } catch (XmlPullParserException e) {
+ Slog.e(TAG, "Failed to save OTA policy", e);
+ }
+ out.endTag(null, TAG_OTA_POLICY);
+ }
out.endDocument();
out.flush();
finishWrite(outputStream);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index c500d798..c5e1933 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -347,6 +347,8 @@
private static final String TAG_DISABLE_KEYGUARD_FEATURES = "disable-keyguard-features";
private static final String TAG_DISABLE_CAMERA = "disable-camera";
private static final String TAG_DISABLE_CALLER_ID = "disable-caller-id";
+ private static final String TAG_DISABLE_BLUETOOTH_CONTACT_SHARING
+ = "disable-bt-contacts-sharing";
private static final String TAG_DISABLE_SCREEN_CAPTURE = "disable-screen-capture";
private static final String TAG_DISABLE_ACCOUNT_MANAGEMENT = "disable-account-management";
private static final String TAG_REQUIRE_AUTO_TIME = "require_auto_time";
@@ -428,6 +430,7 @@
boolean encryptionRequested = false;
boolean disableCamera = false;
boolean disableCallerId = false;
+ boolean disableBluetoothContactSharing = true;
boolean disableScreenCapture = false; // Can only be set by a device/profile owner.
boolean requireAutoTime = false; // Can only be set by a device owner.
@@ -569,6 +572,12 @@
out.attribute(null, ATTR_VALUE, Boolean.toString(disableCallerId));
out.endTag(null, TAG_DISABLE_CALLER_ID);
}
+ if (disableBluetoothContactSharing) {
+ out.startTag(null, TAG_DISABLE_BLUETOOTH_CONTACT_SHARING);
+ out.attribute(null, ATTR_VALUE,
+ Boolean.toString(disableBluetoothContactSharing));
+ out.endTag(null, TAG_DISABLE_BLUETOOTH_CONTACT_SHARING);
+ }
if (disableScreenCapture) {
out.startTag(null, TAG_DISABLE_SCREEN_CAPTURE);
out.attribute(null, ATTR_VALUE, Boolean.toString(disableScreenCapture));
@@ -714,6 +723,9 @@
} else if (TAG_DISABLE_CALLER_ID.equals(tag)) {
disableCallerId = Boolean.parseBoolean(
parser.getAttributeValue(null, ATTR_VALUE));
+ } else if (TAG_DISABLE_BLUETOOTH_CONTACT_SHARING.equals(tag)) {
+ disableBluetoothContactSharing = Boolean.parseBoolean(parser
+ .getAttributeValue(null, ATTR_VALUE));
} else if (TAG_DISABLE_SCREEN_CAPTURE.equals(tag)) {
disableScreenCapture = Boolean.parseBoolean(
parser.getAttributeValue(null, ATTR_VALUE));
@@ -904,6 +916,8 @@
pw.println(disableCamera);
pw.print(prefix); pw.print("disableCallerId=");
pw.println(disableCallerId);
+ pw.print(prefix); pw.print("disableBluetoothContactSharing=");
+ pw.println(disableBluetoothContactSharing);
pw.print(prefix); pw.print("disableScreenCapture=");
pw.println(disableScreenCapture);
pw.print(prefix); pw.print("requireAutoTime=");
@@ -2799,7 +2813,7 @@
try {
LockPatternUtils utils = new LockPatternUtils(mContext);
if (!TextUtils.isEmpty(password)) {
- utils.saveLockPassword(password, quality, userHandle);
+ utils.saveLockPassword(password, null, quality, userHandle);
} else {
utils.clearLock(userHandle);
}
@@ -3027,9 +3041,14 @@
@Override
public boolean installKeyPair(ComponentName who, byte[] privKey, byte[] cert, String alias) {
- Preconditions.checkNotNull(who, "ComponentName is null");
- synchronized (this) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ if (who == null) {
+ if (!isCallerDelegatedCertInstaller()) {
+ throw new SecurityException("who == null, but caller is not cert installer");
+ }
+ } else {
+ synchronized (this) {
+ getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ }
}
final UserHandle userHandle = new UserHandle(UserHandle.getCallingUserId());
final long id = Binder.clearCallingIdentity();
@@ -5517,6 +5536,46 @@
return -1;
}
+ @Override
+ public void setBluetoothContactSharingDisabled(ComponentName who, boolean disabled) {
+ if (!mHasFeature) {
+ return;
+ }
+ Preconditions.checkNotNull(who, "ComponentName is null");
+ synchronized (this) {
+ ActiveAdmin admin = getActiveAdminForCallerLocked(who,
+ DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ if (admin.disableBluetoothContactSharing != disabled) {
+ admin.disableBluetoothContactSharing = disabled;
+ saveSettingsLocked(UserHandle.getCallingUserId());
+ }
+ }
+ }
+
+ @Override
+ public boolean getBluetoothContactSharingDisabled(ComponentName who) {
+ if (!mHasFeature) {
+ return false;
+ }
+ Preconditions.checkNotNull(who, "ComponentName is null");
+ synchronized (this) {
+ ActiveAdmin admin = getActiveAdminForCallerLocked(who,
+ DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ return admin.disableBluetoothContactSharing;
+ }
+ }
+
+ @Override
+ public boolean getBluetoothContactSharingDisabledForUser(int userId) {
+ // TODO: Should there be a check to make sure this relationship is
+ // within a profile group?
+ // enforceSystemProcess("getCrossProfileCallerIdDisabled can only be called by system");
+ synchronized (this) {
+ ActiveAdmin admin = getProfileOwnerAdmin(userId);
+ return (admin != null) ? admin.disableBluetoothContactSharing : false;
+ }
+ }
+
/**
* Sets which packages may enter lock task mode.
*
@@ -5749,6 +5808,28 @@
}
}
+ @Override
+ public boolean setKeyguardEnabledState(ComponentName who, boolean enabled) {
+ Preconditions.checkNotNull(who, "ComponentName is null");
+ synchronized (this) {
+ getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
+ }
+ final int userId = UserHandle.getCallingUserId();
+ LockPatternUtils utils = new LockPatternUtils(mContext);
+
+ // disallow disabling the keyguard if a password is currently set
+ if (!enabled && utils.isSecure(userId)) {
+ return false;
+ }
+ long ident = Binder.clearCallingIdentity();
+ try {
+ utils.setLockScreenDisabled(!enabled, userId);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ return true;
+ }
+
/**
* We need to update the internal state of whether a user has completed setup once. After
* that, we ignore any changes that reset the Settings.Secure.USER_SETUP_COMPLETE changes
@@ -5867,4 +5948,26 @@
}
return admin.info.usesPolicy(DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD);
}
+
+ @Override
+ public void setOtaPolicy(ComponentName who, PersistableBundle policy) {
+ synchronized (this) {
+ getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
+ if (policy == null) {
+ mDeviceOwner.clearOtaPolicy();
+ } else {
+ mDeviceOwner.setOtaPolicy(policy);
+ }
+ mDeviceOwner.writeOwnerFile();
+ }
+ mContext.sendBroadcastAsUser(new Intent(DevicePolicyManager.ACTION_OTA_POLICY_CHANGED),
+ UserHandle.OWNER);
+ }
+
+ @Override
+ public PersistableBundle getOtaPolicy() {
+ synchronized (this) {
+ return mDeviceOwner.getOtaPolicy();
+ }
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/LockSettingsStorageTests.java b/services/tests/servicestests/src/com/android/server/LockSettingsStorageTests.java
index bf0e75d..dae8447 100644
--- a/services/tests/servicestests/src/com/android/server/LockSettingsStorageTests.java
+++ b/services/tests/servicestests/src/com/android/server/LockSettingsStorageTests.java
@@ -219,31 +219,31 @@
public void testPassword_Write() {
mStorage.writePasswordHash("thepassword".getBytes(), 0);
- assertArrayEquals("thepassword".getBytes(), mStorage.readPasswordHash(0));
+ assertArrayEquals("thepassword".getBytes(), mStorage.readPasswordHash(0).hash);
mStorage.clearCache();
- assertArrayEquals("thepassword".getBytes(), mStorage.readPasswordHash(0));
+ assertArrayEquals("thepassword".getBytes(), mStorage.readPasswordHash(0).hash);
}
public void testPassword_WriteProfileWritesParent() {
mStorage.writePasswordHash("parentpasswordd".getBytes(), 1);
mStorage.writePasswordHash("profilepassword".getBytes(), 2);
- assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(1));
- assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(2));
+ assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(1).hash);
+ assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(2).hash);
mStorage.clearCache();
- assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(1));
- assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(2));
+ assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(1).hash);
+ assertArrayEquals("profilepassword".getBytes(), mStorage.readPasswordHash(2).hash);
}
public void testPassword_WriteParentWritesProfile() {
mStorage.writePasswordHash("profilepassword".getBytes(), 2);
mStorage.writePasswordHash("parentpasswordd".getBytes(), 1);
- assertArrayEquals("parentpasswordd".getBytes(), mStorage.readPasswordHash(1));
- assertArrayEquals("parentpasswordd".getBytes(), mStorage.readPasswordHash(2));
+ assertArrayEquals("parentpasswordd".getBytes(), mStorage.readPasswordHash(1).hash);
+ assertArrayEquals("parentpasswordd".getBytes(), mStorage.readPasswordHash(2).hash);
mStorage.clearCache();
- assertArrayEquals("parentpasswordd".getBytes(), mStorage.readPasswordHash(1));
- assertArrayEquals("parentpasswordd".getBytes(), mStorage.readPasswordHash(2));
+ assertArrayEquals("parentpasswordd".getBytes(), mStorage.readPasswordHash(1).hash);
+ assertArrayEquals("parentpasswordd".getBytes(), mStorage.readPasswordHash(2).hash);
}
public void testPattern_Default() {
@@ -253,31 +253,31 @@
public void testPattern_Write() {
mStorage.writePatternHash("thepattern".getBytes(), 0);
- assertArrayEquals("thepattern".getBytes(), mStorage.readPatternHash(0));
+ assertArrayEquals("thepattern".getBytes(), mStorage.readPatternHash(0).hash);
mStorage.clearCache();
- assertArrayEquals("thepattern".getBytes(), mStorage.readPatternHash(0));
+ assertArrayEquals("thepattern".getBytes(), mStorage.readPatternHash(0).hash);
}
public void testPattern_WriteProfileWritesParent() {
mStorage.writePatternHash("parentpatternn".getBytes(), 1);
mStorage.writePatternHash("profilepattern".getBytes(), 2);
- assertArrayEquals("profilepattern".getBytes(), mStorage.readPatternHash(1));
- assertArrayEquals("profilepattern".getBytes(), mStorage.readPatternHash(2));
+ assertArrayEquals("profilepattern".getBytes(), mStorage.readPatternHash(1).hash);
+ assertArrayEquals("profilepattern".getBytes(), mStorage.readPatternHash(2).hash);
mStorage.clearCache();
- assertArrayEquals("profilepattern".getBytes(), mStorage.readPatternHash(1));
- assertArrayEquals("profilepattern".getBytes(), mStorage.readPatternHash(2));
+ assertArrayEquals("profilepattern".getBytes(), mStorage.readPatternHash(1).hash);
+ assertArrayEquals("profilepattern".getBytes(), mStorage.readPatternHash(2).hash);
}
public void testPattern_WriteParentWritesProfile() {
mStorage.writePatternHash("profilepattern".getBytes(), 2);
mStorage.writePatternHash("parentpatternn".getBytes(), 1);
- assertArrayEquals("parentpatternn".getBytes(), mStorage.readPatternHash(1));
- assertArrayEquals("parentpatternn".getBytes(), mStorage.readPatternHash(2));
+ assertArrayEquals("parentpatternn".getBytes(), mStorage.readPatternHash(1).hash);
+ assertArrayEquals("parentpatternn".getBytes(), mStorage.readPatternHash(2).hash);
mStorage.clearCache();
- assertArrayEquals("parentpatternn".getBytes(), mStorage.readPatternHash(1));
- assertArrayEquals("parentpatternn".getBytes(), mStorage.readPatternHash(2));
+ assertArrayEquals("parentpatternn".getBytes(), mStorage.readPatternHash(1).hash);
+ assertArrayEquals("parentpatternn".getBytes(), mStorage.readPatternHash(2).hash);
}
public void testPrefetch() {
@@ -289,8 +289,8 @@
mStorage.prefetchUser(0);
assertEquals("toBeFetched", mStorage.readKeyValue("key", "default", 0));
- assertArrayEquals("pattern".getBytes(), mStorage.readPatternHash(0));
- assertArrayEquals("password".getBytes(), mStorage.readPasswordHash(0));
+ assertArrayEquals("pattern".getBytes(), mStorage.readPatternHash(0).hash);
+ assertArrayEquals("password".getBytes(), mStorage.readPasswordHash(0).hash);
}
public void testFileLocation_Owner() {
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index cc0ab81..3d54dfb 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -53,6 +53,7 @@
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.IndentingPrintWriter;
+import com.android.server.SystemConfig;
import com.android.server.SystemService;
import java.io.File;
@@ -383,6 +384,9 @@
}
boolean isAppIdle(String packageName, int userId) {
+ if (SystemConfig.getInstance().getAllowInPowerSave().contains(packageName)) {
+ return false;
+ }
final long lastUsed = getLastPackageAccessTime(packageName, userId);
return hasPassedIdleDuration(lastUsed);
}