Merge "Add easy way to get device idle whitelist." into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index bb1070d..ba1d0eb 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -30690,6 +30690,11 @@
method public abstract int getDbm();
method public abstract int getLevel();
method public abstract int hashCode();
+ field public static final int SIGNAL_STRENGTH_GOOD = 3; // 0x3
+ field public static final int SIGNAL_STRENGTH_GREAT = 4; // 0x4
+ field public static final int SIGNAL_STRENGTH_MODERATE = 2; // 0x2
+ field public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0; // 0x0
+ field public static final int SIGNAL_STRENGTH_POOR = 1; // 0x1
}
public final class CellSignalStrengthCdma extends android.telephony.CellSignalStrength implements android.os.Parcelable {
diff --git a/api/system-current.txt b/api/system-current.txt
index 5861560..63c28c1 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -32922,6 +32922,11 @@
method public abstract int getDbm();
method public abstract int getLevel();
method public abstract int hashCode();
+ field public static final int SIGNAL_STRENGTH_GOOD = 3; // 0x3
+ field public static final int SIGNAL_STRENGTH_GREAT = 4; // 0x4
+ field public static final int SIGNAL_STRENGTH_MODERATE = 2; // 0x2
+ field public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0; // 0x0
+ field public static final int SIGNAL_STRENGTH_POOR = 1; // 0x1
}
public final class CellSignalStrengthCdma extends android.telephony.CellSignalStrength implements android.os.Parcelable {
diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl
index 9cf3759..acad496 100644
--- a/core/java/android/view/IWindow.aidl
+++ b/core/java/android/view/IWindow.aidl
@@ -83,7 +83,8 @@
* The window is beginning to animate. The application should stop drawing frames until the
* window is not animating anymore, indicated by being called {@link #windowEndAnimating}.
*
- * @param remainingFrameCount how many frames the app might still draw before stopping drawing
+ * @param remainingFrameCount how many frames the app might still draw before stopping drawing;
+ * pass -1 to let it continue drawing
*/
void onAnimationStarted(int remainingFrameCount);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 63dd492..de61c31 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15366,7 +15366,8 @@
ViewConfiguration.get(mContext).getScaledMaximumDrawingCacheSize();
if (width <= 0 || height <= 0 || projectedBitmapSize > drawingCacheSize) {
if (width > 0 && height > 0) {
- Log.w(VIEW_LOG_TAG, "View too large to fit into drawing cache, needs "
+ Log.w(VIEW_LOG_TAG, getClass().getSimpleName() + " not displayed because it is"
+ + " too large to fit into a software layer (or drawing cache), needs "
+ projectedBitmapSize + " bytes, only "
+ drawingCacheSize + " available");
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 6d0d788..09d7a21 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -5327,7 +5327,7 @@
}
public void handleDispatchWindowAnimationStarted(int remainingFrameCount) {
- if (!mDrawDuringWindowsAnimating) {
+ if (!mDrawDuringWindowsAnimating && remainingFrameCount != -1) {
mRemainingFrameCount = remainingFrameCount;
mWindowsAnimating = true;
}
diff --git a/docs/html/preview/api-overview.jd b/docs/html/preview/api-overview.jd
index 1686d79..75b3c52 100644
--- a/docs/html/preview/api-overview.jd
+++ b/docs/html/preview/api-overview.jd
@@ -86,9 +86,11 @@
<a href="{@docRoot}preview/features/app-linking.html">App Linking</a>.
<h2 id="backup">Auto Backup for Apps</h2>
-<p>The system now performs automatic full data backup and restore for apps. This behavior is
-enabled by default for apps targeting M Preview; you do not need to add any additional code. If
-users delete their Google accounts, their backup data is deleted as well. To learn how this feature
+<p>The system now performs automatic full data backup and restore for apps. For the
+duration of the <a href="{@docRoot}preview/overview.html">M Developer Preview program</a>, all
+apps are backed up, independent of which SDK version they target. After the final M SDK release,
+your app must target M to enable this behavior; you do not need to add any additional code. If users
+delete their Google accounts, their backup data is deleted as well. To learn how this feature
works and how to configure what to back up on the file system, see
<a href="{@docRoot}preview/backup/index.html">Auto Backup for Apps</a>.</p>
@@ -152,10 +154,9 @@
<p>To set the timeout duration for which the same key can be re-used after a user is successfully
authenticated, call the new
-{@code android.security.keystore.KeyGenParameterSpec.setUserAuthenticationValidityDurationSeconds()}
+{@code android.security.keystore.KeyGenParameterSpec.Builder.setUserAuthenticationValidityDurationSeconds()}
method when you set up a {@link javax.crypto.KeyGenerator} or
-{@link java.security.KeyPairGenerator}. This feature currently works for symmetric cryptographic
-operations.</p>
+{@link java.security.KeyPairGenerator}.</p>
<p>Avoid showing the re-authentication dialog excessively -- your apps should try using the
cryptographic object first and if the the timeout expires, use the
@@ -236,7 +237,7 @@
<p>Your app can elect to not share the current context with the assistant by setting the
{@link android.view.WindowManager.LayoutParams#FLAG_SECURE} flag. In addition to the
standard set of information that the platform passes to the assistant, your app can share
-additional information by using the new {@code android.app.Activity.AssistContent} class.</p>
+additional information by using the new {@code android.app.assist.AssistContent} class.</p>
<p>To provide the assistant with additional context from your app, follow these steps:</p>
@@ -273,7 +274,7 @@
information from the touch screen is fused with pressure and button information from the stylus to
provide a greater range of expression than with the touch screen alone. Your app can listen for
stylus button presses and perform secondary actions, by registering the new
-{@code View.onStylusButtonPressListener} and {@code GestureDetector.OnStylusButtonPressListener}
+{@code View.onContextClickListener} and {@code GestureDetector.onContextClickListener}
callbacks in your activity.</p>
<p>Use the {@link android.view.MotionEvent} methods and constants to detect stylus button
@@ -284,11 +285,11 @@
{@link android.view.MotionEvent#TOOL_TYPE_STYLUS}.</li>
<li>For apps targeting M Preview, the
{@link android.view.MotionEvent#getButtonState() getButtonState()}
-method returns {@code MotionEvent.STYLUS_BUTTON_PRIMARY} when the user
+method returns {@code MotionEvent.BUTTON_STYLUS_PRIMARY} when the user
presses the primary stylus button. If the stylus has a second button, the same method returns
-{@code MotionEvent.STYLUS_BUTTON_SECONDARY} when the user presses it. If the user presses
+{@code MotionEvent.BUTTON_STYLUS_SECONDARY} when the user presses it. If the user presses
both buttons simultaneously, the method returns both values OR'ed together
-({@code STYLUS_BUTTON_PRIMARY|STYLUS_BUTTON_SECONDARY}).</li>
+({@code BUTTON_STYLUS_PRIMARY|BUTTON_STYLUS_SECONDARY}).</li>
<li>
For apps targeting a lower platform version, the
{@link android.view.MotionEvent#getButtonState() getButtonState()} method returns
@@ -314,7 +315,7 @@
{@link android.net.wifi.WifiEnterpriseConfig} class, such as {@code setPlmn()} and
{@code setRealm()}. In the {@link android.net.wifi.WifiConfiguration} object, you can set the
{@link android.net.wifi.WifiConfiguration#FQDN} and the {@code providerFriendlyName} fields.
-The new {@code ScanResult.PasspointNetwork} property indicates if a detected
+The new {@code ScanResult.isPasspointNetwork()} method indicates if a detected
network represents a Hotspot 2.0 access point.
</p>
@@ -356,10 +357,10 @@
TV. The system invokes the new {@code android.app.Activity.onSearchRequested()} callback when the
user starts a search. To determine if the user's input device has a built-in microphone, retrieve
the {@link android.view.InputDevice} object from that callback, then call the new
-{@code InputDevice.hasMic()} method.</li>
- <li>New {@code android.media.AudioDevicesManager} class which lets you retrieve a list of all
-attached source and sink audio devices. You can also specify an
-{@code android.media.OnAudioDeviceConnectionListener} object if you want your app to be notified
+{@code InputDevice.hasMicrophone()} method.</li>
+ <li>New {@code AudioManager.getDevices() method which lets you retrieve a list of all
+ audio devices currently connected to the system. You can also register an
+{@code android.media.AudioDeviceCallback} object if you want your app to be notified
when an audio device is connected or disconnected.</li>
</ul>
@@ -407,14 +408,15 @@
<h3 id="reprocessing">Reprocessing API</h3>
<p>The {@link android.hardware.camera2 Camera2} API is extended to support YUV and private
-opaque format image reprocessing. Your app determine if the reprocessing capabilities are available
-via {@code CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES}. If a device supports reprocessing,
-you can create a reprocessable camera capture session by calling
+opaque format image reprocessing. To determine if these reprocessing capabilities are available,
+call {@link android.hardware.camera2.CameraManager#getCameraCharacteristics(java.lang.String)
+getCameraCharacteristics()} and check for the {@code REPROCESS_MAX_CAPTURE_STALL} key. If a
+device supports reprocessing, you can create a reprocessable camera capture session by calling
{@code CameraDevice.createReprocessableCaptureSession()}, and create requests for input
buffer reprocessing.</p>
-<p>Use the {@code ImageWriter} class to connect the input buffer flow to the camera reprocessing
-input. To get an empty buffer, follow this programming model:</p>
+<p>Use the {@code android.media.ImageWriter} class to connect the input buffer flow to the camera
+reprocessing input. To get an empty buffer, follow this programming model:</p>
<ol>
<li>Call the {@code ImageWriter.dequeueInputImage()} method.</li>
@@ -428,10 +430,10 @@
{@code ImageWriter} by calling the {@code ImageWriter.queueInputImage()} method without any
buffer copy.</p>
-<p>The {@code ImageReader} class now supports {@code android.graphics.ImageFormat.PRIVATE} format
-image streams. This support allows your app to maintain a circular image queue of
-{@code ImageReader} output images, select one or more images, and send them to the
-{@code ImageWriter} for camera reprocessing.</p>
+<p>The {@link android.media.ImageReader} class now supports
+{@code android.graphics.ImageFormat.PRIVATE} format image streams. This support allows your app to
+maintain a circular image queue of {@link android.media.ImageReader} output images, select one or
+more images, and send them to the {@code ImageWriter} for camera reprocessing.</p>
<h2 id="afw">Android for Work Features</h2>
<p>This preview includes the following new APIs for Android for Work:</p>
@@ -441,10 +443,10 @@
Corporate-Owned, Single-Use (COSU) devices:
<ul>
<li>Disable or re-enable the keyguard with the
-{@code DevicePolicyManager.setKeyguardEnabledState()} method.</li>
+{@code DevicePolicyManager.setKeyguardDisabled()} method.</li>
<li>Disable or re-enable the status bar (including quick settings, notifications, and the
navigation swipe-up gesture that launches Google Now) with the
-{@code DevicePolicyManager.setStatusBarEnabledState()} method.</li>
+{@code DevicePolicyManager.setStatusBarDisabled()} method.</li>
<li>Disable or re-enable safe boot with the {@link android.os.UserManager} constant
{@code DISALLOW_SAFE_BOOT}.</li>
<li>Prevent the screen from turning off while plugged in with the
@@ -489,16 +491,6 @@
installKeyPair()}</li>
</ul>
</li>
-<li><strong>Enterprise factory reset protection:</strong> When provisioning a Device Owner, you can
-now configure parameters to unlock Factory Reset Protection (FRP) by setting the
-{@code DeviceManagerPolicy.EXTRA_PROVISIONING_RESET_PROTECTION_PARAMETERS} bundle. An NFC Programmer
-app can provide these parameters after a device has been reset to unlock FRP and provision the device,
-without requiring the previously configured Google account. If you don't modify these parameters,
-FRP remains in-place and prevents the device from being activated without the previously activated
-Google credentials.
-<p>Additionally, by setting app restrictions on Google Play services, Device Owners can specify
-alternative Google accounts for unlocking FRP to replace the ones activated on the device.</p>
-</li>
<img src="{@docRoot}preview/images/work-profile-screen.png"
srcset="{@docRoot}preview/images/work-profile-screen.png 1x, {@docRoot}preview/images/work-profile-screen_2x.png 2x"
style="float:right; margin:0 0 10px 20px" width="282" height="476" />
diff --git a/docs/html/preview/behavior-changes.jd b/docs/html/preview/behavior-changes.jd
index 5ddac7a..8a8ea05 100644
--- a/docs/html/preview/behavior-changes.jd
+++ b/docs/html/preview/behavior-changes.jd
@@ -23,8 +23,9 @@
<li><a href="#behavior-keystore">Android Keystore Changes</a></li>
<li><a href="#behavior-network">Wi-Fi and Networking Changes</a></li>
<li><a href="#behavior-camera">Camera Service Changes</a></li>
- <li><a href="#behavior-art-runtime">ART Runtime</a></li>
+ <li><a href="#behavior-runtime">Runtime</a></li>
<li><a href="#behavior-apk-validation">APK Validation</a></li>
+ <li><a href="#behavior-usb">USB Connection</a></li>
<li><a href="#behavior-afw">Android for Work Changes</a></li>
</ol>
@@ -46,8 +47,8 @@
system changes and API behavior changes. This document highlights
some of the key changes that you should understand and account for in your apps.</p>
-<p>If you have previously published an app for Android, be aware that your app
- might be affected by these changes in the platform.</p>
+<p>If you have previously published an app for Android, be aware that these changes in the
+platform affect your app.</p>
<h2 id="behavior-runtime-permissions">Runtime Permissions</h1>
<p>This preview introduces a new permissions model, where users can now directly manage
@@ -55,11 +56,11 @@
permissions, while streamlining the installation and auto-update processes for app developers.
Users can grant or revoke permissions individually for installed apps. </p>
-<p>On your apps that target the M Preview, make sure to check and request for permissions at
-runtime. To determine if your app has been granted a permission, call the
-new {@code Context.checkSelfPermission()} method. To request for a permission, call the new
-{@code Activity.requestPermission()} method. Even if your app is not targeting M, you
-should test your app under the new permissions model.</p>
+<p>On your apps that target the M Preview release or higher, make sure to check for and request
+permissions at runtime. To determine if your app has been granted a permission, call the
+new {@code Context.checkSelfPermission()} method. To request a permission, call the new
+{@code Activity.requestPermission()} method. Even if your app is not targeting the M Preview
+release, you should test your app under the new permissions model.</p>
<p>For details on supporting the new permissions model in your app, see the
<a href="{@docRoot}preview/features/runtime-permissions.html">
@@ -329,7 +330,7 @@
</li>
</ul>
-<h2 id="behavior-art-runtime">ART Runtime</h2>
+<h2 id="behavior-runtime">Runtime</h2>
<p>The ART runtime now properly implements access rules for the
{@link java.lang.reflect.Constructor#newInstance(java.lang.Object...) newInstance()} method. This
change fixes a problem where Dalvik was checking access rules incorrectly in previous versions.
@@ -362,14 +363,22 @@
declared in the manifest but not present in the APK itself. An APK must be re-signed if any of the
contents are removed.</p>
+<h2 id="behavior-usb">USB Connection</h2>
+<p>Device connections through the USB port are now set to charge-only mode by default. To access
+the device and its content over a USB connection, users must explicitly grant permission for such
+interactions. If your app supports user interactions with the device over a USB port, take into
+consideration that the interaction must be explicitly enabled.
+</p>
+
<h2 id="behavior-afw">Android for Work Changes</h2>
<p>This preview includes the following behavior changes for Android for Work:</p>
<ul>
<li><strong>Work contacts in personal contexts.</strong> The Google Dialer
Call Log now displays work contacts when the user views past calls.
-Setting {@code DevicePolicyManager.setCrossProfileCallerIdDisabled()} to {@code true} hides the
-work profile contacts in the Google Dialer Call Log. Work contacts can be displayed along with
-personal contacts to devices over Bluetooth only if
+Setting
+{@link android.app.admin.DevicePolicyManager#setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean) setCrossProfileCallerIdDisabled()}
+to {@code true} hides the work profile contacts in the Google Dialer Call Log. Work contacts can be
+displayed along with personal contacts to devices over Bluetooth only if
you set {@code DevicePolicyManager.setBluetoothContactSharingDisabled()} to {@code false}. By
default, it is set to {@code true}.
</li>
diff --git a/docs/html/preview/support.jd b/docs/html/preview/support.jd
index dd9736a..f05fa98 100644
--- a/docs/html/preview/support.jd
+++ b/docs/html/preview/support.jd
@@ -17,44 +17,48 @@
<h2 id="release-notes">Release Notes</h2>
-<!--
<div class="toggle-content opened">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-content-img"
- alt=""/>M Developer Preview, Revision 2</a> <em>(Month 2015)</em>
+ alt=""/>M Developer Preview 2</a> <em>(July 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
- <dt>Fix Category 1</dt>
+ <dt>API Name Changes:</dt>
<dd>
<ul>
- <li>Fixed issue X.</li>
- <li>Fixed issue Y.</li>
- <li>Fixed issue Z.</li>
- </ul>
- </dd>
-
- <dt>Fix Category 2</dt>
- <dd>
- <ul>
- <li>Fixed issue X.</li>
- <li>Fixed issue Y.</li>
- <li>Fixed issue Z.</li>
+ <li>Moved the {@code android.app.AssistContent} class into the new package,
+ {@code android.app.assist} in the Assist API. The full class
+ name is now {@code android.app.assist.AssistContent}.</li>
+ <li>Moved the {@code android.app.AssistStructure} class to the new package,
+ {@code android.app.assist} in the Assist API. The full class name
+ is now {@code android.app.assist.AssistStructure}.</li>
+ <li>Replaced the {@code ScanResult.PasspointNetwork} property with the
+ {@code ScanResult.isPasspointNetwork()} method for HotSpot 2.0 support.</li>
+ <li>Replaced the {@code InputDevice.hasMic()} method with {@code InputDevice.hasMicrophone()}
+ for the Audio API.</li>
+ <li>Renamed the {@code View.OnStylusButtonPressListener} class to
+ {@code View.OnContextClickListener} for Bluetooth Stylus support.</li>
+ <li>Renamed the {@code GestureDetector.OnStylusButtonPressListener} class to
+ {@code GestureDetector.OnContextClickListener} for Bluetooth Stylus support.</li>
+ <li>Renamed the {@code android.app.usage.NetworkUsageStats} class to
+ {@code android.app.usage.NetworkStats}.</li>
+ <li>Renamed the {@code android.app.usage.NetworkUsageStats.Bucket} class to
+ {@code android.app.usage.NetworkStats.Bucket}.</li>
</ul>
</dd>
</dl>
</div>
</div>
--->
-<div class="toggle-content opened">
+<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
- <img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-content-img"
- alt=""/>M Developer Preview, Revision 1</a> <em>(May 2015)</em>
+ <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
+ alt=""/>M Developer Preview 1</a> <em>(May 2015)</em>
</p>
<div class="toggle-content-toggleme">
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
index 258133d..6a7930a 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
@@ -239,6 +239,13 @@
"At least one digest algorithm must be specified");
}
}
+
+ // Check that user authentication related parameters are acceptable. This method
+ // will throw an IllegalStateException if there are issues (e.g., secure lock screen
+ // not set up).
+ KeymasterUtils.addUserAuthArgs(new KeymasterArguments(),
+ spec.isUserAuthenticationRequired(),
+ spec.getUserAuthenticationValidityDurationSeconds());
} catch (IllegalStateException | IllegalArgumentException e) {
throw new InvalidAlgorithmParameterException(e);
}
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreKeyPairGeneratorSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreKeyPairGeneratorSpi.java
index 459514d..6b36a58 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreKeyPairGeneratorSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreKeyPairGeneratorSpi.java
@@ -310,7 +310,14 @@
} else {
mKeymasterDigests = EmptyArray.INT;
}
- } catch (IllegalArgumentException e) {
+
+ // Check that user authentication related parameters are acceptable. This method
+ // will throw an IllegalStateException if there are issues (e.g., secure lock screen
+ // not set up).
+ KeymasterUtils.addUserAuthArgs(new KeymasterArguments(),
+ mSpec.isUserAuthenticationRequired(),
+ mSpec.getUserAuthenticationValidityDurationSeconds());
+ } catch (IllegalArgumentException | IllegalStateException e) {
throw new InvalidAlgorithmParameterException(e);
}
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
index dc8f1e3..e9f19cd 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
@@ -484,8 +484,8 @@
spec.getKeyValidityForOriginationEnd());
importArgs.addDateIfNotNull(KeymasterDefs.KM_TAG_USAGE_EXPIRE_DATETIME,
spec.getKeyValidityForConsumptionEnd());
- } catch (IllegalArgumentException e) {
- throw new KeyStoreException("Invalid parameter", e);
+ } catch (IllegalArgumentException | IllegalStateException e) {
+ throw new KeyStoreException(e);
}
}
@@ -598,102 +598,100 @@
+ " RAW format export");
}
- String keyAlgorithmString = key.getAlgorithm();
- int keymasterAlgorithm;
- int keymasterDigest;
- try {
- keymasterAlgorithm =
- KeyProperties.KeyAlgorithm.toKeymasterSecretKeyAlgorithm(keyAlgorithmString);
- keymasterDigest = KeyProperties.KeyAlgorithm.toKeymasterDigest(keyAlgorithmString);
- } catch (IllegalArgumentException e) {
- throw new KeyStoreException("Unsupported secret key algorithm: " + keyAlgorithmString);
- }
-
KeymasterArguments args = new KeymasterArguments();
- args.addEnum(KeymasterDefs.KM_TAG_ALGORITHM, keymasterAlgorithm);
+ try {
+ int keymasterAlgorithm =
+ KeyProperties.KeyAlgorithm.toKeymasterSecretKeyAlgorithm(key.getAlgorithm());
+ args.addEnum(KeymasterDefs.KM_TAG_ALGORITHM, keymasterAlgorithm);
- int[] keymasterDigests;
- if (params.isDigestsSpecified()) {
- // Digest(s) specified in parameters
- keymasterDigests = KeyProperties.Digest.allToKeymaster(params.getDigests());
- if (keymasterDigest != -1) {
- // Digest also specified in the JCA key algorithm name.
- if (!com.android.internal.util.ArrayUtils.contains(
- keymasterDigests, keymasterDigest)) {
- throw new KeyStoreException("Key digest mismatch"
- + ". Key: " + keyAlgorithmString
- + ", parameter spec: " + Arrays.asList(params.getDigests()));
- }
- // When the key is read back from keystore we reconstruct the JCA key algorithm
- // name from the KM_TAG_ALGORITHM and the first KM_TAG_DIGEST. Thus we need to
- // ensure that the digest reflected in the JCA key algorithm name is the first
- // KM_TAG_DIGEST tag.
- if (keymasterDigests[0] != keymasterDigest) {
- // The first digest is not the one implied by the JCA key algorithm name.
- // Swap the implied digest with the first one.
- for (int i = 0; i < keymasterDigests.length; i++) {
- if (keymasterDigests[i] == keymasterDigest) {
- keymasterDigests[i] = keymasterDigests[0];
- keymasterDigests[0] = keymasterDigest;
- break;
+ int[] keymasterDigests;
+ int keymasterDigest = KeyProperties.KeyAlgorithm.toKeymasterDigest(key.getAlgorithm());
+ if (params.isDigestsSpecified()) {
+ // Digest(s) specified in parameters
+ keymasterDigests = KeyProperties.Digest.allToKeymaster(params.getDigests());
+ if (keymasterDigest != -1) {
+ // Digest also specified in the JCA key algorithm name.
+ if (!com.android.internal.util.ArrayUtils.contains(
+ keymasterDigests, keymasterDigest)) {
+ throw new KeyStoreException("Digest specified in key algorithm "
+ + key.getAlgorithm() + " not specified in protection parameters: "
+ + Arrays.asList(params.getDigests()));
+ }
+ // When the key is read back from keystore we reconstruct the JCA key algorithm
+ // name from the KM_TAG_ALGORITHM and the first KM_TAG_DIGEST. Thus we need to
+ // ensure that the digest reflected in the JCA key algorithm name is the first
+ // KM_TAG_DIGEST tag.
+ if (keymasterDigests[0] != keymasterDigest) {
+ // The first digest is not the one implied by the JCA key algorithm name.
+ // Swap the implied digest with the first one.
+ for (int i = 0; i < keymasterDigests.length; i++) {
+ if (keymasterDigests[i] == keymasterDigest) {
+ keymasterDigests[i] = keymasterDigests[0];
+ keymasterDigests[0] = keymasterDigest;
+ break;
+ }
}
}
}
- }
- } else {
- // No digest specified in parameters
- if (keymasterDigest != -1) {
- // Digest specified in the JCA key algorithm name.
- keymasterDigests = new int[] {keymasterDigest};
} else {
- keymasterDigests = EmptyArray.INT;
- }
- }
- args.addEnums(KeymasterDefs.KM_TAG_DIGEST, keymasterDigests);
- if (keymasterAlgorithm == KeymasterDefs.KM_ALGORITHM_HMAC) {
- if (keymasterDigests.length == 0) {
- throw new KeyStoreException("At least one digest algorithm must be specified"
- + " for key algorithm " + keyAlgorithmString);
- }
- }
-
- @KeyProperties.PurposeEnum int purposes = params.getPurposes();
- int[] keymasterBlockModes =
- KeyProperties.BlockMode.allToKeymaster(params.getBlockModes());
- if (((purposes & KeyProperties.PURPOSE_ENCRYPT) != 0)
- && (params.isRandomizedEncryptionRequired())) {
- for (int keymasterBlockMode : keymasterBlockModes) {
- if (!KeymasterUtils.isKeymasterBlockModeIndCpaCompatibleWithSymmetricCrypto(
- keymasterBlockMode)) {
- throw new KeyStoreException(
- "Randomized encryption (IND-CPA) required but may be violated by block"
- + " mode: "
- + KeyProperties.BlockMode.fromKeymaster(keymasterBlockMode)
- + ". See KeyProtection documentation.");
+ // No digest specified in parameters
+ if (keymasterDigest != -1) {
+ // Digest specified in the JCA key algorithm name.
+ keymasterDigests = new int[] {keymasterDigest};
+ } else {
+ keymasterDigests = EmptyArray.INT;
}
}
- }
- args.addEnums(KeymasterDefs.KM_TAG_PURPOSE, KeyProperties.Purpose.allToKeymaster(purposes));
- args.addEnums(KeymasterDefs.KM_TAG_BLOCK_MODE, keymasterBlockModes);
- if (params.getSignaturePaddings().length > 0) {
- throw new KeyStoreException("Signature paddings not supported for symmetric keys");
- }
- int[] keymasterPaddings = KeyProperties.EncryptionPadding.allToKeymaster(
- params.getEncryptionPaddings());
- args.addEnums(KeymasterDefs.KM_TAG_PADDING, keymasterPaddings);
- KeymasterUtils.addUserAuthArgs(args,
- params.isUserAuthenticationRequired(),
- params.getUserAuthenticationValidityDurationSeconds());
- args.addDateIfNotNull(KeymasterDefs.KM_TAG_ACTIVE_DATETIME, params.getKeyValidityStart());
- args.addDateIfNotNull(KeymasterDefs.KM_TAG_ORIGINATION_EXPIRE_DATETIME,
- params.getKeyValidityForOriginationEnd());
- args.addDateIfNotNull(KeymasterDefs.KM_TAG_USAGE_EXPIRE_DATETIME,
- params.getKeyValidityForConsumptionEnd());
+ args.addEnums(KeymasterDefs.KM_TAG_DIGEST, keymasterDigests);
+ if (keymasterAlgorithm == KeymasterDefs.KM_ALGORITHM_HMAC) {
+ if (keymasterDigests.length == 0) {
+ throw new KeyStoreException("At least one digest algorithm must be specified"
+ + " for key algorithm " + key.getAlgorithm());
+ }
+ }
- if (((purposes & KeyProperties.PURPOSE_ENCRYPT) != 0)
- && (!params.isRandomizedEncryptionRequired())) {
- // Permit caller-provided IV when encrypting with this key
- args.addBoolean(KeymasterDefs.KM_TAG_CALLER_NONCE);
+ @KeyProperties.PurposeEnum int purposes = params.getPurposes();
+ int[] keymasterBlockModes =
+ KeyProperties.BlockMode.allToKeymaster(params.getBlockModes());
+ if (((purposes & KeyProperties.PURPOSE_ENCRYPT) != 0)
+ && (params.isRandomizedEncryptionRequired())) {
+ for (int keymasterBlockMode : keymasterBlockModes) {
+ if (!KeymasterUtils.isKeymasterBlockModeIndCpaCompatibleWithSymmetricCrypto(
+ keymasterBlockMode)) {
+ throw new KeyStoreException(
+ "Randomized encryption (IND-CPA) required but may be violated by"
+ + " block mode: "
+ + KeyProperties.BlockMode.fromKeymaster(keymasterBlockMode)
+ + ". See KeyProtection documentation.");
+ }
+ }
+ }
+ args.addEnums(KeymasterDefs.KM_TAG_PURPOSE,
+ KeyProperties.Purpose.allToKeymaster(purposes));
+ args.addEnums(KeymasterDefs.KM_TAG_BLOCK_MODE, keymasterBlockModes);
+ if (params.getSignaturePaddings().length > 0) {
+ throw new KeyStoreException("Signature paddings not supported for symmetric keys");
+ }
+ int[] keymasterPaddings = KeyProperties.EncryptionPadding.allToKeymaster(
+ params.getEncryptionPaddings());
+ args.addEnums(KeymasterDefs.KM_TAG_PADDING, keymasterPaddings);
+ KeymasterUtils.addUserAuthArgs(args,
+ params.isUserAuthenticationRequired(),
+ params.getUserAuthenticationValidityDurationSeconds());
+ args.addDateIfNotNull(KeymasterDefs.KM_TAG_ACTIVE_DATETIME,
+ params.getKeyValidityStart());
+ args.addDateIfNotNull(KeymasterDefs.KM_TAG_ORIGINATION_EXPIRE_DATETIME,
+ params.getKeyValidityForOriginationEnd());
+ args.addDateIfNotNull(KeymasterDefs.KM_TAG_USAGE_EXPIRE_DATETIME,
+ params.getKeyValidityForConsumptionEnd());
+
+ if (((purposes & KeyProperties.PURPOSE_ENCRYPT) != 0)
+ && (!params.isRandomizedEncryptionRequired())) {
+ // Permit caller-provided IV when encrypting with this key
+ args.addBoolean(KeymasterDefs.KM_TAG_CALLER_NONCE);
+ }
+ } catch (IllegalArgumentException | IllegalStateException e) {
+ throw new KeyStoreException(e);
}
Credentials.deleteAllTypesForAlias(mKeyStore, entryAlias);
diff --git a/keystore/java/android/security/keystore/KeymasterUtils.java b/keystore/java/android/security/keystore/KeymasterUtils.java
index 3cd3f2a..92d636c 100644
--- a/keystore/java/android/security/keystore/KeymasterUtils.java
+++ b/keystore/java/android/security/keystore/KeymasterUtils.java
@@ -87,6 +87,10 @@
* @param userAuthenticationValidityDurationSeconds duration of time (seconds) for which user
* authentication is valid as authorization for using the key or {@code -1} if every
* use of the key needs authorization.
+ *
+ * @throws IllegalStateException if user authentication is required but the system is in a wrong
+ * state (e.g., secure lock screen not set up) for generating or importing keys that
+ * require user authentication.
*/
public static void addUserAuthArgs(KeymasterArguments args,
boolean userAuthenticationRequired,
diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java
index 76baaa7..0bc6d22 100644
--- a/services/core/java/com/android/server/wm/WindowAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowAnimator.java
@@ -272,8 +272,9 @@
try {
if (anyAnimating && !anyWasAnimating) {
- win.mClient.onAnimationStarted(
- winAnimator.mKeyguardGoingAwayAnimation ? 1 : 0);
+ win.mClient.onAnimationStarted(winAnimator.mAnimatingMove ? -1
+ : winAnimator.mKeyguardGoingAwayAnimation ? 1
+ : 0);
} else if (!anyAnimating && anyWasAnimating) {
win.mClient.onAnimationStopped();
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index fc86920..03ca95a 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -10002,6 +10002,7 @@
winAnimator.mAnimDw = w.mLastFrame.left - left;
winAnimator.mAnimDh = w.mLastFrame.top - top;
winAnimator.mAnimateMove = true;
+ winAnimator.mAnimatingMove = true;
}
//TODO (multidisplay): Accessibility supported only for the default display.
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index d818519..0532312 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -122,7 +122,13 @@
// used.
int mAnimDw;
int mAnimDh;
+
+ /** Is the next animation to be started a window move animation? */
boolean mAnimateMove = false;
+
+ /** Are we currently running a window move animation? */
+ boolean mAnimatingMove = false;
+
float mDsDx=1, mDtDx=0, mDsDy=0, mDtDy=1;
float mLastDsDx=1, mLastDtDx=0, mLastDsDy=0, mLastDtDy=1;
@@ -361,6 +367,7 @@
mAnimating = false;
mKeyguardGoingAwayAnimation = false;
+ mAnimatingMove = false;
mLocalAnimating = false;
if (mAnimation != null) {
mAnimation.cancel();
diff --git a/telephony/java/android/telephony/CellSignalStrength.java b/telephony/java/android/telephony/CellSignalStrength.java
index 9c23f78..2a3ef21 100644
--- a/telephony/java/android/telephony/CellSignalStrength.java
+++ b/telephony/java/android/telephony/CellSignalStrength.java
@@ -21,18 +21,19 @@
*/
public abstract class CellSignalStrength {
- /** @hide */
public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
- /** @hide */
+
public static final int SIGNAL_STRENGTH_POOR = 1;
- /** @hide */
+
public static final int SIGNAL_STRENGTH_MODERATE = 2;
- /** @hide */
+
public static final int SIGNAL_STRENGTH_GOOD = 3;
- /** @hide */
+
public static final int SIGNAL_STRENGTH_GREAT = 4;
+
/** @hide */
public static final int NUM_SIGNAL_STRENGTH_BINS = 5;
+
/** @hide */
public static final String[] SIGNAL_STRENGTH_NAMES = {
"none", "poor", "moderate", "good", "great"
@@ -47,6 +48,12 @@
/**
* Get signal level as an int from 0..4
+ * <p>
+ * @see SIGNAL_STRENGTH_NONE_OR_UNKNOWN
+ * @see SIGNAL_STRENGTH_POOR
+ * @see SIGNAL_STRENGTH_MODERATE
+ * @see SIGNAL_STRENGTH_GOOD
+ * @see SIGNAL_STRENGTH_GREAT
*/
public abstract int getLevel();