diff options
143 files changed, 1254 insertions, 372 deletions
diff --git a/Android.bp b/Android.bp index 70438d200cb7..dda318b38d0d 100644 --- a/Android.bp +++ b/Android.bp @@ -25,8 +25,8 @@ // // READ ME: ######################################################## -java_library { - name: "framework", +java_defaults { + name: "framework-defaults", installable: true, srcs: [ @@ -695,12 +695,38 @@ java_library { "libmedia2_jni", ], - javac_shard_size: 150, - dxflags: [ "--core-library", "--multi-dex", ], + +} + +java_library { + name: "framework", + defaults: ["framework-defaults"], + javac_shard_size: 150, +} + +java_library { + name: "framework-annotation-proc", + defaults: ["framework-defaults"], + // Use UsedByApps annotation processor + annotation_processors: ["unsupportedappusage-annotation-processor"], + // b/25860419: annotation processors must be explicitly specified for grok + annotation_processor_classes: [ + "android.processor.unsupportedappusage.UsedByAppsProcessor", + ], +} + +// A host library including just UnsupportedAppUsage.java so that the annotation +// processor can also use this annotation. +java_library_host { + name: "unsupportedappusage-annotation", + srcs: [ + "core/java/android/annotation/IntDef.java", + "core/java/android/annotation/UnsupportedAppUsage.java", + ], } // A temporary build target that is conditionally included on the bootclasspath if diff --git a/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp b/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp index 0615c74b8d64..2a89c920c119 100644 --- a/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp +++ b/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp @@ -75,18 +75,13 @@ PageTypeInfoParser::Parse(const int in, const int out) const } else return BAD_VALUE; // expect part 2 starts with "type" if (stripPrefix(&record[2], "type")) { - // expect the rest of part 2 has number of (pageBlockOrder + 2) parts // An example looks like: // header line: type 0 1 2 3 4 5 6 7 8 9 10 // record line: Unmovable 426 279 226 1 1 1 0 0 2 2 0 - // The pageBlockOrder = 10 and it's zero-indexed. so total parts - // are 10 + 1(zero-indexed) + 1(the type part) = 12. record_t pageCounts = parseRecord(record[2]); - int pageCountsSize = pageBlockOrder + 2; - if ((int)pageCounts.size() != pageCountsSize) return BAD_VALUE; proto.write(PageTypeInfoProto::MigrateType::TYPE, pageCounts[0]); - for (auto i=1; i<pageCountsSize; i++) { + for (size_t i=1; i<pageCounts.size(); i++) { proto.write(PageTypeInfoProto::MigrateType::FREE_PAGES_COUNT, toInt(pageCounts[i])); } } else return BAD_VALUE; @@ -125,4 +120,4 @@ PageTypeInfoParser::Parse(const int in, const int out) const fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); return NO_ERROR; -}
\ No newline at end of file +} diff --git a/cmds/incident_helper/testdata/pagetypeinfo.txt b/cmds/incident_helper/testdata/pagetypeinfo.txt index d45ddc408c0f..c65b5a1fa1e1 100644 --- a/cmds/incident_helper/testdata/pagetypeinfo.txt +++ b/cmds/incident_helper/testdata/pagetypeinfo.txt @@ -1,5 +1,5 @@ -Page block order: 10 -Pages per block: 1024 +Page block order: 9 +Pages per block: 512 Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10 Node 0, zone DMA, type Unmovable 426 279 226 1 1 1 0 0 2 2 0 diff --git a/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp b/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp index 9bad7be4a07e..5688681e45fd 100644 --- a/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp +++ b/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp @@ -54,8 +54,8 @@ TEST_F(PageTypeInfoParserTest, Success) { PageTypeInfoParser parser; PageTypeInfoProto expected; - expected.set_page_block_order(10); - expected.set_pages_per_block(1024); + expected.set_page_block_order(9); + expected.set_pages_per_block(512); PageTypeInfoProto::MigrateType* mt1 = expected.add_migrate_types(); mt1->set_node(0); diff --git a/cmds/statsd/src/external/Perfetto.cpp b/cmds/statsd/src/external/Perfetto.cpp index 05544837b752..c1f9a643e153 100644 --- a/cmds/statsd/src/external/Perfetto.cpp +++ b/cmds/statsd/src/external/Perfetto.cpp @@ -105,9 +105,9 @@ bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config, readPipe.reset(); // Close the read end (owned by the child process). - // Using fopen() because fwrite() has the right logic to chunking write() + // Using fdopen() because fwrite() has the right logic to chunking write() // over a pipe (see __sfvwrite()). - FILE* writePipeStream = fdopen(writePipe.get(), "wb"); + FILE* writePipeStream = android::base::Fdopen(std::move(writePipe), "wb"); if (!writePipeStream) { ALOGE("fdopen() failed while calling the Perfetto client: %s", strerror(errno)); return false; diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index c3a57070c440..9b18e9a12969 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -2371,13 +2371,25 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}, is defined relative to the active array rectangle given in * this field, with <code>(0, 0)</code> being the top-left of this rectangle.</p> * <p>The active array may be smaller than the full pixel array, since the full array may - * include black calibration pixels or other inactive regions, and geometric correction - * resulting in scaling or cropping may have been applied.</p> + * include black calibration pixels or other inactive regions.</p> + * <p>For devices that do not support {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the active + * array must be the same as {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.</p> + * <p>For devices that support {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the active array must + * be enclosed by {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}. The difference between + * pre-correction active array and active array accounts for scaling or cropping caused + * by lens geometric distortion correction.</p> + * <p>In general, application should always refer to active array size for controls like + * metering regions or crop region. Two exceptions are when the application is dealing with + * RAW image buffers (RAW_SENSOR, RAW10, RAW12 etc), or when application explicitly set + * {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} to OFF. In these cases, application should refer + * to {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.</p> * <p><b>Units</b>: Pixel coordinates on the image sensor</p> * <p>This key is available on all devices.</p> * + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_PIXEL_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.graphics.Rect> SENSOR_INFO_ACTIVE_ARRAY_SIZE = @@ -2622,9 +2634,9 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri * <ol> * <li>{@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion}.</li> * </ol> - * <p>If all of the geometric distortion fields are no-ops, this rectangle will be the same - * as the post-distortion-corrected rectangle given in - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.</p> + * <p>If the camera device doesn't support geometric distortion correction, or all of the + * geometric distortion fields are no-ops, this rectangle will be the same as the + * post-distortion-corrected rectangle given in {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.</p> * <p>This rectangle is defined relative to the full pixel array; (0,0) is the top-left of * the full pixel array, and the size of the full pixel array is given by * {@link CameraCharacteristics#SENSOR_INFO_PIXEL_ARRAY_SIZE android.sensor.info.pixelArraySize}.</p> @@ -3130,12 +3142,26 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri * the following code snippet can be used:</p> * <pre><code>// Returns true if the device supports the required hardware level, or better. * boolean isHardwareLevelSupported(CameraCharacteristics c, int requiredLevel) { + * final int[] sortedHwLevels = { + * CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, + * CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL, + * CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED, + * CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL, + * CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3 + * }; * int deviceLevel = c.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL); - * if (deviceLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) { - * return requiredLevel == deviceLevel; + * if (requiredLevel == deviceLevel) { + * return true; + * } + * + * for (int sortedlevel : sortedHwLevels) { + * if (sortedlevel == requiredLevel) { + * return true; + * } else if (sortedlevel == deviceLevel) { + * return false; + * } * } - * // deviceLevel is not LEGACY, can use numerical sort - * return requiredLevel <= deviceLevel; + * return false; // Should never reach here * } * </code></pre> * <p>At a high level, the levels are:</p> @@ -3149,6 +3175,8 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri * post-processing settings, and image capture at a high rate.</li> * <li><code>LEVEL_3</code> devices additionally support YUV reprocessing and RAW image capture, along * with additional output stream configurations.</li> + * <li><code>EXTERNAL</code> devices are similar to <code>LIMITED</code> devices with exceptions like some sensor or + * lens information not reorted or less stable framerates.</li> * </ul> * <p>See the individual level enums for full descriptions of the supported capabilities. The * {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} entry describes the device's capabilities at a diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java index f47d4640c09c..ce88697fa8db 100644 --- a/core/java/android/hardware/camera2/CameraDevice.java +++ b/core/java/android/hardware/camera2/CameraDevice.java @@ -44,19 +44,27 @@ import java.lang.annotation.RetentionPolicy; * {@link android.Manifest.permission#CAMERA Camera} permission in its manifest * in order to access camera devices.</p> * - * <p>A given camera device may provide support at one of two levels: limited or - * full. If a device only supports the limited level, then Camera2 exposes a - * feature set that is roughly equivalent to the older + * <p>A given camera device may provide support at one of several levels defined + * in {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL}. + * If a device supports {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY} level, + * the camera device is running in backward compatibility mode and has minimum camera2 API support. + * If a device supports the {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} + * level, then Camera2 exposes a feature set that is roughly equivalent to the older * {@link android.hardware.Camera Camera} API, although with a cleaner and more - * efficient interface. Devices that implement the full level of support + * efficient interface. + * If a device supports the {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL EXTERNAL} + * level, then the device is a removable camera that provides similar but slightly less features + * as the {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED LIMITED} level. + * Devices that implement the {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL} or + * {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3 LEVEL3} level of support * provide substantially improved capabilities over the older camera - * API. Applications that target the limited level devices will run unchanged on - * the full-level devices; if your application requires a full-level device for + * API. If your application requires a full-level device for * proper operation, declare the "android.hardware.camera.level.full" feature in your * manifest.</p> * * @see CameraManager#openCamera * @see android.Manifest.permission#CAMERA + * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL */ public abstract class CameraDevice implements AutoCloseable { diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index ec51ba56c571..0b92b0cbef15 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -1277,11 +1277,26 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * Otherwise will always be present.</p> * <p>The maximum number of regions supported by the device is determined by the value * of {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AE android.control.maxRegionsAe}.</p> - * <p>The coordinate system is based on the active pixel array, - * with (0,0) being the top-left pixel in the active pixel array, and + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0,0) being + * the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the - * bottom-right pixel in the active pixel array.</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.height - 1) being the bottom-right + * pixel in the pre-correction active pixel array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> * <p>The weight must be within <code>[0, 1000]</code>, and represents a weight * for every pixel in the area. This means that a large metering area * with the same weight as a smaller area will have more effect in @@ -1297,15 +1312,20 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> - * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on + * distortion correction capability and mode</p> * <p><b>Range of valid values:</b><br> * Coordinates must be between <code>[(0,0), (width, height))</code> of - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} + * depending on distortion correction capability and mode</p> * <p><b>Optional</b> - This value may be {@code null} on some devices.</p> * * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AE + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.hardware.camera2.params.MeteringRectangle[]> CONTROL_AE_REGIONS = @@ -1451,11 +1471,26 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * Otherwise will always be present.</p> * <p>The maximum number of focus areas supported by the device is determined by the value * of {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AF android.control.maxRegionsAf}.</p> - * <p>The coordinate system is based on the active pixel array, - * with (0,0) being the top-left pixel in the active pixel array, and + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0,0) being + * the top-left pixel in the active pixel array, and + * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.height - 1) being the bottom-right + * pixel in the pre-correction active pixel array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the active array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the - * bottom-right pixel in the active pixel array.</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> * <p>The weight must be within <code>[0, 1000]</code>, and represents a weight * for every pixel in the area. This means that a large metering area * with the same weight as a smaller area will have more effect in @@ -1472,15 +1507,20 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> - * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on + * distortion correction capability and mode</p> * <p><b>Range of valid values:</b><br> * Coordinates must be between <code>[(0,0), (width, height))</code> of - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} + * depending on distortion correction capability and mode</p> * <p><b>Optional</b> - This value may be {@code null} on some devices.</p> * * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AF + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.hardware.camera2.params.MeteringRectangle[]> CONTROL_AF_REGIONS = @@ -1620,11 +1660,26 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * Otherwise will always be present.</p> * <p>The maximum number of regions supported by the device is determined by the value * of {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AWB android.control.maxRegionsAwb}.</p> - * <p>The coordinate system is based on the active pixel array, - * with (0,0) being the top-left pixel in the active pixel array, and + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0,0) being + * the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the - * bottom-right pixel in the active pixel array.</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.height - 1) being the bottom-right + * pixel in the pre-correction active pixel array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> * <p>The weight must range from 0 to 1000, and represents a weight * for every pixel in the area. This means that a large metering area * with the same weight as a smaller area will have more effect in @@ -1640,15 +1695,20 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> - * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on + * distortion correction capability and mode</p> * <p><b>Range of valid values:</b><br> * Coordinates must be between <code>[(0,0), (width, height))</code> of - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} + * depending on distortion correction capability and mode</p> * <p><b>Optional</b> - This value may be {@code null} on some devices.</p> * * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AWB + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.hardware.camera2.params.MeteringRectangle[]> CONTROL_AWB_REGIONS = @@ -2441,9 +2501,17 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> /** * <p>The desired region of the sensor to read out for this capture.</p> * <p>This control can be used to implement digital zoom.</p> - * <p>The crop region coordinate system is based off - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with <code>(0, 0)</code> being the - * top-left corner of the sensor active array.</p> + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with <code>(0, 0)</code> being + * the top-left pixel of the active array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the active array.</p> * <p>Output streams use this rectangle to produce their output, * cropping to a smaller region if necessary to maintain the * stream's aspect ratio, then scaling the sensor input to @@ -2462,20 +2530,30 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * outputs will crop horizontally (pillarbox), and 16:9 * streams will match exactly. These additional crops will * be centered within the crop region.</p> - * <p>The width and height of the crop region cannot - * be set to be smaller than + * <p>If the coordinate system is android.sensor.info.activeArraysSize, the width and height + * of the crop region cannot be set to be smaller than * <code>floor( activeArraySize.width / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code> and * <code>floor( activeArraySize.height / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code>, respectively.</p> + * <p>If the coordinate system is {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, the width + * and height of the crop region cannot be set to be smaller than + * <code>floor( preCorrectionActiveArraySize.width / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code> + * and + * <code>floor( preCorrectionActiveArraySize.height / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code>, + * respectively.</p> * <p>The camera device may adjust the crop region to account * for rounding and other hardware requirements; the final * crop region used will be included in the output capture * result.</p> * <p><b>Units</b>: Pixel coordinates relative to - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on distortion correction + * capability and mode</p> * <p>This key is available on all devices.</p> * + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.graphics.Rect> SCALER_CROP_REGION = @@ -3194,15 +3272,14 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * any correction at all would slow down capture rate. Every output stream will have a * similar amount of enhancement applied.</p> * <p>The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not - * applied to any RAW output. Metadata coordinates such as face rectangles or metering + * applied to any RAW output. Metadata coordinates such as face rectangles or metering * regions are also not affected by correction.</p> - * <p>Applications enabling distortion correction need to pay extra attention when converting - * image coordinates between corrected output buffers and the sensor array. For example, if - * the app supports tap-to-focus and enables correction, it then has to apply the distortion - * model described in {@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion} to the image buffer tap coordinates to properly - * calculate the tap position on the sensor active array to be used with - * {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}. The same applies in reverse to detected face rectangles if - * they need to be drawn on top of the corrected output buffers.</p> + * <p>This control will be on by default on devices that support this control. Applications + * disabling distortion correction need to pay extra attention with the coordinate system of + * metering regions, crop region, and face rectangles. When distortion correction is OFF, + * metadata coordinates follow the coordinate system of + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}. When distortion is not OFF, metadata + * coordinates follow the coordinate system of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.</p> * <p><b>Possible values:</b> * <ul> * <li>{@link #DISTORTION_CORRECTION_MODE_OFF OFF}</li> @@ -3213,9 +3290,10 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * {@link CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES android.distortionCorrection.availableModes}</p> * <p><b>Optional</b> - This value may be {@code null} on some devices.</p> * - * @see CaptureRequest#CONTROL_AF_REGIONS * @see CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES * @see CameraCharacteristics#LENS_DISTORTION + * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE * @see #DISTORTION_CORRECTION_MODE_OFF * @see #DISTORTION_CORRECTION_MODE_FAST * @see #DISTORTION_CORRECTION_MODE_HIGH_QUALITY diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index a49064f8fb71..e007d282ad04 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -736,11 +736,26 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * Otherwise will always be present.</p> * <p>The maximum number of regions supported by the device is determined by the value * of {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AE android.control.maxRegionsAe}.</p> - * <p>The coordinate system is based on the active pixel array, - * with (0,0) being the top-left pixel in the active pixel array, and + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0,0) being + * the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the - * bottom-right pixel in the active pixel array.</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.height - 1) being the bottom-right + * pixel in the pre-correction active pixel array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> * <p>The weight must be within <code>[0, 1000]</code>, and represents a weight * for every pixel in the area. This means that a large metering area * with the same weight as a smaller area will have more effect in @@ -756,15 +771,20 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> - * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on + * distortion correction capability and mode</p> * <p><b>Range of valid values:</b><br> * Coordinates must be between <code>[(0,0), (width, height))</code> of - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} + * depending on distortion correction capability and mode</p> * <p><b>Optional</b> - This value may be {@code null} on some devices.</p> * * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AE + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.hardware.camera2.params.MeteringRectangle[]> CONTROL_AE_REGIONS = @@ -1158,11 +1178,26 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * Otherwise will always be present.</p> * <p>The maximum number of focus areas supported by the device is determined by the value * of {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AF android.control.maxRegionsAf}.</p> - * <p>The coordinate system is based on the active pixel array, - * with (0,0) being the top-left pixel in the active pixel array, and + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0,0) being + * the top-left pixel in the active pixel array, and + * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.height - 1) being the bottom-right + * pixel in the pre-correction active pixel array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the active array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the - * bottom-right pixel in the active pixel array.</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> * <p>The weight must be within <code>[0, 1000]</code>, and represents a weight * for every pixel in the area. This means that a large metering area * with the same weight as a smaller area will have more effect in @@ -1179,15 +1214,20 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> - * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on + * distortion correction capability and mode</p> * <p><b>Range of valid values:</b><br> * Coordinates must be between <code>[(0,0), (width, height))</code> of - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} + * depending on distortion correction capability and mode</p> * <p><b>Optional</b> - This value may be {@code null} on some devices.</p> * * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AF + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.hardware.camera2.params.MeteringRectangle[]> CONTROL_AF_REGIONS = @@ -1736,11 +1776,26 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * Otherwise will always be present.</p> * <p>The maximum number of regions supported by the device is determined by the value * of {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AWB android.control.maxRegionsAwb}.</p> - * <p>The coordinate system is based on the active pixel array, - * with (0,0) being the top-left pixel in the active pixel array, and + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0,0) being + * the top-left pixel in the active pixel array, and + * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array, and + * ({@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.width - 1, + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}.height - 1) being the bottom-right + * pixel in the pre-correction active pixel array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the active array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the - * bottom-right pixel in the active pixel array.</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.height - 1) being the bottom-right pixel in the + * active pixel array.</p> * <p>The weight must range from 0 to 1000, and represents a weight * for every pixel in the area. This means that a large metering area * with the same weight as a smaller area will have more effect in @@ -1756,15 +1811,20 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * region and output only the intersection rectangle as the metering region in the result * metadata. If the region is entirely outside the crop region, it will be ignored and * not reported in the result metadata.</p> - * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * <p><b>Units</b>: Pixel coordinates within {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on + * distortion correction capability and mode</p> * <p><b>Range of valid values:</b><br> * Coordinates must be between <code>[(0,0), (width, height))</code> of - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} + * depending on distortion correction capability and mode</p> * <p><b>Optional</b> - This value may be {@code null} on some devices.</p> * * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AWB + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.hardware.camera2.params.MeteringRectangle[]> CONTROL_AWB_REGIONS = @@ -3105,9 +3165,17 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { /** * <p>The desired region of the sensor to read out for this capture.</p> * <p>This control can be used to implement digital zoom.</p> - * <p>The crop region coordinate system is based off - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with <code>(0, 0)</code> being the - * top-left corner of the sensor active array.</p> + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with <code>(0, 0)</code> being + * the top-left pixel of the active array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the active array.</p> * <p>Output streams use this rectangle to produce their output, * cropping to a smaller region if necessary to maintain the * stream's aspect ratio, then scaling the sensor input to @@ -3126,20 +3194,30 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * outputs will crop horizontally (pillarbox), and 16:9 * streams will match exactly. These additional crops will * be centered within the crop region.</p> - * <p>The width and height of the crop region cannot - * be set to be smaller than + * <p>If the coordinate system is android.sensor.info.activeArraysSize, the width and height + * of the crop region cannot be set to be smaller than * <code>floor( activeArraySize.width / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code> and * <code>floor( activeArraySize.height / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code>, respectively.</p> + * <p>If the coordinate system is {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, the width + * and height of the crop region cannot be set to be smaller than + * <code>floor( preCorrectionActiveArraySize.width / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code> + * and + * <code>floor( preCorrectionActiveArraySize.height / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code>, + * respectively.</p> * <p>The camera device may adjust the crop region to account * for rounding and other hardware requirements; the final * crop region used will be included in the output capture * result.</p> * <p><b>Units</b>: Pixel coordinates relative to - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}</p> + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on distortion correction + * capability and mode</p> * <p>This key is available on all devices.</p> * + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.graphics.Rect> SCALER_CROP_REGION = @@ -3630,12 +3708,23 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { /** * <p>List of landmarks for detected * faces.</p> - * <p>The coordinate system is that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with <code>(0, 0)</code> being + * the top-left pixel of the active array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with * <code>(0, 0)</code> being the top-left pixel of the active array.</p> * <p>Only available if {@link CaptureRequest#STATISTICS_FACE_DETECT_MODE android.statistics.faceDetectMode} == FULL * This key is available on all devices.</p> * + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE * @see CaptureRequest#STATISTICS_FACE_DETECT_MODE * @hide */ @@ -3645,12 +3734,23 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { /** * <p>List of the bounding rectangles for detected * faces.</p> - * <p>The coordinate system is that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with + * <p>For devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with <code>(0, 0)</code> being + * the top-left pixel of the active array.</p> + * <p>For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate + * system depends on the mode being set. + * When the distortion correction mode is OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with + * <code>(0, 0)</code> being the top-left pixel of the pre-correction active array. + * When the distortion correction mode is not OFF, the coordinate system follows + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with * <code>(0, 0)</code> being the top-left pixel of the active array.</p> * <p>Only available if {@link CaptureRequest#STATISTICS_FACE_DETECT_MODE android.statistics.faceDetectMode} != OFF * This key is available on all devices.</p> * + * @see CaptureRequest#DISTORTION_CORRECTION_MODE * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE * @see CaptureRequest#STATISTICS_FACE_DETECT_MODE * @hide */ @@ -4484,15 +4584,14 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * any correction at all would slow down capture rate. Every output stream will have a * similar amount of enhancement applied.</p> * <p>The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not - * applied to any RAW output. Metadata coordinates such as face rectangles or metering + * applied to any RAW output. Metadata coordinates such as face rectangles or metering * regions are also not affected by correction.</p> - * <p>Applications enabling distortion correction need to pay extra attention when converting - * image coordinates between corrected output buffers and the sensor array. For example, if - * the app supports tap-to-focus and enables correction, it then has to apply the distortion - * model described in {@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion} to the image buffer tap coordinates to properly - * calculate the tap position on the sensor active array to be used with - * {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}. The same applies in reverse to detected face rectangles if - * they need to be drawn on top of the corrected output buffers.</p> + * <p>This control will be on by default on devices that support this control. Applications + * disabling distortion correction need to pay extra attention with the coordinate system of + * metering regions, crop region, and face rectangles. When distortion correction is OFF, + * metadata coordinates follow the coordinate system of + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}. When distortion is not OFF, metadata + * coordinates follow the coordinate system of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.</p> * <p><b>Possible values:</b> * <ul> * <li>{@link #DISTORTION_CORRECTION_MODE_OFF OFF}</li> @@ -4503,9 +4602,10 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * {@link CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES android.distortionCorrection.availableModes}</p> * <p><b>Optional</b> - This value may be {@code null} on some devices.</p> * - * @see CaptureRequest#CONTROL_AF_REGIONS * @see CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES * @see CameraCharacteristics#LENS_DISTORTION + * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE * @see #DISTORTION_CORRECTION_MODE_OFF * @see #DISTORTION_CORRECTION_MODE_FAST * @see #DISTORTION_CORRECTION_MODE_HIGH_QUALITY diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index acaaf07984f0..d165889e8325 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -62,7 +62,6 @@ import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowManager; -import android.view.WindowManager.BadTokenException; import android.view.animation.AnimationUtils; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.CursorAnchorInfo; @@ -354,7 +353,6 @@ public class InputMethodService extends AbstractInputMethodService { SoftInputWindow mWindow; boolean mInitialized; boolean mWindowCreated; - boolean mWindowAdded; boolean mWindowVisible; boolean mWindowWasVisible; boolean mInShowWindow; @@ -572,16 +570,7 @@ public class InputMethodService extends AbstractInputMethodService { if (DEBUG) Log.v(TAG, "showSoftInput()"); boolean wasVis = isInputViewShown(); if (dispatchOnShowInputRequested(flags, false)) { - try { - showWindow(true); - } catch (BadTokenException e) { - // We have ignored BadTokenException here since Jelly Bean MR-2 (API Level 18). - // We could ignore BadTokenException in InputMethodService#showWindow() instead, - // but it may break assumptions for those who override #showWindow() that we can - // detect errors in #showWindow() by checking BadTokenException. - // TODO: Investigate its feasibility. Update JavaDoc of #showWindow() of - // whether it's OK to override #showWindow() or not. - } + showWindow(true); } clearInsetOfPreviousIme(); // If user uses hard keyboard, IME button should always be shown. @@ -999,13 +988,7 @@ public class InputMethodService extends AbstractInputMethodService { mRootView.getViewTreeObserver().removeOnComputeInternalInsetsListener( mInsetsComputer); doFinishInput(); - if (mWindowAdded) { - // Disable exit animation for the current IME window - // to avoid the race condition between the exit and enter animations - // when the current IME is being switched to another one. - mWindow.getWindow().setWindowAnimations(0); - mWindow.dismiss(); - } + mWindow.dismissForDestroyIfNecessary(); if (mSettingsObserver != null) { mSettingsObserver.unregister(); mSettingsObserver = null; @@ -1792,7 +1775,6 @@ public class InputMethodService extends AbstractInputMethodService { public void showWindow(boolean showInput) { if (DEBUG) Log.v(TAG, "Showing window: showInput=" + showInput + " mShowInputRequested=" + mShowInputRequested - + " mWindowAdded=" + mWindowAdded + " mWindowCreated=" + mWindowCreated + " mWindowVisible=" + mWindowVisible + " mInputStarted=" + mInputStarted @@ -1802,27 +1784,12 @@ public class InputMethodService extends AbstractInputMethodService { Log.w(TAG, "Re-entrance in to showWindow"); return; } - - try { - mWindowWasVisible = mWindowVisible; - mInShowWindow = true; - showWindowInner(showInput); - } catch (BadTokenException e) { - // BadTokenException is a normal consequence in certain situations, e.g., swapping IMEs - // while there is a DO_SHOW_SOFT_INPUT message in the IIMethodWrapper queue. - if (DEBUG) Log.v(TAG, "BadTokenException: IME is done."); - mWindowVisible = false; - mWindowAdded = false; - // Rethrow the exception to preserve the existing behavior. Some IMEs may have directly - // called this method and relied on this exception for some clean-up tasks. - // TODO: Give developers a clear guideline of whether it's OK to call this method or - // InputMethodService#requestShowSelf(int) should always be used instead. - throw e; - } finally { - // TODO: Is it OK to set true when we get BadTokenException? - mWindowWasVisible = true; - mInShowWindow = false; - } + + mWindowWasVisible = mWindowVisible; + mInShowWindow = true; + showWindowInner(showInput); + mWindowWasVisible = true; + mInShowWindow = false; } void showWindowInner(boolean showInput) { @@ -1839,9 +1806,8 @@ public class InputMethodService extends AbstractInputMethodService { initialize(); updateFullscreenMode(); updateInputViewShown(); - - if (!mWindowAdded || !mWindowCreated) { - mWindowAdded = true; + + if (!mWindowCreated) { mWindowCreated = true; initialize(); if (DEBUG) Log.v(TAG, "CALL: onCreateCandidatesView"); @@ -2867,8 +2833,7 @@ public class InputMethodService extends AbstractInputMethodService { @Override protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) { final Printer p = new PrintWriterPrinter(fout); p.println("Input method service state for " + this + ":"); - p.println(" mWindowCreated=" + mWindowCreated - + " mWindowAdded=" + mWindowAdded); + p.println(" mWindowCreated=" + mWindowCreated); p.println(" mWindowVisible=" + mWindowVisible + " mWindowWasVisible=" + mWindowWasVisible + " mInShowWindow=" + mInShowWindow); diff --git a/core/java/android/inputmethodservice/SoftInputWindow.java b/core/java/android/inputmethodservice/SoftInputWindow.java index 795117e493b6..b4b88871d251 100644 --- a/core/java/android/inputmethodservice/SoftInputWindow.java +++ b/core/java/android/inputmethodservice/SoftInputWindow.java @@ -16,15 +16,22 @@ package android.inputmethodservice; +import static java.lang.annotation.RetentionPolicy.SOURCE; + +import android.annotation.IntDef; import android.app.Dialog; import android.content.Context; import android.graphics.Rect; +import android.os.Debug; import android.os.IBinder; +import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.WindowManager; +import java.lang.annotation.Retention; + /** * A SoftInputWindow is a Dialog that is intended to be used for a top-level input * method window. It will be displayed along the edge of the screen, moving @@ -33,6 +40,9 @@ import android.view.WindowManager; * @hide */ public class SoftInputWindow extends Dialog { + private static final boolean DEBUG = false; + private static final String TAG = "SoftInputWindow"; + final String mName; final Callback mCallback; final KeyEvent.Callback mKeyEventCallback; @@ -42,16 +52,65 @@ public class SoftInputWindow extends Dialog { final boolean mTakesFocus; private final Rect mBounds = new Rect(); + @Retention(SOURCE) + @IntDef(value = {SoftInputWindowState.TOKEN_PENDING, SoftInputWindowState.TOKEN_SET, + SoftInputWindowState.SHOWN_AT_LEAST_ONCE, SoftInputWindowState.REJECTED_AT_LEAST_ONCE}) + private @interface SoftInputWindowState { + /** + * The window token is not set yet. + */ + int TOKEN_PENDING = 0; + /** + * The window token was set, but the window is not shown yet. + */ + int TOKEN_SET = 1; + /** + * The window was shown at least once. + */ + int SHOWN_AT_LEAST_ONCE = 2; + /** + * {@link android.view.WindowManager.BadTokenException} was sent when calling + * {@link Dialog#show()} at least once. + */ + int REJECTED_AT_LEAST_ONCE = 3; + /** + * The window is considered destroyed. Any incoming request should be ignored. + */ + int DESTROYED = 4; + } + + @SoftInputWindowState + private int mWindowState = SoftInputWindowState.TOKEN_PENDING; + public interface Callback { public void onBackPressed(); } public void setToken(IBinder token) { - WindowManager.LayoutParams lp = getWindow().getAttributes(); - lp.token = token; - getWindow().setAttributes(lp); + switch (mWindowState) { + case SoftInputWindowState.TOKEN_PENDING: + // Normal scenario. Nothing to worry about. + WindowManager.LayoutParams lp = getWindow().getAttributes(); + lp.token = token; + getWindow().setAttributes(lp); + updateWindowState(SoftInputWindowState.TOKEN_SET); + return; + case SoftInputWindowState.TOKEN_SET: + case SoftInputWindowState.SHOWN_AT_LEAST_ONCE: + case SoftInputWindowState.REJECTED_AT_LEAST_ONCE: + throw new IllegalStateException("setToken can be called only once"); + case SoftInputWindowState.DESTROYED: + // Just ignore. Since there are multiple event queues from the token is issued + // in the system server to the timing when it arrives here, it can be delivered + // after the is already destroyed. No one should be blamed because of such an + // unfortunate but possible scenario. + Log.i(TAG, "Ignoring setToken() because window is already destroyed."); + return; + default: + throw new IllegalStateException("Unexpected state=" + mWindowState); + } } - + /** * Create a SoftInputWindow that uses a custom style. * @@ -190,4 +249,109 @@ public class SoftInputWindow extends Dialog { getWindow().setFlags(windowSetFlags, windowModFlags); } + + @Override + public final void show() { + switch (mWindowState) { + case SoftInputWindowState.TOKEN_PENDING: + throw new IllegalStateException("Window token is not set yet."); + case SoftInputWindowState.TOKEN_SET: + case SoftInputWindowState.SHOWN_AT_LEAST_ONCE: + // Normal scenario. Nothing to worry about. + try { + super.show(); + updateWindowState(SoftInputWindowState.SHOWN_AT_LEAST_ONCE); + } catch (WindowManager.BadTokenException e) { + // Just ignore this exception. Since show() can be requested from other + // components such as the system and there could be multiple event queues before + // the request finally arrives here, the system may have already invalidated the + // window token attached to our window. In such a scenario, receiving + // BadTokenException here is an expected behavior. We just ignore it and update + // the state so that we do not touch this window later. + Log.i(TAG, "Probably the IME window token is already invalidated." + + " show() does nothing."); + updateWindowState(SoftInputWindowState.REJECTED_AT_LEAST_ONCE); + } + return; + case SoftInputWindowState.REJECTED_AT_LEAST_ONCE: + // Just ignore. In general we cannot completely avoid this kind of race condition. + Log.i(TAG, "Not trying to call show() because it was already rejected once."); + return; + case SoftInputWindowState.DESTROYED: + // Just ignore. In general we cannot completely avoid this kind of race condition. + Log.i(TAG, "Ignoring show() because the window is already destroyed."); + return; + default: + throw new IllegalStateException("Unexpected state=" + mWindowState); + } + } + + final void dismissForDestroyIfNecessary() { + switch (mWindowState) { + case SoftInputWindowState.TOKEN_PENDING: + case SoftInputWindowState.TOKEN_SET: + // nothing to do because the window has never been shown. + updateWindowState(SoftInputWindowState.DESTROYED); + return; + case SoftInputWindowState.SHOWN_AT_LEAST_ONCE: + // Disable exit animation for the current IME window + // to avoid the race condition between the exit and enter animations + // when the current IME is being switched to another one. + try { + getWindow().setWindowAnimations(0); + dismiss(); + } catch (WindowManager.BadTokenException e) { + // Just ignore this exception. Since show() can be requested from other + // components such as the system and there could be multiple event queues before + // the request finally arrives here, the system may have already invalidated the + // window token attached to our window. In such a scenario, receiving + // BadTokenException here is an expected behavior. We just ignore it and update + // the state so that we do not touch this window later. + Log.i(TAG, "Probably the IME window token is already invalidated. " + + "No need to dismiss it."); + } + // Either way, consider that the window is destroyed. + updateWindowState(SoftInputWindowState.DESTROYED); + return; + case SoftInputWindowState.REJECTED_AT_LEAST_ONCE: + // Just ignore. In general we cannot completely avoid this kind of race condition. + Log.i(TAG, + "Not trying to dismiss the window because it is most likely unnecessary."); + // Anyway, consider that the window is destroyed. + updateWindowState(SoftInputWindowState.DESTROYED); + return; + case SoftInputWindowState.DESTROYED: + throw new IllegalStateException( + "dismissForDestroyIfNecessary can be called only once"); + default: + throw new IllegalStateException("Unexpected state=" + mWindowState); + } + } + + private void updateWindowState(@SoftInputWindowState int newState) { + if (DEBUG) { + if (mWindowState != newState) { + Log.d(TAG, "WindowState: " + stateToString(mWindowState) + " -> " + + stateToString(newState) + " @ " + Debug.getCaller()); + } + } + mWindowState = newState; + } + + private static String stateToString(@SoftInputWindowState int state) { + switch (state) { + case SoftInputWindowState.TOKEN_PENDING: + return "TOKEN_PENDING"; + case SoftInputWindowState.TOKEN_SET: + return "TOKEN_SET"; + case SoftInputWindowState.SHOWN_AT_LEAST_ONCE: + return "SHOWN_AT_LEAST_ONCE"; + case SoftInputWindowState.REJECTED_AT_LEAST_ONCE: + return "REJECTED_AT_LEAST_ONCE"; + case SoftInputWindowState.DESTROYED: + return "DESTROYED"; + default: + throw new IllegalStateException("Unknown state=" + state); + } + } } diff --git a/data/keyboards/Generic.kcm b/data/keyboards/Generic.kcm index d0565ca7e876..1ab4c6385ac1 100644 --- a/data/keyboards/Generic.kcm +++ b/data/keyboards/Generic.kcm @@ -540,7 +540,7 @@ key BUTTON_SELECT { } key BUTTON_MODE { - base: fallback MENU + base: fallback HOME } key BUTTON_1 { diff --git a/data/keyboards/Vendor_045e_Product_02e0.kl b/data/keyboards/Vendor_045e_Product_02e0.kl index 1012fb1eb28d..1dd8e157c5a7 100644 --- a/data/keyboards/Vendor_045e_Product_02e0.kl +++ b/data/keyboards/Vendor_045e_Product_02e0.kl @@ -56,4 +56,4 @@ key 0x136 BUTTON_SELECT key 0x137 BUTTON_START # Xbox key -key 0x8b HOME
\ No newline at end of file +key 0x8b BUTTON_MODE
\ No newline at end of file diff --git a/data/keyboards/Vendor_054c_Product_0268.kl b/data/keyboards/Vendor_054c_Product_0268.kl index 7c601373c2d0..522db3c9235e 100644 --- a/data/keyboards/Vendor_054c_Product_0268.kl +++ b/data/keyboards/Vendor_054c_Product_0268.kl @@ -35,7 +35,7 @@ key 0x121 BUTTON_THUMBL key 0x122 BUTTON_THUMBR # PS key -key 0x2d0 HOME +key 0x2d0 BUTTON_MODE # Left Analog Stick axis 0x00 X diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java index e8bc62298c47..047622222065 100644 --- a/media/java/android/media/AudioAttributes.java +++ b/media/java/android/media/AudioAttributes.java @@ -1035,7 +1035,7 @@ public final class AudioAttributes implements Parcelable { return fromGetVolumeControlStream ? AudioSystem.STREAM_SYSTEM : AudioSystem.STREAM_SYSTEM_ENFORCED; } - if ((aa.getFlags() & FLAG_SCO) == FLAG_SCO) { + if ((aa.getAllFlags() & FLAG_SCO) == FLAG_SCO) { return fromGetVolumeControlStream ? AudioSystem.STREAM_VOICE_CALL : AudioSystem.STREAM_BLUETOOTH_SCO; } diff --git a/packages/SettingsLib/src/com/android/settingslib/CustomDialogPreference.java b/packages/SettingsLib/src/com/android/settingslib/CustomDialogPreference.java index cf1c2c348367..3bade25b712a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/CustomDialogPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/CustomDialogPreference.java @@ -20,11 +20,12 @@ import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import androidx.preference.PreferenceDialogFragment; -import androidx.preference.DialogPreference; import android.util.AttributeSet; import android.view.View; +import androidx.preference.DialogPreference; +import androidx.preference.PreferenceDialogFragment; + public class CustomDialogPreference extends DialogPreference { private CustomPreferenceDialogFragment mFragment; diff --git a/packages/SettingsLib/src/com/android/settingslib/CustomEditTextPreference.java b/packages/SettingsLib/src/com/android/settingslib/CustomEditTextPreference.java index 04c39540cf27..dfaff6108c89 100644 --- a/packages/SettingsLib/src/com/android/settingslib/CustomEditTextPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/CustomEditTextPreference.java @@ -23,13 +23,14 @@ import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import androidx.annotation.CallSuper; -import androidx.preference.EditTextPreferenceDialogFragment; -import androidx.preference.EditTextPreference; import android.util.AttributeSet; import android.view.View; import android.widget.EditText; +import androidx.annotation.CallSuper; +import androidx.preference.EditTextPreference; +import androidx.preference.EditTextPreferenceDialogFragment; + public class CustomEditTextPreference extends EditTextPreference { private CustomPreferenceDialogFragment mFragment; diff --git a/packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java b/packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java index c98bc39fe574..bc5a2c05e379 100644 --- a/packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java @@ -16,6 +16,8 @@ package com.android.settingslib; +import static android.content.Context.TELEPHONY_SERVICE; + import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; @@ -30,6 +32,7 @@ import android.telephony.TelephonyManager; import android.text.TextUtils; import android.text.format.DateFormat; import android.util.Log; + import androidx.annotation.VisibleForTesting; import java.io.BufferedReader; @@ -43,8 +46,6 @@ import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static android.content.Context.TELEPHONY_SERVICE; - public class DeviceInfoUtils { private static final String TAG = "DeviceInfoUtils"; diff --git a/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java b/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java index 8055caaad536..4cbeb8a48f8f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java @@ -24,16 +24,15 @@ import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; -import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.net.Uri; import android.provider.Settings.Global; import android.text.TextUtils; import android.util.Log; -import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; import android.view.MenuItem.OnMenuItemClickListener; + import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java index 7f518c1d71d3..bd54edd80697 100644 --- a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java @@ -35,7 +35,6 @@ import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; -import androidx.annotation.VisibleForTesting; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; @@ -43,6 +42,8 @@ import android.text.style.ImageSpan; import android.view.MenuItem; import android.widget.TextView; +import androidx.annotation.VisibleForTesting; + import com.android.internal.widget.LockPatternUtils; import java.util.List; diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java index 79e011c6e7ed..ad7e995412aa 100644 --- a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java @@ -16,15 +16,16 @@ package com.android.settingslib; +import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; + import android.content.Context; import android.os.UserHandle; -import androidx.core.content.res.TypedArrayUtils; -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.view.View; -import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; +import androidx.core.content.res.TypedArrayUtils; +import androidx.preference.PreferenceManager; +import androidx.preference.PreferenceViewHolder; /** * Preference class that supports being disabled by a user restriction diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java index a930bb8373ba..4b84920e7884 100644 --- a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java +++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java @@ -16,19 +16,18 @@ package com.android.settingslib; +import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; + import android.content.Context; import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; import android.os.UserHandle; -import androidx.preference.Preference; -import androidx.preference.PreferenceViewHolder; import android.text.TextUtils; import android.util.AttributeSet; import android.util.TypedValue; -import android.view.View; import android.widget.TextView; -import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; /** * Helper class for managing settings preferences that can be disabled diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedSwitchPreference.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedSwitchPreference.java index fe6d9fe77b73..0ed507c46372 100644 --- a/packages/SettingsLib/src/com/android/settingslib/RestrictedSwitchPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedSwitchPreference.java @@ -21,15 +21,16 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import android.content.Context; import android.content.res.TypedArray; import android.os.UserHandle; -import androidx.preference.SwitchPreference; -import androidx.core.content.res.TypedArrayUtils; -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.util.TypedValue; import android.view.View; import android.widget.TextView; +import androidx.core.content.res.TypedArrayUtils; +import androidx.preference.PreferenceManager; +import androidx.preference.PreferenceViewHolder; +import androidx.preference.SwitchPreference; + /** * Version of SwitchPreference that can be disabled by a device admin * using a user restriction. diff --git a/packages/SettingsLib/src/com/android/settingslib/TetherUtil.java b/packages/SettingsLib/src/com/android/settingslib/TetherUtil.java index 535b2929563a..dc02f266b39a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/TetherUtil.java +++ b/packages/SettingsLib/src/com/android/settingslib/TetherUtil.java @@ -17,9 +17,10 @@ package com.android.settingslib; import android.content.Context; import android.os.SystemProperties; -import androidx.annotation.VisibleForTesting; import android.telephony.CarrierConfigManager; +import androidx.annotation.VisibleForTesting; + public class TetherUtil { @VisibleForTesting diff --git a/packages/SettingsLib/src/com/android/settingslib/TwoTargetPreference.java b/packages/SettingsLib/src/com/android/settingslib/TwoTargetPreference.java index 3a26f4649b64..02895a479352 100644 --- a/packages/SettingsLib/src/com/android/settingslib/TwoTargetPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/TwoTargetPreference.java @@ -18,13 +18,14 @@ package com.android.settingslib; import android.annotation.IntDef; import android.content.Context; -import androidx.preference.Preference; -import androidx.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java index df76125a99f2..efac6bc3572d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java @@ -19,15 +19,12 @@ package com.android.settingslib.animation; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.content.Context; import android.view.RenderNodeAnimator; import android.view.View; -import android.view.ViewPropertyAnimator; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; -import com.android.internal.widget.LockPatternView; import com.android.settingslib.R; /** diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java index a3c1fc6ff265..452f1fc8c624 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java @@ -22,9 +22,6 @@ import android.app.AppGlobals; import android.app.Application; import android.app.usage.StorageStats; import android.app.usage.StorageStatsManager; -import androidx.lifecycle.Lifecycle; -import androidx.lifecycle.LifecycleObserver; -import androidx.lifecycle.OnLifecycleEvent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -49,12 +46,16 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; -import androidx.annotation.VisibleForTesting; import android.text.format.Formatter; import android.util.IconDrawableFactory; import android.util.Log; import android.util.SparseArray; +import androidx.annotation.VisibleForTesting; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleObserver; +import androidx.lifecycle.OnLifecycleEvent; + import com.android.internal.R; import com.android.internal.util.ArrayUtils; diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/StorageStatsSource.java b/packages/SettingsLib/src/com/android/settingslib/applications/StorageStatsSource.java index b15f35ddc240..b457406dda03 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/StorageStatsSource.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/StorageStatsSource.java @@ -21,6 +21,7 @@ import android.app.usage.StorageStatsManager; import android.content.Context; import android.content.pm.PackageManager; import android.os.UserHandle; + import androidx.annotation.VisibleForTesting; import java.io.IOException; diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java index 04a7afa61c50..e96c44db695b 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java @@ -16,6 +16,7 @@ package com.android.settingslib.bluetooth; +import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHearingAid; @@ -28,7 +29,7 @@ import android.os.ParcelUuid; import android.os.SystemClock; import android.text.TextUtils; import android.util.Log; -import android.bluetooth.BluetoothAdapter; + import androidx.annotation.VisibleForTesting; import com.android.settingslib.R; diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java index e9d96ae0310f..b360faabcbb0 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java @@ -31,8 +31,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Objects; +import java.util.Set; /** * CachedBluetoothDeviceManager manages the set of remote Bluetooth devices. diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java index 4c21e61eb47b..1d2fda94deaa 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java @@ -16,23 +16,17 @@ package com.android.settingslib.bluetooth; -import android.bluetooth.BluetoothHearingAid; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; -import android.bluetooth.BluetoothCodecConfig; -import android.bluetooth.BluetoothCodecStatus; import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothHearingAid; import android.bluetooth.BluetoothProfile; -import android.bluetooth.BluetoothUuid; import android.content.Context; -import android.os.ParcelUuid; import android.util.Log; -import com.android.internal.annotations.VisibleForTesting; import com.android.settingslib.R; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class HearingAidProfile implements LocalBluetoothProfile { diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java index d0819098deb1..03f6afb39613 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java @@ -16,10 +16,10 @@ package com.android.settingslib.bluetooth; -import android.bluetooth.BluetoothHeadsetClient; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothHeadsetClient; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothUuid; import android.content.Context; diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidDeviceProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidDeviceProfile.java index 45ec4a1e554d..ca1eea522cd0 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidDeviceProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidDeviceProfile.java @@ -26,7 +26,6 @@ import android.util.Log; import com.android.settingslib.R; -import java.util.Collection; import java.util.List; /** diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java index 85c65cc4f398..08fbbedac19c 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java @@ -34,9 +34,12 @@ import android.bluetooth.BluetoothUuid; import android.content.Context; import android.content.Intent; import android.os.ParcelUuid; -import androidx.annotation.VisibleForTesting; import android.util.Log; + +import androidx.annotation.VisibleForTesting; + import com.android.internal.R; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/OppProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/OppProfile.java index e5c0b147f97b..dfd16224ef8f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/OppProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/OppProfile.java @@ -16,12 +16,12 @@ package com.android.settingslib.bluetooth; -import com.android.settingslib.R; - import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; +import com.android.settingslib.R; + /** * OppProfile handles Bluetooth OPP. */ diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java index b735c23e966f..bdbfc9df59dd 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java @@ -16,10 +16,10 @@ package com.android.settingslib.bluetooth; -import android.bluetooth.BluetoothPbapClient; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothPbapClient; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothUuid; import android.content.Context; diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java index 93e6be6559f6..2c455d5f4c32 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java @@ -19,8 +19,8 @@ package com.android.settingslib.bluetooth; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothSap; import android.bluetooth.BluetoothProfile; +import android.bluetooth.BluetoothSap; import android.bluetooth.BluetoothUuid; import android.content.Context; import android.os.ParcelUuid; diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/Utils.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/Utils.java index 26f3ab69ba37..bcb417c5e912 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/Utils.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/Utils.java @@ -5,9 +5,10 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.graphics.drawable.Drawable; -import androidx.annotation.DrawableRes; import android.util.Pair; +import androidx.annotation.DrawableRes; + import com.android.settingslib.R; import com.android.settingslib.graph.BluetoothDeviceLayerDrawable; diff --git a/packages/SettingsLib/src/com/android/settingslib/core/AbstractPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/core/AbstractPreferenceController.java index f4d647d61005..9572fb3c629d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/AbstractPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/AbstractPreferenceController.java @@ -1,6 +1,7 @@ package com.android.settingslib.core; import android.content.Context; + import androidx.preference.Preference; import androidx.preference.PreferenceGroup; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/EventLogWriter.java b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/EventLogWriter.java index 72273046ef29..78963f3e1bfa 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/EventLogWriter.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/EventLogWriter.java @@ -18,7 +18,6 @@ package com.android.settingslib.core.instrumentation; import android.content.Context; import android.metrics.LogMaker; -import android.util.Log; import android.util.Pair; import com.android.internal.logging.MetricsLogger; diff --git a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/SharedPreferencesLogger.java b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/SharedPreferencesLogger.java index a79f125d4c99..a28e45ce08f7 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/SharedPreferencesLogger.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/SharedPreferencesLogger.java @@ -20,11 +20,12 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.AsyncTask; -import androidx.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Log; import android.util.Pair; +import androidx.annotation.VisibleForTesting; + import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import java.util.Map; diff --git a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/VisibilityLoggerMixin.java b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/VisibilityLoggerMixin.java index cb1ca59d2f43..06d7c4d9cbc3 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/VisibilityLoggerMixin.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/VisibilityLoggerMixin.java @@ -16,17 +16,18 @@ package com.android.settingslib.core.instrumentation; +import static com.android.settingslib.core.instrumentation.Instrumentable.METRICS_CATEGORY_UNKNOWN; + import android.app.Activity; +import android.content.Intent; +import android.os.SystemClock; + import androidx.lifecycle.Lifecycle.Event; import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.OnLifecycleEvent; -import android.content.Intent; -import android.os.SystemClock; import com.android.internal.logging.nano.MetricsProto; -import static com.android.settingslib.core.instrumentation.Instrumentable.METRICS_CATEGORY_UNKNOWN; - /** * Logs visibility change of a fragment. */ diff --git a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/Lifecycle.java b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/Lifecycle.java index 7ec757a56217..56de280a0049 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/Lifecycle.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/Lifecycle.java @@ -18,19 +18,20 @@ package com.android.settingslib.core.lifecycle; import static androidx.lifecycle.Lifecycle.Event.ON_ANY; import android.annotation.UiThread; -import androidx.lifecycle.LifecycleOwner; -import androidx.lifecycle.LifecycleRegistry; -import androidx.lifecycle.OnLifecycleEvent; import android.content.Context; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.preference.PreferenceScreen; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.lifecycle.LifecycleOwner; +import androidx.lifecycle.LifecycleRegistry; +import androidx.lifecycle.OnLifecycleEvent; +import androidx.preference.PreferenceScreen; + import com.android.settingslib.core.lifecycle.events.OnAttach; import com.android.settingslib.core.lifecycle.events.OnCreate; import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu; diff --git a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableActivity.java b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableActivity.java index f9aa062b64da..a3b4a08eafa8 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableActivity.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableActivity.java @@ -24,12 +24,13 @@ import static androidx.lifecycle.Lifecycle.Event.ON_STOP; import android.annotation.Nullable; import android.app.Activity; -import androidx.lifecycle.LifecycleOwner; import android.os.Bundle; import android.os.PersistableBundle; import android.view.Menu; import android.view.MenuItem; +import androidx.lifecycle.LifecycleOwner; + /** * {@link Activity} that has hooks to observe activity lifecycle events. */ diff --git a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableDialogFragment.java b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableDialogFragment.java index 972e062bb396..03727d6ba6de 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableDialogFragment.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableDialogFragment.java @@ -23,13 +23,14 @@ import static androidx.lifecycle.Lifecycle.Event.ON_START; import static androidx.lifecycle.Lifecycle.Event.ON_STOP; import android.app.DialogFragment; -import androidx.lifecycle.LifecycleOwner; import android.content.Context; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import androidx.lifecycle.LifecycleOwner; + /** * {@link DialogFragment} that has hooks to observe fragment lifecycle events. */ diff --git a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableFragment.java b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableFragment.java index 55597cc1247a..db3f8e860903 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableFragment.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservableFragment.java @@ -25,13 +25,14 @@ import static androidx.lifecycle.Lifecycle.Event.ON_STOP; import android.annotation.CallSuper; import android.app.Fragment; -import androidx.lifecycle.LifecycleOwner; import android.content.Context; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import androidx.lifecycle.LifecycleOwner; + public class ObservableFragment extends Fragment implements LifecycleOwner { private final Lifecycle mLifecycle = new Lifecycle(this); diff --git a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java index 904681c4aa3c..3f3a02b1c16e 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java @@ -24,15 +24,16 @@ import static androidx.lifecycle.Lifecycle.Event.ON_START; import static androidx.lifecycle.Lifecycle.Event.ON_STOP; import android.annotation.CallSuper; -import androidx.lifecycle.LifecycleOwner; import android.content.Context; import android.os.Bundle; -import androidx.preference.PreferenceFragment; -import androidx.preference.PreferenceScreen; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import androidx.lifecycle.LifecycleOwner; +import androidx.preference.PreferenceFragment; +import androidx.preference.PreferenceScreen; + /** * {@link PreferenceFragment} that has hooks to observe fragment lifecycle events. */ diff --git a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/events/OnCreate.java b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/events/OnCreate.java index ada1537250b6..4f6d00157b72 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/events/OnCreate.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/events/OnCreate.java @@ -16,9 +16,10 @@ package com.android.settingslib.core.lifecycle.events; +import android.os.Bundle; + import androidx.lifecycle.Lifecycle; import androidx.lifecycle.OnLifecycleEvent; -import android.os.Bundle; /** * @deprecated use {@link OnLifecycleEvent(Lifecycle.Event) } diff --git a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/events/OnPrepareOptionsMenu.java b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/events/OnPrepareOptionsMenu.java index b9f13713c59f..92ae9fdd50a9 100644 --- a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/events/OnPrepareOptionsMenu.java +++ b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/events/OnPrepareOptionsMenu.java @@ -17,7 +17,6 @@ package com.android.settingslib.core.lifecycle.events; import android.view.Menu; -import android.view.MenuInflater; public interface OnPrepareOptionsMenu { void onPrepareOptionsMenu(Menu menu); diff --git a/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java b/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java index 955f64a357dc..7e165d09ec64 100644 --- a/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java +++ b/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java @@ -20,9 +20,6 @@ import android.content.Context; import android.content.res.XmlResourceParser; import android.icu.text.TimeZoneFormat; import android.icu.text.TimeZoneNames; -import androidx.annotation.VisibleForTesting; -import androidx.core.text.BidiFormatter; -import androidx.core.text.TextDirectionHeuristicsCompat; import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.TextUtils; @@ -31,6 +28,10 @@ import android.text.style.TtsSpan; import android.util.Log; import android.view.View; +import androidx.annotation.VisibleForTesting; +import androidx.core.text.BidiFormatter; +import androidx.core.text.TextDirectionHeuristicsCompat; + import com.android.settingslib.R; import libcore.util.TimeZoneFinder; diff --git a/packages/SettingsLib/src/com/android/settingslib/development/AbstractEnableAdbPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/development/AbstractEnableAdbPreferenceController.java index a2ae9031d7b3..6076dd30f0bd 100644 --- a/packages/SettingsLib/src/com/android/settingslib/development/AbstractEnableAdbPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/development/AbstractEnableAdbPreferenceController.java @@ -22,13 +22,14 @@ import android.content.Context; import android.content.Intent; import android.os.UserManager; import android.provider.Settings; +import android.text.TextUtils; + import androidx.annotation.VisibleForTesting; -import androidx.preference.SwitchPreference; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; +import androidx.preference.SwitchPreference; import androidx.preference.TwoStatePreference; -import android.text.TextUtils; import com.android.settingslib.core.ConfirmationDialogController; diff --git a/packages/SettingsLib/src/com/android/settingslib/development/AbstractLogdSizePreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/development/AbstractLogdSizePreferenceController.java index e2f6b7b87560..5a823976cd0e 100644 --- a/packages/SettingsLib/src/com/android/settingslib/development/AbstractLogdSizePreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/development/AbstractLogdSizePreferenceController.java @@ -19,6 +19,7 @@ package com.android.settingslib.development; import android.content.Context; import android.content.Intent; import android.os.SystemProperties; + import androidx.annotation.VisibleForTesting; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.ListPreference; diff --git a/packages/SettingsLib/src/com/android/settingslib/development/AbstractLogpersistPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/development/AbstractLogpersistPreferenceController.java index f277c16a1e2c..87226746668e 100644 --- a/packages/SettingsLib/src/com/android/settingslib/development/AbstractLogpersistPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/development/AbstractLogpersistPreferenceController.java @@ -22,12 +22,13 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.SystemProperties; +import android.text.TextUtils; + import androidx.annotation.VisibleForTesting; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; -import android.text.TextUtils; import com.android.settingslib.R; import com.android.settingslib.core.ConfirmationDialogController; diff --git a/packages/SettingsLib/src/com/android/settingslib/development/DeveloperOptionsPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/development/DeveloperOptionsPreferenceController.java index 15d5522bbd7b..f757aa4e4dab 100644 --- a/packages/SettingsLib/src/com/android/settingslib/development/DeveloperOptionsPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/development/DeveloperOptionsPreferenceController.java @@ -17,6 +17,7 @@ package com.android.settingslib.development; import android.content.Context; + import androidx.preference.Preference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/src/com/android/settingslib/development/DevelopmentSettingsEnabler.java b/packages/SettingsLib/src/com/android/settingslib/development/DevelopmentSettingsEnabler.java index 8d186032bfef..7f1f185615a1 100644 --- a/packages/SettingsLib/src/com/android/settingslib/development/DevelopmentSettingsEnabler.java +++ b/packages/SettingsLib/src/com/android/settingslib/development/DevelopmentSettingsEnabler.java @@ -21,6 +21,7 @@ import android.content.Intent; import android.os.Build; import android.os.UserManager; import android.provider.Settings; + import androidx.localbroadcastmanager.content.LocalBroadcastManager; public class DevelopmentSettingsEnabler { diff --git a/packages/SettingsLib/src/com/android/settingslib/development/SystemPropPoker.java b/packages/SettingsLib/src/com/android/settingslib/development/SystemPropPoker.java index dba22d0c6af3..3f16be184c41 100644 --- a/packages/SettingsLib/src/com/android/settingslib/development/SystemPropPoker.java +++ b/packages/SettingsLib/src/com/android/settingslib/development/SystemPropPoker.java @@ -21,9 +21,10 @@ import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; import android.os.ServiceManager; +import android.util.Log; + import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; -import android.util.Log; public class SystemPropPoker { private static final String TAG = "SystemPropPoker"; diff --git a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractBluetoothAddressPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractBluetoothAddressPreferenceController.java index 821b4d5da049..745591235dbb 100644 --- a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractBluetoothAddressPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractBluetoothAddressPreferenceController.java @@ -19,10 +19,11 @@ package com.android.settingslib.deviceinfo; import android.annotation.SuppressLint; import android.bluetooth.BluetoothAdapter; import android.content.Context; +import android.text.TextUtils; + import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; -import android.text.TextUtils; import com.android.settingslib.R; import com.android.settingslib.core.lifecycle.Lifecycle; diff --git a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractImsStatusPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractImsStatusPreferenceController.java index 10260de289d3..a5f403690dab 100644 --- a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractImsStatusPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractImsStatusPreferenceController.java @@ -21,13 +21,14 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; import android.os.PersistableBundle; -import androidx.annotation.VisibleForTesting; -import androidx.preference.Preference; -import androidx.preference.PreferenceScreen; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; +import androidx.annotation.VisibleForTesting; +import androidx.preference.Preference; +import androidx.preference.PreferenceScreen; + import com.android.settingslib.R; import com.android.settingslib.core.lifecycle.Lifecycle; diff --git a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractIpAddressPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractIpAddressPreferenceController.java index 45cd86667f1e..24da72ea611a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractIpAddressPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractIpAddressPreferenceController.java @@ -20,6 +20,7 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.LinkProperties; import android.net.wifi.WifiManager; + import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractSerialNumberPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractSerialNumberPreferenceController.java index 60b29fb8682f..d28792ef30de 100644 --- a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractSerialNumberPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractSerialNumberPreferenceController.java @@ -18,10 +18,11 @@ package com.android.settingslib.deviceinfo; import android.content.Context; import android.os.Build; +import android.text.TextUtils; + import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; -import android.text.TextUtils; import com.android.settingslib.core.AbstractPreferenceController; diff --git a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractUptimePreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractUptimePreferenceController.java index 332a2a463b74..4045b81cc07c 100644 --- a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractUptimePreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractUptimePreferenceController.java @@ -20,10 +20,11 @@ import android.content.Context; import android.os.Handler; import android.os.Message; import android.os.SystemClock; +import android.text.format.DateUtils; + import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; -import android.text.format.DateUtils; import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.lifecycle.Lifecycle; diff --git a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractWifiMacAddressPreferenceController.java b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractWifiMacAddressPreferenceController.java index 89d259507d8a..c209f232b39e 100644 --- a/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractWifiMacAddressPreferenceController.java +++ b/packages/SettingsLib/src/com/android/settingslib/deviceinfo/AbstractWifiMacAddressPreferenceController.java @@ -22,10 +22,11 @@ import android.net.ConnectivityManager; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.provider.Settings; +import android.text.TextUtils; + import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; -import android.text.TextUtils; import com.android.settingslib.R; import com.android.settingslib.core.lifecycle.Lifecycle; diff --git a/packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java b/packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java index af8fd4c46a64..e0ca1ab0c07c 100644 --- a/packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/display/DisplayDensityUtils.java @@ -16,11 +16,8 @@ package com.android.settingslib.display; -import com.android.settingslib.R; - import android.content.Context; import android.content.res.Resources; -import android.hardware.display.DisplayManager; import android.os.AsyncTask; import android.os.RemoteException; import android.os.UserHandle; @@ -31,6 +28,8 @@ import android.view.Display; import android.view.IWindowManager; import android.view.WindowManagerGlobal; +import com.android.settingslib.R; + import java.util.Arrays; /** diff --git a/packages/SettingsLib/src/com/android/settingslib/drawer/CategoryManager.java b/packages/SettingsLib/src/com/android/settingslib/drawer/CategoryManager.java index d9605367dc56..a980e4f5bb22 100644 --- a/packages/SettingsLib/src/com/android/settingslib/drawer/CategoryManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/drawer/CategoryManager.java @@ -17,12 +17,13 @@ package com.android.settingslib.drawer; import android.content.ComponentName; import android.content.Context; -import androidx.annotation.VisibleForTesting; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; import android.util.Pair; +import androidx.annotation.VisibleForTesting; + import com.android.settingslib.applications.InterestingConfigChanges; import java.util.ArrayList; @@ -32,8 +33,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import static java.lang.String.CASE_INSENSITIVE_ORDER; - public class CategoryManager { private static final String TAG = "CategoryManager"; diff --git a/packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java b/packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java index 8a09df2849c9..a1f314d92b3a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java +++ b/packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java @@ -17,7 +17,6 @@ package com.android.settingslib.drawer; import android.app.ActivityManager; - import android.content.Context; import android.content.pm.UserInfo; import android.database.DataSetObserver; @@ -32,10 +31,10 @@ import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.SpinnerAdapter; import android.widget.TextView; -import com.android.internal.util.UserIcons; -import com.android.settingslib.drawable.UserIconDrawable; +import com.android.internal.util.UserIcons; import com.android.settingslib.R; +import com.android.settingslib.drawable.UserIconDrawable; import java.util.ArrayList; import java.util.List; diff --git a/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java b/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java index 988060eac64d..5db5f526f10c 100644 --- a/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java +++ b/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java @@ -36,12 +36,12 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Xml; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; diff --git a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerWhitelistBackend.java b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerWhitelistBackend.java index 134b3cf57876..dc9e4586fe2c 100644 --- a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerWhitelistBackend.java +++ b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerWhitelistBackend.java @@ -22,12 +22,13 @@ import android.content.pm.PackageManager; import android.os.IDeviceIdleController; import android.os.RemoteException; import android.os.ServiceManager; -import androidx.annotation.VisibleForTesting; import android.telecom.DefaultDialerManager; import android.text.TextUtils; import android.util.ArraySet; import android.util.Log; +import androidx.annotation.VisibleForTesting; + import com.android.internal.telephony.SmsApplication; import com.android.internal.util.ArrayUtils; diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java b/packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java index 17523013a94f..a7c7d52a8d7e 100644 --- a/packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java +++ b/packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java @@ -19,18 +19,13 @@ package com.android.settingslib.graph; import android.annotation.NonNull; import android.content.Context; import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Matrix; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; -import android.graphics.Rect; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; -import androidx.annotation.VisibleForTesting; import android.view.Gravity; -import android.view.View; + +import androidx.annotation.VisibleForTesting; import com.android.settingslib.R; import com.android.settingslib.Utils; diff --git a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodAndSubtypeEnablerManager.java b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodAndSubtypeEnablerManager.java index 628e70af8318..117b48ff852d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodAndSubtypeEnablerManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodAndSubtypeEnablerManager.java @@ -19,16 +19,17 @@ package com.android.settingslib.inputmethod; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Configuration; -import androidx.preference.PreferenceFragment; -import androidx.preference.Preference; -import androidx.preference.PreferenceCategory; -import androidx.preference.PreferenceScreen; -import androidx.preference.TwoStatePreference; import android.text.TextUtils; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; +import androidx.preference.Preference; +import androidx.preference.PreferenceCategory; +import androidx.preference.PreferenceFragment; +import androidx.preference.PreferenceScreen; +import androidx.preference.TwoStatePreference; + import com.android.settingslib.R; import java.text.Collator; diff --git a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodAndSubtypeUtil.java b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodAndSubtypeUtil.java index 0a5c28c7b127..4691c4c10d8e 100644 --- a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodAndSubtypeUtil.java +++ b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodAndSubtypeUtil.java @@ -25,15 +25,16 @@ import android.content.res.Configuration; import android.icu.text.ListFormatter; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; -import androidx.preference.PreferenceFragment; -import androidx.preference.Preference; -import androidx.preference.PreferenceScreen; -import androidx.preference.TwoStatePreference; import android.text.TextUtils; import android.util.Log; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; +import androidx.preference.Preference; +import androidx.preference.PreferenceFragment; +import androidx.preference.PreferenceScreen; +import androidx.preference.TwoStatePreference; + import com.android.internal.app.LocaleHelper; import com.android.internal.inputmethod.InputMethodUtils; diff --git a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodPreference.java b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodPreference.java index 2e34dc5cac83..3d7bb507ae91 100644 --- a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodPreference.java @@ -24,9 +24,6 @@ import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.os.UserHandle; -import androidx.preference.Preference; -import androidx.preference.Preference.OnPreferenceChangeListener; -import androidx.preference.Preference.OnPreferenceClickListener; import android.text.TextUtils; import android.util.Log; import android.view.inputmethod.InputMethodInfo; @@ -34,6 +31,10 @@ import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; import android.widget.Toast; +import androidx.preference.Preference; +import androidx.preference.Preference.OnPreferenceChangeListener; +import androidx.preference.Preference.OnPreferenceClickListener; + import com.android.internal.annotations.VisibleForTesting; import com.android.internal.inputmethod.InputMethodUtils; import com.android.settingslib.R; diff --git a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodSubtypePreference.java b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodSubtypePreference.java index a0b1df25baf6..f261d29fd0f3 100644 --- a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodSubtypePreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodSubtypePreference.java @@ -17,11 +17,12 @@ package com.android.settingslib.inputmethod; import android.content.Context; -import androidx.preference.Preference; import android.text.TextUtils; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; +import androidx.preference.Preference; + import com.android.internal.annotations.VisibleForTesting; import com.android.internal.inputmethod.InputMethodUtils; diff --git a/packages/SettingsLib/src/com/android/settingslib/inputmethod/SwitchWithNoTextPreference.java b/packages/SettingsLib/src/com/android/settingslib/inputmethod/SwitchWithNoTextPreference.java index 2b38697a65ce..2360298822ba 100644 --- a/packages/SettingsLib/src/com/android/settingslib/inputmethod/SwitchWithNoTextPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/inputmethod/SwitchWithNoTextPreference.java @@ -17,6 +17,7 @@ package com.android.settingslib.inputmethod; import android.content.Context; + import androidx.preference.SwitchPreference; public class SwitchWithNoTextPreference extends SwitchPreference { diff --git a/packages/SettingsLib/src/com/android/settingslib/license/LicenseHtmlGeneratorFromXml.java b/packages/SettingsLib/src/com/android/settingslib/license/LicenseHtmlGeneratorFromXml.java index 444c19c94c9f..42306f6d46d0 100644 --- a/packages/SettingsLib/src/com/android/settingslib/license/LicenseHtmlGeneratorFromXml.java +++ b/packages/SettingsLib/src/com/android/settingslib/license/LicenseHtmlGeneratorFromXml.java @@ -16,11 +16,12 @@ package com.android.settingslib.license; -import androidx.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Log; import android.util.Xml; +import androidx.annotation.VisibleForTesting; + import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; diff --git a/packages/SettingsLib/src/com/android/settingslib/license/LicenseHtmlLoader.java b/packages/SettingsLib/src/com/android/settingslib/license/LicenseHtmlLoader.java index 307b025107d6..2aaea657d29f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/license/LicenseHtmlLoader.java +++ b/packages/SettingsLib/src/com/android/settingslib/license/LicenseHtmlLoader.java @@ -17,9 +17,10 @@ package com.android.settingslib.license; import android.content.Context; -import androidx.annotation.VisibleForTesting; import android.util.Log; +import androidx.annotation.VisibleForTesting; + import com.android.settingslib.utils.AsyncLoader; import java.io.File; diff --git a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java index 96bed93165fb..b8e1251dd79a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java +++ b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java @@ -25,10 +25,12 @@ import android.graphics.drawable.Drawable; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; -import androidx.annotation.VisibleForTesting; import android.text.format.DateUtils; import android.util.IconDrawableFactory; import android.util.Log; + +import androidx.annotation.VisibleForTesting; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; diff --git a/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java b/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java index 224b9679a9a2..c14f5588cddf 100644 --- a/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java +++ b/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java @@ -28,9 +28,9 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; import android.net.TrafficStats; -import android.os.UserManager; -import android.os.UserHandle; import android.os.RemoteException; +import android.os.UserHandle; +import android.os.UserManager; import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java b/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java index 6da486ab3aa8..027860ca2a46 100644 --- a/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java +++ b/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java @@ -24,7 +24,6 @@ import android.content.DialogInterface; import android.provider.Settings; import android.service.notification.Condition; import android.service.notification.ZenModeConfig; -import androidx.annotation.VisibleForTesting; import android.view.LayoutInflater; import android.view.View; import android.widget.CompoundButton; @@ -35,6 +34,8 @@ import android.widget.RadioGroup; import android.widget.ScrollView; import android.widget.TextView; +import androidx.annotation.VisibleForTesting; + import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto; import com.android.internal.policy.PhoneWindow; diff --git a/packages/SettingsLib/src/com/android/settingslib/suggestions/SuggestionController.java b/packages/SettingsLib/src/com/android/settingslib/suggestions/SuggestionController.java index 6a8b01a23688..ec774872ce67 100644 --- a/packages/SettingsLib/src/com/android/settingslib/suggestions/SuggestionController.java +++ b/packages/SettingsLib/src/com/android/settingslib/suggestions/SuggestionController.java @@ -24,9 +24,10 @@ import android.os.IBinder; import android.os.RemoteException; import android.service.settings.suggestions.ISuggestionService; import android.service.settings.suggestions.Suggestion; +import android.util.Log; + import androidx.annotation.Nullable; import androidx.annotation.WorkerThread; -import android.util.Log; import java.util.List; diff --git a/packages/SettingsLib/src/com/android/settingslib/suggestions/SuggestionControllerMixin.java b/packages/SettingsLib/src/com/android/settingslib/suggestions/SuggestionControllerMixin.java index ee8b6fe60478..6597daa9acaf 100644 --- a/packages/SettingsLib/src/com/android/settingslib/suggestions/SuggestionControllerMixin.java +++ b/packages/SettingsLib/src/com/android/settingslib/suggestions/SuggestionControllerMixin.java @@ -17,15 +17,16 @@ package com.android.settingslib.suggestions; import android.app.LoaderManager; -import androidx.lifecycle.OnLifecycleEvent; import android.content.ComponentName; import android.content.Context; import android.content.Loader; import android.os.Bundle; import android.service.settings.suggestions.Suggestion; -import androidx.annotation.Nullable; import android.util.Log; +import androidx.annotation.Nullable; +import androidx.lifecycle.OnLifecycleEvent; + import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.List; diff --git a/packages/SettingsLib/src/com/android/settingslib/users/AppRestrictionsHelper.java b/packages/SettingsLib/src/com/android/settingslib/users/AppRestrictionsHelper.java index 7cdbe719df78..9451b3620418 100644 --- a/packages/SettingsLib/src/com/android/settingslib/users/AppRestrictionsHelper.java +++ b/packages/SettingsLib/src/com/android/settingslib/users/AppRestrictionsHelper.java @@ -31,12 +31,13 @@ import android.graphics.drawable.Drawable; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; -import androidx.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Log; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; +import androidx.annotation.VisibleForTesting; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; diff --git a/packages/SettingsLib/src/com/android/settingslib/utils/IconCache.java b/packages/SettingsLib/src/com/android/settingslib/utils/IconCache.java index f0548ff7a923..c8c8ac22089a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/utils/IconCache.java +++ b/packages/SettingsLib/src/com/android/settingslib/utils/IconCache.java @@ -19,6 +19,7 @@ package com.android.settingslib.utils; import android.content.Context; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; + import androidx.annotation.VisibleForTesting; import androidx.collection.ArrayMap; diff --git a/packages/SettingsLib/src/com/android/settingslib/utils/PowerUtil.java b/packages/SettingsLib/src/com/android/settingslib/utils/PowerUtil.java index e16da84ce713..fa59688d1523 100644 --- a/packages/SettingsLib/src/com/android/settingslib/utils/PowerUtil.java +++ b/packages/SettingsLib/src/com/android/settingslib/utils/PowerUtil.java @@ -22,9 +22,10 @@ import android.icu.text.MeasureFormat; import android.icu.text.MeasureFormat.FormatWidth; import android.icu.util.Measure; import android.icu.util.MeasureUnit; -import androidx.annotation.Nullable; import android.text.TextUtils; +import androidx.annotation.Nullable; + import com.android.settingslib.R; import java.time.Instant; diff --git a/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java b/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java index 87a56c7548d2..f02044dc52e0 100644 --- a/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreference.java @@ -17,13 +17,14 @@ package com.android.settingslib.widget; import android.content.Context; -import androidx.core.content.res.TypedArrayUtils; -import androidx.preference.Preference; -import androidx.preference.PreferenceViewHolder; import android.text.method.LinkMovementMethod; import android.util.AttributeSet; import android.widget.TextView; +import androidx.core.content.res.TypedArrayUtils; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; + import com.android.settingslib.R; /** diff --git a/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreferenceMixin.java b/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreferenceMixin.java index 5883754fa2ed..2987c1597193 100644 --- a/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreferenceMixin.java +++ b/packages/SettingsLib/src/com/android/settingslib/widget/FooterPreferenceMixin.java @@ -17,6 +17,7 @@ package com.android.settingslib.widget; import android.content.Context; + import androidx.preference.PreferenceFragment; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java index b9c76013b0d7..d62605dd3362 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java @@ -48,7 +48,6 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; -import androidx.annotation.NonNull; import android.text.Spannable; import android.text.SpannableString; import android.text.TextUtils; @@ -56,6 +55,8 @@ import android.text.style.TtsSpan; import android.util.ArraySet; import android.util.Log; +import androidx.annotation.NonNull; + import com.android.internal.annotations.VisibleForTesting; import com.android.settingslib.R; import com.android.settingslib.utils.ThreadUtils; diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java index b07dd8f18354..468b6753c311 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java @@ -25,9 +25,6 @@ import android.graphics.drawable.StateListDrawable; import android.net.wifi.WifiConfiguration; import android.os.Looper; import android.os.UserHandle; -import androidx.annotation.VisibleForTesting; -import androidx.preference.Preference; -import androidx.preference.PreferenceViewHolder; import android.text.TextUtils; import android.util.AttributeSet; import android.util.SparseArray; @@ -35,9 +32,12 @@ import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.VisibleForTesting; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; + import com.android.settingslib.R; import com.android.settingslib.TronUtils; -import com.android.settingslib.TwoTargetPreference; import com.android.settingslib.Utils; import com.android.settingslib.wifi.AccessPoint.Speed; diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/TestAccessPointBuilder.java b/packages/SettingsLib/src/com/android/settingslib/wifi/TestAccessPointBuilder.java index 5862e6f19e16..afea5d2078b0 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/TestAccessPointBuilder.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/TestAccessPointBuilder.java @@ -24,6 +24,7 @@ import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; import android.os.Bundle; import android.os.Parcelable; + import androidx.annotation.Keep; import com.android.settingslib.wifi.AccessPoint.Speed; diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java index 6211d1214fcc..9050b4b0a15b 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java @@ -41,15 +41,16 @@ import android.os.Message; import android.os.Process; import android.os.SystemClock; import android.provider.Settings; -import androidx.annotation.GuardedBy; -import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; import android.text.format.DateUtils; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; import android.widget.Toast; +import androidx.annotation.GuardedBy; +import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; + import com.android.settingslib.R; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.LifecycleObserver; diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTrackerFactory.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTrackerFactory.java index e73d952cd645..93e4fce6e74b 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTrackerFactory.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTrackerFactory.java @@ -16,6 +16,7 @@ package com.android.settingslib.wifi; import android.content.Context; + import androidx.annotation.Keep; import androidx.annotation.NonNull; diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java index 4792317c9f1e..4e6c005457c0 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java @@ -21,6 +21,7 @@ import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; import android.os.SystemClock; + import androidx.annotation.VisibleForTesting; import com.android.settingslib.R; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/HelpUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/HelpUtilsTest.java index e153c3ed1edf..12aee6f813fb 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/HelpUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/HelpUtilsTest.java @@ -17,6 +17,7 @@ package com.android.settingslib; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.mock; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/RestrictedLockUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/RestrictedLockUtilsTest.java index 710dbc221f07..bf49ef3615ba 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/RestrictedLockUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/RestrictedLockUtilsTest.java @@ -20,8 +20,11 @@ import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NO import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT; import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_REMOTE_INPUT; import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS; + import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; + import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/RestrictedPreferenceHelperTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/RestrictedPreferenceHelperTest.java index f00ae0b08019..79d682d67a4a 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/RestrictedPreferenceHelperTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/RestrictedPreferenceHelperTest.java @@ -24,11 +24,12 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; -import androidx.preference.Preference; -import androidx.preference.PreferenceViewHolder; import android.view.View; import android.widget.TextView; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TetherUtilTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TetherUtilTest.java index 0109f48e0c5d..69193b77565e 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TetherUtilTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TetherUtilTest.java @@ -17,6 +17,7 @@ package com.android.settingslib; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Mockito.when; import android.content.Context; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TwoTargetPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TwoTargetPreferenceTest.java index efd7de351ebe..c0b69f2260eb 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TwoTargetPreferenceTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TwoTargetPreferenceTest.java @@ -19,16 +19,19 @@ package com.android.settingslib; import static com.android.settingslib.TwoTargetPreference.ICON_SIZE_DEFAULT; import static com.android.settingslib.TwoTargetPreference.ICON_SIZE_MEDIUM; import static com.android.settingslib.TwoTargetPreference.ICON_SIZE_SMALL; + import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import android.content.Context; -import androidx.preference.PreferenceViewHolder; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; +import androidx.preference.PreferenceViewHolder; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java index 09a2bd299c0b..967d4520303c 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java @@ -20,6 +20,7 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS; import static com.android.settingslib.Utils.STORAGE_MANAGER_SHOW_OPT_IN_PROPERTY; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java index 2dbabe0b76cc..19ce424257ac 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java @@ -25,7 +25,6 @@ import static org.robolectric.shadow.api.Shadow.extract; import android.annotation.UserIdInt; import android.app.ApplicationPackageManager; -import android.app.usage.IStorageStatsManager; import android.app.usage.StorageStats; import android.app.usage.StorageStatsManager; import android.content.ComponentName; @@ -42,10 +41,10 @@ import android.os.Handler; import android.os.UserHandle; import android.util.IconDrawableFactory; +import com.android.settingslib.SettingsLibRobolectricTestRunner; import com.android.settingslib.applications.ApplicationsState.AppEntry; import com.android.settingslib.applications.ApplicationsState.Callbacks; import com.android.settingslib.applications.ApplicationsState.Session; -import com.android.settingslib.SettingsLibRobolectricTestRunner; import com.android.settingslib.testutils.shadow.ShadowUserManager; import org.junit.Before; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/DefaultAppInfoTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/DefaultAppInfoTest.java index 6a161d0a645c..815cb3a2f828 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/DefaultAppInfoTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/DefaultAppInfoTest.java @@ -41,7 +41,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; @RunWith(SettingsLibRobolectricTestRunner.class) public class DefaultAppInfoTest { diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ServiceListingTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ServiceListingTest.java index 060b716bb435..d8c459c07b75 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ServiceListingTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ServiceListingTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.applications; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java index ef13a5faa11c..afd738ea307d 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java @@ -16,6 +16,7 @@ package com.android.settingslib.bluetooth; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java index 108069022567..26230bd1e891 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java @@ -15,15 +15,12 @@ */ package com.android.settingslib.bluetooth; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.verify; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; - import android.telephony.TelephonyManager; import org.junit.Before; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java index 16ed85cf5afa..6d6a13284a80 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java @@ -17,12 +17,8 @@ package com.android.settingslib.bluetooth; import static com.google.common.truth.Truth.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.bluetooth.BluetoothAdapter; @@ -31,8 +27,6 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.content.Context; -import com.android.settingslib.R; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -40,7 +34,6 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; import java.util.Collection; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java index d342bc878477..ca997bf8d27f 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java @@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -37,9 +36,6 @@ import android.content.Context; import android.content.Intent; import android.os.ParcelUuid; -import java.util.ArrayList; -import java.util.List; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -49,6 +45,9 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; +import java.util.ArrayList; +import java.util.List; + @RunWith(RobolectricTestRunner.class) @Config(resourceDir = "../../res") public class LocalBluetoothProfileManagerTest { diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/AbstractPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/AbstractPreferenceControllerTest.java index 5261ea0c88bb..28de1914838f 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/AbstractPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/AbstractPreferenceControllerTest.java @@ -16,9 +16,11 @@ package com.android.settingslib.core; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Mockito.when; import android.content.Context; + import androidx.preference.Preference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java index 5c19e61d44dc..f4fd77930506 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java @@ -16,6 +16,7 @@ package com.android.settingslib.core.instrumentation; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/SharedPreferenceLoggerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/SharedPreferenceLoggerTest.java index 017d37388340..be671e6d4e22 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/SharedPreferenceLoggerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/SharedPreferenceLoggerTest.java @@ -15,10 +15,15 @@ */ package com.android.settingslib.core.instrumentation; -import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_SETTINGS_PREFERENCE_CHANGE; -import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_FLOAT_VALUE; -import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_INT_VALUE; -import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_NAME; +import static com.android.internal.logging.nano.MetricsProto.MetricsEvent + .ACTION_SETTINGS_PREFERENCE_CHANGE; +import static com.android.internal.logging.nano.MetricsProto.MetricsEvent + .FIELD_SETTINGS_PREFERENCE_CHANGE_FLOAT_VALUE; +import static com.android.internal.logging.nano.MetricsProto.MetricsEvent + .FIELD_SETTINGS_PREFERENCE_CHANGE_INT_VALUE; +import static com.android.internal.logging.nano.MetricsProto.MetricsEvent + .FIELD_SETTINGS_PREFERENCE_CHANGE_NAME; + import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.argThat; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/VisibilityLoggerMixinTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/VisibilityLoggerMixinTest.java index f34c33844d11..f78573a79f1c 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/VisibilityLoggerMixinTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/VisibilityLoggerMixinTest.java @@ -16,6 +16,7 @@ package com.android.settingslib.core.instrumentation; import static com.android.settingslib.core.instrumentation.Instrumentable.METRICS_CATEGORY_UNKNOWN; + import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; @@ -30,6 +31,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; + import androidx.fragment.app.FragmentActivity; import com.android.internal.logging.nano.MetricsProto; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/lifecycle/LifecycleTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/lifecycle/LifecycleTest.java index 52068e9842e5..301c493e062f 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/lifecycle/LifecycleTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/lifecycle/LifecycleTest.java @@ -16,14 +16,16 @@ package com.android.settingslib.core.lifecycle; import static androidx.lifecycle.Lifecycle.Event.ON_START; + import static com.google.common.truth.Truth.assertThat; -import androidx.lifecycle.LifecycleOwner; import android.content.Context; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import androidx.lifecycle.LifecycleOwner; + import com.android.settingslib.SettingsLibRobolectricTestRunner; import com.android.settingslib.core.lifecycle.events.OnAttach; import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/EnableAdbPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/EnableAdbPreferenceControllerTest.java index 7c653351974a..2a60839990c4 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/EnableAdbPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/EnableAdbPreferenceControllerTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.development; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Answers.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; @@ -26,9 +27,10 @@ import android.content.Context; import android.content.pm.PackageManager; import android.os.UserManager; import android.provider.Settings; -import androidx.preference.SwitchPreference; + import androidx.preference.Preference; import androidx.preference.PreferenceScreen; +import androidx.preference.SwitchPreference; import com.android.settingslib.SettingsLibRobolectricTestRunner; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/LogdSizePreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/LogdSizePreferenceControllerTest.java index ae3072ca86b8..2f78899ff92d 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/LogdSizePreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/LogdSizePreferenceControllerTest.java @@ -40,6 +40,7 @@ import static org.mockito.Mockito.verify; import android.content.Context; import android.os.SystemProperties; + import androidx.preference.ListPreference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/LogpersistPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/LogpersistPreferenceControllerTest.java index b0aaa256fdab..ed128e098c6f 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/LogpersistPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/development/LogpersistPreferenceControllerTest.java @@ -17,12 +17,14 @@ package com.android.settingslib.development; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; -import androidx.lifecycle.LifecycleOwner; import android.os.SystemProperties; + +import androidx.lifecycle.LifecycleOwner; import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/BluetoothAddressPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/BluetoothAddressPreferenceControllerTest.java index 8ec7149ce1a8..234b4d5ac604 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/BluetoothAddressPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/BluetoothAddressPreferenceControllerTest.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.doReturn; import android.bluetooth.BluetoothAdapter; import android.content.Context; + import androidx.preference.Preference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/ConnectivityPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/ConnectivityPreferenceControllerTest.java index 7c127e5cd5b7..aee956cf5518 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/ConnectivityPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/ConnectivityPreferenceControllerTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.deviceinfo; import static com.google.common.truth.Truth.assertWithMessage; + import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.doReturn; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/ImsStatusPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/ImsStatusPreferenceControllerTest.java index cb7861b30562..2b490ee63856 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/ImsStatusPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/ImsStatusPreferenceControllerTest.java @@ -17,17 +17,19 @@ package com.android.settingslib.deviceinfo; import static com.google.common.truth.Truth.assertWithMessage; + import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import android.content.Context; import android.os.PersistableBundle; -import androidx.preference.Preference; -import androidx.preference.PreferenceScreen; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; +import androidx.preference.Preference; +import androidx.preference.PreferenceScreen; + import com.android.settingslib.SettingsLibRobolectricTestRunner; import com.android.settingslib.core.lifecycle.Lifecycle; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/IpAddressPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/IpAddressPreferenceControllerTest.java index 8f144cdf3a15..1d957c3b5e5b 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/IpAddressPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/IpAddressPreferenceControllerTest.java @@ -23,6 +23,7 @@ import static org.mockito.Mockito.doReturn; import android.content.Context; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; + import androidx.preference.Preference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/SerialNumberPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/SerialNumberPreferenceControllerTest.java index 69fb86e88d5b..dc77400e2547 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/SerialNumberPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/SerialNumberPreferenceControllerTest.java @@ -17,9 +17,11 @@ package com.android.settingslib.deviceinfo; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Mockito.when; import android.content.Context; + import androidx.preference.Preference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/SimStatusImeiInfoPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/SimStatusImeiInfoPreferenceControllerTest.java index eaae40553d6e..eb77cb6271e9 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/SimStatusImeiInfoPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/SimStatusImeiInfoPreferenceControllerTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.deviceinfo; import static com.google.common.truth.Truth.assertThat; + import static org.robolectric.shadow.api.Shadow.extract; import android.net.ConnectivityManager; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/UptimePreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/UptimePreferenceControllerTest.java index ba955f9f2275..aea4d57356a4 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/UptimePreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/UptimePreferenceControllerTest.java @@ -23,9 +23,10 @@ import static org.mockito.Mockito.verify; import android.content.Context; import android.os.SystemClock; +import android.text.format.DateUtils; + import androidx.preference.Preference; import androidx.preference.PreferenceScreen; -import android.text.format.DateUtils; import com.android.settingslib.SettingsLibRobolectricTestRunner; import com.android.settingslib.core.lifecycle.Lifecycle; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/WifiMacAddressPreferenceControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/WifiMacAddressPreferenceControllerTest.java index ddbcb87725d1..5aa00efbb2d8 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/WifiMacAddressPreferenceControllerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/deviceinfo/WifiMacAddressPreferenceControllerTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.deviceinfo; import static com.google.common.truth.Truth.assertWithMessage; + import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -28,6 +29,7 @@ import android.net.ConnectivityManager; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.provider.Settings; + import androidx.preference.Preference; import androidx.preference.PreferenceScreen; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/display/BrightnessUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/display/BrightnessUtilsTest.java index eb7ad6d919cf..ca621ca66829 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/display/BrightnessUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/display/BrightnessUtilsTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.display; import static com.android.settingslib.display.BrightnessUtils.GAMMA_SPACE_MAX; + import static com.google.common.truth.Truth.assertThat; import com.android.settingslib.SettingsLibRobolectricTestRunner; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java index 6e66805795b0..fef569362a8a 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.drawer; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/fuelgauge/BatterySaverUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/fuelgauge/BatterySaverUtilsTest.java index ba5a2c5e5fe7..de96af4fa6a1 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/fuelgauge/BatterySaverUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/fuelgauge/BatterySaverUtilsTest.java @@ -17,8 +17,8 @@ package com.android.settingslib.fuelgauge; import static com.google.common.truth.Truth.assertThat; + import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/fuelgauge/PowerWhitelistBackendTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/fuelgauge/PowerWhitelistBackendTest.java index a23eebcce797..a0d53f29f319 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/fuelgauge/PowerWhitelistBackendTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/fuelgauge/PowerWhitelistBackendTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.fuelgauge; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doNothing; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/license/LicenseHtmlLoaderTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/license/LicenseHtmlLoaderTest.java index 5095f508997e..0a3cb44ad76d 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/license/LicenseHtmlLoaderTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/license/LicenseHtmlLoaderTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.license; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java index 8a54aeec6d79..9c168f7b1a45 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java @@ -1,6 +1,7 @@ package com.android.settingslib.location; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.isA; import static org.mockito.Mockito.when; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/EnableZenModeDialogTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/EnableZenModeDialogTest.java index ccd2f538c731..89c319a7e483 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/EnableZenModeDialogTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/EnableZenModeDialogTest.java @@ -20,6 +20,7 @@ import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java index 9b491c200cdc..d500ec2e7649 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java @@ -19,34 +19,22 @@ package com.android.settingslib.notification; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyObject; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; + import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; import android.app.AlertDialog; -import android.app.Fragment; -import android.app.NotificationManager; -import android.content.Context; import android.content.ContentResolver; -import android.content.DialogInterface; -import android.content.res.Resources; -import android.net.Uri; +import android.content.Context; import android.provider.Settings; import android.service.notification.Condition; import android.view.LayoutInflater; import android.view.View; -import android.widget.Button; import com.android.settingslib.SettingsLibRobolectricTestRunner; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.robolectric.RuntimeEnvironment; @RunWith(SettingsLibRobolectricTestRunner.class) diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/suggestions/SuggestionControllerMixinTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/suggestions/SuggestionControllerMixinTest.java index f486989f5a56..aac582f9b3ac 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/suggestions/SuggestionControllerMixinTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/suggestions/SuggestionControllerMixinTest.java @@ -18,16 +18,19 @@ package com.android.settingslib.suggestions; import static androidx.lifecycle.Lifecycle.Event.ON_START; import static androidx.lifecycle.Lifecycle.Event.ON_STOP; + import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.LoaderManager; -import androidx.lifecycle.LifecycleOwner; import android.content.ComponentName; import android.content.Context; +import androidx.lifecycle.LifecycleOwner; + import com.android.settingslib.SettingsLibRobolectricTestRunner; import com.android.settingslib.core.lifecycle.Lifecycle; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/users/UserManagerHelperRoboTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/users/UserManagerHelperRoboTest.java index 890abefddd73..4705cd2b183b 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/users/UserManagerHelperRoboTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/users/UserManagerHelperRoboTest.java @@ -22,14 +22,13 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; - import android.content.Context; import android.content.pm.UserInfo; import android.os.UserHandle; import android.os.UserManager; -import com.android.settingslib.testutils.shadow.ShadowActivityManager; import com.android.settingslib.SettingsLibRobolectricTestRunner; +import com.android.settingslib.testutils.shadow.ShadowActivityManager; import org.junit.After; import org.junit.Before; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/PowerUtilTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/PowerUtilTest.java index f2ef99c42df5..6a9579b770ce 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/PowerUtilTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/PowerUtilTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.utils; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Mockito.spy; import android.content.Context; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/StringUtilTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/StringUtilTest.java index 743951a6ed7a..e4bbbcb0b207 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/StringUtilTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/StringUtilTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.utils; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Mockito.spy; import android.content.Context; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/ThreadUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/ThreadUtilsTest.java index 83a9d5be0ae7..63248a0d370c 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/ThreadUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/ThreadUtilsTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.utils; import static com.google.common.truth.Truth.assertThat; + import static org.junit.Assert.fail; import org.junit.Test; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceMixinTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceMixinTest.java index 78b7616716f5..366b720fc87b 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceMixinTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceMixinTest.java @@ -17,6 +17,7 @@ package com.android.settingslib.widget; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java index 3280089a88f6..84a043e15eb5 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/FooterPreferenceTest.java @@ -19,11 +19,12 @@ package com.android.settingslib.widget; import static com.google.common.truth.Truth.assertThat; import android.content.Context; -import androidx.preference.PreferenceViewHolder; import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.widget.TextView; +import androidx.preference.PreferenceViewHolder; + import com.android.settingslib.R; import com.android.settingslib.SettingsLibRobolectricTestRunner; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/AccessPointPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/AccessPointPreferenceTest.java index ee2c2ffc4b4b..86443bde4667 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/AccessPointPreferenceTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/AccessPointPreferenceTest.java @@ -16,6 +16,7 @@ package com.android.settingslib.wifi; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/WifiUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/WifiUtilsTest.java index d25adde98694..07c50fde00fa 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/WifiUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/WifiUtilsTest.java @@ -16,6 +16,7 @@ package com.android.settingslib.wifi; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doReturn; diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index ba5f32308a30..760209024c57 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -183,6 +183,7 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -202,6 +203,8 @@ public class ConnectivityService extends IConnectivityManager.Stub private static final String DIAG_ARG = "--diag"; public static final String SHORT_ARG = "--short"; private static final String TETHERING_ARG = "tethering"; + private static final String NETWORK_ARG = "networks"; + private static final String REQUEST_ARG = "requests"; private static final boolean DBG = true; private static final boolean VDBG = false; @@ -1978,7 +1981,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private void dumpNetworkDiagnostics(IndentingPrintWriter pw) { final List<NetworkDiagnostics> netDiags = new ArrayList<NetworkDiagnostics>(); final long DIAG_TIME_MS = 5000; - for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { + for (NetworkAgentInfo nai : networksSortedById()) { // Start gathering diagnostic information. netDiags.add(new NetworkDiagnostics( nai.network, @@ -2009,6 +2012,12 @@ public class ConnectivityService extends IConnectivityManager.Stub } else if (ArrayUtils.contains(args, TETHERING_ARG)) { mTethering.dump(fd, pw, args); return; + } else if (ArrayUtils.contains(args, NETWORK_ARG)) { + dumpNetworks(pw); + return; + } else if (ArrayUtils.contains(args, REQUEST_ARG)) { + dumpNetworkRequests(pw); + return; } pw.print("NetworkFactories for:"); @@ -2029,36 +2038,15 @@ public class ConnectivityService extends IConnectivityManager.Stub pw.println("Current Networks:"); pw.increaseIndent(); - for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { - pw.println(nai.toString()); - pw.increaseIndent(); - pw.println(String.format( - "Requests: REQUEST:%d LISTEN:%d BACKGROUND_REQUEST:%d total:%d", - nai.numForegroundNetworkRequests(), - nai.numNetworkRequests() - nai.numRequestNetworkRequests(), - nai.numBackgroundNetworkRequests(), - nai.numNetworkRequests())); - pw.increaseIndent(); - for (int i = 0; i < nai.numNetworkRequests(); i++) { - pw.println(nai.requestAt(i).toString()); - } - pw.decreaseIndent(); - pw.println("Lingered:"); - pw.increaseIndent(); - nai.dumpLingerTimers(pw); - pw.decreaseIndent(); - pw.decreaseIndent(); - } + dumpNetworks(pw); pw.decreaseIndent(); pw.println(); pw.println("Network Requests:"); pw.increaseIndent(); - for (NetworkRequestInfo nri : mNetworkRequests.values()) { - pw.println(nri.toString()); - } - pw.println(); + dumpNetworkRequests(pw); pw.decreaseIndent(); + pw.println(); mLegacyTypeTracker.dump(pw); @@ -2126,6 +2114,55 @@ public class ConnectivityService extends IConnectivityManager.Stub } } + private void dumpNetworks(IndentingPrintWriter pw) { + for (NetworkAgentInfo nai : networksSortedById()) { + pw.println(nai.toString()); + pw.increaseIndent(); + pw.println(String.format( + "Requests: REQUEST:%d LISTEN:%d BACKGROUND_REQUEST:%d total:%d", + nai.numForegroundNetworkRequests(), + nai.numNetworkRequests() - nai.numRequestNetworkRequests(), + nai.numBackgroundNetworkRequests(), + nai.numNetworkRequests())); + pw.increaseIndent(); + for (int i = 0; i < nai.numNetworkRequests(); i++) { + pw.println(nai.requestAt(i).toString()); + } + pw.decreaseIndent(); + pw.println("Lingered:"); + pw.increaseIndent(); + nai.dumpLingerTimers(pw); + pw.decreaseIndent(); + pw.decreaseIndent(); + } + } + + private void dumpNetworkRequests(IndentingPrintWriter pw) { + for (NetworkRequestInfo nri : requestsSortedById()) { + pw.println(nri.toString()); + } + } + + /** + * Return an array of all current NetworkAgentInfos sorted by network id. + */ + private NetworkAgentInfo[] networksSortedById() { + NetworkAgentInfo[] networks = new NetworkAgentInfo[0]; + networks = mNetworkAgentInfos.values().toArray(networks); + Arrays.sort(networks, Comparator.comparingInt(nai -> nai.network.netId)); + return networks; + } + + /** + * Return an array of all current NetworkRequest sorted by request id. + */ + private NetworkRequestInfo[] requestsSortedById() { + NetworkRequestInfo[] requests = new NetworkRequestInfo[0]; + requests = mNetworkRequests.values().toArray(requests); + Arrays.sort(requests, Comparator.comparingInt(nri -> nri.request.requestId)); + return requests; + } + private boolean isLiveNetworkAgent(NetworkAgentInfo nai, int what) { if (nai.network == null) return false; final NetworkAgentInfo officialNai = getNetworkAgentInfoForNetwork(nai.network); @@ -2916,7 +2953,7 @@ public class ConnectivityService extends IConnectivityManager.Stub pw.println("User setting: " + description); pw.println("Network overrides:"); pw.increaseIndent(); - for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { + for (NetworkAgentInfo nai : networksSortedById()) { if (nai.avoidUnvalidated) { pw.println(nai.name()); } diff --git a/services/core/java/com/android/server/am/OWNERS b/services/core/java/com/android/server/am/OWNERS index f60c5c3208d9..79c98e550774 100644 --- a/services/core/java/com/android/server/am/OWNERS +++ b/services/core/java/com/android/server/am/OWNERS @@ -4,7 +4,6 @@ yamasani@google.com jsharkey@google.com hackbod@google.com omakoto@google.com -fkupolov@google.com ctate@google.com huiyu@google.com mwachens@google.com @@ -28,7 +27,4 @@ toddke@google.com michaelwr@google.com narayan@google.com -per-file GlobalSettingsToPropertiesMapper.java=fkupolov@google.com -per-file GlobalSettingsToPropertiesMapper.java=omakoto@google.com -per-file GlobalSettingsToPropertiesMapper.java=svetoslavganov@google.com -per-file GlobalSettingsToPropertiesMapper.java=yamasani@google.com +per-file GlobalSettingsToPropertiesMapper.java = omakoto@google.com, svetoslavganov@google.com, yamasani@google.com diff --git a/tools/processors/unsupportedappusage/Android.bp b/tools/processors/unsupportedappusage/Android.bp new file mode 100644 index 000000000000..98f3c955a2d2 --- /dev/null +++ b/tools/processors/unsupportedappusage/Android.bp @@ -0,0 +1,15 @@ + +java_library_host { + name: "unsupportedappusage-annotation-processor", + java_resources: [ + "META-INF/**/*", + ], + srcs: [ + "src/**/*.java", + ], + static_libs: [ + "guava", + "unsupportedappusage-annotation" + ], + use_tools_jar: true, +} diff --git a/tools/processors/unsupportedappusage/META-INF/services/javax.annotation.processing.Processor b/tools/processors/unsupportedappusage/META-INF/services/javax.annotation.processing.Processor new file mode 100644 index 000000000000..4a969d319070 --- /dev/null +++ b/tools/processors/unsupportedappusage/META-INF/services/javax.annotation.processing.Processor @@ -0,0 +1 @@ +android.processor.unsupportedappusage.UnsupportedAppUsageProcessor diff --git a/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SignatureBuilder.java b/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SignatureBuilder.java new file mode 100644 index 000000000000..ef2914610f80 --- /dev/null +++ b/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/SignatureBuilder.java @@ -0,0 +1,228 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.processor.unsupportedappusage; + +import static javax.lang.model.element.ElementKind.PACKAGE; +import static javax.tools.Diagnostic.Kind.ERROR; +import static javax.tools.Diagnostic.Kind.WARNING; + +import android.annotation.UnsupportedAppUsage; + +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableMap; +import com.sun.tools.javac.code.Type; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import javax.annotation.processing.Messager; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.PackageElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; + +/** + * Builds a dex signature for a given method or field. + */ +public class SignatureBuilder { + + private static final Map<TypeKind, String> TYPE_MAP = ImmutableMap.<TypeKind, String>builder() + .put(TypeKind.BOOLEAN, "Z") + .put(TypeKind.BYTE, "B") + .put(TypeKind.CHAR, "C") + .put(TypeKind.DOUBLE, "D") + .put(TypeKind.FLOAT, "F") + .put(TypeKind.INT, "I") + .put(TypeKind.LONG, "J") + .put(TypeKind.SHORT, "S") + .put(TypeKind.VOID, "V") + .build(); + + private final Messager mMessager; + + /** + * Exception used internally when we can't build a signature. Whenever this is thrown, an error + * will also be written to the Messager. + */ + private class SignatureBuilderException extends Exception { + public SignatureBuilderException(String message) { + super(message); + } + public void report(Element offendingElement) { + mMessager.printMessage(ERROR, getMessage(), offendingElement); + } + } + + public SignatureBuilder(Messager messager) { + mMessager = messager; + } + + /** + * Returns a list of enclosing elements for the given element, with the package first, and + * excluding the element itself. + */ + private List<Element> getEnclosingElements(Element e) { + List<Element> enclosing = new ArrayList<>(); + e = e.getEnclosingElement(); // don't include the element itself. + while (e != null) { + enclosing.add(e); + e = e.getEnclosingElement(); + } + Collections.reverse(enclosing); + return enclosing; + } + + /** + * Get the dex signature for a clazz, in format "Lpackage/name/Outer$Inner;" + */ + private String getClassSignature(TypeElement clazz) { + StringBuilder sb = new StringBuilder("L"); + for (Element enclosing : getEnclosingElements(clazz)) { + if (enclosing.getKind() == PACKAGE) { + sb.append(((PackageElement) enclosing) + .getQualifiedName() + .toString() + .replace('.', '/')); + sb.append('/'); + } else { + sb.append(enclosing.getSimpleName()).append('$'); + } + + } + return sb + .append(clazz.getSimpleName()) + .append(";") + .toString(); + } + + /** + * Returns the type signature for a given type. For primitive types, a single character. + * For classes, the class signature. For arrays, a "[" preceeding the component type. + */ + private String getTypeSignature(TypeMirror type) throws SignatureBuilderException { + String sig = TYPE_MAP.get(type.getKind()); + if (sig != null) { + return sig; + } + switch (type.getKind()) { + case ARRAY: + return "[" + getTypeSignature(((ArrayType) type).getComponentType()); + case DECLARED: + Element declaring = ((DeclaredType) type).asElement(); + if (!(declaring instanceof TypeElement)) { + throw new SignatureBuilderException( + "Can't handle declared type of kind " + declaring.getKind()); + } + return getClassSignature((TypeElement) declaring); + case TYPEVAR: + Type.TypeVar typeVar = (Type.TypeVar) type; + if (typeVar.getLowerBound().getKind() != TypeKind.NULL) { + return getTypeSignature(typeVar.getLowerBound()); + } else if (typeVar.getUpperBound().getKind() != TypeKind.NULL) { + return getTypeSignature(typeVar.getUpperBound()); + } else { + throw new SignatureBuilderException("Can't handle typevar with no bound"); + } + + default: + throw new SignatureBuilderException("Can't handle type of kind " + type.getKind()); + } + } + + /** + * Get the signature for an executable, either a method or a constructor. + * + * @param name "<init>" for constructor, else the method name + * @param method The executable element in question. + */ + private String getExecutableSignature(CharSequence name, ExecutableElement method) + throws SignatureBuilderException { + StringBuilder sig = new StringBuilder(); + sig.append(getClassSignature((TypeElement) method.getEnclosingElement())) + .append("->") + .append(name) + .append("("); + for (VariableElement param : method.getParameters()) { + sig.append(getTypeSignature(param.asType())); + } + sig.append(")") + .append(getTypeSignature(method.getReturnType())); + return sig.toString(); + } + + private String buildMethodSignature(ExecutableElement method) throws SignatureBuilderException { + return getExecutableSignature(method.getSimpleName(), method); + } + + private String buildConstructorSignature(ExecutableElement cons) + throws SignatureBuilderException { + return getExecutableSignature("<init>", cons); + } + + private String buildFieldSignature(VariableElement field) throws SignatureBuilderException { + StringBuilder sig = new StringBuilder(); + sig.append(getClassSignature((TypeElement) field.getEnclosingElement())) + .append("->") + .append(field.getSimpleName()) + .append(":") + .append(getTypeSignature(field.asType())) + ; + return sig.toString(); + } + + public String buildSignature(Element element) { + UnsupportedAppUsage uba = element.getAnnotation(UnsupportedAppUsage.class); + try { + String signature; + switch (element.getKind()) { + case METHOD: + signature = buildMethodSignature((ExecutableElement) element); + break; + case CONSTRUCTOR: + signature = buildConstructorSignature((ExecutableElement) element); + break; + case FIELD: + signature = buildFieldSignature((VariableElement) element); + break; + default: + return null; + } + // if we have an expected signature on the annotation, warn if it doesn't match. + if (!Strings.isNullOrEmpty(uba.expectedSignature())) { + if (!signature.equals(uba.expectedSignature())) { + mMessager.printMessage( + WARNING, + String.format("Expected signature doesn't match generated signature.\n" + + " Expected: %s\n Generated: %s", + uba.expectedSignature(), signature), + element); + } + } + return signature; + } catch (SignatureBuilderException problem) { + problem.report(element); + return null; + } + } +} diff --git a/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessor.java b/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessor.java new file mode 100644 index 000000000000..1d4c435939db --- /dev/null +++ b/tools/processors/unsupportedappusage/src/android/processor/unsupportedappusage/UnsupportedAppUsageProcessor.java @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.processor.unsupportedappusage; + +import static javax.tools.StandardLocation.CLASS_OUTPUT; + +import android.annotation.UnsupportedAppUsage; + +import com.google.common.base.Joiner; +import com.sun.tools.javac.model.JavacElements; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.util.Pair; +import com.sun.tools.javac.util.Position; + +import java.io.IOException; +import java.io.PrintStream; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Stream; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; + +/** + * Annotation processor for {@link UnsupportedAppUsage} annotations. + * + * This processor currently outputs two things: + * 1. A greylist.txt containing dex signatures of all annotated elements. + * 2. A CSV file with a mapping of dex signatures to corresponding source positions. + * + * The first will be used at a later stage of the build to add access flags to the dex file. The + * second is used for automating updates to the annotations themselves. + */ +@SupportedAnnotationTypes({"android.annotation.UnsupportedAppUsage"}) +public class UnsupportedAppUsageProcessor extends AbstractProcessor { + + // Package name for writing output. Output will be written to the "class output" location within + // this package. + private static final String PACKAGE = "unsupportedappusage"; + private static final String INDEX_CSV = "unsupportedappusage_index.csv"; + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + /** + * Write the contents of a stream to a text file, with one line per item. + */ + private void writeToFile(String name, + String headerLine, + Stream<?> contents) throws IOException { + PrintStream out = new PrintStream(processingEnv.getFiler().createResource( + CLASS_OUTPUT, + PACKAGE, + name) + .openOutputStream()); + out.println(headerLine); + contents.forEach(o -> out.println(o)); + if (out.checkError()) { + throw new IOException("Error when writing to " + name); + } + out.close(); + } + + /** + * Find the annotation mirror for the @UnsupportedAppUsage annotation on the given element. + */ + private AnnotationMirror getUnsupportedAppUsageAnnotationMirror(Element e) { + for (AnnotationMirror m : e.getAnnotationMirrors()) { + TypeElement type = (TypeElement) m.getAnnotationType().asElement(); + if (type.getQualifiedName().toString().equals( + UnsupportedAppUsage.class.getCanonicalName())) { + return m; + } + } + return null; + } + + /** + * Returns a CSV header line for the columns returned by + * {@link #getAnnotationIndex(String, Element)}. + */ + private String getCsvHeaders() { + return Joiner.on(',').join( + "signature", + "file", + "startline", + "startcol", + "endline", + "endcol" + ); + } + + /** + * Maps an annotated element to the source position of the @UnsupportedAppUsage annotation + * attached to it. It returns CSV in the format: + * dex-signature,filename,start-line,start-col,end-line,end-col + * + * The positions refer to the annotation itself, *not* the annotated member. This can therefore + * be used to read just the annotation from the file, and to perform in-place edits on it. + * + * @param signature the dex signature for the element. + * @param annotatedElement The annotated element + * @return A single line of CSV text + */ + private String getAnnotationIndex(String signature, Element annotatedElement) { + JavacElements javacElem = (JavacElements) processingEnv.getElementUtils(); + AnnotationMirror unsupportedAppUsage = + getUnsupportedAppUsageAnnotationMirror(annotatedElement); + Pair<JCTree, JCTree.JCCompilationUnit> pair = + javacElem.getTreeAndTopLevel(annotatedElement, unsupportedAppUsage, null); + Position.LineMap lines = pair.snd.lineMap; + return Joiner.on(",").join( + signature, + pair.snd.getSourceFile().getName(), + lines.getLineNumber(pair.fst.pos().getStartPosition()), + lines.getColumnNumber(pair.fst.pos().getStartPosition()), + lines.getLineNumber(pair.fst.pos().getEndPosition(pair.snd.endPositions)), + lines.getColumnNumber(pair.fst.pos().getEndPosition(pair.snd.endPositions))); + } + + /** + * This is the main entry point in the processor, called by the compiler. + */ + @Override + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { + Set<? extends Element> annotated = roundEnv.getElementsAnnotatedWith( + UnsupportedAppUsage.class); + if (annotated.size() == 0) { + return true; + } + // build signatures for each annotated member, and put them in a map of signature to member + Map<String, Element> signatureMap = new TreeMap<>(); + SignatureBuilder sb = new SignatureBuilder(processingEnv.getMessager()); + for (Element e : annotated) { + String sig = sb.buildSignature(e); + if (sig != null) { + signatureMap.put(sig, e); + } + } + try { + writeToFile(INDEX_CSV, + getCsvHeaders(), + signatureMap.entrySet() + .stream() + .map(e -> getAnnotationIndex(e.getKey() ,e.getValue()))); + } catch (IOException e) { + throw new RuntimeException("Failed to write output", e); + } + return true; + } +} |