diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-08-12 22:36:00 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-08-12 22:36:00 +0000 |
commit | 5b202eec3429d69666c897a391cd845cef4970da (patch) | |
tree | 9d103d5afa1bb6b3cf16c79a358f043fd17ac6c2 | |
parent | adee32324fdf78cc054d5d17bdda4d3064d81bc2 (diff) | |
parent | 54b1606727b74029c601a5eca4eccf7a5083020b (diff) | |
download | base-5b202eec3429d69666c897a391cd845cef4970da.tar.gz |
Merge cherrypicks of [15548052, 15548053, 15548731, 15548784, 15548801, 15548711, 15548732, 15548733] into sc-release
Change-Id: I7e4035112dc704b50d137494297280376b44d54f
4 files changed, 21 insertions, 8 deletions
diff --git a/location/java/android/location/CorrelationVector.java b/location/java/android/location/CorrelationVector.java index 718977ff4296..5493e2579225 100644 --- a/location/java/android/location/CorrelationVector.java +++ b/location/java/android/location/CorrelationVector.java @@ -94,8 +94,6 @@ public final class CorrelationVector implements Parcelable { "FrequencyOffsetMetersPerSecond must be non-negative (greater than or equal to 0)"); Preconditions.checkArgument(builder.mSamplingWidthMeters > 0.0, "SamplingWidthMeters must be positive (greater than 0)"); - Preconditions.checkArgument(builder.mSamplingStartMeters >= 0.0, - "SamplingStartMeters must be non-negative (greater than or equal to 0)"); mMagnitude = builder.mMagnitude; mFrequencyOffsetMetersPerSecond = builder.mFrequencyOffsetMetersPerSecond; mSamplingWidthMeters = builder.mSamplingWidthMeters; diff --git a/services/core/java/com/android/server/SensorPrivacyService.java b/services/core/java/com/android/server/SensorPrivacyService.java index 422e8ae14862..91b2440f71fe 100644 --- a/services/core/java/com/android/server/SensorPrivacyService.java +++ b/services/core/java/com/android/server/SensorPrivacyService.java @@ -1021,7 +1021,15 @@ public final class SensorPrivacyService extends SystemService { } } - return upgradeAndInit(version, map); + try { + return upgradeAndInit(version, map); + } catch (Exception e) { + Log.wtf(TAG, "Failed to upgrade and set sensor privacy state," + + " resetting to default.", e); + mEnabled = new SparseBooleanArray(); + mIndividualEnabled = new SparseArray<>(); + return true; + } } private boolean upgradeAndInit(int version, SparseArray map) { @@ -1037,22 +1045,22 @@ public final class SensorPrivacyService extends SystemService { final int[] users = getLocalService(UserManagerInternal.class).getUserIds(); if (version == 0) { final boolean enabled = (boolean) map.get(VER0_ENABLED); - final SparseBooleanArray individualEnabled = - (SparseBooleanArray) map.get(VER0_INDIVIDUAL_ENABLED); + final SparseArray<SensorState> individualEnabled = + (SparseArray<SensorState>) map.get(VER0_INDIVIDUAL_ENABLED); final SparseBooleanArray perUserEnabled = new SparseBooleanArray(); - final SparseArray<SparseBooleanArray> perUserIndividualEnabled = + final SparseArray<SparseArray<SensorState>> perUserIndividualEnabled = new SparseArray<>(); // Copy global state to each user for (int i = 0; i < users.length; i++) { int user = users[i]; perUserEnabled.put(user, enabled); - SparseBooleanArray userIndividualSensorEnabled = new SparseBooleanArray(); + SparseArray<SensorState> userIndividualSensorEnabled = new SparseArray<>(); perUserIndividualEnabled.put(user, userIndividualSensorEnabled); for (int j = 0; j < individualEnabled.size(); j++) { final int sensor = individualEnabled.keyAt(j); - final boolean isSensorEnabled = individualEnabled.valueAt(j); + final SensorState isSensorEnabled = individualEnabled.valueAt(j); userIndividualSensorEnabled.put(sensor, isSensorEnabled); } } diff --git a/services/tests/mockingservicestests/assets/SensorPrivacyServiceMockingTest/persisted_file6.xml b/services/tests/mockingservicestests/assets/SensorPrivacyServiceMockingTest/persisted_file6.xml new file mode 100644 index 000000000000..b3c142285c8a --- /dev/null +++ b/services/tests/mockingservicestests/assets/SensorPrivacyServiceMockingTest/persisted_file6.xml @@ -0,0 +1,3 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes' ?> +<sensor-privacy enabled="false"> +</sensor-privacy> diff --git a/services/tests/mockingservicestests/src/com/android/server/sensorprivacy/SensorPrivacyServiceMockingTest.java b/services/tests/mockingservicestests/src/com/android/server/sensorprivacy/SensorPrivacyServiceMockingTest.java index 844687f34555..ba79a764b672 100644 --- a/services/tests/mockingservicestests/src/com/android/server/sensorprivacy/SensorPrivacyServiceMockingTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/sensorprivacy/SensorPrivacyServiceMockingTest.java @@ -60,6 +60,8 @@ public class SensorPrivacyServiceMockingTest { String.format(PERSISTENCE_FILE_PATHS_TEMPLATE, 4); public static final String PERSISTENCE_FILE5 = String.format(PERSISTENCE_FILE_PATHS_TEMPLATE, 5); + public static final String PERSISTENCE_FILE6 = + String.format(PERSISTENCE_FILE_PATHS_TEMPLATE, 6); private Context mContext; @Mock @@ -111,6 +113,7 @@ public class SensorPrivacyServiceMockingTest { initServiceWithPersistenceFile(onDeviceFile, PERSISTENCE_FILE3); initServiceWithPersistenceFile(onDeviceFile, PERSISTENCE_FILE4); initServiceWithPersistenceFile(onDeviceFile, PERSISTENCE_FILE5); + initServiceWithPersistenceFile(onDeviceFile, PERSISTENCE_FILE6); // Try all files with two known users doReturn(new int[]{0, 10}).when(mMockedUserManagerInternal).getUserIds(); @@ -124,6 +127,7 @@ public class SensorPrivacyServiceMockingTest { initServiceWithPersistenceFile(onDeviceFile, PERSISTENCE_FILE3); initServiceWithPersistenceFile(onDeviceFile, PERSISTENCE_FILE4); initServiceWithPersistenceFile(onDeviceFile, PERSISTENCE_FILE5); + initServiceWithPersistenceFile(onDeviceFile, PERSISTENCE_FILE6); } finally { mockitoSession.finishMocking(); |