diff options
15 files changed, 262 insertions, 114 deletions
diff --git a/api/current.txt b/api/current.txt index 92d349e..e6bbdbe 100644 --- a/api/current.txt +++ b/api/current.txt @@ -13325,6 +13325,7 @@ package android.hardware.camera2 { field public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Long> SENSOR_INFO_MAX_FRAME_DURATION; field public static final android.hardware.camera2.CameraCharacteristics.Key<android.util.SizeF> SENSOR_INFO_PHYSICAL_SIZE; field public static final android.hardware.camera2.CameraCharacteristics.Key<android.util.Size> SENSOR_INFO_PIXEL_ARRAY_SIZE; + field public static final android.hardware.camera2.CameraCharacteristics.Key<android.graphics.Rect> SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE; field public static final android.hardware.camera2.CameraCharacteristics.Key<android.util.Range<java.lang.Integer>> SENSOR_INFO_SENSITIVITY_RANGE; field public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Integer> SENSOR_INFO_TIMESTAMP_SOURCE; field public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Integer> SENSOR_INFO_WHITE_LEVEL; diff --git a/api/system-current.txt b/api/system-current.txt index c28f4353..fb3c874 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -13645,6 +13645,7 @@ package android.hardware.camera2 { field public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Long> SENSOR_INFO_MAX_FRAME_DURATION; field public static final android.hardware.camera2.CameraCharacteristics.Key<android.util.SizeF> SENSOR_INFO_PHYSICAL_SIZE; field public static final android.hardware.camera2.CameraCharacteristics.Key<android.util.Size> SENSOR_INFO_PIXEL_ARRAY_SIZE; + field public static final android.hardware.camera2.CameraCharacteristics.Key<android.graphics.Rect> SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE; field public static final android.hardware.camera2.CameraCharacteristics.Key<android.util.Range<java.lang.Integer>> SENSOR_INFO_SENSITIVITY_RANGE; field public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Integer> SENSOR_INFO_TIMESTAMP_SOURCE; field public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Integer> SENSOR_INFO_WHITE_LEVEL; diff --git a/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java b/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java index 161c339..834a587 100644 --- a/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java +++ b/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java @@ -28,10 +28,10 @@ import android.os.Parcelable; public final class BluetoothActivityEnergyInfo implements Parcelable { private final long mTimestamp; private final int mBluetoothStackState; - private final int mControllerTxTimeMs; - private final int mControllerRxTimeMs; - private final int mControllerIdleTimeMs; - private final int mControllerEnergyUsed; + private final long mControllerTxTimeMs; + private final long mControllerRxTimeMs; + private final long mControllerIdleTimeMs; + private final long mControllerEnergyUsed; public static final int BT_STACK_STATE_INVALID = 0; public static final int BT_STACK_STATE_STATE_ACTIVE = 1; @@ -39,7 +39,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { public static final int BT_STACK_STATE_STATE_IDLE = 3; public BluetoothActivityEnergyInfo(long timestamp, int stackState, - int txTime, int rxTime, int idleTime, int energyUsed) { + long txTime, long rxTime, long idleTime, long energyUsed) { mTimestamp = timestamp; mBluetoothStackState = stackState; mControllerTxTimeMs = txTime; @@ -65,10 +65,10 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { public BluetoothActivityEnergyInfo createFromParcel(Parcel in) { long timestamp = in.readLong(); int stackState = in.readInt(); - int txTime = in.readInt(); - int rxTime = in.readInt(); - int idleTime = in.readInt(); - int energyUsed = in.readInt(); + long txTime = in.readLong(); + long rxTime = in.readLong(); + long idleTime = in.readLong(); + long energyUsed = in.readLong(); return new BluetoothActivityEnergyInfo(timestamp, stackState, txTime, rxTime, idleTime, energyUsed); } @@ -80,10 +80,10 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeLong(mTimestamp); out.writeInt(mBluetoothStackState); - out.writeInt(mControllerTxTimeMs); - out.writeInt(mControllerRxTimeMs); - out.writeInt(mControllerIdleTimeMs); - out.writeInt(mControllerEnergyUsed); + out.writeLong(mControllerTxTimeMs); + out.writeLong(mControllerRxTimeMs); + out.writeLong(mControllerIdleTimeMs); + out.writeLong(mControllerEnergyUsed); } public int describeContents() { @@ -100,21 +100,21 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { /** * @return tx time in ms */ - public int getControllerTxTimeMillis() { + public long getControllerTxTimeMillis() { return mControllerTxTimeMs; } /** * @return rx time in ms */ - public int getControllerRxTimeMillis() { + public long getControllerRxTimeMillis() { return mControllerRxTimeMs; } /** * @return idle time in ms */ - public int getControllerIdleTimeMillis() { + public long getControllerIdleTimeMillis() { return mControllerIdleTimeMs; } @@ -122,7 +122,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { * product of current(mA), voltage(V) and time(ms) * @return energy used */ - public int getControllerEnergyUsed() { + public long getControllerEnergyUsed() { return mControllerEnergyUsed; } @@ -137,8 +137,8 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { * @return if the record is valid */ public boolean isValid() { - return ((getControllerTxTimeMillis() !=0) || - (getControllerRxTimeMillis() !=0) || - (getControllerIdleTimeMillis() !=0)); + return ((mControllerTxTimeMs !=0) || + (mControllerRxTimeMs !=0) || + (mControllerIdleTimeMs !=0)); } } diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index 921e9f1..152bc22 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -1959,22 +1959,25 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri new Key<Integer>("android.scaler.croppingType", int.class); /** - * <p>The area of the image sensor which corresponds to - * active pixels.</p> - * <p>This is the region of the sensor that actually receives light from the scene. - * Therefore, the size of this region determines the maximum field of view and the maximum - * number of pixels that an image from this sensor can contain.</p> - * <p>The rectangle is defined in terms of 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 + * <p>The area of the image sensor which corresponds to active pixels after any geometric + * distortion correction has been applied.</p> + * <p>This is the rectangle representing the size of the active region of the sensor (i.e. + * the region that actually receives light from the scene) after any geometric correction + * has been applied, and should be treated as the maximum size in pixels of any of the + * image output formats aside from the raw formats.</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> - * <p>Most other keys listing pixel coordinates have their coordinate systems based on the - * active array, with <code>(0, 0)</code> being the top-left of the active array rectangle.</p> + * <p>The coordinate system for most other keys that list pixel coordinates, including + * {@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.</p> + * include black calibration pixels or other inactive regions, and geometric correction + * resulting in scaling or cropping may have been applied.</p> * <p><b>Units</b>: Pixel coordinates on the image sensor</p> - * <p><b>Range of valid values:</b><br></p> * <p>This key is available on all devices.</p> * + * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_PIXEL_ARRAY_SIZE */ @PublicKey @@ -1982,6 +1985,69 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri new Key<android.graphics.Rect>("android.sensor.info.activeArraySize", android.graphics.Rect.class); /** + * <p>The area of the image sensor which corresponds to active pixels prior to the + * application of any geometric distortion correction.</p> + * <p>This is the rectangle representing the size of the active region of the sensor (i.e. + * the region that actually receives light from the scene) before any geometric correction + * has been applied, and should be treated as the active region rectangle for any of the + * raw formats. All metadata associated with raw processing (e.g. the lens shading + * correction map, and radial distortion fields) treats the top, left of this rectangle as + * the origin, (0,0).</p> + * <p>The size of this region determines the maximum field of view and the maximum number of + * pixels that an image from this sensor can contain, prior to the application of + * geometric distortion correction. The effective maximum pixel dimensions of a + * post-distortion-corrected image is given by the {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} + * field, and the effective maximum field of view for a post-distortion-corrected image + * can be calculated by applying the geometric distortion correction fields to this + * rectangle, and cropping to the rectangle given in {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.</p> + * <p>E.g. to calculate position of a pixel, (x,y), in a processed YUV output image with the + * dimensions in {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} given the position of a pixel, + * (x', y'), in the raw pixel array with dimensions give in + * {@link CameraCharacteristics#SENSOR_INFO_PIXEL_ARRAY_SIZE android.sensor.info.pixelArraySize}:</p> + * <ol> + * <li>Choose a pixel (x', y') within the active array region of the raw buffer given in + * android.sensor.info.preCorrectedActiveArraySize, otherwise this pixel is considered + * to be outside of the FOV, and will not be shown in the processed output image.</li> + * <li>Apply geometric distortion correction to get the post-distortion pixel coordinate, + * (x_i, y_i). When applying geometric correction metadata, note that metadata for raw + * buffers is defined relative to the top, left of the + * android.sensor.info.preCorrectedActiveArraySize rectangle.</li> + * <li>If the resulting corrected pixel coordinate is within the region given in + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, then the position of this pixel in the + * processed output image buffer is <code>(x_i - activeArray.left, y_i - activeArray.top)</code>, + * when the top, left coordinate of that buffer is treated as (0, 0).</li> + * </ol> + * <p>Thus, for pixel x',y' = (25, 25) on a sensor where {@link CameraCharacteristics#SENSOR_INFO_PIXEL_ARRAY_SIZE android.sensor.info.pixelArraySize} + * is (100,100), android.sensor.info.preCorrectedActiveArraySize is (10, 10, 100, 100), + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} is (20, 20, 80, 80), and the geometric distortion + * correction doesn't change the pixel coordinate, the resulting pixel selected in + * pixel coordinates would be x,y = (25, 25) relative to the top,left of the raw buffer + * with dimensions given in {@link CameraCharacteristics#SENSOR_INFO_PIXEL_ARRAY_SIZE android.sensor.info.pixelArraySize}, and would be (5, 5) + * relative to the top,left of post-processed YUV output buffer with dimensions given in + * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.</p> + * <p>The currently supported fields that correct for geometric distortion are:</p> + * <ol> + * <li>android.lens.radialDistortion.</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>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> + * <p>The pre-correction active array may be smaller than the full pixel array, since the + * full array may include black calibration pixels or other inactive regions.</p> + * <p><b>Units</b>: Pixel coordinates on the image sensor</p> + * <p>This key is available on all devices.</p> + * + * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PIXEL_ARRAY_SIZE + */ + @PublicKey + public static final Key<android.graphics.Rect> SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE = + new Key<android.graphics.Rect>("android.sensor.info.preCorrectionActiveArraySize", android.graphics.Rect.class); + + /** * <p>Range of sensitivities for {@link CaptureRequest#SENSOR_SENSITIVITY android.sensor.sensitivity} supported by this * camera device.</p> * <p>The values are the standard ISO sensitivity values, @@ -2089,22 +2155,24 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri /** * <p>Dimensions of the full pixel array, possibly * including black calibration pixels.</p> - * <p>The pixel count of the full pixel array, - * which covers {@link CameraCharacteristics#SENSOR_INFO_PHYSICAL_SIZE android.sensor.info.physicalSize} area.</p> - * <p>If a camera device supports raw sensor formats, either this - * or {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} is the maximum output - * raw size listed in {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap}. - * If a size corresponding to pixelArraySize is listed, the resulting - * raw sensor image will include black pixels.</p> + * <p>The pixel count of the full pixel array of the image sensor, which covers + * {@link CameraCharacteristics#SENSOR_INFO_PHYSICAL_SIZE android.sensor.info.physicalSize} area. This represents the full pixel dimensions of + * the raw buffers produced by this sensor.</p> + * <p>If a camera device supports raw sensor formats, either this or + * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} is the maximum dimensions for the raw + * output formats listed in {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP android.scaler.streamConfigurationMap} (this depends on + * whether or not the image sensor returns buffers containing pixels that are not + * part of the active array region for blacklevel calibration or other purposes).</p> * <p>Some parts of the full pixel array may not receive light from the scene, - * or are otherwise inactive. The {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} key - * defines the rectangle of active pixels that actually forms an image.</p> + * or be otherwise inactive. The {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} key + * defines the rectangle of active pixels that will be included in processed image + * formats.</p> * <p><b>Units</b>: Pixels</p> * <p>This key is available on all devices.</p> * * @see CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP - * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE * @see CameraCharacteristics#SENSOR_INFO_PHYSICAL_SIZE + * @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE */ @PublicKey public static final Key<android.util.Size> SENSOR_INFO_PIXEL_ARRAY_SIZE = diff --git a/core/java/android/net/Network.java b/core/java/android/net/Network.java index 9628bae..fe69320 100644 --- a/core/java/android/net/Network.java +++ b/core/java/android/net/Network.java @@ -378,6 +378,9 @@ public class Network implements Parcelable { // // The HANDLE_MAGIC value MUST be kept in sync with the corresponding // value in the native/android/net.c NDK implementation. + if (netId == 0) { + return 0L; // make this zero condition obvious for debugging + } final long HANDLE_MAGIC = 0xfacade; return (((long) netId) << 32) | HANDLE_MAGIC; } diff --git a/core/tests/coretests/src/android/net/NetworkTest.java b/core/tests/coretests/src/android/net/NetworkTest.java index b0ecb04..74b6d98 100644 --- a/core/tests/coretests/src/android/net/NetworkTest.java +++ b/core/tests/coretests/src/android/net/NetworkTest.java @@ -16,11 +16,14 @@ package android.net; +import static android.test.MoreAsserts.assertNotEqual; + import android.net.LocalServerSocket; import android.net.LocalSocket; import android.net.LocalSocketAddress; import android.net.Network; import android.test.suitebuilder.annotation.SmallTest; + import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; @@ -29,6 +32,7 @@ import java.net.DatagramSocket; import java.net.InetAddress; import java.net.Inet6Address; import java.net.SocketException; + import junit.framework.TestCase; public class NetworkTest extends TestCase { @@ -93,4 +97,50 @@ public class NetworkTest extends TestCase { fail("SocketException not thrown"); } catch (SocketException expected) {} } + + @SmallTest + public void testZeroIsObviousForDebugging() { + Network zero = new Network(0); + assertEquals(0, zero.hashCode()); + assertEquals(0, zero.getNetworkHandle()); + assertEquals("0", zero.toString()); + } + + @SmallTest + public void testGetNetworkHandle() { + Network one = new Network(1); + Network two = new Network(2); + Network three = new Network(3); + + // None of the hashcodes are zero. + assertNotEqual(0, one.hashCode()); + assertNotEqual(0, two.hashCode()); + assertNotEqual(0, three.hashCode()); + + // All the hashcodes are distinct. + assertNotEqual(one.hashCode(), two.hashCode()); + assertNotEqual(one.hashCode(), three.hashCode()); + assertNotEqual(two.hashCode(), three.hashCode()); + + // None of the handles are zero. + assertNotEqual(0, one.getNetworkHandle()); + assertNotEqual(0, two.getNetworkHandle()); + assertNotEqual(0, three.getNetworkHandle()); + + // All the handles are distinct. + assertNotEqual(one.getNetworkHandle(), two.getNetworkHandle()); + assertNotEqual(one.getNetworkHandle(), three.getNetworkHandle()); + assertNotEqual(two.getNetworkHandle(), three.getNetworkHandle()); + + // The handles are not equal to the hashcodes. + assertNotEqual(one.hashCode(), one.getNetworkHandle()); + assertNotEqual(two.hashCode(), two.getNetworkHandle()); + assertNotEqual(three.hashCode(), three.getNetworkHandle()); + + // Adjust as necessary to test an implementation's specific constants. + // When running with runtest, "adb logcat -s TestRunner" can be useful. + assertEquals(4311403230L, one.getNetworkHandle()); + assertEquals(8606370526L, two.getNetworkHandle()); + assertEquals(12901337822L, three.getNetworkHandle()); + } } diff --git a/media/java/android/mtp/MtpDevice.java b/media/java/android/mtp/MtpDevice.java index 72dcaa8..a68361b 100644 --- a/media/java/android/mtp/MtpDevice.java +++ b/media/java/android/mtp/MtpDevice.java @@ -132,7 +132,8 @@ public final class MtpDevice { * * @param storageId the storage unit to query * @param format the format of the object to return, or zero for all formats - * @param objectHandle the parent object to query, or zero for the storage root + * @param objectHandle the parent object to query, -1 for the storage root, + * or zero for all objects * @return the object handles */ public int[] getObjectHandles(int storageId, int format, int objectHandle) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index c8212c2..9761cd1 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -242,6 +242,9 @@ public class QSPanel extends ViewGroup { } private void handleSetTileVisibility(View v, int visibility) { + if (visibility == VISIBLE && !mGridContentVisible) { + visibility = INVISIBLE; + } if (visibility == v.getVisibility()) return; v.setVisibility(visibility); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index a750572..e3b1b9f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -1263,7 +1263,7 @@ public class NotificationPanelView extends PanelView implements setQsExpanded(true); } else if (height <= mQsMinExpansionHeight && mQsExpanded) { setQsExpanded(false); - if (mLastAnnouncementWasQuickSettings && !mTracking) { + if (mLastAnnouncementWasQuickSettings && !mTracking && !isCollapsing()) { announceForAccessibility(getKeyguardOrLockScreenString()); mLastAnnouncementWasQuickSettings = false; } diff --git a/services/core/java/com/android/server/IntentResolver.java b/services/core/java/com/android/server/IntentResolver.java index 744156b..3359060 100644 --- a/services/core/java/com/android/server/IntentResolver.java +++ b/services/core/java/com/android/server/IntentResolver.java @@ -731,6 +731,10 @@ public abstract class IntentResolver<F extends IntentFilter, R extends Object> { if (filter.getAutoVerify()) { if (localVerificationLOGV || debug) { Slog.v(TAG, " Filter verified: " + isFilterVerified(filter)); + int authorities = filter.countDataAuthorities(); + for (int z = 0; z < authorities; z++) { + Slog.v(TAG, " " + filter.getDataAuthority(z).getHost()); + } } } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 421ba86..e9b9767 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -5267,7 +5267,7 @@ public final class ActivityManagerService extends ActivityManagerNative } int callerUid = Binder.getCallingUid(); // Only the system server can kill an application - if (callerUid == Process.SYSTEM_UID) { + if (UserHandle.getAppId(callerUid) == Process.SYSTEM_UID) { // Post an aysnc message to kill the application Message msg = mHandler.obtainMessage(KILL_APPLICATION_MSG); msg.arg1 = appid; diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java index b56e326..c973386 100644 --- a/services/core/java/com/android/server/am/BatteryStatsService.java +++ b/services/core/java/com/android/server/am/BatteryStatsService.java @@ -1167,6 +1167,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub BluetoothActivityEnergyInfo info = adapter.getControllerActivityEnergyInfo( BluetoothAdapter.ACTIVITY_ENERGY_INFO_REFRESHED); if (info != null && info.isValid()) { + if (info.getControllerEnergyUsed() < 0 || info.getControllerIdleTimeMillis() < 0 || + info.getControllerRxTimeMillis() < 0 || info.getControllerTxTimeMillis() < 0) { + Slog.wtf(TAG, "Bluetooth energy data is invalid: " + info); + } return info; } } diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index a24bd52..548d93c 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -268,6 +268,7 @@ public class PackageManagerService extends IPackageManager.Stub { static final boolean DEBUG_SETTINGS = false; static final boolean DEBUG_PREFERRED = false; static final boolean DEBUG_UPGRADE = false; + static final boolean DEBUG_DOMAIN_VERIFICATION = false; private static final boolean DEBUG_BACKUP = true; private static final boolean DEBUG_INSTALL = false; private static final boolean DEBUG_REMOVE = false; @@ -279,7 +280,6 @@ public class PackageManagerService extends IPackageManager.Stub { private static final boolean DEBUG_VERIFY = false; private static final boolean DEBUG_DEXOPT = false; private static final boolean DEBUG_ABI_SELECTION = false; - private static final boolean DEBUG_DOMAIN_VERIFICATION = false; private static final int RADIO_UID = Process.PHONE_UID; private static final int LOG_UID = Process.LOG_UID; @@ -11818,50 +11818,45 @@ public class PackageManagerService extends IPackageManager.Stub { final int verificationId = mIntentFilterVerificationToken++; int count = 0; final String packageName = pkg.packageName; - ArrayList<String> allHosts = new ArrayList<>(); + boolean needToVerify = false; synchronized (mPackages) { + // If any filters need to be verified, then all need to be. for (PackageParser.Activity a : pkg.activities) { for (ActivityIntentInfo filter : a.intents) { - boolean needsFilterVerification = filter.needsVerification(); - if (needsFilterVerification && needsNetworkVerificationLPr(filter)) { - if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, - "Verification needed for IntentFilter:" + filter.toString()); - mIntentFilterVerifier.addOneIntentFilterVerification( - verifierUid, userId, verificationId, filter, packageName); - count++; - } else if (!needsFilterVerification) { - if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, - "No verification needed for IntentFilter:" + filter.toString()); - if (hasValidDomains(filter)) { - ArrayList<String> hosts = filter.getHostsList(); - if (hosts.size() > 0) { - allHosts.addAll(hosts); - } else { - if (allHosts.isEmpty()) { - allHosts.add("*"); - } - } + if (filter.needsVerification() && needsNetworkVerificationLPr(filter)) { + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.d(TAG, "Intent filter needs verification, so processing all filters"); + } + needToVerify = true; + break; + } + } + } + if (needToVerify) { + for (PackageParser.Activity a : pkg.activities) { + for (ActivityIntentInfo filter : a.intents) { + boolean needsFilterVerification = filter.hasWebDataURI(); + if (needsFilterVerification && needsNetworkVerificationLPr(filter)) { + if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, + "Verification needed for IntentFilter:" + filter.toString()); + mIntentFilterVerifier.addOneIntentFilterVerification( + verifierUid, userId, verificationId, filter, packageName); + count++; } - } else { - if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, - "Verification already done for IntentFilter:" + filter.toString()); } } } } if (count > 0) { - mIntentFilterVerifier.startVerifications(userId); - if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, "Started " + count + if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, "Starting " + count + " IntentFilter verification" + (count > 1 ? "s" : "") - + " for userId:" + userId + "!"); + + " for userId:" + userId); + mIntentFilterVerifier.startVerifications(userId); } else { - if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, - "No need to start any IntentFilter verification!"); - if (allHosts.size() > 0 && mSettings.createIntentFilterVerificationIfNeededLPw( - packageName, allHosts) != null) { - scheduleWriteSettingsLocked(); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.d(TAG, "No filters or not all autoVerify for " + packageName); } } } diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index 8f2db30..cd50946 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -27,6 +27,7 @@ import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATIO import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED; import static android.os.Process.SYSTEM_UID; import static android.os.Process.PACKAGE_INFO_GID; +import static com.android.server.pm.PackageManagerService.DEBUG_DOMAIN_VERIFICATION; import android.content.IntentFilter; import android.content.pm.ActivityInfo; @@ -977,7 +978,9 @@ final class Settings { IntentFilterVerificationInfo getIntentFilterVerificationLPr(String packageName) { PackageSetting ps = mPackages.get(packageName); if (ps == null) { - Slog.w(PackageManagerService.TAG, "No package known for name: " + packageName); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.w(PackageManagerService.TAG, "No package known: " + packageName); + } return null; } return ps.getIntentFilterVerificationInfo(); @@ -988,20 +991,26 @@ final class Settings { ArrayList<String> domains) { PackageSetting ps = mPackages.get(packageName); if (ps == null) { - Slog.w(PackageManagerService.TAG, "No package known for name: " + packageName); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.w(PackageManagerService.TAG, "No package known: " + packageName); + } return null; } IntentFilterVerificationInfo ivi = ps.getIntentFilterVerificationInfo(); if (ivi == null) { ivi = new IntentFilterVerificationInfo(packageName, domains); ps.setIntentFilterVerificationInfo(ivi); - Slog.d(PackageManagerService.TAG, - "Creating new IntentFilterVerificationInfo for packageName: " + packageName); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.d(PackageManagerService.TAG, + "Creating new IntentFilterVerificationInfo for pkg: " + packageName); + } } else { ivi.setDomains(domains); - Slog.d(PackageManagerService.TAG, - "Setting domains to existing IntentFilterVerificationInfo for packageName: " + - packageName + " and with domains: " + ivi.getDomainsString()); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.d(PackageManagerService.TAG, + "Setting domains to existing IntentFilterVerificationInfo for pkg: " + + packageName + " and with domains: " + ivi.getDomainsString()); + } } return ivi; } @@ -1009,7 +1018,9 @@ final class Settings { int getIntentFilterVerificationStatusLPr(String packageName, int userId) { PackageSetting ps = mPackages.get(packageName); if (ps == null) { - Slog.w(PackageManagerService.TAG, "No package known for name: " + packageName); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.w(PackageManagerService.TAG, "No package known: " + packageName); + } return INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED; } int status = ps.getDomainVerificationStatusForUser(userId); @@ -1025,14 +1036,18 @@ final class Settings { // Update the status for the current package PackageSetting current = mPackages.get(packageName); if (current == null) { - Slog.w(PackageManagerService.TAG, "No package known for name: " + packageName); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.w(PackageManagerService.TAG, "No package known: " + packageName); + } return false; } current.setDomainVerificationStatusForUser(status, userId); if (current.getIntentFilterVerificationInfo() == null) { - Slog.w(PackageManagerService.TAG, - "No IntentFilterVerificationInfo known for name: " + packageName); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.w(PackageManagerService.TAG, + "No IntentFilterVerificationInfo known: " + packageName); + } return false; } @@ -1080,7 +1095,9 @@ final class Settings { boolean removeIntentFilterVerificationLPw(String packageName, int userId) { PackageSetting ps = mPackages.get(packageName); if (ps == null) { - Slog.w(PackageManagerService.TAG, "No package known for name: " + packageName); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.w(PackageManagerService.TAG, "No package known: " + packageName); + } return false; } ps.clearDomainVerificationStatusForUser(userId); @@ -1549,8 +1566,10 @@ final class Settings { if (verificationInfo != null && verificationInfo.getPackageName() != null) { serializer.startTag(null, TAG_DOMAIN_VERIFICATION); verificationInfo.writeToXml(serializer); - Log.d(TAG, "Wrote domain verification for package: " - + verificationInfo.getPackageName()); + if (DEBUG_DOMAIN_VERIFICATION) { + Slog.d(TAG, "Wrote domain verification for package: " + + verificationInfo.getPackageName()); + } serializer.endTag(null, TAG_DOMAIN_VERIFICATION); } } diff --git a/wifi/java/android/net/wifi/WifiActivityEnergyInfo.java b/wifi/java/android/net/wifi/WifiActivityEnergyInfo.java index 0f73342..035317e 100644 --- a/wifi/java/android/net/wifi/WifiActivityEnergyInfo.java +++ b/wifi/java/android/net/wifi/WifiActivityEnergyInfo.java @@ -39,22 +39,22 @@ public final class WifiActivityEnergyInfo implements Parcelable { /** * @hide */ - public int mControllerTxTimeMs; + public long mControllerTxTimeMs; /** * @hide */ - public int mControllerRxTimeMs; + public long mControllerRxTimeMs; /** * @hide */ - public int mControllerIdleTimeMs; + public long mControllerIdleTimeMs; /** * @hide */ - public int mControllerEnergyUsed; + public long mControllerEnergyUsed; public static final int STACK_STATE_INVALID = 0; public static final int STACK_STATE_STATE_ACTIVE = 1; @@ -62,7 +62,7 @@ public final class WifiActivityEnergyInfo implements Parcelable { public static final int STACK_STATE_STATE_IDLE = 3; public WifiActivityEnergyInfo(long timestamp, int stackState, - int txTime, int rxTime, int idleTime, int energyUsed) { + long txTime, long rxTime, long idleTime, long energyUsed) { mTimestamp = timestamp; mStackState = stackState; mControllerTxTimeMs = txTime; @@ -88,10 +88,10 @@ public final class WifiActivityEnergyInfo implements Parcelable { public WifiActivityEnergyInfo createFromParcel(Parcel in) { long timestamp = in.readLong(); int stackState = in.readInt(); - int txTime = in.readInt(); - int rxTime = in.readInt(); - int idleTime = in.readInt(); - int energyUsed = in.readInt(); + long txTime = in.readLong(); + long rxTime = in.readLong(); + long idleTime = in.readLong(); + long energyUsed = in.readLong(); return new WifiActivityEnergyInfo(timestamp, stackState, txTime, rxTime, idleTime, energyUsed); } @@ -103,10 +103,10 @@ public final class WifiActivityEnergyInfo implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeLong(mTimestamp); out.writeInt(mStackState); - out.writeInt(mControllerTxTimeMs); - out.writeInt(mControllerRxTimeMs); - out.writeInt(mControllerIdleTimeMs); - out.writeInt(mControllerEnergyUsed); + out.writeLong(mControllerTxTimeMs); + out.writeLong(mControllerRxTimeMs); + out.writeLong(mControllerIdleTimeMs); + out.writeLong(mControllerEnergyUsed); } public int describeContents() { @@ -123,30 +123,29 @@ public final class WifiActivityEnergyInfo implements Parcelable { /** * @return tx time in ms */ - public int getControllerTxTimeMillis() { - return (int)mControllerTxTimeMs; + public long getControllerTxTimeMillis() { + return mControllerTxTimeMs; } /** * @return rx time in ms */ - public int getControllerRxTimeMillis() { - return (int)mControllerRxTimeMs; + public long getControllerRxTimeMillis() { + return mControllerRxTimeMs; } /** * @return idle time in ms */ - public int getControllerIdleTimeMillis() { - return (int)mControllerIdleTimeMs; + public long getControllerIdleTimeMillis() { + return mControllerIdleTimeMs; } - /** * product of current(mA), voltage(V) and time(ms) * @return energy used */ - public int getControllerEnergyUsed() { + public long getControllerEnergyUsed() { return mControllerEnergyUsed; } /** @@ -160,8 +159,8 @@ public final class WifiActivityEnergyInfo implements Parcelable { * @return if the record is valid */ public boolean isValid() { - return ((getControllerTxTimeMillis() !=0) || - (getControllerRxTimeMillis() !=0) || - (getControllerIdleTimeMillis() !=0)); + return ((mControllerTxTimeMs !=0) || + (mControllerRxTimeMs !=0) || + (mControllerIdleTimeMs !=0)); } } |