Merge "Rename windowLightStatusBar" into mnc-dev
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 341fb18..19e821c 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -603,10 +603,9 @@
/**
* <p>List of available high speed video size and fps range configurations
* supported by the camera device, in the format of (width, height, fps_min, fps_max).</p>
- * <p>When HIGH_SPEED_VIDEO is supported in {@link CameraCharacteristics#CONTROL_AVAILABLE_SCENE_MODES android.control.availableSceneModes},
- * this metadata will list the supported high speed video size and fps range
- * configurations. All the sizes listed in this configuration will be a subset
- * of the sizes reported by StreamConfigurationMap#getOutputSizes for processed
+ * <p>When HIGH_SPEED_VIDEO is supported in {@link CameraCharacteristics#CONTROL_AVAILABLE_SCENE_MODES android.control.availableSceneModes}, this metadata
+ * will list the supported high speed video size and fps range configurations. All the sizes
+ * listed in this configuration will be a subset of the sizes reported by {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputSizes } for processed
* non-stalling formats.</p>
* <p>For the high speed video use case, where the application will set
* {@link CaptureRequest#CONTROL_SCENE_MODE android.control.sceneMode} to HIGH_SPEED_VIDEO in capture requests, the application must
@@ -1116,11 +1115,12 @@
* into the 3 stream types as below:</p>
* <ul>
* <li>Processed (but stalling): any non-RAW format with a stallDurations > 0.
- * Typically JPEG format (ImageFormat#JPEG).</li>
- * <li>Raw formats: ImageFormat#RAW_SENSOR, ImageFormat#RAW10, ImageFormat#RAW12,
- * and ImageFormat#RAW_OPAQUE.</li>
+ * Typically {@link android.graphics.ImageFormat#JPEG JPEG format}.</li>
+ * <li>Raw formats: {@link android.graphics.ImageFormat#RAW_SENSOR RAW_SENSOR}, {@link android.graphics.ImageFormat#RAW10 RAW10}, or {@link android.graphics.ImageFormat#RAW12 RAW12}.</li>
* <li>Processed (but not-stalling): any non-RAW format without a stall duration.
- * Typically ImageFormat#YUV_420_888, ImageFormat#NV21, ImageFormat#YV12.</li>
+ * Typically {@link android.graphics.ImageFormat#YUV_420_888 YUV_420_888},
+ * {@link android.graphics.ImageFormat#NV21 NV21}, or
+ * {@link android.graphics.ImageFormat#YV12 YV12}.</li>
* </ul>
* <p><b>Range of valid values:</b><br></p>
* <p>For processed (and stalling) format streams, >= 1.</p>
@@ -1148,10 +1148,9 @@
* be any <code>RAW</code> and supported format provided by {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap}.</p>
* <p>In particular, a <code>RAW</code> format is typically one of:</p>
* <ul>
- * <li>ImageFormat#RAW_SENSOR</li>
- * <li>ImageFormat#RAW10</li>
- * <li>ImageFormat#RAW12</li>
- * <li>Opaque <code>RAW</code></li>
+ * <li>{@link android.graphics.ImageFormat#RAW_SENSOR RAW_SENSOR}</li>
+ * <li>{@link android.graphics.ImageFormat#RAW10 RAW10}</li>
+ * <li>{@link android.graphics.ImageFormat#RAW12 RAW12}</li>
* </ul>
* <p>LEGACY mode devices ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel} <code>==</code> LEGACY)
* never support raw streams.</p>
@@ -1180,13 +1179,13 @@
* <p>Processed (but not-stalling) is defined as any non-RAW format without a stall duration.
* Typically:</p>
* <ul>
- * <li>ImageFormat#YUV_420_888</li>
- * <li>ImageFormat#NV21</li>
- * <li>ImageFormat#YV12</li>
- * <li>Implementation-defined formats, i.e. StreamConfiguration#isOutputSupportedFor(Class)</li>
+ * <li>{@link android.graphics.ImageFormat#YUV_420_888 YUV_420_888}</li>
+ * <li>{@link android.graphics.ImageFormat#NV21 NV21}</li>
+ * <li>{@link android.graphics.ImageFormat#YV12 YV12}</li>
+ * <li>Implementation-defined formats, i.e. {@link android.hardware.camera2.params.StreamConfigurationMap#isOutputSupportedFor(Class) }</li>
* </ul>
- * <p>For full guarantees, query StreamConfigurationMap#getOutputStallDuration with
- * a processed format -- it will return 0 for a non-stalling stream.</p>
+ * <p>For full guarantees, query {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration } with a
+ * processed format -- it will return 0 for a non-stalling stream.</p>
* <p>LEGACY devices will support at least 2 processing/non-stalling streams.</p>
* <p><b>Range of valid values:</b><br></p>
* <p>>= 3
@@ -1212,10 +1211,11 @@
* the camera device. Using more streams simultaneously may require more hardware and
* CPU resources that will consume more power. The image format for this kind of an output stream can
* be any non-<code>RAW</code> and supported format provided by {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap}.</p>
- * <p>A processed and stalling format is defined as any non-RAW format with a stallDurations > 0.
- * Typically only the <code>JPEG</code> format (ImageFormat#JPEG) is a stalling format.</p>
- * <p>For full guarantees, query StreamConfigurationMap#getOutputStallDuration with
- * a processed format -- it will return a non-0 value for a stalling stream.</p>
+ * <p>A processed and stalling format is defined as any non-RAW format with a stallDurations
+ * > 0. Typically only the {@link android.graphics.ImageFormat#JPEG JPEG format} is a
+ * stalling format.</p>
+ * <p>For full guarantees, query {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration } with a
+ * processed format -- it will return a non-0 value for a stalling stream.</p>
* <p>LEGACY devices will support up to 1 processing/stalling stream.</p>
* <p><b>Range of valid values:</b><br></p>
* <p>>= 1</p>
@@ -1232,10 +1232,9 @@
* <p>The maximum numbers of any type of input streams
* that can be configured and used simultaneously by a camera device.</p>
* <p>When set to 0, it means no input stream is supported.</p>
- * <p>The image format for a input stream can be any supported
- * format returned by StreamConfigurationMap#getInputFormats. When using an
- * input stream, there must be at least one output stream
- * configured to to receive the reprocessed images.</p>
+ * <p>The image format for a input stream can be any supported format returned by {@link android.hardware.camera2.params.StreamConfigurationMap#getInputFormats }. When using an
+ * input stream, there must be at least one output stream configured to to receive the
+ * reprocessed images.</p>
* <p>When an input stream and some output streams are used in a reprocessing request,
* only the input buffer will be used to produce these output stream buffers, and a
* new sensor image will not be captured.</p>
@@ -1352,7 +1351,7 @@
/**
* <p>A list of all keys that the camera device has available
- * to use with CaptureRequest.</p>
+ * to use with {@link android.hardware.camera2.CaptureRequest }.</p>
* <p>Attempting to set a key into a CaptureRequest that is not
* listed here will result in an invalid request and will be rejected
* by the camera device.</p>
@@ -1370,7 +1369,7 @@
/**
* <p>A list of all keys that the camera device has available
- * to use with CaptureResult.</p>
+ * to use with {@link android.hardware.camera2.CaptureResult }.</p>
* <p>Attempting to get a key from a CaptureResult that is not
* listed here will always return a <code>null</code> value. Getting a key from
* a CaptureResult that is listed here will generally never return a <code>null</code>
@@ -1396,7 +1395,7 @@
/**
* <p>A list of all keys that the camera device has available
- * to use with CameraCharacteristics.</p>
+ * to use with {@link android.hardware.camera2.CameraCharacteristics }.</p>
* <p>This entry follows the same rules as
* android.request.availableResultKeys (except that it applies for
* CameraCharacteristics instead of CaptureResult). See above for more
@@ -1535,34 +1534,31 @@
* </thead>
* <tbody>
* <tr>
- * <td align="left">PRIVATE (ImageFormat#PRIVATE)</td>
- * <td align="left">JPEG</td>
+ * <td align="left">{@link android.graphics.ImageFormat#PRIVATE }</td>
+ * <td align="left">{@link android.graphics.ImageFormat#JPEG }</td>
* <td align="left">OPAQUE_REPROCESSING</td>
* </tr>
* <tr>
- * <td align="left">PRIVATE</td>
- * <td align="left">YUV_420_888</td>
+ * <td align="left">{@link android.graphics.ImageFormat#PRIVATE }</td>
+ * <td align="left">{@link android.graphics.ImageFormat#YUV_420_888 }</td>
* <td align="left">OPAQUE_REPROCESSING</td>
* </tr>
* <tr>
- * <td align="left">YUV_420_888</td>
- * <td align="left">JPEG</td>
+ * <td align="left">{@link android.graphics.ImageFormat#YUV_420_888 }</td>
+ * <td align="left">{@link android.graphics.ImageFormat#JPEG }</td>
* <td align="left">YUV_REPROCESSING</td>
* </tr>
* <tr>
- * <td align="left">YUV_420_888</td>
- * <td align="left">YUV_420_888</td>
+ * <td align="left">{@link android.graphics.ImageFormat#YUV_420_888 }</td>
+ * <td align="left">{@link android.graphics.ImageFormat#YUV_420_888 }</td>
* <td align="left">YUV_REPROCESSING</td>
* </tr>
* </tbody>
* </table>
- * <p>PRIVATE refers to a device-internal format that is not directly application-visible.
- * A PRIVATE input surface can be acquired by
- * ImageReader.newOpaqueInstance(width, height, maxImages).
- * For a OPAQUE_REPROCESSING-capable camera device, using the PRIVATE format
- * as either input or output will never hurt maximum frame rate (i.e.
- * StreamConfigurationMap#getOutputStallDuration(format, size) is always 0),
- * where format is ImageFormat#PRIVATE.</p>
+ * <p>PRIVATE refers to a device-internal format that is not directly application-visible. A
+ * PRIVATE input surface can be acquired by {@link android.media.ImageReader#newOpaqueInstance }.</p>
+ * <p>For a OPAQUE_REPROCESSING-capable camera device, using the PRIVATE format as either input
+ * or output will never hurt maximum frame rate (i.e. {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration getOutputStallDuration(ImageFormat.PRIVATE, size)} is always 0),</p>
* <p>Attempting to configure an input stream with output streams not
* listed as available in this map is not valid.</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
@@ -1680,7 +1676,7 @@
* android.scaler.availableStallDurations for more details about
* calculating the max frame rate.</p>
* <p>(Keep in sync with
- * StreamConfigurationMap#getOutputMinFrameDuration)</p>
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputMinFrameDuration })</p>
* <p><b>Units</b>: (format, width, height, ns) x n</p>
* <p>This key is available on all devices.</p>
*
@@ -1734,12 +1730,13 @@
* ignored).</p>
* <p>The following formats may always have a stall duration:</p>
* <ul>
- * <li>ImageFormat#JPEG</li>
- * <li>ImageFormat#RAW_SENSOR</li>
+ * <li>{@link android.graphics.ImageFormat#JPEG }</li>
+ * <li>{@link android.graphics.ImageFormat#RAW_SENSOR }</li>
* </ul>
* <p>The following formats will never have a stall duration:</p>
* <ul>
- * <li>ImageFormat#YUV_420_888</li>
+ * <li>{@link android.graphics.ImageFormat#YUV_420_888 }</li>
+ * <li>{@link android.graphics.ImageFormat#RAW10 }</li>
* </ul>
* <p>All other formats may or may not have an allowed stall duration on
* a per-capability basis; refer to {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities}
@@ -1747,7 +1744,7 @@
* <p>See {@link CaptureRequest#SENSOR_FRAME_DURATION android.sensor.frameDuration} for more information about
* calculating the max frame rate (absent stalls).</p>
* <p>(Keep up to date with
- * StreamConfigurationMap#getOutputStallDuration(int, Size) )</p>
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration } )</p>
* <p><b>Units</b>: (format, width, height, ns) x n</p>
* <p>This key is available on all devices.</p>
*
@@ -1786,57 +1783,57 @@
* </thead>
* <tbody>
* <tr>
- * <td align="center">JPEG</td>
+ * <td align="center">{@link android.graphics.ImageFormat#JPEG }</td>
* <td align="center">{@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</td>
* <td align="center">Any</td>
* <td align="center"></td>
* </tr>
* <tr>
- * <td align="center">JPEG</td>
+ * <td align="center">{@link android.graphics.ImageFormat#JPEG }</td>
* <td align="center">1920x1080 (1080p)</td>
* <td align="center">Any</td>
* <td align="center">if 1080p <= activeArraySize</td>
* </tr>
* <tr>
- * <td align="center">JPEG</td>
+ * <td align="center">{@link android.graphics.ImageFormat#JPEG }</td>
* <td align="center">1280x720 (720)</td>
* <td align="center">Any</td>
* <td align="center">if 720p <= activeArraySize</td>
* </tr>
* <tr>
- * <td align="center">JPEG</td>
+ * <td align="center">{@link android.graphics.ImageFormat#JPEG }</td>
* <td align="center">640x480 (480p)</td>
* <td align="center">Any</td>
* <td align="center">if 480p <= activeArraySize</td>
* </tr>
* <tr>
- * <td align="center">JPEG</td>
+ * <td align="center">{@link android.graphics.ImageFormat#JPEG }</td>
* <td align="center">320x240 (240p)</td>
* <td align="center">Any</td>
* <td align="center">if 240p <= activeArraySize</td>
* </tr>
* <tr>
- * <td align="center">YUV_420_888</td>
+ * <td align="center">{@link android.graphics.ImageFormat#YUV_420_888 }</td>
* <td align="center">all output sizes available for JPEG</td>
* <td align="center">FULL</td>
* <td align="center"></td>
* </tr>
* <tr>
- * <td align="center">YUV_420_888</td>
+ * <td align="center">{@link android.graphics.ImageFormat#YUV_420_888 }</td>
* <td align="center">all output sizes available for JPEG, up to the maximum video size</td>
* <td align="center">LIMITED</td>
* <td align="center"></td>
* </tr>
* <tr>
- * <td align="center">IMPLEMENTATION_DEFINED</td>
+ * <td align="center">{@link android.graphics.ImageFormat#PRIVATE }</td>
* <td align="center">same as YUV_420_888</td>
* <td align="center">Any</td>
* <td align="center"></td>
* </tr>
* </tbody>
* </table>
- * <p>Refer to {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} for additional
- * mandatory stream configurations on a per-capability basis.</p>
+ * <p>Refer to {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} and {@link android.hardware.camera2.CameraDevice#createCaptureSession } for additional mandatory
+ * stream configurations on a per-capability basis.</p>
* <p>This key is available on all devices.</p>
*
* @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL
@@ -1973,8 +1970,8 @@
* <p>Attempting to use frame durations beyond the maximum will result in the frame
* duration being clipped to the maximum. See that control for a full definition of frame
* durations.</p>
- * <p>Refer to StreamConfigurationMap#getOutputMinFrameDuration(int,Size) for the minimum
- * frame duration values.</p>
+ * <p>Refer to {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputMinFrameDuration }
+ * for the minimum frame duration values.</p>
* <p><b>Units</b>: Nanoseconds</p>
* <p><b>Range of valid values:</b><br>
* For FULL capability devices
@@ -2707,8 +2704,7 @@
* <p>See {@link CaptureRequest#SENSOR_FRAME_DURATION android.sensor.frameDuration} and
* android.scaler.availableStallDurations for more details about
* calculating the max frame rate.</p>
- * <p>(Keep in sync with
- * StreamConfigurationMap#getOutputMinFrameDuration)</p>
+ * <p>(Keep in sync with {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputMinFrameDuration })</p>
* <p><b>Units</b>: (format, width, height, ns) x n</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
* <p><b>Limited capability</b> -
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 2d9f61d..ca9439b 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -461,19 +461,17 @@
* <p>The camera device supports the Zero Shutter Lag reprocessing use case.</p>
* <ul>
* <li>One input stream is supported, that is, <code>{@link CameraCharacteristics#REQUEST_MAX_NUM_INPUT_STREAMS android.request.maxNumInputStreams} == 1</code>.</li>
- * <li>ImageFormat#PRIVATE is supported as an output/input format, that is,
- * ImageFormat#PRIVATE is included in the lists of formats returned by
- * StreamConfigurationMap#getInputFormats and
- * StreamConfigurationMap#getOutputFormats.</li>
- * <li>StreamConfigurationMap#getValidOutputFormatsForInput returns non empty int[] for
- * each supported input format returned by StreamConfigurationMap#getInputFormats.</li>
- * <li>Each size returned by StreamConfigurationMap#getInputSizes(ImageFormat#PRIVATE)
- * is also included in StreamConfigurationMap#getOutputSizes(ImageFormat#PRIVATE)</li>
- * <li>Using ImageFormat#PRIVATE does not cause a frame rate drop
- * relative to the sensor's maximum capture rate (at that
- * resolution).</li>
- * <li>ImageFormat#PRIVATE will be reprocessable into both YUV_420_888
- * and JPEG formats.</li>
+ * <li>{@link android.graphics.ImageFormat#PRIVATE } is supported as an output/input format,
+ * that is, {@link android.graphics.ImageFormat#PRIVATE } is included in the lists of
+ * formats returned by {@link android.hardware.camera2.params.StreamConfigurationMap#getInputFormats } and {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputFormats }.</li>
+ * <li>{@link android.hardware.camera2.params.StreamConfigurationMap#getValidOutputFormatsForInput }
+ * returns non empty int[] for each supported input format returned by {@link android.hardware.camera2.params.StreamConfigurationMap#getInputFormats }.</li>
+ * <li>Each size returned by {@link android.hardware.camera2.params.StreamConfigurationMap#getInputSizes getInputSizes(ImageFormat.PRIVATE)} is also included in {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputSizes getOutputSizes(ImageFormat.PRIVATE)}</li>
+ * <li>Using {@link android.graphics.ImageFormat#PRIVATE } does not cause a frame rate drop
+ * relative to the sensor's maximum capture rate (at that resolution).</li>
+ * <li>{@link android.graphics.ImageFormat#PRIVATE } will be reprocessable into both
+ * {@link android.graphics.ImageFormat#YUV_420_888 } and
+ * {@link android.graphics.ImageFormat#JPEG } formats.</li>
* <li>The maximum available resolution for OPAQUE streams
* (both input/output) will match the maximum available
* resolution of JPEG streams.</li>
@@ -571,26 +569,25 @@
* following:</p>
* <ul>
* <li>One input stream is supported, that is, <code>{@link CameraCharacteristics#REQUEST_MAX_NUM_INPUT_STREAMS android.request.maxNumInputStreams} == 1</code>.</li>
- * <li>YUV_420_888 is supported as an output/input format, that is,
+ * <li>{@link android.graphics.ImageFormat#YUV_420_888 } is supported as an output/input format, that is,
* YUV_420_888 is included in the lists of formats returned by
- * StreamConfigurationMap#getInputFormats and
- * StreamConfigurationMap#getOutputFormats.</li>
- * <li>StreamConfigurationMap#getValidOutputFormatsForInput returns non empty int[] for
- * each supported input format returned by StreamConfigurationMap#getInputFormats.</li>
- * <li>Each size returned by StreamConfigurationMap#getInputSizes(YUV_420_888)
- * is also included in StreamConfigurationMap#getOutputSizes(YUV_420_888)</li>
- * <li>Using YUV_420_888 does not cause a frame rate drop
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getInputFormats } and
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputFormats }.</li>
+ * <li>{@link android.hardware.camera2.params.StreamConfigurationMap#getValidOutputFormatsForInput }
+ * returns non-empty int[] for each supported input format returned by {@link android.hardware.camera2.params.StreamConfigurationMap#getInputFormats }.</li>
+ * <li>Each size returned by {@link android.hardware.camera2.params.StreamConfigurationMap#getInputSizes getInputSizes(YUV_420_888)} is also included in {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputSizes getOutputSizes(YUV_420_888)}</li>
+ * <li>Using {@link android.graphics.ImageFormat#YUV_420_888 } does not cause a frame rate drop
* relative to the sensor's maximum capture rate (at that resolution).</li>
- * <li>YUV_420_888 will be reprocessable into both YUV_420_888
- * and JPEG formats.</li>
- * <li>The maximum available resolution for YUV_420_888 streams
- * (both input/output) will match the maximum available
- * resolution of JPEG streams.</li>
+ * <li>{@link android.graphics.ImageFormat#YUV_420_888 } will be reprocessable into both
+ * {@link android.graphics.ImageFormat#YUV_420_888 } and {@link android.graphics.ImageFormat#JPEG } formats.</li>
+ * <li>The maximum available resolution for {@link android.graphics.ImageFormat#YUV_420_888 } streams (both input/output) will match the
+ * maximum available resolution of {@link android.graphics.ImageFormat#JPEG } streams.</li>
* <li>Static metadata {@link CameraCharacteristics#REPROCESS_MAX_CAPTURE_STALL android.reprocess.maxCaptureStall}.</li>
- * <li>Only the below controls are effective for reprocessing requests and will be
- * present in capture results. The reprocess requests are from the original capture
- * results that are assocaited with the intermidate YUV_420_888 output buffers.
- * All other controls in the reprocess requests will be ignored by the camera device.<ul>
+ * <li>Only the below controls are effective for reprocessing requests and will be present
+ * in capture results. The reprocess requests are from the original capture results that
+ * are associated with the intermediate {@link android.graphics.ImageFormat#YUV_420_888 }
+ * output buffers. All other controls in the reprocess requests will be ignored by the
+ * camera device.<ul>
* <li>android.jpeg.*</li>
* <li>{@link CaptureRequest#NOISE_REDUCTION_MODE android.noiseReduction.mode}</li>
* <li>{@link CaptureRequest#EDGE_MODE android.edge.mode}</li>
@@ -612,11 +609,13 @@
* <p>The camera device can produce depth measurements from its field of view.</p>
* <p>This capability requires the camera device to support the following:</p>
* <ul>
- * <li>DEPTH16 is supported as an output format.</li>
- * <li>DEPTH_POINT_CLOUD is optionally supported as an output format.</li>
- * <li>This camera device, and all camera devices with the same android.lens.info.facing,
- * will list the following calibration entries in both CameraCharacteristics and
- * CaptureResults:<ul>
+ * <li>{@link android.graphics.ImageFormat#DEPTH16 } is supported as an output format.</li>
+ * <li>{@link android.graphics.ImageFormat#DEPTH_POINT_CLOUD } is optionally supported as an
+ * output format.</li>
+ * <li>This camera device, and all camera devices with the same {@link CameraCharacteristics#LENS_FACING android.lens.facing},
+ * will list the following calibration entries in both
+ * {@link android.hardware.camera2.CameraCharacteristics } and
+ * {@link android.hardware.camera2.CaptureResult }:<ul>
* <li>{@link CameraCharacteristics#LENS_POSE_TRANSLATION android.lens.poseTranslation}</li>
* <li>{@link CameraCharacteristics#LENS_POSE_ROTATION android.lens.poseRotation}</li>
* <li>android.lens.intrinsicCalibration</li>
@@ -631,13 +630,14 @@
* <p>Generally, depth output operates at a slower frame rate than standard color capture,
* so the DEPTH16 and DEPTH_POINT_CLOUD formats will commonly have a stall duration that
* should be accounted for (see
- * android.hardware.camera2.StreamConfigurationMap#getOutputStallDuration). On a device
- * that supports both depth and color-based output, to enable smooth preview, using a
- * repeating burst is recommended, where a depth-output target is only included once
- * every N frames, where N is the ratio between preview output rate and depth output
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration }).
+ * On a device that supports both depth and color-based output, to enable smooth preview,
+ * using a repeating burst is recommended, where a depth-output target is only included
+ * once every N frames, where N is the ratio between preview output rate and depth output
* rate, including depth stall time.</p>
*
* @see CameraCharacteristics#DEPTH_DEPTH_IS_EXCLUSIVE
+ * @see CameraCharacteristics#LENS_FACING
* @see CameraCharacteristics#LENS_POSE_ROTATION
* @see CameraCharacteristics#LENS_POSE_TRANSLATION
* @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
@@ -711,7 +711,7 @@
/**
* <p>Timestamps from {@link CaptureResult#SENSOR_TIMESTAMP android.sensor.timestamp} are in the same timebase as
- * android.os.SystemClock#elapsedRealtimeNanos(),
+ * {@link android.os.SystemClock#elapsedRealtimeNanos },
* and they can be compared to other timestamps using that base.</p>
*
* @see CaptureResult#SENSOR_TIMESTAMP
@@ -870,7 +870,7 @@
/**
* <p>Every frame has the requests immediately applied.</p>
* <p>Furthermore for all results,
- * <code>android.sync.frameNumber == CaptureResult#getFrameNumber()</code></p>
+ * <code>android.sync.frameNumber == {@link android.hardware.camera2.CaptureResult#getFrameNumber }</code></p>
* <p>Changing controls over multiple requests one after another will
* produce results that have those controls applied atomically
* each frame.</p>
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index 9106060..ab6ce91 100644
--- a/core/java/android/hardware/camera2/CaptureRequest.java
+++ b/core/java/android/hardware/camera2/CaptureRequest.java
@@ -2040,8 +2040,8 @@
* cannot process more than 1 capture at a time.</li>
* </ul>
* <p>The necessary information for the application, given the model above,
- * is provided via the {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} field
- * using StreamConfigurationMap#getOutputMinFrameDuration(int, Size).
+ * is provided via the {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} field using
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputMinFrameDuration }.
* These are used to determine the maximum frame rate / minimum frame
* duration that is possible for a given stream configuration.</p>
* <p>Specifically, the application can use the following rules to
@@ -2050,21 +2050,19 @@
* <ol>
* <li>Let the set of currently configured input/output streams
* be called <code>S</code>.</li>
- * <li>Find the minimum frame durations for each stream in <code>S</code>, by
- * looking it up in {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} using
- * StreamConfigurationMap#getOutputMinFrameDuration(int, Size) (with
- * its respective size/format). Let this set of frame durations be called
- * <code>F</code>.</li>
+ * <li>Find the minimum frame durations for each stream in <code>S</code>, by looking
+ * it up in {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} using {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputMinFrameDuration }
+ * (with its respective size/format). Let this set of frame durations be
+ * called <code>F</code>.</li>
* <li>For any given request <code>R</code>, the minimum frame duration allowed
* for <code>R</code> is the maximum out of all values in <code>F</code>. Let the streams
* used in <code>R</code> be called <code>S_r</code>.</li>
* </ol>
- * <p>If none of the streams in <code>S_r</code> have a stall time (listed in
- * StreamConfigurationMap#getOutputStallDuration(int,Size) using its
- * respective size/format), then the frame duration in
- * <code>F</code> determines the steady state frame rate that the application will
- * get if it uses <code>R</code> as a repeating request. Let this special kind
- * of request be called <code>Rsimple</code>.</p>
+ * <p>If none of the streams in <code>S_r</code> have a stall time (listed in {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration }
+ * using its respective size/format), then the frame duration in <code>F</code>
+ * determines the steady state frame rate that the application will get
+ * if it uses <code>R</code> as a repeating request. Let this special kind of
+ * request be called <code>Rsimple</code>.</p>
* <p>A repeating request <code>Rsimple</code> can be <em>occasionally</em> interleaved
* by a single capture of a new request <code>Rstall</code> (which has at least
* one in-use stream with a non-0 stall time) and if <code>Rstall</code> has the
@@ -2072,7 +2070,7 @@
* if all buffers from the previous <code>Rstall</code> have already been
* delivered.</p>
* <p>For more details about stalling, see
- * StreamConfigurationMap#getOutputStallDuration(int,Size).</p>
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration }.</p>
* <p>This control is only effective if {@link CaptureRequest#CONTROL_AE_MODE android.control.aeMode} or {@link CaptureRequest#CONTROL_MODE android.control.mode} is set to
* OFF; otherwise the auto-exposure algorithm will override this value.</p>
* <p><b>Units</b>: Nanoseconds</p>
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index 8c8f0dc..3dc8970 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -2886,8 +2886,8 @@
* cannot process more than 1 capture at a time.</li>
* </ul>
* <p>The necessary information for the application, given the model above,
- * is provided via the {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} field
- * using StreamConfigurationMap#getOutputMinFrameDuration(int, Size).
+ * is provided via the {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} field using
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputMinFrameDuration }.
* These are used to determine the maximum frame rate / minimum frame
* duration that is possible for a given stream configuration.</p>
* <p>Specifically, the application can use the following rules to
@@ -2896,21 +2896,19 @@
* <ol>
* <li>Let the set of currently configured input/output streams
* be called <code>S</code>.</li>
- * <li>Find the minimum frame durations for each stream in <code>S</code>, by
- * looking it up in {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} using
- * StreamConfigurationMap#getOutputMinFrameDuration(int, Size) (with
- * its respective size/format). Let this set of frame durations be called
- * <code>F</code>.</li>
+ * <li>Find the minimum frame durations for each stream in <code>S</code>, by looking
+ * it up in {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} using {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputMinFrameDuration }
+ * (with its respective size/format). Let this set of frame durations be
+ * called <code>F</code>.</li>
* <li>For any given request <code>R</code>, the minimum frame duration allowed
* for <code>R</code> is the maximum out of all values in <code>F</code>. Let the streams
* used in <code>R</code> be called <code>S_r</code>.</li>
* </ol>
- * <p>If none of the streams in <code>S_r</code> have a stall time (listed in
- * StreamConfigurationMap#getOutputStallDuration(int,Size) using its
- * respective size/format), then the frame duration in
- * <code>F</code> determines the steady state frame rate that the application will
- * get if it uses <code>R</code> as a repeating request. Let this special kind
- * of request be called <code>Rsimple</code>.</p>
+ * <p>If none of the streams in <code>S_r</code> have a stall time (listed in {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration }
+ * using its respective size/format), then the frame duration in <code>F</code>
+ * determines the steady state frame rate that the application will get
+ * if it uses <code>R</code> as a repeating request. Let this special kind of
+ * request be called <code>Rsimple</code>.</p>
* <p>A repeating request <code>Rsimple</code> can be <em>occasionally</em> interleaved
* by a single capture of a new request <code>Rstall</code> (which has at least
* one in-use stream with a non-0 stall time) and if <code>Rstall</code> has the
@@ -2918,7 +2916,7 @@
* if all buffers from the previous <code>Rstall</code> have already been
* delivered.</p>
* <p>For more details about stalling, see
- * StreamConfigurationMap#getOutputStallDuration(int,Size).</p>
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration }.</p>
* <p>This control is only effective if {@link CaptureRequest#CONTROL_AE_MODE android.control.aeMode} or {@link CaptureRequest#CONTROL_MODE android.control.mode} is set to
* OFF; otherwise the auto-exposure algorithm will override this value.</p>
* <p><b>Units</b>: Nanoseconds</p>
@@ -2980,11 +2978,10 @@
* and are monotonically increasing. They can be compared with the
* timestamps for other captures from the same camera device, but are
* not guaranteed to be comparable to any other time source.</p>
- * <p>When {@link CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE android.sensor.info.timestampSource} <code>==</code> REALTIME,
- * the timestamps measure time in the same timebase as
- * android.os.SystemClock#elapsedRealtimeNanos(), and they can be
- * compared to other timestamps from other subsystems that are using
- * that base.</p>
+ * <p>When {@link CameraCharacteristics#SENSOR_INFO_TIMESTAMP_SOURCE android.sensor.info.timestampSource} <code>==</code> REALTIME, the
+ * timestamps measure time in the same timebase as {@link android.os.SystemClock#elapsedRealtimeNanos }, and they can
+ * be compared to other timestamps from other subsystems that
+ * are using that base.</p>
* <p><b>Units</b>: Nanoseconds</p>
* <p><b>Range of valid values:</b><br>
* > 0</p>
@@ -3142,7 +3139,7 @@
* <p><b>Units</b>: Nanoseconds</p>
* <p><b>Range of valid values:</b><br>
* >= 0 and <
- * StreamConfigurationMap#getOutputMinFrameDuration(int, Size).</p>
+ * {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputMinFrameDuration }.</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
* <p><b>Limited capability</b> -
* Present on all camera devices that report being at least {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED HARDWARE_LEVEL_LIMITED} devices in the
diff --git a/core/java/android/transition/TransitionInflater.java b/core/java/android/transition/TransitionInflater.java
index a7d9503..ca37d49 100644
--- a/core/java/android/transition/TransitionInflater.java
+++ b/core/java/android/transition/TransitionInflater.java
@@ -214,7 +214,7 @@
sConstructors.put(className, constructor);
}
}
-
+ constructor.setAccessible(true);
return constructor.newInstance(mContext, attrs);
}
} catch (InstantiationException e) {
diff --git a/core/java/android/view/DisplayListCanvas.java b/core/java/android/view/DisplayListCanvas.java
index eedbc70..46dd857 100644
--- a/core/java/android/view/DisplayListCanvas.java
+++ b/core/java/android/view/DisplayListCanvas.java
@@ -234,25 +234,13 @@
* Draws the specified display list onto this canvas. The display list can only
* be drawn if {@link android.view.RenderNode#isValid()} returns true.
*
- * @param renderNode The RenderNode to replay.
+ * @param renderNode The RenderNode to draw.
*/
public void drawRenderNode(RenderNode renderNode) {
- drawRenderNode(renderNode, RenderNode.FLAG_CLIP_CHILDREN);
+ nDrawRenderNode(mNativeCanvasWrapper, renderNode.getNativeDisplayList());
}
- /**
- * Draws the specified display list onto this canvas.
- *
- * @param renderNode The RenderNode to replay.
- * @param flags Optional flags about drawing, see {@link RenderNode} for
- * the possible flags.
- */
- public void drawRenderNode(RenderNode renderNode, int flags) {
- nDrawRenderNode(mNativeCanvasWrapper, renderNode.getNativeDisplayList(), flags);
- }
-
- private static native void nDrawRenderNode(long renderer, long renderNode,
- int flags);
+ private static native void nDrawRenderNode(long renderer, long renderNode);
///////////////////////////////////////////////////////////////////////////
// Hardware layer
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 9f90884..fa74797 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15540,7 +15540,7 @@
if (!drawingWithDrawingCache) {
if (drawingWithRenderNode) {
mPrivateFlags &= ~PFLAG_DIRTY_MASK;
- ((DisplayListCanvas) canvas).drawRenderNode(renderNode, parentFlags);
+ ((DisplayListCanvas) canvas).drawRenderNode(renderNode);
} else {
// Fast path for layouts with no backgrounds
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) {
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 39b9907..089074a 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -145,16 +145,16 @@
InputContentType mInputContentType;
InputMethodState mInputMethodState;
- private static class TextDisplayList {
- RenderNode displayList;
+ private static class TextRenderNode {
+ RenderNode renderNode;
boolean isDirty;
- public TextDisplayList(String name) {
+ public TextRenderNode(String name) {
isDirty = true;
- displayList = RenderNode.create(name, null);
+ renderNode = RenderNode.create(name, null);
}
- boolean needsRecord() { return isDirty || !displayList.isValid(); }
+ boolean needsRecord() { return isDirty || !renderNode.isValid(); }
}
- TextDisplayList[] mTextDisplayLists;
+ TextRenderNode[] mTextRenderNodes;
boolean mFrozenWithFocus;
boolean mSelectionMoved;
@@ -360,10 +360,10 @@
}
private void destroyDisplayListsData() {
- if (mTextDisplayLists != null) {
- for (int i = 0; i < mTextDisplayLists.length; i++) {
- RenderNode displayList = mTextDisplayLists[i] != null
- ? mTextDisplayLists[i].displayList : null;
+ if (mTextRenderNodes != null) {
+ for (int i = 0; i < mTextRenderNodes.length; i++) {
+ RenderNode displayList = mTextRenderNodes[i] != null
+ ? mTextRenderNodes[i].renderNode : null;
if (displayList != null && displayList.isValid()) {
displayList.destroyDisplayListData();
}
@@ -1467,8 +1467,8 @@
firstLine, lastLine);
if (layout instanceof DynamicLayout) {
- if (mTextDisplayLists == null) {
- mTextDisplayLists = ArrayUtils.emptyArray(TextDisplayList.class);
+ if (mTextRenderNodes == null) {
+ mTextRenderNodes = ArrayUtils.emptyArray(TextRenderNode.class);
}
DynamicLayout dynamicLayout = (DynamicLayout) layout;
@@ -1489,19 +1489,19 @@
searchStartIndex);
// Note how dynamic layout's internal block indices get updated from Editor
blockIndices[i] = blockIndex;
- if (mTextDisplayLists[blockIndex] != null) {
- mTextDisplayLists[blockIndex].isDirty = true;
+ if (mTextRenderNodes[blockIndex] != null) {
+ mTextRenderNodes[blockIndex].isDirty = true;
}
searchStartIndex = blockIndex + 1;
}
- if (mTextDisplayLists[blockIndex] == null) {
- mTextDisplayLists[blockIndex] =
- new TextDisplayList("Text " + blockIndex);
+ if (mTextRenderNodes[blockIndex] == null) {
+ mTextRenderNodes[blockIndex] =
+ new TextRenderNode("Text " + blockIndex);
}
- final boolean blockDisplayListIsInvalid = mTextDisplayLists[blockIndex].needsRecord();
- RenderNode blockDisplayList = mTextDisplayLists[blockIndex].displayList;
+ final boolean blockDisplayListIsInvalid = mTextRenderNodes[blockIndex].needsRecord();
+ RenderNode blockDisplayList = mTextRenderNodes[blockIndex].renderNode;
if (i >= indexFirstChangedBlock || blockDisplayListIsInvalid) {
final int blockBeginLine = endOfPreviousBlock + 1;
final int top = layout.getLineTop(blockBeginLine);
@@ -1528,7 +1528,7 @@
// brings this range of text back to the top left corner of the viewport
displayListCanvas.translate(-left, -top);
layout.drawText(displayListCanvas, blockBeginLine, blockEndLine);
- mTextDisplayLists[blockIndex].isDirty = false;
+ mTextRenderNodes[blockIndex].isDirty = false;
// No need to untranslate, previous context is popped after
// drawDisplayList
} finally {
@@ -1543,8 +1543,7 @@
blockDisplayList.setLeftTopRightBottom(left, top, right, bottom);
}
- ((DisplayListCanvas) canvas).drawRenderNode(blockDisplayList,
- 0 /* no child clipping, our TextView parent enforces it */);
+ ((DisplayListCanvas) canvas).drawRenderNode(blockDisplayList);
endOfPreviousBlock = blockEndLine;
}
@@ -1558,7 +1557,7 @@
private int getAvailableDisplayListIndex(int[] blockIndices, int numberOfBlocks,
int searchStartIndex) {
- int length = mTextDisplayLists.length;
+ int length = mTextRenderNodes.length;
for (int i = searchStartIndex; i < length; i++) {
boolean blockIndexFound = false;
for (int j = 0; j < numberOfBlocks; j++) {
@@ -1572,7 +1571,7 @@
}
// No available index found, the pool has to grow
- mTextDisplayLists = GrowingArrayUtils.append(mTextDisplayLists, length, null);
+ mTextRenderNodes = GrowingArrayUtils.append(mTextRenderNodes, length, null);
return length;
}
@@ -1589,7 +1588,7 @@
* Invalidates all the sub-display lists that overlap the specified character range
*/
void invalidateTextDisplayList(Layout layout, int start, int end) {
- if (mTextDisplayLists != null && layout instanceof DynamicLayout) {
+ if (mTextRenderNodes != null && layout instanceof DynamicLayout) {
final int firstLine = layout.getLineForOffset(start);
final int lastLine = layout.getLineForOffset(end);
@@ -1609,7 +1608,7 @@
while (i < numberOfBlocks) {
final int blockIndex = blockIndices[i];
if (blockIndex != DynamicLayout.INVALID_BLOCK_INDEX) {
- mTextDisplayLists[blockIndex].isDirty = true;
+ mTextRenderNodes[blockIndex].isDirty = true;
}
if (blockEndLines[i] >= lastLine) break;
i++;
@@ -1618,9 +1617,9 @@
}
void invalidateTextDisplayList() {
- if (mTextDisplayLists != null) {
- for (int i = 0; i < mTextDisplayLists.length; i++) {
- if (mTextDisplayLists[i] != null) mTextDisplayLists[i].isDirty = true;
+ if (mTextRenderNodes != null) {
+ for (int i = 0; i < mTextRenderNodes.length; i++) {
+ if (mTextRenderNodes[i] != null) mTextRenderNodes[i].isDirty = true;
}
}
}
@@ -4491,7 +4490,7 @@
private class CorrectionHighlighter {
private final Path mPath = new Path();
- private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private final Paint mPaint = new Paint();
private int mStart, mEnd;
private long mFadingStartTime;
private RectF mTempRectF;
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java
index ae779fe..f94f97c 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -216,7 +216,7 @@
public Switch(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
+ mTextPaint = new TextPaint();
final Resources res = getResources();
mTextPaint.density = res.getDisplayMetrics().density;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 3e8df08..8ce5f08 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -668,11 +668,11 @@
final Resources res = getResources();
final CompatibilityInfo compat = res.getCompatibilityInfo();
- mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
+ mTextPaint = new TextPaint();
mTextPaint.density = res.getDisplayMetrics().density;
mTextPaint.setCompatibilityScaling(compat.applicationScale);
- mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mHighlightPaint = new Paint();
mHighlightPaint.setCompatibilityScaling(compat.applicationScale);
mMovement = getDefaultMovementMethod();
diff --git a/core/java/com/android/internal/midi/MidiFramer.java b/core/java/com/android/internal/midi/MidiFramer.java
index 53d71bb..1a7fa0b 100644
--- a/core/java/com/android/internal/midi/MidiFramer.java
+++ b/core/java/com/android/internal/midi/MidiFramer.java
@@ -17,6 +17,7 @@
package com.android.internal.midi;
import android.media.midi.MidiReceiver;
+import android.util.Log;
import java.io.IOException;
@@ -38,6 +39,7 @@
private int mCount;
private int mRunningStatus;
private int mNeeded;
+ private boolean mInSysEx;
public MidiFramer(MidiReceiver receiver) {
mReceiver = receiver;
@@ -52,12 +54,14 @@
}
/*
- * @see android.midi.MidiReceiver#onPost(byte[], int, int, long)
+ * @see android.midi.MidiReceiver#onReceive(byte[], int, int, long)
*/
@Override
public void onReceive(byte[] data, int offset, int count, long timestamp)
throws IOException {
// Log.i(TAG, formatMidiData(data, offset, count));
+ int sysExStartOffset = (mInSysEx ? offset : -1);
+
for (int i = 0; i < count; i++) {
int b = data[offset] & 0xFF;
if (b >= 0x80) { // status byte?
@@ -66,27 +70,50 @@
mCount = 1;
mNeeded = MidiConstants.getBytesPerMessage(b) - 1;
} else if (b < 0xF8) { // system common?
- mBuffer[0] = (byte) b;
- mRunningStatus = 0;
- mCount = 1;
- mNeeded = MidiConstants.getBytesPerMessage(b) - 1;
+ if (b == 0xF0 /* SysEx Start */) {
+ // Log.i(TAG, "SysEx Start");
+ mInSysEx = true;
+ sysExStartOffset = offset;
+ } else if (b == 0xF7 /* SysEx End */) {
+ // Log.i(TAG, "SysEx End");
+ if (mInSysEx) {
+ mReceiver.sendWithTimestamp(data, sysExStartOffset,
+ offset - sysExStartOffset, timestamp);
+ mInSysEx = false;
+ sysExStartOffset = -1;
+ }
+ } else {
+ mBuffer[0] = (byte) b;
+ mRunningStatus = 0;
+ mCount = 1;
+ mNeeded = MidiConstants.getBytesPerMessage(b) - 1;
+ }
} else { // real-time?
// Single byte message interleaved with other data.
mReceiver.sendWithTimestamp(data, offset, 1, timestamp);
}
} else { // data byte
- mBuffer[mCount++] = (byte) b;
- if (--mNeeded == 0) {
- if (mRunningStatus != 0) {
- mBuffer[0] = (byte) mRunningStatus;
+ // Save SysEx data for SysEx End marker or end of buffer.
+ if (!mInSysEx) {
+ mBuffer[mCount++] = (byte) b;
+ if (--mNeeded == 0) {
+ if (mRunningStatus != 0) {
+ mBuffer[0] = (byte) mRunningStatus;
+ }
+ mReceiver.sendWithTimestamp(mBuffer, 0, mCount, timestamp);
+ mNeeded = MidiConstants.getBytesPerMessage(mBuffer[0]) - 1;
+ mCount = 1;
}
- mReceiver.sendWithTimestamp(mBuffer, 0, mCount, timestamp);
- mNeeded = MidiConstants.getBytesPerMessage(mBuffer[0]) - 1;
- mCount = 1;
}
}
++offset;
}
+
+ // send any accumulatedSysEx data
+ if (sysExStartOffset >= 0) {
+ mReceiver.sendWithTimestamp(data, sysExStartOffset,
+ offset - sysExStartOffset, timestamp);
+ }
}
}
diff --git a/core/java/com/android/internal/util/ImageUtils.java b/core/java/com/android/internal/util/ImageUtils.java
index 7d56e9e..a0d0b20 100644
--- a/core/java/com/android/internal/util/ImageUtils.java
+++ b/core/java/com/android/internal/util/ImageUtils.java
@@ -66,7 +66,7 @@
COMPACT_BITMAP_SIZE, COMPACT_BITMAP_SIZE, Bitmap.Config.ARGB_8888
);
mTempCompactBitmapCanvas = new Canvas(mTempCompactBitmap);
- mTempCompactBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mTempCompactBitmapPaint = new Paint();
mTempCompactBitmapPaint.setFilterBitmap(true);
}
mTempMatrix.reset();
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 1096e34..3d23986 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -17,9 +17,11 @@
package com.android.internal.widget;
import android.Manifest;
+import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
+import android.bluetooth.BluetoothClass;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -142,11 +144,6 @@
private DevicePolicyManager mDevicePolicyManager;
private ILockSettings mLockSettingsService;
- private final boolean mMultiUserMode;
-
- // The current user is set by KeyguardViewMediator and shared by all LockPatternUtils.
- private static volatile int sCurrentUserId = UserHandle.USER_NULL;
-
public DevicePolicyManager getDevicePolicyManager() {
if (mDevicePolicyManager == null) {
mDevicePolicyManager =
@@ -171,12 +168,6 @@
public LockPatternUtils(Context context) {
mContext = context;
mContentResolver = context.getContentResolver();
-
- // If this is being called by the system or by an application like keyguard that
- // has permision INTERACT_ACROSS_USERS, then LockPatternUtils will operate in multi-user
- // mode where calls are for the current user rather than the user of the calling process.
- mMultiUserMode = context.checkCallingOrSelfPermission(
- Manifest.permission.INTERACT_ACROSS_USERS_FULL) == PackageManager.PERMISSION_GRANTED;
}
private ILockSettings getLockSettings() {
@@ -188,93 +179,55 @@
return mLockSettingsService;
}
- public int getRequestedMinimumPasswordLength() {
- return getDevicePolicyManager().getPasswordMinimumLength(null, getCurrentOrCallingUserId());
+ public int getRequestedMinimumPasswordLength(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumLength(null, userId);
}
/**
* Gets the device policy password mode. If the mode is non-specific, returns
* MODE_PATTERN which allows the user to choose anything.
*/
- public int getRequestedPasswordQuality() {
- return getDevicePolicyManager().getPasswordQuality(null, getCurrentOrCallingUserId());
- }
-
- public int getRequestedPasswordHistoryLength() {
- return getRequestedPasswordHistoryLength(getCurrentOrCallingUserId());
+ public int getRequestedPasswordQuality(int userId) {
+ return getDevicePolicyManager().getPasswordQuality(null, userId);
}
private int getRequestedPasswordHistoryLength(int userId) {
return getDevicePolicyManager().getPasswordHistoryLength(null, userId);
}
- public int getRequestedPasswordMinimumLetters() {
- return getDevicePolicyManager().getPasswordMinimumLetters(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumLetters(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumLetters(null, userId);
}
- public int getRequestedPasswordMinimumUpperCase() {
- return getDevicePolicyManager().getPasswordMinimumUpperCase(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumUpperCase(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumUpperCase(null, userId);
}
- public int getRequestedPasswordMinimumLowerCase() {
- return getDevicePolicyManager().getPasswordMinimumLowerCase(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumLowerCase(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumLowerCase(null, userId);
}
- public int getRequestedPasswordMinimumNumeric() {
- return getDevicePolicyManager().getPasswordMinimumNumeric(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumNumeric(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumNumeric(null, userId);
}
- public int getRequestedPasswordMinimumSymbols() {
- return getDevicePolicyManager().getPasswordMinimumSymbols(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumSymbols(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumSymbols(null, userId);
}
- public int getRequestedPasswordMinimumNonLetter() {
- return getDevicePolicyManager().getPasswordMinimumNonLetter(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumNonLetter(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumNonLetter(null, userId);
}
- public void reportFailedPasswordAttempt() {
- int userId = getCurrentOrCallingUserId();
+ public void reportFailedPasswordAttempt(int userId) {
getDevicePolicyManager().reportFailedPasswordAttempt(userId);
getTrustManager().reportUnlockAttempt(false /* authenticated */, userId);
getTrustManager().reportRequireCredentialEntry(userId);
}
- public void reportSuccessfulPasswordAttempt() {
- getDevicePolicyManager().reportSuccessfulPasswordAttempt(getCurrentOrCallingUserId());
- getTrustManager().reportUnlockAttempt(true /* authenticated */,
- getCurrentOrCallingUserId());
- }
-
- public void setCurrentUser(int userId) {
- sCurrentUserId = userId;
- }
-
- public int getCurrentUser() {
- if (sCurrentUserId != UserHandle.USER_NULL) {
- // Someone is regularly updating using setCurrentUser() use that value.
- return sCurrentUserId;
- }
- try {
- return ActivityManagerNative.getDefault().getCurrentUser().id;
- } catch (RemoteException re) {
- return UserHandle.USER_OWNER;
- }
- }
-
- private int getCurrentOrCallingUserId() {
- if (mMultiUserMode) {
- // TODO: This is a little inefficient. See if all users of this are able to
- // handle USER_CURRENT and pass that instead.
- return getCurrentUser();
- } else {
- return UserHandle.getCallingUserId();
- }
+ public void reportSuccessfulPasswordAttempt(int userId) {
+ getDevicePolicyManager().reportSuccessfulPasswordAttempt(userId);
+ getTrustManager().reportUnlockAttempt(true /* authenticated */, userId);
}
/**
@@ -286,8 +239,7 @@
* @param challenge The challenge to verify against the pattern
* @return the attestation that the challenge was verified, or null.
*/
- public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge) {
- final int userId = getCurrentOrCallingUserId();
+ public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge, int userId) {
try {
return getLockSettings().verifyPattern(patternToString(pattern), challenge, userId);
} catch (RemoteException re) {
@@ -301,8 +253,7 @@
* @param pattern The pattern to check.
* @return Whether the pattern matches the stored one.
*/
- public boolean checkPattern(List<LockPatternView.Cell> pattern) {
- final int userId = getCurrentOrCallingUserId();
+ public boolean checkPattern(List<LockPatternView.Cell> pattern, int userId) {
try {
return getLockSettings().checkPattern(patternToString(pattern), userId);
} catch (RemoteException re) {
@@ -319,8 +270,7 @@
* @param challenge The challenge to verify against the password
* @return the attestation that the challenge was verified, or null.
*/
- public byte[] verifyPassword(String password, long challenge) {
- final int userId = getCurrentOrCallingUserId();
+ public byte[] verifyPassword(String password, long challenge, int userId) {
try {
return getLockSettings().verifyPassword(password, challenge, userId);
} catch (RemoteException re) {
@@ -334,8 +284,7 @@
* @param password The password to check.
* @return Whether the password matches the stored one.
*/
- public boolean checkPassword(String password) {
- final int userId = getCurrentOrCallingUserId();
+ public boolean checkPassword(String password, int userId) {
try {
return getLockSettings().checkPassword(password, userId);
} catch (RemoteException re) {
@@ -348,8 +297,7 @@
* Note that this also clears vold's copy of the password.
* @return Whether the vold password matches or not.
*/
- public boolean checkVoldPassword() {
- final int userId = getCurrentOrCallingUserId();
+ public boolean checkVoldPassword(int userId) {
try {
return getLockSettings().checkVoldPassword(userId);
} catch (RemoteException re) {
@@ -364,8 +312,7 @@
* @param password The password to check.
* @return Whether the password matches any in the history.
*/
- public boolean checkPasswordHistory(String password) {
- int userId = getCurrentOrCallingUserId();
+ public boolean checkPasswordHistory(String password, int userId) {
String passwordHashString = new String(
passwordToHash(password, userId), StandardCharsets.UTF_8);
String passwordHistory = getString(PASSWORD_HISTORY_KEY, userId);
@@ -374,7 +321,7 @@
}
// Password History may be too long...
int passwordHashLength = passwordHashString.length();
- int passwordHistoryLength = getRequestedPasswordHistoryLength();
+ int passwordHistoryLength = getRequestedPasswordHistoryLength(userId);
if(passwordHistoryLength == 0) {
return false;
}
@@ -416,16 +363,8 @@
*
* @return True if the user has ever chosen a pattern.
*/
- public boolean isPatternEverChosen() {
- return getBoolean(PATTERN_EVER_CHOSEN_KEY, false, getCurrentOrCallingUserId());
- }
-
- /**
- * Used by device policy manager to validate the current password
- * information it has.
- */
- public int getActivePasswordQuality() {
- return getActivePasswordQuality(getCurrentOrCallingUserId());
+ public boolean isPatternEverChosen(int userId) {
+ return getBoolean(PATTERN_EVER_CHOSEN_KEY, false, userId);
}
/**
@@ -448,10 +387,6 @@
return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
}
- public void clearLock() {
- clearLock(getCurrentOrCallingUserId());
- }
-
/**
* Clear any lock pattern or password.
*/
@@ -479,16 +414,6 @@
}
/**
- * Disable showing lock screen at all when the DevicePolicyManager allows it.
- * This is only meaningful if pattern, pin or password are not set.
- *
- * @param disable Disables lock screen when true
- */
- public void setLockScreenDisabled(boolean disable) {
- setLockScreenDisabled(disable, getCurrentOrCallingUserId());
- }
-
- /**
* Disable showing lock screen at all for a given user.
* This is only meaningful if pattern, pin or password are not set.
*
@@ -505,21 +430,16 @@
*
* @return true if lock screen is disabled
*/
- public boolean isLockScreenDisabled() {
- return !isSecure() &&
- getBoolean(DISABLE_LOCKSCREEN_KEY, false, getCurrentOrCallingUserId());
+ public boolean isLockScreenDisabled(int userId) {
+ return !isSecure(userId) &&
+ getBoolean(DISABLE_LOCKSCREEN_KEY, false, userId);
}
/**
* Save a lock pattern.
* @param pattern The new pattern to save.
- * @param savedPattern The previously saved pattern, or null if none
+ * @param userId the user whose pattern is to be saved.
*/
- public void saveLockPattern(List<LockPatternView.Cell> pattern,
- String savedPattern) {
- this.saveLockPattern(pattern, savedPattern, getCurrentOrCallingUserId());
- }
-
public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId) {
this.saveLockPattern(pattern, null, userId);
}
@@ -588,8 +508,7 @@
updateCryptoUserInfo(userId);
}
- public void setOwnerInfoEnabled(boolean enabled) {
- int userId = getCurrentOrCallingUserId();
+ public void setOwnerInfoEnabled(boolean enabled, int userId) {
setBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, enabled, userId);
updateCryptoUserInfo(userId);
}
@@ -598,11 +517,7 @@
return getString(LOCK_SCREEN_OWNER_INFO, userId);
}
- public boolean isOwnerInfoEnabled() {
- return isOwnerInfoEnabled(getCurrentOrCallingUserId());
- }
-
- private boolean isOwnerInfoEnabled(int userId) {
+ public boolean isOwnerInfoEnabled(int userId) {
return getBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, false, userId);
}
@@ -724,21 +639,10 @@
/**
* Save a lock password. Does not ensure that the password is as good
* as the requested mode, but will adjust the mode to be as good as the
- * pattern.
+ * password.
* @param password The password to save
* @param savedPassword The previously saved lock password, or null if none
* @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
- */
- public void saveLockPassword(String password, String savedPassword, int quality) {
- saveLockPassword(password, savedPassword, quality, getCurrentOrCallingUserId());
- }
-
- /**
- * Save a lock password. Does not ensure that the password is as good
- * as the requested mode, but will adjust the mode to be as good as the
- * pattern.
- * @param password The password to save
- * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
* @param userHandle The userId of the user to change the password for
*/
public void saveLockPassword(String password, String savedPassword, int quality,
@@ -865,16 +769,6 @@
}
/**
- * Retrieves the quality mode we're in.
- * {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
- *
- * @return stored password quality
- */
- public int getKeyguardStoredPasswordQuality() {
- return getKeyguardStoredPasswordQuality(getCurrentOrCallingUserId());
- }
-
- /**
* Retrieves the quality mode for {@param userHandle}.
* {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
*
@@ -997,13 +891,6 @@
}
/**
- * @return Whether the lock screen is secured.
- */
- public boolean isSecure() {
- return isSecure(getCurrentOrCallingUserId());
- }
-
- /**
* @param userId the user for which to report the value
* @return Whether the lock screen is secured.
*/
@@ -1012,13 +899,6 @@
return isLockPatternEnabled(mode, userId) || isLockPasswordEnabled(mode, userId);
}
- /**
- * @return Whether the lock password is enabled
- */
- public boolean isLockPasswordEnabled() {
- return isLockPasswordEnabled(getCurrentOrCallingUserId());
- }
-
public boolean isLockPasswordEnabled(int userId) {
return isLockPasswordEnabled(getKeyguardStoredPasswordQuality(userId), userId);
}
@@ -1035,10 +915,6 @@
/**
* @return Whether the lock pattern is enabled
*/
- public boolean isLockPatternEnabled() {
- return isLockPatternEnabled(getCurrentOrCallingUserId());
- }
-
public boolean isLockPatternEnabled(int userId) {
return isLockPatternEnabled(getKeyguardStoredPasswordQuality(userId), userId);
}
@@ -1051,16 +927,14 @@
/**
* @return Whether the visible pattern is enabled.
*/
- public boolean isVisiblePatternEnabled() {
- return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, false, getCurrentOrCallingUserId());
+ public boolean isVisiblePatternEnabled(int userId) {
+ return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, false, userId);
}
/**
* Set whether the visible pattern is enabled.
*/
- public void setVisiblePatternEnabled(boolean enabled) {
- int userId = getCurrentOrCallingUserId();
-
+ public void setVisiblePatternEnabled(boolean enabled, int userId) {
setBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, enabled, userId);
// Update for crypto if owner
@@ -1095,9 +969,9 @@
* pattern until the deadline has passed.
* @return the chosen deadline.
*/
- public long setLockoutAttemptDeadline() {
+ public long setLockoutAttemptDeadline(int userId) {
final long deadline = SystemClock.elapsedRealtime() + FAILED_ATTEMPT_TIMEOUT_MS;
- setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, getCurrentOrCallingUserId());
+ setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, userId);
return deadline;
}
@@ -1106,8 +980,8 @@
* attempt to enter his/her lock pattern, or 0 if the user is welcome to
* enter a pattern.
*/
- public long getLockoutAttemptDeadline() {
- final long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, getCurrentOrCallingUserId());
+ public long getLockoutAttemptDeadline(int userId) {
+ final long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, userId);
final long now = SystemClock.elapsedRealtime();
if (deadline < now || deadline > (now + FAILED_ATTEMPT_TIMEOUT_MS)) {
return 0L;
@@ -1166,21 +1040,12 @@
}
}
- public void setPowerButtonInstantlyLocks(boolean enabled) {
- setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, getCurrentOrCallingUserId());
+ public void setPowerButtonInstantlyLocks(boolean enabled, int userId) {
+ setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, userId);
}
- public boolean getPowerButtonInstantlyLocks() {
- return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true,
- getCurrentOrCallingUserId());
- }
-
- public void setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents) {
- setEnabledTrustAgents(activeTrustAgents, getCurrentOrCallingUserId());
- }
-
- public List<ComponentName> getEnabledTrustAgents() {
- return getEnabledTrustAgents(getCurrentOrCallingUserId());
+ public boolean getPowerButtonInstantlyLocks(int userId) {
+ return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true, userId);
}
public void setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents, int userId) {
@@ -1192,7 +1057,7 @@
sb.append(cn.flattenToShortString());
}
setString(ENABLED_TRUST_AGENTS, sb.toString(), userId);
- getTrustManager().reportEnabledTrustAgentsChanged(getCurrentOrCallingUserId());
+ getTrustManager().reportEnabledTrustAgentsChanged(userId);
}
public List<ComponentName> getEnabledTrustAgents(int userId) {
@@ -1228,7 +1093,7 @@
}
public void setCredentialRequiredToDecrypt(boolean required) {
- if (getCurrentUser() != UserHandle.USER_OWNER) {
+ if (ActivityManager.getCurrentUser() != UserHandle.USER_OWNER) {
Log.w(TAG, "Only device owner may call setCredentialRequiredForDecrypt()");
return;
}
diff --git a/core/jni/android_view_DisplayListCanvas.cpp b/core/jni/android_view_DisplayListCanvas.cpp
index 6bcc92e..a362684 100644
--- a/core/jni/android_view_DisplayListCanvas.cpp
+++ b/core/jni/android_view_DisplayListCanvas.cpp
@@ -112,8 +112,7 @@
jlong rendererPtr, jlong functorPtr) {
DisplayListCanvas* renderer = reinterpret_cast<DisplayListCanvas*>(rendererPtr);
Functor* functor = reinterpret_cast<Functor*>(functorPtr);
- android::uirenderer::Rect dirty;
- renderer->callDrawGLFunction(functor, dirty);
+ renderer->callDrawGLFunction(functor);
}
// ----------------------------------------------------------------------------
@@ -212,12 +211,10 @@
}
static void android_view_DisplayListCanvas_drawRenderNode(JNIEnv* env,
- jobject clazz, jlong rendererPtr, jlong renderNodePtr,
- jint flags) {
+ jobject clazz, jlong rendererPtr, jlong renderNodePtr) {
DisplayListCanvas* renderer = reinterpret_cast<DisplayListCanvas*>(rendererPtr);
RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
- android::uirenderer::Rect bounds;
- renderer->drawRenderNode(renderNode, bounds, flags);
+ renderer->drawRenderNode(renderNode);
}
// ----------------------------------------------------------------------------
@@ -283,7 +280,7 @@
{ "nDrawCircle", "(JJJJJ)V", (void*) android_view_DisplayListCanvas_drawCircleProps },
{ "nFinishRecording", "(J)J", (void*) android_view_DisplayListCanvas_finishRecording },
- { "nDrawRenderNode", "(JJI)V", (void*) android_view_DisplayListCanvas_drawRenderNode },
+ { "nDrawRenderNode", "(JJ)V", (void*) android_view_DisplayListCanvas_drawRenderNode },
{ "nCreateDisplayListCanvas", "()J", (void*) android_view_DisplayListCanvas_createDisplayListCanvas },
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java
index e04c214..4b82c3d 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java
@@ -184,10 +184,10 @@
result.putInt("ap-discovered", ssidAppearInScanResultsCount);
getInstrumentation().sendStatus(Activity.RESULT_FIRST_USER, result);
if (i == mScanIterations + 1) {
- writeOutput(String.format("iteration %d out of %d", i, mScanIterations));
+ writeOutput(String.format("iteration %d out of %d", i - 1, mScanIterations));
writeOutput(String.format("average scanning time is %d", scanTimeSum / (i - 1)));
writeOutput(String.format("ssid appear %d out of %d scan iterations",
- ssidAppearInScanResultsCount, i));
+ ssidAppearInScanResultsCount, i - 1));
}
}
@@ -289,7 +289,7 @@
getInstrumentation().sendStatus(Activity.RESULT_FIRST_USER, result);
if (i == mReconnectIterations + 1) {
writeOutput(String.format("iteration %d out of %d",
- i, mReconnectIterations));
+ i - 1, mReconnectIterations));
}
}
}
diff --git a/docs/html/training/wearables/data-layer/messages.jd b/docs/html/training/wearables/data-layer/messages.jd
index 043aff2..ef9bfb1 100644
--- a/docs/html/training/wearables/data-layer/messages.jd
+++ b/docs/html/training/wearables/data-layer/messages.jd
@@ -34,7 +34,7 @@
<p>Multiple wearable devices can be connected to a user’s handheld device. Each connected device in
the network is considered a <em>node</em>. With multiple connected devices, you must consider which
-nodes receive the messages. For example, In a voice transcription app that receives voice data on
+nodes receive the messages. For example, in a voice transcription app that receives voice data on
the wearable device, you should send the message to a node with the processing power and battery
capacity to handle the request, such as a handheld device.</p>
@@ -196,7 +196,15 @@
<p>The following example shows how to send a message to the transcription-capable node from a
wearable device. Verify that the node is available before you attempt to send the message. This call
-is synchronous and blocks processing until the message is received or until the request times out.
+is synchronous and blocks processing until the system queues the message for delivery.
+</p>
+
+<p class="note"><strong>Note:</strong> A successful result code does not guarantee delivery of the
+message. If your app requires data reliability, use
+<a href="{@docRoot}reference/com/google/android/gms/wearable/DataItem.html"><code>DataItem</code></a>
+objects or the
+<a href="{@docRoot}reference/com/google/android/gms/wearable/ChannelApi.html"><code>ChannelApi</code></a>
+class to send data between devices.
</p>
<pre>
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index 4c2817c..dc9aa67 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -133,7 +133,7 @@
private GradientState mGradientState;
- private final Paint mFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private final Paint mFillPaint = new Paint();
private Rect mPadding;
private Paint mStrokePaint; // optional, set by the caller
private ColorFilter mColorFilter; // optional, set by the caller
@@ -323,7 +323,7 @@
private void setStrokeInternal(int width, int color, float dashWidth, float dashGap) {
if (mStrokePaint == null) {
- mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mStrokePaint = new Paint();
mStrokePaint.setStyle(Paint.Style.STROKE);
}
mStrokePaint.setStrokeWidth(width);
@@ -1802,7 +1802,7 @@
mPadding = state.mPadding;
if (state.mStrokeWidth >= 0) {
- mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mStrokePaint = new Paint();
mStrokePaint.setStyle(Paint.Style.STROKE);
mStrokePaint.setStrokeWidth(state.mStrokeWidth);
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index 3bbbc71..c3d8cfa 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -1464,7 +1464,8 @@
bounds.right - insetR - padR, bounds.bottom - r.mInsetB - padB);
// Apply resolved gravity to drawable based on resolved size.
- final int gravity = resolveGravity(r.mGravity, r.mWidth, r.mHeight);
+ final int gravity = resolveGravity(r.mGravity, r.mWidth, r.mHeight,
+ d.getIntrinsicWidth(), d.getIntrinsicHeight());
final int w = r.mWidth < 0 ? d.getIntrinsicWidth() : r.mWidth;
final int h = r.mHeight < 0 ? d.getIntrinsicHeight() : r.mHeight;
Gravity.apply(gravity, w, h, container, outRect, layoutDirection);
@@ -1491,7 +1492,8 @@
* @param height height of the layer if set, -1 otherwise
* @return the default gravity for the layer
*/
- private static int resolveGravity(int gravity, int width, int height) {
+ private static int resolveGravity(int gravity, int width, int height,
+ int intrinsicWidth, int intrinsicHeight) {
if (!Gravity.isHorizontal(gravity)) {
if (width < 0) {
gravity |= Gravity.FILL_HORIZONTAL;
@@ -1508,6 +1510,17 @@
}
}
+ // If a dimension if not specified, either implicitly or explicitly,
+ // force FILL for that dimension's gravity. This ensures that colors
+ // are handled correctly and ensures backward compatibility.
+ if (width < 0 && intrinsicWidth < 0) {
+ gravity |= Gravity.FILL_HORIZONTAL;
+ }
+
+ if (height < 0 && intrinsicHeight < 0) {
+ gravity |= Gravity.FILL_VERTICAL;
+ }
+
return gravity;
}
diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java
index 334b3bd..caa0787 100644
--- a/graphics/java/android/graphics/drawable/ShapeDrawable.java
+++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java
@@ -501,7 +501,7 @@
if (mShapeState.mPaint != null) {
mShapeState.mPaint = new Paint(mShapeState.mPaint);
} else {
- mShapeState.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mShapeState.mPaint = new Paint();
}
if (mShapeState.mPadding != null) {
mShapeState.mPadding = new Rect(mShapeState.mPadding);
@@ -555,7 +555,7 @@
mAlpha = orig.mAlpha;
mShaderFactory = orig.mShaderFactory;
} else {
- mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mPaint = new Paint();
}
}
diff --git a/libs/hwui/DisplayListCanvas.cpp b/libs/hwui/DisplayListCanvas.cpp
index 6b86030..a7784b6 100644
--- a/libs/hwui/DisplayListCanvas.cpp
+++ b/libs/hwui/DisplayListCanvas.cpp
@@ -88,8 +88,7 @@
void DisplayListCanvas::resume() {
}
-void DisplayListCanvas::callDrawGLFunction(Functor *functor, Rect& dirty) {
- // Ignore dirty during recording, it matters only when we replay
+void DisplayListCanvas::callDrawGLFunction(Functor *functor) {
addDrawOp(new (alloc()) DrawFunctorOp(functor));
mDisplayListData->functors.add(functor);
}
@@ -202,12 +201,12 @@
return mState.clipRegion(region, op);
}
-void DisplayListCanvas::drawRenderNode(RenderNode* renderNode, Rect& dirty, int32_t flags) {
+void DisplayListCanvas::drawRenderNode(RenderNode* renderNode) {
LOG_ALWAYS_FATAL_IF(!renderNode, "missing rendernode");
// dirty is an out parameter and should not be recorded,
// it matters only when replaying the display list
- DrawRenderNodeOp* op = new (alloc()) DrawRenderNodeOp(renderNode, flags, *mState.currentTransform());
+ DrawRenderNodeOp* op = new (alloc()) DrawRenderNodeOp(renderNode, *mState.currentTransform());
addRenderNodeOp(op);
}
diff --git a/libs/hwui/DisplayListCanvas.h b/libs/hwui/DisplayListCanvas.h
index 2b0b6b2..fa4b2b4 100644
--- a/libs/hwui/DisplayListCanvas.h
+++ b/libs/hwui/DisplayListCanvas.h
@@ -115,10 +115,10 @@
// HWUI Canvas draw operations - special
// ----------------------------------------------------------------------------
void drawLayer(DeferredLayerUpdater* layerHandle, float x, float y);
- void drawRenderNode(RenderNode* renderNode, Rect& dirty, int32_t replayFlags);
+ void drawRenderNode(RenderNode* renderNode);
// TODO: rename for consistency
- void callDrawGLFunction(Functor* functor, Rect& dirty);
+ void callDrawGLFunction(Functor* functor);
void setHighContrastText(bool highContrastText) {
mHighContrastText = highContrastText;
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h
index b5801fc..4863ed2 100644
--- a/libs/hwui/DisplayListOp.h
+++ b/libs/hwui/DisplayListOp.h
@@ -1398,10 +1398,9 @@
friend class RenderNode; // grant RenderNode access to info of child
friend class DisplayListData; // grant DisplayListData access to info of child
public:
- DrawRenderNodeOp(RenderNode* renderNode, int flags, const mat4& transformFromParent)
+ DrawRenderNodeOp(RenderNode* renderNode, const mat4& transformFromParent)
: DrawBoundedOp(0, 0, renderNode->getWidth(), renderNode->getHeight(), nullptr)
, mRenderNode(renderNode)
- , mFlags(flags)
, mTransformFromParent(transformFromParent)
, mSkipInOrderDraw(false) {}
@@ -1424,7 +1423,7 @@
}
virtual void output(int level, uint32_t logFlags) const override {
- OP_LOG("Draw RenderNode %p %s, flags %#x", mRenderNode, mRenderNode->getName(), mFlags);
+ OP_LOG("Draw RenderNode %p %s, flags %#x", mRenderNode, mRenderNode->getName());
if (mRenderNode && (logFlags & kOpLogFlag_Recurse)) {
mRenderNode->output(level + 1);
}
@@ -1436,7 +1435,6 @@
private:
RenderNode* mRenderNode;
- const int mFlags;
///////////////////////////
// Properties below are used by RenderNode::computeOrderingImpl() and issueOperations()
diff --git a/libs/hwui/tests/main.cpp b/libs/hwui/tests/main.cpp
index 61ad082..62782af 100644
--- a/libs/hwui/tests/main.cpp
+++ b/libs/hwui/tests/main.cpp
@@ -111,15 +111,13 @@
public:
std::vector< sp<RenderNode> > cards;
void createContent(int width, int height, DisplayListCanvas* renderer) override {
- android::uirenderer::Rect DUMMY;
-
renderer->drawColor(0xFFFFFFFF, SkXfermode::kSrcOver_Mode);
renderer->insertReorderBarrier(true);
for (int x = dp(16); x < (width - dp(116)); x += dp(116)) {
for (int y = dp(16); y < (height - dp(116)); y += dp(116)) {
sp<RenderNode> card = createCard(x, y, dp(100), dp(100));
- renderer->drawRenderNode(card.get(), DUMMY, 0);
+ renderer->drawRenderNode(card.get());
cards.push_back(card);
}
}
@@ -153,13 +151,11 @@
public:
sp<RenderNode> card;
void createContent(int width, int height, DisplayListCanvas* renderer) override {
- android::uirenderer::Rect DUMMY;
-
renderer->drawColor(0xFFFFFFFF, SkXfermode::kSrcOver_Mode);
renderer->insertReorderBarrier(true);
card = createCard(40, 40, 200, 200);
- renderer->drawRenderNode(card.get(), DUMMY, 0);
+ renderer->drawRenderNode(card.get());
renderer->insertReorderBarrier(false);
}
@@ -202,13 +198,11 @@
public:
sp<RenderNode> card;
void createContent(int width, int height, DisplayListCanvas* renderer) override {
- android::uirenderer::Rect DUMMY;
-
renderer->drawColor(0xFFFFFFFF, SkXfermode::kSrcOver_Mode);
renderer->insertReorderBarrier(true);
card = createCard(40, 40, 400, 400);
- renderer->drawRenderNode(card.get(), DUMMY, 0);
+ renderer->drawRenderNode(card.get());
renderer->insertReorderBarrier(false);
}
diff --git a/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java b/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java
index 1699809..25b1875 100644
--- a/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java
+++ b/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java
@@ -120,7 +120,7 @@
KeyguardUpdateMonitor.getInstance(mContext).reportEmergencyCallAction(
true /* bypassHandler */);
getContext().startActivityAsUser(INTENT_EMERGENCY_DIAL,
- new UserHandle(mLockPatternUtils.getCurrentUser()));
+ new UserHandle(KeyguardUpdateMonitor.getCurrentUser()));
}
}
@@ -138,7 +138,7 @@
visible = mEnableEmergencyCallWhileSimLocked;
} else {
// Only show if there is a secure screen (pin/pattern/SIM pin/SIM puk);
- visible = mLockPatternUtils.isSecure();
+ visible = mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser());
}
}
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
index 322be91..c4f4b9a 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
@@ -63,7 +63,8 @@
// start fresh
resetPasswordText(false /* animate */);
// if the user is currently locked out, enforce it.
- long deadline = mLockPatternUtils.getLockoutAttemptDeadline();
+ long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
+ KeyguardUpdateMonitor.getCurrentUser());
if (shouldLockout(deadline)) {
handleAttemptLockout(deadline);
} else {
@@ -106,7 +107,7 @@
protected void verifyPasswordAndUnlock() {
String entry = getPasswordText();
- if (mLockPatternUtils.checkPassword(entry)) {
+ if (mLockPatternUtils.checkPassword(entry, KeyguardUpdateMonitor.getCurrentUser())) {
mCallback.reportUnlockAttempt(true);
mCallback.dismiss(true);
} else {
@@ -116,7 +117,8 @@
mCallback.reportUnlockAttempt(false);
int attempts = KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts();
if (0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
- long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
+ long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
+ KeyguardUpdateMonitor.getCurrentUser());
handleAttemptLockout(deadline);
}
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
index be71b034..2cf30ba 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
@@ -71,7 +71,7 @@
@Override
public void onTrustGrantedWithFlags(int flags, int userId) {
- if (userId != mLockPatternUtils.getCurrentUser()) return;
+ if (userId != KeyguardUpdateMonitor.getCurrentUser()) return;
if (!isAttachedToWindow()) return;
boolean bouncerVisible = isVisibleToUser();
boolean initiatedByUser =
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
index 9aa5729..557cd13 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
@@ -130,7 +130,8 @@
mLockPatternView.setOnPatternListener(new UnlockPatternListener());
// stealth mode will be the same for the life of this screen
- mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled());
+ mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled(
+ KeyguardUpdateMonitor.getCurrentUser()));
// vibrate mode will be the same for the life of this screen
mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());
@@ -176,7 +177,8 @@
mLockPatternView.clearPattern();
// if the user is currently locked out, enforce it.
- long deadline = mLockPatternUtils.getLockoutAttemptDeadline();
+ long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
+ KeyguardUpdateMonitor.getCurrentUser());
if (deadline != 0) {
handleAttemptLockout(deadline);
} else {
@@ -213,7 +215,7 @@
}
public void onPatternDetected(List<LockPatternView.Cell> pattern) {
- if (mLockPatternUtils.checkPattern(pattern)) {
+ if (mLockPatternUtils.checkPattern(pattern, KeyguardUpdateMonitor.getCurrentUser())) {
mCallback.reportUnlockAttempt(true);
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
mCallback.dismiss(true);
@@ -230,7 +232,8 @@
int attempts = mKeyguardUpdateMonitor.getFailedUnlockAttempts();
if (registeredAttempt &&
0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
- long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
+ long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
+ KeyguardUpdateMonitor.getCurrentUser());
handleAttemptLockout(deadline);
} else {
mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
index 5af7783..ae4baad 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -261,7 +261,7 @@
SecurityMode mode = mSecurityModel.getSecurityMode();
final boolean usingPattern = mode == KeyguardSecurityModel.SecurityMode.Pattern;
- final int currentUser = mLockPatternUtils.getCurrentUser();
+ final int currentUser = KeyguardUpdateMonitor.getCurrentUser();
final DevicePolicyManager dpm = mLockPatternUtils.getDevicePolicyManager();
final int failedAttemptsBeforeWipe =
dpm.getMaximumFailedPasswordsForWipe(null, currentUser);
@@ -296,7 +296,7 @@
(failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) == 0;
}
monitor.reportFailedUnlockAttempt();
- mLockPatternUtils.reportFailedPasswordAttempt();
+ mLockPatternUtils.reportFailedPasswordAttempt(KeyguardUpdateMonitor.getCurrentUser());
if (showTimeout) {
showTimeoutDialog();
}
@@ -321,7 +321,7 @@
boolean showNextSecurityScreenOrFinish(boolean authenticated) {
if (DEBUG) Log.d(TAG, "showNextSecurityScreenOrFinish(" + authenticated + ")");
boolean finish = false;
- if (mUpdateMonitor.getUserHasTrust(mLockPatternUtils.getCurrentUser())) {
+ if (mUpdateMonitor.getUserHasTrust(KeyguardUpdateMonitor.getCurrentUser())) {
finish = true;
} else if (SecurityMode.None == mCurrentSecuritySelection) {
SecurityMode securityMode = mSecurityModel.getSecurityMode();
@@ -430,7 +430,8 @@
KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
if (success) {
monitor.clearFailedUnlockAttempts();
- mLockPatternUtils.reportSuccessfulPasswordAttempt();
+ mLockPatternUtils.reportSuccessfulPasswordAttempt(
+ KeyguardUpdateMonitor.getCurrentUser());
} else {
KeyguardSecurityContainer.this.reportFailedUnlockAttempt();
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
index 3eb31ad..454221a 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
@@ -67,7 +67,8 @@
return SecurityMode.SimPuk;
}
- final int security = mLockPatternUtils.getActivePasswordQuality();
+ final int security = mLockPatternUtils.getActivePasswordQuality(
+ KeyguardUpdateMonitor.getCurrentUser());
switch (security) {
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
index af6360a..4e9621a 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
@@ -200,9 +200,10 @@
private String getOwnerInfo() {
ContentResolver res = getContext().getContentResolver();
String info = null;
- final boolean ownerInfoEnabled = mLockPatternUtils.isOwnerInfoEnabled();
+ final boolean ownerInfoEnabled = mLockPatternUtils.isOwnerInfoEnabled(
+ KeyguardUpdateMonitor.getCurrentUser());
if (ownerInfoEnabled) {
- info = mLockPatternUtils.getOwnerInfo(mLockPatternUtils.getCurrentUser());
+ info = mLockPatternUtils.getOwnerInfo(KeyguardUpdateMonitor.getCurrentUser());
}
return info;
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 1eec5325..e5cca234 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -244,6 +244,16 @@
private SparseBooleanArray mUserFingerprintAuthenticated = new SparseBooleanArray();
private SparseBooleanArray mUserFaceUnlockRunning = new SparseBooleanArray();
+ private static int sCurrentUser;
+
+ public synchronized static void setCurrentUser(int currentUser) {
+ sCurrentUser = currentUser;
+ }
+
+ public synchronized static int getCurrentUser() {
+ return sCurrentUser;
+ }
+
@Override
public void onTrustChanged(boolean enabled, int userId, int flags) {
mUserHasTrust.put(userId, enabled);
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 870f043..7bf2223 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2066,7 +2066,7 @@
LockPatternUtils lpu = new LockPatternUtils(mContext);
List<LockPatternView.Cell> cellPattern =
LockPatternUtils.stringToPattern(lockPattern);
- lpu.saveLockPattern(cellPattern, null);
+ lpu.saveLockPattern(cellPattern, null, UserHandle.USER_OWNER);
} catch (IllegalArgumentException e) {
// Don't want corrupted lock pattern to hang the reboot process
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 7f826ef..d99f741 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -754,7 +754,7 @@
*/
private byte[] getLockSettings() {
final LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
- final boolean ownerInfoEnabled = lockPatternUtils.isOwnerInfoEnabled();
+ final boolean ownerInfoEnabled = lockPatternUtils.isOwnerInfoEnabled(UserHandle.myUserId());
final String ownerInfo = lockPatternUtils.getOwnerInfo(UserHandle.myUserId());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -871,7 +871,8 @@
}
switch (key) {
case KEY_LOCK_SETTINGS_OWNER_INFO_ENABLED:
- lockPatternUtils.setOwnerInfoEnabled("1".equals(value));
+ lockPatternUtils.setOwnerInfoEnabled("1".equals(value),
+ UserHandle.myUserId());
break;
case KEY_LOCK_SETTINGS_OWNER_INFO:
lockPatternUtils.setOwnerInfo(value, UserHandle.myUserId());
diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
index 0d331d1..3fbc76b 100755
--- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
+++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
@@ -225,23 +225,23 @@
mSubpixelSmoothingRight = context.getResources().getFraction(
R.fraction.battery_subpixel_smoothing_right, 1, 1);
- mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mFramePaint = new Paint();
mFramePaint.setColor(frameColor);
mFramePaint.setDither(true);
mFramePaint.setStrokeWidth(0);
mFramePaint.setStyle(Paint.Style.FILL_AND_STROKE);
- mBatteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mBatteryPaint = new Paint();
mBatteryPaint.setDither(true);
mBatteryPaint.setStrokeWidth(0);
mBatteryPaint.setStyle(Paint.Style.FILL_AND_STROKE);
- mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mTextPaint = new Paint();
Typeface font = Typeface.create("sans-serif-condensed", Typeface.BOLD);
mTextPaint.setTypeface(font);
mTextPaint.setTextAlign(Paint.Align.CENTER);
- mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mWarningTextPaint = new Paint();
mWarningTextPaint.setColor(mColors[1]);
font = Typeface.create("sans-serif", Typeface.BOLD);
mWarningTextPaint.setTypeface(font);
@@ -249,7 +249,7 @@
mChargeColor = context.getColor(R.color.batterymeter_charge_color);
- mBoltPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mBoltPaint = new Paint();
mBoltPaint.setColor(context.getColor(R.color.batterymeter_bolt_color));
mBoltPoints = loadBoltPoints(res);
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 7b555fc..40b867c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -539,10 +539,11 @@
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
mLockPatternUtils = new LockPatternUtils(mContext);
- mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser());
+ KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser());
// Assume keyguard is showing (unless it's disabled) until we know for sure...
- setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled());
+ setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled(
+ KeyguardUpdateMonitor.getCurrentUser()));
mTrustManager.reportKeyguardShowingChanged();
mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext,
@@ -623,8 +624,10 @@
// Lock immediately based on setting if secure (user has a pin/pattern/password).
// This also "locks" the device when not secure to provide easy access to the
// camera while preventing unwanted input.
+ int currentUser = KeyguardUpdateMonitor.getCurrentUser();
final boolean lockImmediately =
- mLockPatternUtils.getPowerButtonInstantlyLocks() || !mLockPatternUtils.isSecure();
+ mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser)
+ || !mLockPatternUtils.isSecure(currentUser);
notifyScreenOffLocked();
@@ -670,7 +673,7 @@
// From DevicePolicyAdmin
final long policyTimeout = mLockPatternUtils.getDevicePolicyManager()
- .getMaximumTimeToLock(null, mLockPatternUtils.getCurrentUser());
+ .getMaximumTimeToLock(null, KeyguardUpdateMonitor.getCurrentUser());
long timeout;
if (policyTimeout > 0) {
@@ -719,7 +722,8 @@
}
private void maybeSendUserPresentBroadcast() {
- if (mSystemReady && mLockPatternUtils.isLockScreenDisabled()) {
+ if (mSystemReady && mLockPatternUtils.isLockScreenDisabled(
+ KeyguardUpdateMonitor.getCurrentUser())) {
// Lock screen is disabled because the user has set the preference to "None".
// In this case, send out ACTION_USER_PRESENT here instead of in
// handleKeyguardDone()
@@ -733,7 +737,7 @@
*/
public void onDreamingStarted() {
synchronized (this) {
- if (mScreenOn && mLockPatternUtils.isSecure()) {
+ if (mScreenOn && mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) {
doKeyguardLaterLocked();
}
}
@@ -974,12 +978,13 @@
return;
}
- if (mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) {
+ if (mLockPatternUtils.isLockScreenDisabled(KeyguardUpdateMonitor.getCurrentUser())
+ && !lockedOrMissing) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
return;
}
- if (mLockPatternUtils.checkVoldPassword()) {
+ if (mLockPatternUtils.checkVoldPassword(KeyguardUpdateMonitor.getCurrentUser())) {
if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted");
// Without this, settings is not enabled until the lock screen first appears
setShowingLocked(false);
@@ -1072,7 +1077,7 @@
}
public boolean isSecure() {
- return mLockPatternUtils.isSecure()
+ return mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())
|| KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure();
}
@@ -1083,7 +1088,7 @@
* @param newUserId The id of the incoming user.
*/
public void setCurrentUser(int newUserId) {
- mLockPatternUtils.setCurrentUser(newUserId);
+ KeyguardUpdateMonitor.setCurrentUser(newUserId);
}
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@@ -1213,7 +1218,7 @@
private void sendUserPresentBroadcast() {
synchronized (this) {
if (mBootCompleted) {
- final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser());
+ final UserHandle currentUser = new UserHandle(KeyguardUpdateMonitor.getCurrentUser());
final UserManager um = (UserManager) mContext.getSystemService(
Context.USER_SERVICE);
List <UserInfo> userHandles = um.getProfiles(currentUser.getIdentifier());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 92bd0df..8050ea0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -87,6 +87,7 @@
import com.android.internal.statusbar.StatusBarIconList;
import com.android.internal.util.NotificationColorUtil;
import com.android.internal.widget.LockPatternUtils;
+import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.SwipeHelper;
@@ -639,7 +640,7 @@
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 1)) {
Log.d(TAG, "user hasn't seen notification about hidden notifications");
final LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext);
- if (!lockPatternUtils.isSecure()) {
+ if (!lockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) {
Log.d(TAG, "insecure lockscreen, skipping notification");
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index e5ef6ff..8099de8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -233,9 +233,9 @@
private Intent getCameraIntent() {
KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
boolean currentUserHasTrust = updateMonitor.getUserHasTrust(
- mLockPatternUtils.getCurrentUser());
- return mLockPatternUtils.isSecure() && !currentUserHasTrust
- ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT;
+ KeyguardUpdateMonitor.getCurrentUser());
+ boolean secure = mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser());
+ return (secure && !currentUserHasTrust) ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT;
}
private void updateCameraVisibility() {
@@ -245,7 +245,7 @@
}
ResolveInfo resolved = mContext.getPackageManager().resolveActivityAsUser(getCameraIntent(),
PackageManager.MATCH_DEFAULT_ONLY,
- mLockPatternUtils.getCurrentUser());
+ KeyguardUpdateMonitor.getCurrentUser());
boolean visible = !isCameraDisabledByDpm() && resolved != null
&& getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance);
mCameraImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
@@ -339,13 +339,13 @@
0 /* velocityDp - N/A */);
mIndicationController.showTransientIndication(
R.string.keyguard_indication_trust_disabled);
- mLockPatternUtils.requireCredentialEntry(mLockPatternUtils.getCurrentUser());
+ mLockPatternUtils.requireCredentialEntry(KeyguardUpdateMonitor.getCurrentUser());
}
public void prewarmCamera() {
Intent intent = getCameraIntent();
String targetPackage = PreviewInflater.getTargetPackage(mContext, intent,
- mLockPatternUtils.getCurrentUser());
+ KeyguardUpdateMonitor.getCurrentUser());
if (targetPackage != null) {
Intent prewarm = new Intent(MediaStore.ACTION_STILL_IMAGE_CAMERA_PREWARM);
prewarm.setPackage(targetPackage);
@@ -361,7 +361,7 @@
mPrewarmSent = false;
Intent intent = getCameraIntent();
String targetPackage = PreviewInflater.getTargetPackage(mContext, intent,
- mLockPatternUtils.getCurrentUser());
+ KeyguardUpdateMonitor.getCurrentUser());
if (targetPackage != null) {
Intent prewarm = new Intent(MediaStore.ACTION_STILL_IMAGE_CAMERA_COOLDOWN);
prewarm.setPackage(targetPackage);
@@ -375,7 +375,7 @@
mPrewarmSent = false;
final Intent intent = getCameraIntent();
boolean wouldLaunchResolverActivity = PreviewInflater.wouldLaunchResolverActivity(
- mContext, intent, mLockPatternUtils.getCurrentUser());
+ mContext, intent, KeyguardUpdateMonitor.getCurrentUser());
if (intent == SECURE_CAMERA_INTENT && !wouldLaunchResolverActivity) {
AsyncTask.execute(new Runnable() {
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java
index 4a43c47..45c8938 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java
@@ -27,6 +27,7 @@
import android.util.Log;
import com.android.internal.widget.LockPatternUtils;
+import com.android.keyguard.KeyguardUpdateMonitor;
import java.util.HashMap;
import java.util.List;
@@ -228,7 +229,7 @@
// Get the list of applications that can handle the intent.
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
- intent, PackageManager.MATCH_DEFAULT_ONLY, mLockPatternUtils.getCurrentUser());
+ intent, PackageManager.MATCH_DEFAULT_ONLY, KeyguardUpdateMonitor.getCurrentUser());
if (appList.size() == 0) {
if (DEBUG) Log.d(TAG, "No targets found for secure camera intent");
return false;
@@ -237,7 +238,7 @@
// Get the application that the intent resolves to.
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA,
- mLockPatternUtils.getCurrentUser());
+ KeyguardUpdateMonitor.getCurrentUser());
if (resolved == null || resolved.activityInfo == null) {
return false;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
index 65cd268..66d71f6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
@@ -80,8 +80,8 @@
}
private void update(boolean updateAlways) {
- int user = mLockPatternUtils.getCurrentUser();
- boolean secure = mLockPatternUtils.isSecure();
+ int user = KeyguardUpdateMonitor.getCurrentUser();
+ boolean secure = mLockPatternUtils.isSecure(user);
boolean currentlyInsecure = !secure || mKeyguardUpdateMonitor.getUserHasTrust(user);
boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user);
boolean faceUnlockRunning = mKeyguardUpdateMonitor.isFaceUnlockRunning(user)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java
index 0dce82f..5d89e2f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java
@@ -26,6 +26,7 @@
import android.view.View;
import com.android.internal.widget.LockPatternUtils;
+import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.statusbar.phone.KeyguardPreviewContainer;
import java.util.List;
@@ -80,13 +81,13 @@
WidgetInfo info = new WidgetInfo();
PackageManager packageManager = mContext.getPackageManager();
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
- intent, PackageManager.MATCH_DEFAULT_ONLY, mLockPatternUtils.getCurrentUser());
+ intent, PackageManager.MATCH_DEFAULT_ONLY, KeyguardUpdateMonitor.getCurrentUser());
if (appList.size() == 0) {
return null;
}
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA,
- mLockPatternUtils.getCurrentUser());
+ KeyguardUpdateMonitor.getCurrentUser());
if (wouldLaunchResolverActivity(resolved, appList)) {
return null;
}
diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java
index 926090e..01c110f 100644
--- a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java
+++ b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java
@@ -41,11 +41,13 @@
private volatile boolean mSimSecure;
private volatile boolean mInputRestricted;
+ private int mCurrentUserId;
+
private final LockPatternUtils mLockPatternUtils;
public KeyguardStateMonitor(Context context, IKeyguardService service) {
mLockPatternUtils = new LockPatternUtils(context);
- mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser());
+ mCurrentUserId = ActivityManager.getCurrentUser();
try {
service.addStateMonitorCallback(this);
} catch (RemoteException e) {
@@ -58,7 +60,7 @@
}
public boolean isSecure() {
- return mLockPatternUtils.isSecure() || mSimSecure;
+ return mLockPatternUtils.isSecure(getCurrentUser()) || mSimSecure;
}
public boolean isInputRestricted() {
@@ -75,8 +77,12 @@
mSimSecure = simSecure;
}
- public void setCurrentUser(int userId) {
- mLockPatternUtils.setCurrentUser(userId);
+ public synchronized void setCurrentUser(int userId) {
+ mCurrentUserId = userId;
+ }
+
+ private synchronized int getCurrentUser() {
+ return mCurrentUserId;
}
@Override // Binder interface
diff --git a/services/core/java/com/android/server/wm/Watermark.java b/services/core/java/com/android/server/wm/Watermark.java
index e226e3d..ba3ce36 100644
--- a/services/core/java/com/android/server/wm/Watermark.java
+++ b/services/core/java/com/android/server/wm/Watermark.java
@@ -84,7 +84,7 @@
int fontSize = WindowManagerService.getPropertyInt(tokens, 1,
TypedValue.COMPLEX_UNIT_DIP, 20, dm);
- mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mTextPaint = new Paint();
mTextPaint.setTextSize(fontSize);
mTextPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index d7542ee..d4b3dab 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -9940,18 +9940,20 @@
final WindowStateAnimator winAnimator = w.mWinAnimator;
- // If the window has moved due to its containing
- // content frame changing, then we'd like to animate
- // it.
- if (w.mHasSurface && w.shouldAnimateMove()) {
- // Frame has moved, containing content frame
- // has also moved, and we're not currently animating...
- // let's do something.
- Animation a = AnimationUtils.loadAnimation(mContext,
- com.android.internal.R.anim.window_move_from_decor);
- winAnimator.setAnimation(a);
- winAnimator.mAnimDw = w.mLastFrame.left - w.mFrame.left;
- winAnimator.mAnimDh = w.mLastFrame.top - w.mFrame.top;
+ // If the window has moved due to its containing content frame changing, then
+ // notify the listeners and optionally animate it.
+ if (w.hasMoved()) {
+ // Frame has moved, containing content frame has also moved, and we're not
+ // currently animating... let's do something.
+ final int left = w.mFrame.left;
+ final int top = w.mFrame.top;
+ if ((w.mAttrs.privateFlags & PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0) {
+ Animation a = AnimationUtils.loadAnimation(mContext,
+ com.android.internal.R.anim.window_move_from_decor);
+ winAnimator.setAnimation(a);
+ winAnimator.mAnimDw = w.mLastFrame.left - left;
+ winAnimator.mAnimDh = w.mLastFrame.top - top;
+ }
//TODO (multidisplay): Accessibility supported only for the default display.
if (mAccessibilityController != null
@@ -9960,7 +9962,7 @@
}
try {
- w.mClient.moved(w.mFrame.left, w.mFrame.top);
+ w.mClient.moved(left, top);
} catch (RemoteException e) {
}
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index c50974c..ad25462 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -20,7 +20,6 @@
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
-import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
@@ -1081,16 +1080,14 @@
}
/**
- * Return whether this window is wanting to have a translation
- * animation applied to it for an in-progress move. (Only makes
+ * Return whether this window has moved. (Only makes
* sense to call from performLayoutAndPlaceSurfacesLockedInner().)
*/
- boolean shouldAnimateMove() {
- return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay()
- && (mFrame.top != mLastFrame.top
+ boolean hasMoved() {
+ return mHasSurface && mContentChanged && !mExiting && !mWinAnimator.mLastHidden
+ && mService.okToDisplay() && (mFrame.top != mLastFrame.top
|| mFrame.left != mLastFrame.left)
- && (mAttrs.privateFlags&PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0
- && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove());
+ && (mAttachedWindow == null || !mAttachedWindow.hasMoved());
}
boolean isFullscreen(int screenWidth, int screenHeight) {
diff --git a/services/tests/servicestests/src/com/android/server/pm/KeySetManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/pm/KeySetManagerServiceTest.java
index fbdb20b..2557974 100644
--- a/services/tests/servicestests/src/com/android/server/pm/KeySetManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/KeySetManagerServiceTest.java
@@ -24,7 +24,6 @@
import android.util.LongSparseArray;
import com.android.internal.util.ArrayUtils;
-import java.lang.reflect.Field;
import java.io.File;
import java.io.IOException;
import java.security.cert.CertificateException;
@@ -43,53 +42,6 @@
"", 1, 0, 0);
}
- public PublicKey getPubKey(long pkId) throws NoSuchFieldException, IllegalAccessException {
- Field pkField = mKsms.getClass().getDeclaredField("mPublicKeys");
- pkField.setAccessible(true);
- LongSparseArray<KeySetManagerService.PublicKeyHandle> mPublicKeys =
- (LongSparseArray<KeySetManagerService.PublicKeyHandle>) pkField.get(mKsms);
- KeySetManagerService.PublicKeyHandle pkh = mPublicKeys.get(pkId);
- if (pkh == null) {
- return null;
- } else {
- return pkh.getKey();
- }
- }
-
- public int getPubKeyRefCount(long pkId) throws NoSuchFieldException, IllegalAccessException {
- Field pkField = mKsms.getClass().getDeclaredField("mPublicKeys");
- pkField.setAccessible(true);
- LongSparseArray<KeySetManagerService.PublicKeyHandle> mPublicKeys =
- (LongSparseArray<KeySetManagerService.PublicKeyHandle>) pkField.get(mKsms);
- KeySetManagerService.PublicKeyHandle pkh = mPublicKeys.get(pkId);
- if (pkh == null) {
- return 0;
- } else {
- return pkh.getRefCountLPr();
- }
- }
-
- public int getKeySetRefCount(long keysetId) throws NoSuchFieldException, IllegalAccessException {
- Field ksField = mKsms.getClass().getDeclaredField("mKeySets");
- ksField.setAccessible(true);
- LongSparseArray<KeySetHandle> mKeySets =
- (LongSparseArray<KeySetHandle>) ksField.get(mKsms);
- KeySetHandle ksh = mKeySets.get(keysetId);
- if (ksh == null) {
- return 0;
- } else {
- return ksh.getRefCountLPr();
- }
- }
-
- public LongSparseArray<ArraySet<Long>> getKeySetMapping()
- throws NoSuchFieldException, IllegalAccessException {
- Field ksField = mKsms.getClass().getDeclaredField("mKeySetMapping");
- ksField.setAccessible(true);
- return (LongSparseArray<ArraySet<Long>>) ksField.get(mKsms);
- }
-
-
@Override
public void setUp() throws Exception {
super.setUp();
@@ -168,10 +120,10 @@
signingKeys.add(keyA);
mKsms.addSigningKeySetToPackageLPw(ps.name, signingKeys);
- assertEquals(1, getKeySetRefCount(1));
- assertEquals(1, getPubKeyRefCount(1));
- assertEquals(keyA, getPubKey(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
@@ -198,10 +150,10 @@
/* add again, to represent upgrade of package */
mKsms.addSigningKeySetToPackageLPw(ps.name, signingKeys);
- assertEquals(1, getKeySetRefCount(1));
- assertEquals(1, getPubKeyRefCount(1));
- assertEquals(keyA, getPubKey(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
@@ -231,12 +183,12 @@
signingKeys.add(keyB);
mKsms.addSigningKeySetToPackageLPw(ps.name, signingKeys);
- assertEquals(0, getKeySetRefCount(1));
- assertEquals(1, getKeySetRefCount(2));
- assertEquals(0, getPubKeyRefCount(1));
- assertEquals(1, getPubKeyRefCount(2));
- assertEquals(keyB, getPubKey(2));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 2));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(2);
assertEquals(1, mapping.size());
@@ -269,13 +221,13 @@
signingKeys.add(keyB);
mKsms.addSigningKeySetToPackageLPw(ps1.name, signingKeys);
- assertEquals(1, getKeySetRefCount(1));
- assertEquals(1, getKeySetRefCount(2));
- assertEquals(1, getPubKeyRefCount(1));
- assertEquals(1, getPubKeyRefCount(2));
- assertEquals(keyA, getPubKey(1));
- assertEquals(keyB, getPubKey(2));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
+ assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 2));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(2, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
@@ -312,10 +264,10 @@
mKsms.addSigningKeySetToPackageLPw(ps2.name, signingKeys2);
/* verify first is unchanged */
- assertEquals(1, getKeySetRefCount(1));
- assertEquals(1, getPubKeyRefCount(1));
- assertEquals(keyA, getPubKey(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(2, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
@@ -323,9 +275,9 @@
assertEquals(1, ps1.keySetData.getProperSigningKeySet());
/* verify second */
- assertEquals(1, getKeySetRefCount(2));
- assertEquals(1, getPubKeyRefCount(2));
- assertEquals(keyB, getPubKey(2));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 2));
mapping = ksMapping.get(2);
assertEquals(1, mapping.size());
assertTrue(mapping.contains(new Long(2)));
@@ -353,10 +305,10 @@
/* add again for second package */
mKsms.addSigningKeySetToPackageLPw(ps2.name, signingKeys);
- assertEquals(2, getKeySetRefCount(1));
- assertEquals(1, getPubKeyRefCount(1));
- assertEquals(keyA, getPubKey(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(2, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
@@ -388,13 +340,13 @@
signingKeys.add(keyB);
mKsms.addSigningKeySetToPackageLPw(ps2.name, signingKeys);
- assertEquals(1, getKeySetRefCount(1));
- assertEquals(1, getKeySetRefCount(2));
- assertEquals(2, getPubKeyRefCount(1));
- assertEquals(1, getPubKeyRefCount(2));
- assertEquals(keyA, getPubKey(1));
- assertEquals(keyB, getPubKey(2));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(2, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
+ assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 2));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(2, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
@@ -429,16 +381,17 @@
signingKeys.add(keyB);
mKsms.addSigningKeySetToPackageLPw(ps.name, signingKeys);
- assertEquals(0, getKeySetRefCount(1));
- assertEquals(1, getKeySetRefCount(2));
- assertEquals(0, getPubKeyRefCount(1));
- assertEquals(1, getPubKeyRefCount(2));
- assertEquals(1, getPubKeyRefCount(3));
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 3));
/* the pub key is removed w/prev keyset and may be either 2 or 3 */
- assertTrue(keyA.equals(getPubKey(2)) && keyB.equals(getPubKey(3))
- || keyA.equals(getPubKey(3)) && keyB.equals(getPubKey(2)));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertTrue(keyA.equals(KeySetUtils.getPubKey(mKsms, 2)) || keyA.equals(KeySetUtils.getPubKey(mKsms, 3)));
+ assertTrue(keyB.equals(KeySetUtils.getPubKey(mKsms, 2)) || keyB.equals(KeySetUtils.getPubKey(mKsms, 3)));
+ assertFalse(KeySetUtils.getPubKey(mKsms, 2).equals(KeySetUtils.getPubKey(mKsms, 3)));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(2);
assertEquals(2, mapping.size());
@@ -462,10 +415,10 @@
definedKS.put("aliasA", keys);
mKsms.addDefinedKeySetsToPackageLPw(ps.name, definedKS);
- assertEquals(1, getKeySetRefCount(1));
- assertEquals(1, getPubKeyRefCount(1));
- assertEquals(keyA, getPubKey(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
@@ -490,10 +443,10 @@
definedKS.put("aliasA2", keys);
mKsms.addDefinedKeySetsToPackageLPw(ps.name, definedKS);
- assertEquals(2, getKeySetRefCount(1));
- assertEquals(1, getPubKeyRefCount(1));
- assertEquals(keyA, getPubKey(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(2, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
@@ -527,12 +480,12 @@
definedKS.put("aliasB", keys);
mKsms.addDefinedKeySetsToPackageLPw(ps.name, definedKS);
- assertEquals(0, getKeySetRefCount(1));
- assertEquals(0, getPubKeyRefCount(1));
- assertEquals(1, getKeySetRefCount(2));
- assertEquals(1, getPubKeyRefCount(2));
- assertEquals(keyB, getPubKey(2));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 2));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(2);
assertEquals(1, mapping.size());
@@ -566,12 +519,12 @@
definedKS.put("aliasA", keys);
mKsms.addDefinedKeySetsToPackageLPw(ps.name, definedKS);
- assertEquals(0, getKeySetRefCount(1));
- assertEquals(0, getPubKeyRefCount(1));
- assertEquals(1, getKeySetRefCount(2));
- assertEquals(1, getPubKeyRefCount(2));
- assertEquals(keyB, getPubKey(2));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 2));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(2);
assertEquals(1, mapping.size());
@@ -608,10 +561,10 @@
definedKS.put("aliasC", keys1);
mKsms.addDefinedKeySetsToPackageLPw(ps.name, definedKS);
- assertEquals(1, getKeySetRefCount(3));
- assertEquals(1, getPubKeyRefCount(3));
- assertEquals(keyC, getPubKey(3));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 3));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 3));
+ assertEquals(keyC, KeySetUtils.getPubKey(mKsms, 3));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(2, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(3);
assertEquals(1, mapping.size());
@@ -619,13 +572,13 @@
assertEquals(new Long(3), ps.keySetData.getAliases().get("aliasC"));
/* either keyset w/keyA or w/keyB was added first, address both cases */
- if (1 == getKeySetRefCount(1)) {
+ if (1 == KeySetUtils.getKeySetRefCount(mKsms, 1)) {
/* keyB was added first and should have keyset 1 and pub-key 1 */
- assertEquals(1, getPubKeyRefCount(1));
- assertEquals(0, getKeySetRefCount(2));
- assertEquals(0, getPubKeyRefCount(2));
- assertEquals(keyB, getPubKey(1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 1));
mapping = ksMapping.get(1);
assertEquals(1, mapping.size());
assertTrue(mapping.contains(new Long(1)));
@@ -633,11 +586,11 @@
} else {
/* keyA was added first and keyB has id 2 */
- assertEquals(1, getKeySetRefCount(2));
- assertEquals(1, getPubKeyRefCount(2));
- assertEquals(0, getKeySetRefCount(1));
- assertEquals(0, getPubKeyRefCount(1));
- assertEquals(keyB, getPubKey(2));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 2));
mapping = ksMapping.get(2);
assertEquals(1, mapping.size());
assertTrue(mapping.contains(new Long(2)));
@@ -674,14 +627,14 @@
definedKS.put("aliasA", keys1);
mKsms.addDefinedKeySetsToPackageLPw(ps.name, definedKS);
- assertEquals(0, getKeySetRefCount(1));
- assertEquals(0, getKeySetRefCount(2));
- assertEquals(1, getKeySetRefCount(3));
- assertEquals(0, getPubKeyRefCount(1));
- assertEquals(0, getPubKeyRefCount(2));
- assertEquals(1, getPubKeyRefCount(3));
- assertEquals(keyA, getPubKey(3));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 2));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 3));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 2));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 3));
+ assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 3));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
ArraySet<Long> mapping = ksMapping.get(3);
assertEquals(1, mapping.size());
@@ -780,9 +733,9 @@
/* remove its references */
mKsms.removeAppKeySetDataLPw(ps.name);
- assertEquals(0, getKeySetRefCount(1));
- assertEquals(0, getPubKeyRefCount(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(0, ksMapping.size());
assertEquals(PackageKeySetData.KEYSET_UNASSIGNED, ps.keySetData.getProperSigningKeySet());
}
@@ -807,9 +760,9 @@
/* remove references from first package */
mKsms.removeAppKeySetDataLPw(ps1.name);
- assertEquals(1, getKeySetRefCount(1));
- assertEquals(1, getPubKeyRefCount(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(1, ksMapping.size());
assertEquals(PackageKeySetData.KEYSET_UNASSIGNED, ps1.keySetData.getProperSigningKeySet());
assertEquals(1, ps2.keySetData.getProperSigningKeySet());
@@ -840,9 +793,9 @@
mKsms.addUpgradeKeySetsToPackageLPw(ps.name, upgradeKS);
mKsms.removeAppKeySetDataLPw(ps.name);
- assertEquals(0, getKeySetRefCount(1));
- assertEquals(0, getPubKeyRefCount(1));
- LongSparseArray<ArraySet<Long>> ksMapping = getKeySetMapping();
+ assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
+ assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
assertEquals(0, ksMapping.size());
assertEquals(PackageKeySetData.KEYSET_UNASSIGNED, ps.keySetData.getProperSigningKeySet());
assertEquals(0, ps.keySetData.getAliases().size());
diff --git a/services/tests/servicestests/src/com/android/server/pm/KeySetUtils.java b/services/tests/servicestests/src/com/android/server/pm/KeySetUtils.java
new file mode 100644
index 0000000..9e1a366
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/pm/KeySetUtils.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.pm;
+
+import android.util.ArraySet;
+import android.util.LongSparseArray;
+
+import java.lang.reflect.Field;
+import java.security.PublicKey;
+
+public class KeySetUtils {
+
+ public static PublicKey getPubKey(KeySetManagerService ksms, long pkId)
+ throws NoSuchFieldException, IllegalAccessException {
+ Field pkField = ksms.getClass().getDeclaredField("mPublicKeys");
+ pkField.setAccessible(true);
+ LongSparseArray<KeySetManagerService.PublicKeyHandle> mPublicKeys =
+ (LongSparseArray<KeySetManagerService.PublicKeyHandle>) pkField.get(ksms);
+ KeySetManagerService.PublicKeyHandle pkh = mPublicKeys.get(pkId);
+ if (pkh == null) {
+ return null;
+ } else {
+ return pkh.getKey();
+ }
+ }
+
+ public static int getPubKeyRefCount(KeySetManagerService ksms, long pkId)
+ throws NoSuchFieldException, IllegalAccessException {
+ Field pkField = ksms.getClass().getDeclaredField("mPublicKeys");
+ pkField.setAccessible(true);
+ LongSparseArray<KeySetManagerService.PublicKeyHandle> mPublicKeys =
+ (LongSparseArray<KeySetManagerService.PublicKeyHandle>) pkField.get(ksms);
+ KeySetManagerService.PublicKeyHandle pkh = mPublicKeys.get(pkId);
+ if (pkh == null) {
+ return 0;
+ } else {
+ return pkh.getRefCountLPr();
+ }
+ }
+
+ public static int getKeySetRefCount(KeySetManagerService ksms, long keysetId)
+ throws NoSuchFieldException, IllegalAccessException {
+ Field ksField = ksms.getClass().getDeclaredField("mKeySets");
+ ksField.setAccessible(true);
+ LongSparseArray<KeySetHandle> mKeySets =
+ (LongSparseArray<KeySetHandle>) ksField.get(ksms);
+ KeySetHandle ksh = mKeySets.get(keysetId);
+ if (ksh == null) {
+ return 0;
+ } else {
+ return ksh.getRefCountLPr();
+ }
+ }
+
+ public static LongSparseArray<ArraySet<Long>> getKeySetMapping(KeySetManagerService ksms)
+ throws NoSuchFieldException, IllegalAccessException {
+ Field ksField = ksms.getClass().getDeclaredField("mKeySetMapping");
+ ksField.setAccessible(true);
+ return (LongSparseArray<ArraySet<Long>>) ksField.get(ksms);
+ }
+
+ public static Long getLastIssuedKeyId(KeySetManagerService ksms)
+ throws NoSuchFieldException, IllegalAccessException {
+ Field ksField = ksms.getClass().getDeclaredField("lastIssuedKeyId");
+ ksField.setAccessible(true);
+ return (Long) ksField.get(ksms);
+ }
+
+ public static Long getLastIssuedKeySetId(KeySetManagerService ksms)
+ throws NoSuchFieldException, IllegalAccessException {
+ Field ksField = ksms.getClass().getDeclaredField("lastIssuedKeySetId");
+ ksField.setAccessible(true);
+ return (Long) ksField.get(ksms);
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/pm/PackageManagerSettingsTests.java b/services/tests/servicestests/src/com/android/server/pm/PackageManagerSettingsTests.java
index a3f3a5d..ed1db6f 100644
--- a/services/tests/servicestests/src/com/android/server/pm/PackageManagerSettingsTests.java
+++ b/services/tests/servicestests/src/com/android/server/pm/PackageManagerSettingsTests.java
@@ -21,15 +21,21 @@
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+import android.content.Context;
+import android.content.pm.PackageParser;
import android.test.AndroidTestCase;
+import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
+import android.util.LongSparseArray;
import com.android.internal.os.AtomicFile;
+import java.lang.reflect.Constructor;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.security.PublicKey;
public class PackageManagerSettingsTests extends AndroidTestCase {
private static final String PACKAGE_NAME_2 = "com.google.app2";
@@ -67,18 +73,24 @@
+ "</permissions>"
+ "<package name=\"com.google.app1\" codePath=\"/system/app/app1.apk\" nativeLibraryPath=\"/data/data/com.google.app1/lib\" flags=\"1\" ft=\"1360e2caa70\" it=\"135f2f80d08\" ut=\"1360e2caa70\" version=\"1109\" sharedUserId=\"11000\">"
+ "<sigs count=\"1\">"
- + "<cert index=\"0\" key=\"308886\" />"
+ + "<cert index=\"0\" key=\"" + KeySetStrings.ctsKeySetCertA + "\" />"
+ "</sigs>"
+ + "<proper-signing-keyset identifier=\"1\" />"
+ "</package>"
+ "<package name=\"com.google.app2\" codePath=\"/system/app/app2.apk\" nativeLibraryPath=\"/data/data/com.google.app2/lib\" flags=\"1\" ft=\"1360e578718\" it=\"135f2f80d08\" ut=\"1360e578718\" version=\"15\" enabled=\"3\" userId=\"11001\">"
+ "<sigs count=\"1\">"
+ "<cert index=\"0\" />"
+ "</sigs>"
+ + "<proper-signing-keyset identifier=\"1\" />"
+ + "<defined-keyset alias=\"AB\" identifier=\"4\" />"
+ "</package>"
+ "<package name=\"com.android.app3\" codePath=\"/system/app/app3.apk\" nativeLibraryPath=\"/data/data/com.android.app3/lib\" flags=\"1\" ft=\"1360e577b60\" it=\"135f2f80d08\" ut=\"1360e577b60\" version=\"15\" userId=\"11030\">"
+ "<sigs count=\"1\">"
- + "<cert index=\"1\" key=\"308366\" />"
+ + "<cert index=\"1\" key=\"" + KeySetStrings.ctsKeySetCertB + "\" />"
+ "</sigs>"
+ + "<proper-signing-keyset identifier=\"2\" />"
+ + "<upgrade-keyset identifier=\"3\" />"
+ + "<defined-keyset alias=\"C\" identifier=\"3\" />"
+ "</package>"
+ "<shared-user name=\"com.android.shared1\" userId=\"11000\">"
+ "<sigs count=\"1\">"
@@ -88,6 +100,30 @@
+ "<item name=\"android.permission.REBOOT\" />"
+ "</perms>"
+ "</shared-user>"
+ + "<keyset-settings version=\"1\">"
+ + "<keys>"
+ + "<public-key identifier=\"1\" value=\"" + KeySetStrings.ctsKeySetPublicKeyA + "\" />"
+ + "<public-key identifier=\"2\" value=\"" + KeySetStrings.ctsKeySetPublicKeyB + "\" />"
+ + "<public-key identifier=\"3\" value=\"" + KeySetStrings.ctsKeySetPublicKeyC + "\" />"
+ + "</keys>"
+ + "<keysets>"
+ + "<keyset identifier=\"1\">"
+ + "<key-id identifier=\"1\" />"
+ + "</keyset>"
+ + "<keyset identifier=\"2\">"
+ + "<key-id identifier=\"2\" />"
+ + "</keyset>"
+ + "<keyset identifier=\"3\">"
+ + "<key-id identifier=\"3\" />"
+ + "</keyset>"
+ + "<keyset identifier=\"4\">"
+ + "<key-id identifier=\"1\" />"
+ + "<key-id identifier=\"2\" />"
+ + "</keyset>"
+ + "</keysets>"
+ + "<lastIssuedKeyId value=\"3\" />"
+ + "<lastIssuedKeySetId value=\"4\" />"
+ + "</keyset-settings>"
+ "</packages>").getBytes());
}
@@ -131,6 +167,104 @@
writePackagesList();
}
+ private void createUserManagerServiceRef() throws ReflectiveOperationException {
+ Constructor<UserManagerService> umsc =
+ UserManagerService.class.getDeclaredConstructor(
+ Context.class,
+ PackageManagerService.class,
+ Object.class,
+ Object.class,
+ File.class,
+ File.class);
+ umsc.setAccessible(true);
+ UserManagerService ums = umsc.newInstance(getContext(), null,
+ new Object(), new Object(), getContext().getFilesDir(),
+ new File(getContext().getFilesDir(), "user"));
+ }
+
+ private void verifyKeySetMetaData(Settings settings)
+ throws ReflectiveOperationException, IllegalAccessException {
+ ArrayMap<String, PackageSetting> packages = settings.mPackages;
+ KeySetManagerService ksms = settings.mKeySetManagerService;
+
+ /* verify keyset and public key ref counts */
+ assertEquals(2, KeySetUtils.getKeySetRefCount(ksms, 1));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(ksms, 2));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(ksms, 3));
+ assertEquals(1, KeySetUtils.getKeySetRefCount(ksms, 4));
+ assertEquals(2, KeySetUtils.getPubKeyRefCount(ksms, 1));
+ assertEquals(2, KeySetUtils.getPubKeyRefCount(ksms, 2));
+ assertEquals(1, KeySetUtils.getPubKeyRefCount(ksms, 3));
+
+ /* verify public keys properly read */
+ PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
+ PublicKey keyB = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyB);
+ PublicKey keyC = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyC);
+ assertEquals(keyA, KeySetUtils.getPubKey(ksms, 1));
+ assertEquals(keyB, KeySetUtils.getPubKey(ksms, 2));
+ assertEquals(keyC, KeySetUtils.getPubKey(ksms, 3));
+
+ /* verify mapping is correct (ks -> pub keys) */
+ LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(ksms);
+ ArraySet<Long> mapping = ksMapping.get(1);
+ assertEquals(1, mapping.size());
+ assertTrue(mapping.contains(new Long(1)));
+ mapping = ksMapping.get(2);
+ assertEquals(1, mapping.size());
+ assertTrue(mapping.contains(new Long(2)));
+ mapping = ksMapping.get(3);
+ assertEquals(1, mapping.size());
+ assertTrue(mapping.contains(new Long(3)));
+ mapping = ksMapping.get(4);
+ assertEquals(2, mapping.size());
+ assertTrue(mapping.contains(new Long(1)));
+ assertTrue(mapping.contains(new Long(2)));
+
+ /* verify lastIssuedIds are consistent */
+ assertEquals(new Long(3), KeySetUtils.getLastIssuedKeyId(ksms));
+ assertEquals(new Long(4), KeySetUtils.getLastIssuedKeySetId(ksms));
+
+ /* verify packages have been given the appropriat information */
+ PackageSetting ps = packages.get("com.google.app1");
+ assertEquals(1, ps.keySetData.getProperSigningKeySet());
+ ps = packages.get("com.google.app2");
+ assertEquals(1, ps.keySetData.getProperSigningKeySet());
+ assertEquals(new Long(4), ps.keySetData.getAliases().get("AB"));
+ ps = packages.get("com.android.app3");
+ assertEquals(2, ps.keySetData.getProperSigningKeySet());
+ assertEquals(new Long(3), ps.keySetData.getAliases().get("C"));
+ assertEquals(1, ps.keySetData.getUpgradeKeySets().length);
+ assertEquals(3, ps.keySetData.getUpgradeKeySets()[0]);
+ }
+
+ /* make sure our initialized keysetmanagerservice metadata matches packages.xml */
+ public void testReadKeySetSettings()
+ throws ReflectiveOperationException, IllegalAccessException {
+
+ /* write out files and read */
+ writeOldFiles();
+ createUserManagerServiceRef();
+ Settings settings = new Settings(getContext().getFilesDir(), new Object());
+ assertEquals(true, settings.readLPw(null, null, 0, false));
+ verifyKeySetMetaData(settings);
+ }
+
+ /* read in data, write it out, and read it back in. Verify same. */
+ public void testWriteKeySetSettings()
+ throws ReflectiveOperationException, IllegalAccessException {
+
+ /* write out files and read */
+ writeOldFiles();
+ createUserManagerServiceRef();
+ Settings settings = new Settings(getContext().getFilesDir(), new Object());
+ assertEquals(true, settings.readLPw(null, null, 0, false));
+
+ /* write out, read back in and verify the same */
+ settings.writeLPr();
+ assertEquals(true, settings.readLPw(null, null, 0, false));
+ verifyKeySetMetaData(settings);
+ }
+
public void testSettingsReadOld() {
// Write the package files and make sure they're parsed properly the first time
writeOldFiles();
@@ -149,9 +283,11 @@
assertEquals(COMPONENT_ENABLED_STATE_DEFAULT, ps.getEnabled(1));
}
- public void testNewPackageRestrictionsFile() {
+ public void testNewPackageRestrictionsFile() throws ReflectiveOperationException {
+
// Write the package files and make sure they're parsed properly the first time
writeOldFiles();
+ createUserManagerServiceRef();
Settings settings = new Settings(getContext().getFilesDir(), new Object());
assertEquals(true, settings.readLPw(null, null, 0, false));
settings.writeLPr();