diff options
Diffstat (limited to 'core/java')
38 files changed, 578 insertions, 171 deletions
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java index 480d171..ffa36d6 100644 --- a/core/java/android/accounts/AccountManager.java +++ b/core/java/android/accounts/AccountManager.java @@ -207,8 +207,7 @@ public class AccountManager { * were authenticated successfully. Time is specified in milliseconds since * epoch. */ - public static final String KEY_LAST_AUTHENTICATE_TIME_MILLIS_EPOCH = - "lastAuthenticatedTimeMillisEpoch"; + public static final String KEY_LAST_AUTHENTICATED_TIME = "lastAuthenticatedTime"; /** * Authenticators using 'customTokens' option will also get the UID of the @@ -671,8 +670,8 @@ public class AccountManager { } /** - * Informs the system that the account has been authenticated recently. This - * recency may be used by other applications to verify the account. This + * Notifies the system that the account has just been authenticated. This + * information may be used by other applications to verify the account. This * should be called only when the user has entered correct credentials for * the account. * <p> @@ -685,7 +684,7 @@ public class AccountManager { * * @param account The {@link Account} to be updated. */ - public boolean accountAuthenticated(Account account) { + public boolean notifyAccountAuthenticated(Account account) { if (account == null) throw new IllegalArgumentException("account is null"); try { @@ -1587,7 +1586,7 @@ public class AccountManager { * password prompt. * * <p>Also the returning Bundle may contain {@link - * #KEY_LAST_AUTHENTICATE_TIME_MILLIS_EPOCH} indicating the last time the + * #KEY_LAST_AUTHENTICATED_TIME} indicating the last time the * credential was validated/created. * * If an error occurred,{@link AccountManagerFuture#getResult()} throws: diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 223d528..1127436 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -221,8 +221,7 @@ public class AppOpsManager { public static final int _NUM_OP = 53; /** Access to coarse location information. */ - public static final String OPSTR_COARSE_LOCATION = - "android:coarse_location"; + public static final String OPSTR_COARSE_LOCATION = "android:coarse_location"; /** Access to fine location information. */ public static final String OPSTR_FINE_LOCATION = "android:fine_location"; @@ -237,7 +236,59 @@ public class AppOpsManager { = "android:get_usage_stats"; /** Activate a VPN connection without user intervention. @hide */ @SystemApi - public static final String OPSTR_ACTIVATE_VPN = "android:activate_vpn"; + public static final String OPSTR_ACTIVATE_VPN + = "android:activate_vpn"; + /** @hide Allows an application to read the user's contacts data. */ + public static final String OPSTR_READ_CONTACTS + = "android:read_contacts"; + /** @hide Allows an application to write to the user's contacts data. */ + public static final String OPSTR_WRITE_CONTACTS + = "android:write_contacts"; + /** @hide Allows an application to read the user's call log. */ + public static final String OPSTR_READ_CALL_LOG + = "android:read_call_log"; + /** @hide Allows an application to write to the user's call log. */ + public static final String OPSTR_WRITE_CALL_LOG + = "android:write_call_log"; + /** @hide Allows an application to read the user's calendar data. */ + public static final String OPSTR_READ_CALENDAR + = "android:read_calendar"; + /** @hide Allows an application to write to the user's calendar data. */ + public static final String OPSTR_WRITE_CALENDAR + = "android:write_calendar"; + /** @hide Allows an application to initiate a phone call. */ + public static final String OPSTR_CALL_PHONE + = "android:call_phone"; + /** @hide Allows an application to read SMS messages. */ + public static final String OPSTR_READ_SMS + = "android:read_sms"; + /** @hide Allows an application to receive SMS messages. */ + public static final String OPSTR_RECEIVE_SMS + = "android:receive_sms"; + /** @hide Allows an application to receive MMS messages. */ + public static final String OPSTR_RECEIVE_MMS + = "android:receive_mms"; + /** @hide Allows an application to receive WAP push messages. */ + public static final String OPSTR_RECEIVE_WAP_PUSH + = "android:receive_wap_push"; + /** @hide Allows an application to send SMS messages. */ + public static final String OPSTR_SEND_SMS + = "android:send_sms"; + /** @hide Allows an application to add system alert windows. */ + public static final String OPSTR_SYSTEM_ALERT_WINDOW + = "android:system_alert_window"; + /** @hide Required to be able to access the camera device. */ + public static final String OPSTR_CAMERA + = "android:camera"; + /** @hide Required to be able to access the microphone device. */ + public static final String OPSTR_RECORD_AUDIO + = "android:record_audio"; + /** @hide Required to access phone state related information. */ + public static final String OPSTR_READ_PHONE_STATE + = "android:read_phone_state"; + /** @hide Required to access phone state related information. */ + public static final String OPSTR_ADD_VOICEMAIL + = "android:add_voicemail"; /** * This maps each operation to the operation that serves as the @@ -726,6 +777,33 @@ public class AppOpsManager { false }; + /** + * This is a mapping from a permission name to public app op name. + */ + private static final ArrayMap<String, String> sPermToOp = new ArrayMap<>(); + static { + sPermToOp.put(Manifest.permission.ACCESS_COARSE_LOCATION, OPSTR_COARSE_LOCATION); + sPermToOp.put(Manifest.permission.ACCESS_FINE_LOCATION, OPSTR_FINE_LOCATION); + sPermToOp.put(Manifest.permission.PACKAGE_USAGE_STATS, OPSTR_GET_USAGE_STATS); + sPermToOp.put(Manifest.permission.READ_CONTACTS, OPSTR_READ_CONTACTS); + sPermToOp.put(Manifest.permission.WRITE_CONTACTS, OPSTR_WRITE_CONTACTS); + sPermToOp.put(Manifest.permission.READ_CALL_LOG, OPSTR_READ_CALL_LOG); + sPermToOp.put(Manifest.permission.WRITE_CALL_LOG, OPSTR_WRITE_CALL_LOG); + sPermToOp.put(Manifest.permission.READ_CALENDAR, OPSTR_READ_CALENDAR); + sPermToOp.put(Manifest.permission.WRITE_CALENDAR, OPSTR_WRITE_CALENDAR); + sPermToOp.put(Manifest.permission.CALL_PHONE, OPSTR_CALL_PHONE); + sPermToOp.put(Manifest.permission.READ_SMS, OPSTR_READ_SMS); + sPermToOp.put(Manifest.permission.RECEIVE_SMS, OPSTR_RECEIVE_SMS); + sPermToOp.put(Manifest.permission.RECEIVE_MMS, OPSTR_RECEIVE_MMS); + sPermToOp.put(Manifest.permission.RECEIVE_WAP_PUSH, OPSTR_RECEIVE_WAP_PUSH); + sPermToOp.put(Manifest.permission.SEND_SMS, OPSTR_SEND_SMS); + sPermToOp.put(Manifest.permission.SYSTEM_ALERT_WINDOW, OPSTR_SYSTEM_ALERT_WINDOW); + sPermToOp.put(Manifest.permission.CAMERA, OPSTR_CAMERA); + sPermToOp.put(Manifest.permission.RECORD_AUDIO, OPSTR_RECORD_AUDIO); + sPermToOp.put(Manifest.permission.READ_PHONE_STATE, OPSTR_READ_PHONE_STATE); + sPermToOp.put(Manifest.permission.ADD_VOICEMAIL, OPSTR_ADD_VOICEMAIL); + } + private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>(); static { @@ -1066,6 +1144,21 @@ public class AppOpsManager { } /** + * Gets the app op name associated with a given permission. + * The app op name is one of the public constants defined + * in this class such as {@link #OPSTR_COARSE_LOCATION}. + * + * @param permission The permission. + * @return The app op associated with the permission or null. + * + * @hide + */ + @SystemApi + public static String permissionToOp(String permission) { + return sPermToOp.get(permission); + } + + /** * Monitor for changes to the operating mode for the given op in the given app package. * @param op The operation to monitor, one of OPSTR_*. * @param packageName The name of the application to monitor. diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 6e511f3..90293a4 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -62,6 +62,7 @@ import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -1561,13 +1562,7 @@ final class ApplicationPackageManager extends PackageManager { public @Nullable VolumeInfo getPrimaryStorageCurrentVolume() { final StorageManager storage = mContext.getSystemService(StorageManager.class); final String volumeUuid = storage.getPrimaryStorageUuid(); - if (Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, volumeUuid)) { - return storage.findVolumeById(VolumeInfo.ID_PRIVATE_INTERNAL); - } else if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, volumeUuid)) { - return storage.getPrimaryPhysicalVolume(); - } else { - return storage.findVolumeByUuid(volumeUuid); - } + return storage.findVolumeByQualifiedUuid(volumeUuid); } @Override @@ -2055,7 +2050,8 @@ final class ApplicationPackageManager extends PackageManager { /** {@hide} */ private static class MoveCallbackDelegate extends IPackageMoveObserver.Stub implements Handler.Callback { - private static final int MSG_STATUS_CHANGED = 1; + private static final int MSG_CREATED = 1; + private static final int MSG_STATUS_CHANGED = 2; final MoveCallback mCallback; final Handler mHandler; @@ -2068,23 +2064,36 @@ final class ApplicationPackageManager extends PackageManager { @Override public boolean handleMessage(Message msg) { switch (msg.what) { - case MSG_STATUS_CHANGED: + case MSG_CREATED: { + final SomeArgs args = (SomeArgs) msg.obj; + mCallback.onCreated(args.argi1, (Bundle) args.arg2); + args.recycle(); + return true; + } + case MSG_STATUS_CHANGED: { final SomeArgs args = (SomeArgs) msg.obj; - mCallback.onStatusChanged(args.argi1, (String) args.arg2, args.argi3, - (long) args.arg4); + mCallback.onStatusChanged(args.argi1, args.argi2, (long) args.arg3); args.recycle(); return true; + } } return false; } @Override - public void onStatusChanged(int moveId, String moveTitle, int status, long estMillis) { + public void onCreated(int moveId, Bundle extras) { + final SomeArgs args = SomeArgs.obtain(); + args.argi1 = moveId; + args.arg2 = extras; + mHandler.obtainMessage(MSG_CREATED, args).sendToTarget(); + } + + @Override + public void onStatusChanged(int moveId, int status, long estMillis) { final SomeArgs args = SomeArgs.obtain(); args.argi1 = moveId; - args.arg2 = moveTitle; - args.argi3 = status; - args.arg4 = estMillis; + args.argi2 = status; + args.arg3 = estMillis; mHandler.obtainMessage(MSG_STATUS_CHANGED, args).sendToTarget(); } } diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java index ebb3c43..2c12317 100644 --- a/core/java/android/app/KeyguardManager.java +++ b/core/java/android/app/KeyguardManager.java @@ -199,9 +199,12 @@ public class KeyguardManager { } /** - * Return whether the keyguard requires a password to unlock. + * Return whether the keyguard is secured by a PIN, pattern or password or a SIM card + * is currently locked. * - * @return true if keyguard is secure. + * <p>See also {@link #isDeviceSecure()} which ignores SIM locked states. + * + * @return true if a PIN, pattern or password is set or a SIM card is locked. */ public boolean isKeyguardSecure() { try { @@ -240,12 +243,8 @@ public class KeyguardManager { } /** - * Returns whether the device is currently locked and requires a PIN, pattern or - * password to unlock. + * Per-user version of {@link #isDeviceLocked()}. * - * @param userId the user for which the locked state should be reported. - * @return true if unlocking the device currently requires a PIN, pattern or - * password. * @hide */ public boolean isDeviceLocked(int userId) { @@ -260,6 +259,8 @@ public class KeyguardManager { * Returns whether the device is secured with a PIN, pattern or * password. * + * <p>See also {@link #isKeyguardSecure} which treats SIM locked states as secure. + * * @return true if a PIN, pattern or password was set. */ public boolean isDeviceSecure() { @@ -267,11 +268,8 @@ public class KeyguardManager { } /** - * Returns whether the device is secured with a PIN, pattern or - * password. + * Per-user version of {@link #isDeviceSecure()}. * - * @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) { diff --git a/core/java/android/bluetooth/le/ScanSettings.java b/core/java/android/bluetooth/le/ScanSettings.java index f103cae..123514e 100644 --- a/core/java/android/bluetooth/le/ScanSettings.java +++ b/core/java/android/bluetooth/le/ScanSettings.java @@ -236,7 +236,7 @@ public final class ScanSettings implements Parcelable { private int mScanResultType = SCAN_RESULT_TYPE_FULL; private long mReportDelayMillis = 0; private int mMatchMode = MATCH_MODE_AGGRESSIVE; - private int mNumOfMatchesPerFilter = MATCH_NUM_ONE_ADVERTISEMENT; + private int mNumOfMatchesPerFilter = MATCH_NUM_MAX_ADVERTISEMENT; /** * Set scan mode for Bluetooth LE scan. * diff --git a/core/java/android/content/ContentProviderNative.java b/core/java/android/content/ContentProviderNative.java index f2e7fc4..4769bd0 100644 --- a/core/java/android/content/ContentProviderNative.java +++ b/core/java/android/content/ContentProviderNative.java @@ -593,7 +593,8 @@ final class ContentProviderProxy implements IContentProvider DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply); int has = reply.readInt(); - ParcelFileDescriptor fd = has != 0 ? reply.readFileDescriptor() : null; + ParcelFileDescriptor fd = has != 0 ? ParcelFileDescriptor.CREATOR + .createFromParcel(reply) : null; return fd; } finally { data.recycle(); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 5eacce3..8687c6b 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -252,6 +252,21 @@ public abstract class Context { public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; /** + * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE}, + * but only applies while the device is awake. + */ + public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000; + + /** + * @hide Flag for {@link #bindService}: For only the case where the binding + * is coming from the system, set the process state to FOREGROUND_SERVICE + * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is + * saying that the process shouldn't participate in the normal power reduction + * modes (removing network access etc). + */ + public static final int BIND_FOREGROUND_SERVICE = 0x04000000; + + /** * @hide Flag for {@link #bindService}: Treat the binding as hosting * an activity, an unbinding as the activity going in the background. * That is, when unbinding, the process when empty will go on the activity @@ -374,24 +389,30 @@ public abstract class Context { } /** - * Return a localized string from the application's package's + * Returns a localized string from the application's package's * default string table. * * @param resId Resource id for the string + * @return The string data associated with the resource, stripped of styled + * text information. */ + @NonNull public final String getString(@StringRes int resId) { return getResources().getString(resId); } /** - * Return a localized formatted string from the application's package's + * Returns a localized formatted string from the application's package's * default string table, substituting the format arguments as defined in * {@link java.util.Formatter} and {@link java.lang.String#format}. * * @param resId Resource id for the format string - * @param formatArgs The format arguments that will be used for substitution. + * @param formatArgs The format arguments that will be used for + * substitution. + * @return The string data associated with the resource, formatted and + * stripped of styled text information. */ - + @NonNull public final String getString(@StringRes int resId, Object... formatArgs) { return getResources().getString(resId, formatArgs); } diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index ae59bfc..0b24594 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -58,6 +58,7 @@ import android.content.IntentSender; * {@hide} */ interface IPackageManager { + boolean isPackageFrozen(String packageName); boolean isPackageAvailable(String packageName, int userId); PackageInfo getPackageInfo(String packageName, int flags, int userId); int getPackageUid(String packageName, int userId); diff --git a/core/java/android/content/pm/IPackageMoveObserver.aidl b/core/java/android/content/pm/IPackageMoveObserver.aidl index 155ed0b..86189fc 100644 --- a/core/java/android/content/pm/IPackageMoveObserver.aidl +++ b/core/java/android/content/pm/IPackageMoveObserver.aidl @@ -17,10 +17,13 @@ package android.content.pm; +import android.os.Bundle; + /** * Callback for moving package resources from the Package Manager. * @hide */ oneway interface IPackageMoveObserver { - void onStatusChanged(int moveId, String moveTitle, int status, long estMillis); + void onCreated(int moveId, in Bundle extras); + void onStatusChanged(int moveId, int status, long estMillis); } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index a1ee7fc..7ff6ec3 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -4212,8 +4212,8 @@ public abstract class PackageManager { /** {@hide} */ public static abstract class MoveCallback { - public abstract void onStatusChanged(int moveId, String moveTitle, int status, - long estMillis); + public void onCreated(int moveId, Bundle extras) {} + public abstract void onStatusChanged(int moveId, int status, long estMillis); } /** {@hide} */ diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index fed9261..9596c42 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -4315,9 +4315,6 @@ public class PackageParser { // Additional data supplied by callers. public Object mExtras; - // Whether an operation is currently pending on this package - public boolean mOperationPending; - // Applications hardware preferences public ArrayList<ConfigurationInfo> configPreferences = null; diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java index fdafb04..14bfac5 100644 --- a/core/java/android/content/res/ColorStateList.java +++ b/core/java/android/content/res/ColorStateList.java @@ -271,7 +271,7 @@ public class ColorStateList implements Parcelable { final TypedArray a = Resources.obtainAttributes(r, theme, attrs, R.styleable.ColorStateListItem); final int[] themeAttrs = a.extractThemeAttrs(); - final int baseColor = a.getColor(R.styleable.ColorStateListItem_color, 0); + final int baseColor = a.getColor(R.styleable.ColorStateListItem_color, Color.MAGENTA); final float alphaMod = a.getFloat(R.styleable.ColorStateListItem_alpha, 1.0f); changingConfigurations |= a.getChangingConfigurations(); @@ -296,7 +296,9 @@ public class ColorStateList implements Parcelable { } stateSpec = StateSet.trimStateSet(stateSpec, j); - // Apply alpha modulation. + // Apply alpha modulation. If we couldn't resolve the color or + // alpha yet, the default values leave us enough information to + // modulate again during applyTheme(). final int color = modulateColorAlpha(baseColor, alphaMod); if (listSize == 0 || stateSpec.length == 0) { defaultColor = color; @@ -365,14 +367,31 @@ public class ColorStateList implements Parcelable { if (themeAttrsList[i] != null) { final TypedArray a = t.resolveAttributes(themeAttrsList[i], R.styleable.ColorStateListItem); + + final float defaultAlphaMod; + if (themeAttrsList[i][R.styleable.ColorStateListItem_color] != 0) { + // If the base color hasn't been resolved yet, the current + // color's alpha channel is either full-opacity (if we + // haven't resolved the alpha modulation yet) or + // pre-modulated. Either is okay as a default value. + defaultAlphaMod = Color.alpha(mColors[i]) / 255.0f; + } else { + // Otherwise, the only correct default value is 1. Even if + // nothing is resolved during this call, we can apply this + // multiple times without losing of information. + defaultAlphaMod = 1.0f; + } + final int baseColor = a.getColor( R.styleable.ColorStateListItem_color, mColors[i]); final float alphaMod = a.getFloat( - R.styleable.ColorStateListItem_alpha, 1.0f); - + R.styleable.ColorStateListItem_alpha, defaultAlphaMod); mColors[i] = modulateColorAlpha(baseColor, alphaMod); + + // Account for any configuration changes. mChangingConfigurations |= a.getChangingConfigurations(); + // Extract the theme attributes, if any. themeAttrsList[i] = a.extractThemeAttrs(themeAttrsList[i]); if (themeAttrsList[i] != null) { hasUnresolvedAttrs = true; diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 334d180..6e77e33 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -393,10 +393,11 @@ public class Resources { * @throws NotFoundException Throws NotFoundException if the given ID does not exist. * * @return String The string data associated with the resource, - * stripped of styled text information. + * stripped of styled text information. */ + @NonNull public String getString(@StringRes int id) throws NotFoundException { - CharSequence res = getText(id); + final CharSequence res = getText(id); if (res != null) { return res.toString(); } @@ -421,11 +422,11 @@ public class Resources { * @throws NotFoundException Throws NotFoundException if the given ID does not exist. * * @return String The string data associated with the resource, - * stripped of styled text information. + * stripped of styled text information. */ - public String getString(@StringRes int id, Object... formatArgs) - throws NotFoundException { - String raw = getString(id); + @NonNull + public String getString(@StringRes int id, Object... formatArgs) throws NotFoundException { + final String raw = getString(id); return String.format(mConfiguration.locale, raw, formatArgs); } diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java index 2257b0a..9f344ad 100644 --- a/core/java/android/hardware/fingerprint/FingerprintManager.java +++ b/core/java/android/hardware/fingerprint/FingerprintManager.java @@ -42,6 +42,7 @@ import java.util.HashMap; import java.util.List; import javax.crypto.Cipher; +import javax.crypto.Mac; /** * A class that coordinates access to the fingerprint hardware. @@ -195,18 +196,26 @@ public class FingerprintManager { /** * A wrapper class for the crypto objects supported by FingerprintManager. Currently the - * framework supports {@link Signature} and {@link Cipher} objects. + * framework supports {@link Signature}, {@link Cipher} and {@link Mac} objects. */ public static class CryptoObject { - public CryptoObject(Signature signature) { + public CryptoObject(@NonNull Signature signature) { mSignature = signature; mCipher = null; + mMac = null; } - public CryptoObject(Cipher cipher) { + public CryptoObject(@NonNull Cipher cipher) { mCipher = cipher; mSignature = null; + mMac = null; + } + + public CryptoObject(@NonNull Mac mac) { + mMac = mac; + mCipher = null; + mSignature = null; } /** @@ -222,6 +231,12 @@ public class FingerprintManager { public Cipher getCipher() { return mCipher; } /** + * Get {@link Mac} object. + * @return {@link Mac} object or null if this doesn't contain one. + */ + public Mac getMac() { return mMac; } + + /** * @hide * @return the opId associated with this object or 0 if none */ @@ -230,12 +245,15 @@ public class FingerprintManager { return AndroidKeyStoreProvider.getKeyStoreOperationHandle(mSignature); } else if (mCipher != null) { return AndroidKeyStoreProvider.getKeyStoreOperationHandle(mCipher); + } else if (mMac != null) { + return AndroidKeyStoreProvider.getKeyStoreOperationHandle(mMac); } return 0; } private final Signature mSignature; private final Cipher mCipher; + private final Mac mMac; }; /** diff --git a/core/java/android/hardware/usb/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java index 1a42319..410d550 100644 --- a/core/java/android/hardware/usb/UsbDevice.java +++ b/core/java/android/hardware/usb/UsbDevice.java @@ -45,6 +45,7 @@ public class UsbDevice implements Parcelable { private final String mName; private final String mManufacturerName; private final String mProductName; + private final String mVersion; private final String mSerialNumber; private final int mVendorId; private final int mProductId; @@ -62,7 +63,7 @@ public class UsbDevice implements Parcelable { */ public UsbDevice(String name, int vendorId, int productId, int Class, int subClass, int protocol, - String manufacturerName, String productName, String serialNumber) { + String manufacturerName, String productName, String version, String serialNumber) { mName = name; mVendorId = vendorId; mProductId = productId; @@ -71,6 +72,7 @@ public class UsbDevice implements Parcelable { mProtocol = protocol; mManufacturerName = manufacturerName; mProductName = productName; + mVersion = version; mSerialNumber = serialNumber; } @@ -104,6 +106,15 @@ public class UsbDevice implements Parcelable { } /** + * Returns the version number of the device. + * + * @return the device version + */ + public String getVersion() { + return mVersion; + } + + /** * Returns the serial number of the device. * * @return the serial number name @@ -263,7 +274,7 @@ public class UsbDevice implements Parcelable { ",mVendorId=" + mVendorId + ",mProductId=" + mProductId + ",mClass=" + mClass + ",mSubclass=" + mSubclass + ",mProtocol=" + mProtocol + ",mManufacturerName=" + mManufacturerName + ",mProductName=" + mProductName + - ",mSerialNumber=" + mSerialNumber + ",mConfigurations=["); + ",mVersion=" + mVersion + ",mSerialNumber=" + mSerialNumber + ",mConfigurations=["); for (int i = 0; i < mConfigurations.length; i++) { builder.append("\n"); builder.append(mConfigurations[i].toString()); @@ -283,10 +294,11 @@ public class UsbDevice implements Parcelable { int protocol = in.readInt(); String manufacturerName = in.readString(); String productName = in.readString(); + String version = in.readString(); String serialNumber = in.readString(); Parcelable[] configurations = in.readParcelableArray(UsbInterface.class.getClassLoader()); UsbDevice device = new UsbDevice(name, vendorId, productId, clasz, subClass, protocol, - manufacturerName, productName, serialNumber); + manufacturerName, productName, version, serialNumber); device.setConfigurations(configurations); return device; } @@ -309,6 +321,7 @@ public class UsbDevice implements Parcelable { parcel.writeInt(mProtocol); parcel.writeString(mManufacturerName); parcel.writeString(mProductName); + parcel.writeString(mVersion); parcel.writeString(mSerialNumber); parcel.writeParcelableArray(mConfigurations, 0); } diff --git a/core/java/android/net/INetworkPolicyManager.aidl b/core/java/android/net/INetworkPolicyManager.aidl index c722fbc..7f5f377 100644 --- a/core/java/android/net/INetworkPolicyManager.aidl +++ b/core/java/android/net/INetworkPolicyManager.aidl @@ -38,8 +38,6 @@ interface INetworkPolicyManager { boolean isUidForeground(int uid); - int[] getPowerSaveAppIdWhitelist(); - void registerListener(INetworkPolicyListener listener); void unregisterListener(INetworkPolicyListener listener); diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index bc03637..ecc3fb4 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -41,6 +41,7 @@ import java.util.HashSet; */ public class NetworkPolicyManager { + /* POLICY_* are masks and can be ORed */ /** No specific network policy, use system default. */ public static final int POLICY_NONE = 0x0; /** Reject network usage on metered networks when application in background. */ @@ -48,10 +49,17 @@ public class NetworkPolicyManager { /** Allow network use (metered or not) in the background in battery save mode. */ public static final int POLICY_ALLOW_BACKGROUND_BATTERY_SAVE = 0x2; + /* RULE_* are not masks and they must be exclusive */ /** All network traffic should be allowed. */ public static final int RULE_ALLOW_ALL = 0x0; /** Reject traffic on metered networks. */ public static final int RULE_REJECT_METERED = 0x1; + /** Reject traffic on all networks. */ + public static final int RULE_REJECT_ALL = 0x2; + + public static final int FIREWALL_RULE_DEFAULT = 0; + public static final int FIREWALL_RULE_ALLOW = 1; + public static final int FIREWALL_RULE_DENY = 2; private static final boolean ALLOW_PLATFORM_APP_POLICY = true; @@ -80,7 +88,7 @@ public class NetworkPolicyManager { * Set policy flags for specific UID. * * @param policy {@link #POLICY_NONE} or combination of flags like - * {@link #POLICY_REJECT_METERED_BACKGROUND}, {@link #POLICY_ALLOW_BACKGROUND_BATTERY_SAVE}. + * {@link #POLICY_REJECT_METERED_BACKGROUND} or {@link #POLICY_ALLOW_BACKGROUND_BATTERY_SAVE}. */ public void setUidPolicy(int uid, int policy) { try { @@ -129,14 +137,6 @@ public class NetworkPolicyManager { } } - public int[] getPowerSaveAppIdWhitelist() { - try { - return mService.getPowerSaveAppIdWhitelist(); - } catch (RemoteException e) { - return new int[0]; - } - } - public void registerListener(INetworkPolicyListener listener) { try { mService.registerListener(listener); @@ -330,6 +330,8 @@ public class NetworkPolicyManager { fout.write("["); if ((rules & RULE_REJECT_METERED) != 0) { fout.write("REJECT_METERED"); + } else if ((rules & RULE_REJECT_ALL) != 0) { + fout.write("REJECT_ALL"); } fout.write("]"); } diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java index f305b2a..4a8dfbc 100644 --- a/core/java/android/net/Uri.java +++ b/core/java/android/net/Uri.java @@ -1657,7 +1657,7 @@ public abstract class Uri implements Parcelable, Comparable<Uri> { /** * Searches the query string for the first value with the given key. * - * <p><strong>Warning:</strong> Prior to Ice Cream Sandwich, this decoded + * <p><strong>Warning:</strong> Prior to Jelly Bean, this decoded * the '+' character as '+' rather than ' '. * * @param key which will be encoded diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java index 2eb97f1..e3e16eb 100644 --- a/core/java/android/os/Environment.java +++ b/core/java/android/os/Environment.java @@ -758,7 +758,6 @@ public class Environment { * @hide */ public static File maybeTranslateEmulatedPathToInternal(File path) { - // TODO: bring back this optimization - return path; + return StorageManager.maybeTranslateEmulatedPathToInternal(path); } } diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index 931cd3e..021e5e4 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -390,7 +390,7 @@ public class FileUtils { * attacks. */ public static boolean contains(File dir, File file) { - if (file == null) return false; + if (dir == null || file == null) return false; String dirPath = dir.getAbsolutePath(); String filePath = file.getAbsolutePath(); diff --git a/core/java/android/os/IDeviceIdleController.aidl b/core/java/android/os/IDeviceIdleController.aidl new file mode 100644 index 0000000..3cb29ff --- /dev/null +++ b/core/java/android/os/IDeviceIdleController.aidl @@ -0,0 +1,26 @@ +/** + * 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.os; + +/** @hide */ +interface IDeviceIdleController { + void addPowerSaveWhitelistApp(String name); + void removePowerSaveWhitelistApp(String name); + String[] getSystemPowerWhitelist(); + String[] getFullPowerWhitelist(); + int[] getAppIdWhitelist(); +} diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index f93550a..b29e8d0 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -342,7 +342,7 @@ interface INetworkManagementService void setFirewallInterfaceRule(String iface, boolean allow); void setFirewallEgressSourceRule(String addr, boolean allow); void setFirewallEgressDestRule(String addr, int port, boolean allow); - void setFirewallUidRule(int uid, boolean allow); + void setFirewallUidRule(int uid, int rule); /** * Set all packets from users in ranges to go through VPN specified by netId. diff --git a/core/java/android/os/IPermissionController.aidl b/core/java/android/os/IPermissionController.aidl index 73a68f1..0cc1603 100644 --- a/core/java/android/os/IPermissionController.aidl +++ b/core/java/android/os/IPermissionController.aidl @@ -20,4 +20,5 @@ package android.os; /** @hide */ interface IPermissionController { boolean checkPermission(String permission, int pid, int uid); + String[] getPackagesForUid(int uid); } diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 01c9a21..1d9d7d2 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -920,6 +920,14 @@ public final class PowerManager { = "android.os.action.DEVICE_IDLE_MODE_CHANGED"; /** + * @hide Intent that is broadcast when the set of power save whitelist apps has changed. + * This broadcast is only sent to registered receivers. + */ + @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_POWER_SAVE_WHITELIST_CHANGED + = "android.os.action.POWER_SAVE_WHITELIST_CHANGED"; + + /** * Intent that is broadcast when the state of {@link #isPowerSaveMode()} is about to change. * This broadcast is only sent to registered receivers. * diff --git a/core/java/android/os/storage/IMountServiceListener.java b/core/java/android/os/storage/IMountServiceListener.java index 2d13e49..c958fb0 100644 --- a/core/java/android/os/storage/IMountServiceListener.java +++ b/core/java/android/os/storage/IMountServiceListener.java @@ -91,10 +91,17 @@ public interface IMountServiceListener extends IInterface { reply.writeNoException(); return true; } - case TRANSACTION_onVolumeMetadataChanged: { + case TRANSACTION_onVolumeRecordChanged: { + data.enforceInterface(DESCRIPTOR); + final VolumeRecord rec = (VolumeRecord) data.readParcelable(null); + onVolumeRecordChanged(rec); + reply.writeNoException(); + return true; + } + case TRANSACTION_onVolumeForgotten: { data.enforceInterface(DESCRIPTOR); final String fsUuid = data.readString(); - onVolumeMetadataChanged(fsUuid); + onVolumeForgotten(fsUuid); reply.writeNoException(); return true; } @@ -192,13 +199,29 @@ public interface IMountServiceListener extends IInterface { } @Override - public void onVolumeMetadataChanged(String fsUuid) throws RemoteException { + public void onVolumeRecordChanged(VolumeRecord rec) throws RemoteException { + Parcel _data = Parcel.obtain(); + Parcel _reply = Parcel.obtain(); + try { + _data.writeInterfaceToken(DESCRIPTOR); + _data.writeParcelable(rec, 0); + mRemote.transact(Stub.TRANSACTION_onVolumeRecordChanged, _data, _reply, + android.os.IBinder.FLAG_ONEWAY); + _reply.readException(); + } finally { + _reply.recycle(); + _data.recycle(); + } + } + + @Override + public void onVolumeForgotten(String fsUuid) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeString(fsUuid); - mRemote.transact(Stub.TRANSACTION_onVolumeMetadataChanged, _data, _reply, + mRemote.transact(Stub.TRANSACTION_onVolumeForgotten, _data, _reply, android.os.IBinder.FLAG_ONEWAY); _reply.readException(); } finally { @@ -228,8 +251,9 @@ public interface IMountServiceListener extends IInterface { static final int TRANSACTION_onUsbMassStorageConnectionChanged = (IBinder.FIRST_CALL_TRANSACTION + 0); static final int TRANSACTION_onStorageStateChanged = (IBinder.FIRST_CALL_TRANSACTION + 1); static final int TRANSACTION_onVolumeStateChanged = (IBinder.FIRST_CALL_TRANSACTION + 2); - static final int TRANSACTION_onVolumeMetadataChanged = (IBinder.FIRST_CALL_TRANSACTION + 3); - static final int TRANSACTION_onDiskScanned = (IBinder.FIRST_CALL_TRANSACTION + 4); + static final int TRANSACTION_onVolumeRecordChanged = (IBinder.FIRST_CALL_TRANSACTION + 3); + static final int TRANSACTION_onVolumeForgotten = (IBinder.FIRST_CALL_TRANSACTION + 4); + static final int TRANSACTION_onDiskScanned = (IBinder.FIRST_CALL_TRANSACTION + 5); } /** @@ -252,8 +276,8 @@ public interface IMountServiceListener extends IInterface { public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) throws RemoteException; - - public void onVolumeMetadataChanged(String fsUuid) throws RemoteException; + public void onVolumeRecordChanged(VolumeRecord rec) throws RemoteException; + public void onVolumeForgotten(String fsUuid) throws RemoteException; public void onDiskScanned(DiskInfo disk, int volumeCount) throws RemoteException; } diff --git a/core/java/android/os/storage/StorageEventListener.java b/core/java/android/os/storage/StorageEventListener.java index 536aca9..214c60d 100644 --- a/core/java/android/os/storage/StorageEventListener.java +++ b/core/java/android/os/storage/StorageEventListener.java @@ -41,7 +41,10 @@ public class StorageEventListener { public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) { } - public void onVolumeMetadataChanged(String fsUuid) { + public void onVolumeRecordChanged(VolumeRecord rec) { + } + + public void onVolumeForgotten(String fsUuid) { } public void onDiskScanned(DiskInfo disk, int volumeCount) { diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index 29da4f1..50e7d1c 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -93,8 +93,9 @@ public class StorageManager { Handler.Callback { private static final int MSG_STORAGE_STATE_CHANGED = 1; private static final int MSG_VOLUME_STATE_CHANGED = 2; - private static final int MSG_VOLUME_METADATA_CHANGED = 3; - private static final int MSG_DISK_SCANNED = 4; + private static final int MSG_VOLUME_RECORD_CHANGED = 3; + private static final int MSG_VOLUME_FORGOTTEN = 4; + private static final int MSG_DISK_SCANNED = 5; final StorageEventListener mCallback; final Handler mHandler; @@ -117,8 +118,12 @@ public class StorageManager { mCallback.onVolumeStateChanged((VolumeInfo) args.arg1, args.argi2, args.argi3); args.recycle(); return true; - case MSG_VOLUME_METADATA_CHANGED: - mCallback.onVolumeMetadataChanged((String) args.arg1); + case MSG_VOLUME_RECORD_CHANGED: + mCallback.onVolumeRecordChanged((VolumeRecord) args.arg1); + args.recycle(); + return true; + case MSG_VOLUME_FORGOTTEN: + mCallback.onVolumeForgotten((String) args.arg1); args.recycle(); return true; case MSG_DISK_SCANNED: @@ -154,10 +159,17 @@ public class StorageManager { } @Override - public void onVolumeMetadataChanged(String fsUuid) { + public void onVolumeRecordChanged(VolumeRecord rec) { + final SomeArgs args = SomeArgs.obtain(); + args.arg1 = rec; + mHandler.obtainMessage(MSG_VOLUME_RECORD_CHANGED, args).sendToTarget(); + } + + @Override + public void onVolumeForgotten(String fsUuid) { final SomeArgs args = SomeArgs.obtain(); args.arg1 = fsUuid; - mHandler.obtainMessage(MSG_VOLUME_METADATA_CHANGED, args).sendToTarget(); + mHandler.obtainMessage(MSG_VOLUME_FORGOTTEN, args).sendToTarget(); } @Override @@ -246,8 +258,9 @@ public class StorageManager { } /** {@hide} */ + @Deprecated public static StorageManager from(Context context) { - return (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); + return context.getSystemService(StorageManager.class); } /** @@ -536,6 +549,17 @@ public class StorageManager { } /** {@hide} */ + public @Nullable VolumeInfo findVolumeByQualifiedUuid(String volumeUuid) { + if (Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, volumeUuid)) { + return findVolumeById(VolumeInfo.ID_PRIVATE_INTERNAL); + } else if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, volumeUuid)) { + return getPrimaryPhysicalVolume(); + } else { + return findVolumeByUuid(volumeUuid); + } + } + + /** {@hide} */ public @NonNull List<VolumeInfo> getVolumes() { try { return Arrays.asList(mMountService.getVolumes(0)); @@ -555,6 +579,8 @@ public class StorageManager { /** {@hide} */ public @Nullable String getBestVolumeDescription(VolumeInfo vol) { + if (vol == null) return null; + // Nickname always takes precedence when defined if (!TextUtils.isEmpty(vol.fsUuid)) { final VolumeRecord rec = findRecordByUuid(vol.fsUuid); @@ -861,6 +887,27 @@ public class StorageManager { DEFAULT_FULL_THRESHOLD_BYTES); } + /** {@hide} */ + public static File maybeTranslateEmulatedPathToInternal(File path) { + final IMountService mountService = IMountService.Stub.asInterface( + ServiceManager.getService("mount")); + try { + final VolumeInfo[] vols = mountService.getVolumes(0); + for (VolumeInfo vol : vols) { + if ((vol.getType() == VolumeInfo.TYPE_EMULATED + || vol.getType() == VolumeInfo.TYPE_PUBLIC) && vol.isMountedReadable()) { + final File internalPath = FileUtils.rewriteAfterRename(vol.getPath(), + vol.getInternalPath(), path); + if (internalPath != null) { + return internalPath; + } + } + } + } catch (RemoteException ignored) { + } + return path; + } + /// Consts to match the password types in cryptfs.h /** @hide */ public static final int CRYPT_TYPE_PASSWORD = 0; diff --git a/core/java/android/os/storage/VolumeInfo.java b/core/java/android/os/storage/VolumeInfo.java index fd10cae..2622ee0 100644 --- a/core/java/android/os/storage/VolumeInfo.java +++ b/core/java/android/os/storage/VolumeInfo.java @@ -129,6 +129,7 @@ public class VolumeInfo implements Parcelable { public String fsUuid; public String fsLabel; public String path; + public String internalPath; /** Framework state */ public final int mtpIndex; @@ -155,6 +156,7 @@ public class VolumeInfo implements Parcelable { fsUuid = parcel.readString(); fsLabel = parcel.readString(); path = parcel.readString(); + internalPath = parcel.readString(); mtpIndex = parcel.readInt(); } @@ -248,7 +250,11 @@ public class VolumeInfo implements Parcelable { } public File getPath() { - return new File(path); + return (path != null) ? new File(path) : null; + } + + public File getInternalPath() { + return (internalPath != null) ? new File(internalPath) : null; } public File getPathForUser(int userId) { @@ -335,14 +341,11 @@ public class VolumeInfo implements Parcelable { final Uri uri; if (type == VolumeInfo.TYPE_PUBLIC) { uri = DocumentsContract.buildRootUri(DOCUMENT_AUTHORITY, fsUuid); - } else if (VolumeInfo.ID_EMULATED_INTERNAL.equals(id)) { + } else if (type == VolumeInfo.TYPE_EMULATED && isPrimary()) { uri = DocumentsContract.buildRootUri(DOCUMENT_AUTHORITY, DOCUMENT_ROOT_PRIMARY_EMULATED); - } else if (type == VolumeInfo.TYPE_EMULATED) { - // TODO: build intent once supported - uri = null; } else { - throw new IllegalArgumentException(); + return null; } final Intent intent = new Intent(DocumentsContract.ACTION_BROWSE_DOCUMENT_ROOT); @@ -372,6 +375,7 @@ public class VolumeInfo implements Parcelable { pw.printPair("fsLabel", fsLabel); pw.println(); pw.printPair("path", path); + pw.printPair("internalPath", internalPath); pw.printPair("mtpIndex", mtpIndex); pw.decreaseIndent(); pw.println(); @@ -437,6 +441,7 @@ public class VolumeInfo implements Parcelable { parcel.writeString(fsUuid); parcel.writeString(fsLabel); parcel.writeString(path); + parcel.writeString(internalPath); parcel.writeInt(mtpIndex); } } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 00c851b..293cf6f 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -919,6 +919,15 @@ public final class Settings { = "android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS"; /** + * Activity Action: Show Zen Mode event rule configuration settings. + * + * @hide + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_ZEN_MODE_EVENT_RULE_SETTINGS + = "android.settings.ZEN_MODE_EVENT_RULE_SETTINGS"; + + /** * Activity Action: Show Zen Mode external rule configuration settings. * * @hide diff --git a/core/java/android/security/keymaster/KeyCharacteristics.java b/core/java/android/security/keymaster/KeyCharacteristics.java index 458f153..03248e5 100644 --- a/core/java/android/security/keymaster/KeyCharacteristics.java +++ b/core/java/android/security/keymaster/KeyCharacteristics.java @@ -87,6 +87,28 @@ public class KeyCharacteristics implements Parcelable { return result; } + public Long getLong(int tag) { + if (hwEnforced.containsTag(tag)) { + return hwEnforced.getLong(tag, -1); + } else if (swEnforced.containsTag(tag)) { + return swEnforced.getLong(tag, -1); + } else { + return null; + } + } + + public long getLong(int tag, long defaultValue) { + Long result = getLong(tag); + return (result != null) ? result : defaultValue; + } + + public List<Long> getLongs(int tag) { + List<Long> result = new ArrayList<Long>(); + result.addAll(hwEnforced.getLongs(tag)); + result.addAll(swEnforced.getLongs(tag)); + return result; + } + public Date getDate(int tag) { Date result = hwEnforced.getDate(tag, null); if (result == null) { diff --git a/core/java/android/security/keymaster/KeymasterDefs.java b/core/java/android/security/keymaster/KeymasterDefs.java index 40baf9c..d8834fe 100644 --- a/core/java/android/security/keymaster/KeymasterDefs.java +++ b/core/java/android/security/keymaster/KeymasterDefs.java @@ -194,6 +194,9 @@ public final class KeymasterDefs { public static final int KM_ERROR_UNSUPPORTED_EC_FIELD = -50; public static final int KM_ERROR_MISSING_NONCE = -51; public static final int KM_ERROR_INVALID_NONCE = -52; + public static final int KM_ERROR_UNSUPPORTED_CHUNK_LENGTH = -53; + public static final int KM_ERROR_RESCOPABLE_KEY_NOT_USABLE = -54; + public static final int KM_ERROR_CALLER_NONCE_PROHIBITED = -55; public static final int KM_ERROR_UNIMPLEMENTED = -100; public static final int KM_ERROR_VERSION_MISMATCH = -101; public static final int KM_ERROR_UNKNOWN_ERROR = -1000; diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java index dc8f3ea..f09f4d2 100644 --- a/core/java/android/service/notification/ZenModeConfig.java +++ b/core/java/android/service/notification/ZenModeConfig.java @@ -95,7 +95,7 @@ public class ZenModeConfig implements Parcelable { private static final String MANUAL_TAG = "manual"; private static final String AUTOMATIC_TAG = "automatic"; - private static final String RULE_ATT_ID = "id"; + private static final String RULE_ATT_ID = "ruleId"; private static final String RULE_ATT_ENABLED = "enabled"; private static final String RULE_ATT_SNOOZING = "snoozing"; private static final String RULE_ATT_NAME = "name"; @@ -279,6 +279,15 @@ public class ZenModeConfig implements Parcelable { } } + private static long tryParseLong(String value, long defValue) { + if (TextUtils.isEmpty(value)) return defValue; + try { + return Long.valueOf(value); + } catch (NumberFormatException e) { + return defValue; + } + } + public static ZenModeConfig readXml(XmlPullParser parser, Migration migration) throws XmlPullParserException, IOException { int type = parser.getEventType(); @@ -367,7 +376,7 @@ public class ZenModeConfig implements Parcelable { rt.conditionId = safeUri(parser, RULE_ATT_CONDITION_ID); rt.component = safeComponentName(parser, RULE_ATT_COMPONENT); rt.condition = readConditionXml(parser); - return rt.condition != null || !conditionRequired ? rt : null; + return rt; } public static void writeRuleXml(ZenRule rule, XmlSerializer out) throws IOException { @@ -568,10 +577,12 @@ public class ZenModeConfig implements Parcelable { Condition.FLAG_RELEVANT_NOW); } - // For built-in conditions + // ==== Built-in system conditions ==== + public static final String SYSTEM_AUTHORITY = "android"; - // Built-in countdown conditions, e.g. condition://android/countdown/1399917958951 + // ==== Built-in system condition: countdown ==== + public static final String COUNTDOWN_PATH = "countdown"; public static Uri toCountdownConditionId(long time) { @@ -598,9 +609,43 @@ public class ZenModeConfig implements Parcelable { return tryParseCountdownConditionId(conditionId) != 0; } - // built-in schedule conditions + // ==== Built-in system condition: schedule ==== + public static final String SCHEDULE_PATH = "schedule"; + public static Uri toScheduleConditionId(ScheduleInfo schedule) { + return new Uri.Builder().scheme(Condition.SCHEME) + .authority(SYSTEM_AUTHORITY) + .appendPath(SCHEDULE_PATH) + .appendQueryParameter("days", toDayList(schedule.days)) + .appendQueryParameter("start", schedule.startHour + "." + schedule.startMinute) + .appendQueryParameter("end", schedule.endHour + "." + schedule.endMinute) + .build(); + } + + public static boolean isValidScheduleConditionId(Uri conditionId) { + return tryParseScheduleConditionId(conditionId) != null; + } + + public static ScheduleInfo tryParseScheduleConditionId(Uri conditionId) { + final boolean isSchedule = conditionId != null + && conditionId.getScheme().equals(Condition.SCHEME) + && conditionId.getAuthority().equals(ZenModeConfig.SYSTEM_AUTHORITY) + && conditionId.getPathSegments().size() == 1 + && conditionId.getPathSegments().get(0).equals(ZenModeConfig.SCHEDULE_PATH); + if (!isSchedule) return null; + final int[] start = tryParseHourAndMinute(conditionId.getQueryParameter("start")); + final int[] end = tryParseHourAndMinute(conditionId.getQueryParameter("end")); + if (start == null || end == null) return null; + final ScheduleInfo rt = new ScheduleInfo(); + rt.days = tryParseDayList(conditionId.getQueryParameter("days"), "\\."); + rt.startHour = start[0]; + rt.startMinute = start[1]; + rt.endHour = end[0]; + rt.endMinute = end[1]; + return rt; + } + public static class ScheduleInfo { public int[] days; public int startHour; @@ -638,39 +683,76 @@ public class ZenModeConfig implements Parcelable { } } - public static Uri toScheduleConditionId(ScheduleInfo schedule) { + // ==== Built-in system condition: event ==== + + public static final String EVENT_PATH = "event"; + + public static Uri toEventConditionId(EventInfo event) { return new Uri.Builder().scheme(Condition.SCHEME) .authority(SYSTEM_AUTHORITY) - .appendPath(SCHEDULE_PATH) - .appendQueryParameter("days", toDayList(schedule.days)) - .appendQueryParameter("start", schedule.startHour + "." + schedule.startMinute) - .appendQueryParameter("end", schedule.endHour + "." + schedule.endMinute) + .appendPath(EVENT_PATH) + .appendQueryParameter("calendar", Long.toString(event.calendar)) + .appendQueryParameter("attendance", Integer.toString(event.attendance)) + .appendQueryParameter("reply", Integer.toString(event.reply)) .build(); } - public static boolean isValidScheduleConditionId(Uri conditionId) { - return tryParseScheduleConditionId(conditionId) != null; + public static boolean isValidEventConditionId(Uri conditionId) { + return tryParseEventConditionId(conditionId) != null; } - public static ScheduleInfo tryParseScheduleConditionId(Uri conditionId) { - final boolean isSchedule = conditionId != null + public static EventInfo tryParseEventConditionId(Uri conditionId) { + final boolean isEvent = conditionId != null && conditionId.getScheme().equals(Condition.SCHEME) && conditionId.getAuthority().equals(ZenModeConfig.SYSTEM_AUTHORITY) && conditionId.getPathSegments().size() == 1 - && conditionId.getPathSegments().get(0).equals(ZenModeConfig.SCHEDULE_PATH); - if (!isSchedule) return null; - final int[] start = tryParseHourAndMinute(conditionId.getQueryParameter("start")); - final int[] end = tryParseHourAndMinute(conditionId.getQueryParameter("end")); - if (start == null || end == null) return null; - final ScheduleInfo rt = new ScheduleInfo(); - rt.days = tryParseDayList(conditionId.getQueryParameter("days"), "\\."); - rt.startHour = start[0]; - rt.startMinute = start[1]; - rt.endHour = end[0]; - rt.endMinute = end[1]; + && conditionId.getPathSegments().get(0).equals(EVENT_PATH); + if (!isEvent) return null; + final EventInfo rt = new EventInfo(); + rt.calendar = tryParseLong(conditionId.getQueryParameter("calendar"), 0L); + rt.attendance = tryParseInt(conditionId.getQueryParameter("attendance"), 0); + rt.reply = tryParseInt(conditionId.getQueryParameter("reply"), 0); return rt; } + public static class EventInfo { + public static final int ATTENDANCE_REQUIRED_OR_OPTIONAL = 0; + public static final int ATTENDANCE_REQUIRED = 1; + public static final int ATTENDANCE_OPTIONAL = 2; + + public static final int REPLY_ANY = 0; + public static final int REPLY_ANY_EXCEPT_NO = 1; + public static final int REPLY_YES = 2; + + public long calendar; // CalendarContract.Calendars._ID, or 0 for any + public int attendance; + public int reply; + + @Override + public int hashCode() { + return 0; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof EventInfo)) return false; + final EventInfo other = (EventInfo) o; + return calendar == other.calendar + && attendance == other.attendance + && reply == other.reply; + } + + public EventInfo copy() { + final EventInfo rt = new EventInfo(); + rt.calendar = calendar; + rt.attendance = attendance; + rt.reply = reply; + return rt; + } + } + + // ==== End built-in system conditions ==== + private static int[] tryParseHourAndMinute(String value) { if (TextUtils.isEmpty(value)) return null; final int i = value.indexOf('.'); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index e8fc15e..b5b7f0f 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -15490,12 +15490,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (drawingWithRenderNode) { renderNode.setAlpha(alpha * getAlpha() * getTransitionAlpha()); } else if (layerType == LAYER_TYPE_NONE) { - int layerFlags = Canvas.HAS_ALPHA_LAYER_SAVE_FLAG; - if ((parentFlags & ViewGroup.FLAG_CLIP_CHILDREN) != 0) { - layerFlags |= Canvas.CLIP_TO_LAYER_SAVE_FLAG; - } canvas.saveLayerAlpha(sx, sy, sx + getWidth(), sy + getHeight(), - multipliedAlpha, layerFlags); + multipliedAlpha); } } else { // Alpha is handled by the child directly, clobber the layer's alpha diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index bbf120a..088adbb 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -18,6 +18,7 @@ package android.widget; import static android.widget.SuggestionsAdapter.getColumnString; +import android.annotation.Nullable; import android.app.PendingIntent; import android.app.SearchManager; import android.app.SearchableInfo; @@ -120,6 +121,8 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { private final Intent mVoiceWebSearchIntent; private final Intent mVoiceAppSearchIntent; + private final CharSequence mDefaultQueryHint; + private OnQueryTextListener mOnQueryChangeListener; private OnCloseListener mOnCloseListener; private OnFocusChangeListener mOnQueryTextFocusChangeListener; @@ -329,10 +332,8 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { setMaxWidth(maxWidth); } - final CharSequence queryHint = a.getText(R.styleable.SearchView_queryHint); - if (!TextUtils.isEmpty(queryHint)) { - setQueryHint(queryHint); - } + mDefaultQueryHint = a.getText(R.styleable.SearchView_defaultQueryHint); + mQueryHint = a.getText(R.styleable.SearchView_queryHint); final int imeOptions = a.getInt(R.styleable.SearchView_imeOptions, -1); if (imeOptions != -1) { @@ -570,36 +571,48 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { } /** - * Sets the hint text to display in the query text field. This overrides any hint specified - * in the SearchableInfo. - * - * @param hint the hint text to display + * Sets the hint text to display in the query text field. This overrides + * any hint specified in the {@link SearchableInfo}. + * <p> + * This value may be specified as an empty string to prevent any query hint + * from being displayed. * + * @param hint the hint text to display or {@code null} to clear * @attr ref android.R.styleable#SearchView_queryHint */ - public void setQueryHint(CharSequence hint) { + public void setQueryHint(@Nullable CharSequence hint) { mQueryHint = hint; updateQueryHint(); } /** - * Gets the hint text to display in the query text field. - * @return the query hint text, if specified, null otherwise. + * Returns the hint text that will be displayed in the query text field. + * <p> + * The displayed query hint is chosen in the following order: + * <ol> + * <li>Non-null value set with {@link #setQueryHint(CharSequence)} + * <li>Value specified in XML using + * {@link android.R.styleable#SearchView_queryHint android:queryHint} + * <li>Valid string resource ID exposed by the {@link SearchableInfo} via + * {@link SearchableInfo#getHintId()} + * <li>Default hint provided by the theme against which the view was + * inflated + * </ol> * + * @return the displayed query hint text, or {@code null} if none set * @attr ref android.R.styleable#SearchView_queryHint */ + @Nullable public CharSequence getQueryHint() { + final CharSequence hint; if (mQueryHint != null) { - return mQueryHint; - } else if (mSearchable != null) { - CharSequence hint = null; - int hintId = mSearchable.getHintId(); - if (hintId != 0) { - hint = getContext().getString(hintId); - } - return hint; + hint = mQueryHint; + } else if (mSearchable != null && mSearchable.getHintId() != 0) { + hint = getContext().getText(mSearchable.getHintId()); + } else { + hint = mDefaultQueryHint; } - return null; + return hint; } /** @@ -1113,20 +1126,8 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { } private void updateQueryHint() { - if (mQueryHint != null) { - mSearchSrcTextView.setHint(getDecoratedHint(mQueryHint)); - } else if (mSearchable != null) { - CharSequence hint = null; - int hintId = mSearchable.getHintId(); - if (hintId != 0) { - hint = getContext().getString(hintId); - } - if (hint != null) { - mSearchSrcTextView.setHint(getDecoratedHint(hint)); - } - } else { - mSearchSrcTextView.setHint(getDecoratedHint("")); - } + final CharSequence hint = getQueryHint(); + mSearchSrcTextView.setHint(getDecoratedHint(hint == null ? "" : hint)); } /** diff --git a/core/java/com/android/internal/content/PackageMonitor.java b/core/java/com/android/internal/content/PackageMonitor.java index eff44bd..481ab0e 100644 --- a/core/java/com/android/internal/content/PackageMonitor.java +++ b/core/java/com/android/internal/content/PackageMonitor.java @@ -44,7 +44,6 @@ public abstract class PackageMonitor extends android.content.BroadcastReceiver { sPackageFilt.addAction(Intent.ACTION_PACKAGE_CHANGED); sPackageFilt.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART); sPackageFilt.addAction(Intent.ACTION_PACKAGE_RESTARTED); - sPackageFilt.addAction(Intent.ACTION_UID_REMOVED); sPackageFilt.addDataScheme("package"); sNonDataFilt.addAction(Intent.ACTION_UID_REMOVED); sNonDataFilt.addAction(Intent.ACTION_USER_STOPPED); diff --git a/core/java/com/android/internal/logging/MetricsLogger.java b/core/java/com/android/internal/logging/MetricsLogger.java index 092c148..3f96174 100644 --- a/core/java/com/android/internal/logging/MetricsLogger.java +++ b/core/java/com/android/internal/logging/MetricsLogger.java @@ -26,11 +26,12 @@ import android.os.Build; */ public class MetricsLogger implements MetricsConstants { // These constants are temporary, they should migrate to MetricsConstants. - // next value is 146; + // next value is 148; public static final int NOTIFICATION_ZEN_MODE_SCHEDULE_RULE = 144; public static final int NOTIFICATION_ZEN_MODE_EXTERNAL_RULE = 145; public static final int ACTION_BAN_APP_NOTES = 146; + public static final int NOTIFICATION_ZEN_MODE_EVENT_RULE = 147; 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/midi/MidiFramer.java b/core/java/com/android/internal/midi/MidiFramer.java index 1a7fa0b..8ed5b5a 100644 --- a/core/java/com/android/internal/midi/MidiFramer.java +++ b/core/java/com/android/internal/midi/MidiFramer.java @@ -78,7 +78,7 @@ public class MidiFramer extends MidiReceiver { // Log.i(TAG, "SysEx End"); if (mInSysEx) { mReceiver.sendWithTimestamp(data, sysExStartOffset, - offset - sysExStartOffset, timestamp); + offset - sysExStartOffset + 1, timestamp); mInSysEx = false; sysExStartOffset = -1; } @@ -90,6 +90,11 @@ public class MidiFramer extends MidiReceiver { } } else { // real-time? // Single byte message interleaved with other data. + if (mInSysEx) { + mReceiver.sendWithTimestamp(data, sysExStartOffset, + offset - sysExStartOffset, timestamp); + sysExStartOffset = offset + 1; + } mReceiver.sendWithTimestamp(data, offset, 1, timestamp); } } else { // data byte @@ -110,7 +115,7 @@ public class MidiFramer extends MidiReceiver { } // send any accumulatedSysEx data - if (sysExStartOffset >= 0) { + if (sysExStartOffset >= 0 && sysExStartOffset < offset) { mReceiver.sendWithTimestamp(data, sysExStartOffset, offset - sysExStartOffset, timestamp); } diff --git a/core/java/com/android/internal/widget/FloatingToolbar.java b/core/java/com/android/internal/widget/FloatingToolbar.java index 3a1e0ca..3f7696f 100644 --- a/core/java/com/android/internal/widget/FloatingToolbar.java +++ b/core/java/com/android/internal/widget/FloatingToolbar.java @@ -438,6 +438,9 @@ public final class FloatingToolbar { // Make sure a panel is set as the content. if (mContentContainer.getChildCount() == 0) { setMainPanelAsContent(); + // If we're yet to show the popup, set the container visibility to zero. + // The "show" animation will make this visible. + mContentContainer.setAlpha(0); } preparePopupContent(); mPopupWindow.showAtLocation(mParent, Gravity.NO_GRAVITY, x, y); @@ -478,7 +481,7 @@ public final class FloatingToolbar { * Returns {@code true} if this popup is currently showing. {@code false} otherwise. */ public boolean isShowing() { - return mPopupWindow.isShowing() && !mDismissed && !mHidden; + return !mDismissed && !mHidden; } /** @@ -494,7 +497,7 @@ public final class FloatingToolbar { * This is a no-op if this popup is not showing. */ public void updateCoordinates(int x, int y) { - if (!isShowing()) { + if (!isShowing() || !mPopupWindow.isShowing()) { return; } |