From 3775f969bacee5013eb13004f932f64f7f38324d Mon Sep 17 00:00:00 2001 From: timhypeng Date: Sun, 8 Apr 2018 13:53:46 +0800 Subject: [PATCH 01/14] Rename onProfileAudioStateChanged() to onAudioModeChanged() Bug: 74134939 Test: Build Change-Id: I85895238b6ee16fec85d0cf3dd0242c9ba17a3bd --- src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java | 2 +- src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java | 2 +- .../settings/bluetooth/DeviceListPreferenceFragment.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java index e322bb4d86b..67cf2994acc 100644 --- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java +++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java @@ -167,7 +167,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback { } @Override - public void onProfileAudioStateChanged(int bluetoothProfile, int state) { + public void onAudioModeChanged() { } /** diff --git a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java index 380bf699a1e..5724ab427bb 100644 --- a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java +++ b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java @@ -81,7 +81,7 @@ public final class BluetoothSummaryUpdater extends SummaryUpdater implements Blu } @Override - public void onProfileAudioStateChanged(int bluetoothProfile, int state) { + public void onAudioModeChanged() { } @Override diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java index 0a7dc7cbf1b..904d737a324 100644 --- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java +++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java @@ -276,7 +276,7 @@ public abstract class DeviceListPreferenceFragment extends public void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile) { } @Override - public void onProfileAudioStateChanged(int bluetoothProfile, int state) { } + public void onAudioModeChanged() { } /** * Return the key of the {@link PreferenceGroup} that contains the bluetooth devices From e832c153c0ccdbe8094946d5e2c3acf5aaafe197 Mon Sep 17 00:00:00 2001 From: Bookatz Date: Tue, 10 Apr 2018 17:40:42 -0700 Subject: [PATCH 02/14] Fuelgauge handle StatsManager Exception API StatsManager now returns Exceptions for certain errors, instead of returning a boolean. Thus Fuelgauge needs to be updated. Bug: 77648233 Test: make ROBOTEST_FILTER=AnomalyConfigJobServiceTest RunSettingsRoboTests Change-Id: I7160ac01141c673c90e33423220dc888a2710340 --- .../batterytip/AnomalyConfigJobService.java | 33 +++++++++++-------- .../batterytip/AnomalyConfigReceiver.java | 6 +++- .../fuelgauge/batterytip/BatteryTipUtils.java | 8 +++-- .../AnomalyConfigJobServiceTest.java | 10 +++--- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobService.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobService.java index 5686d6e0aea..eb1e98341eb 100644 --- a/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobService.java +++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobService.java @@ -71,7 +71,11 @@ public class AnomalyConfigJobService extends JobService { ThreadUtils.postOnBackgroundThread(() -> { final StatsManager statsManager = getSystemService(StatsManager.class); checkAnomalyConfig(statsManager); - BatteryTipUtils.uploadAnomalyPendingIntent(this, statsManager); + try { + BatteryTipUtils.uploadAnomalyPendingIntent(this, statsManager); + } catch (StatsManager.StatsUnavailableException e) { + Log.w(TAG, "Failed to uploadAnomalyPendingIntent.", e); + } jobFinished(params, false /* wantsReschedule */); }); @@ -96,23 +100,26 @@ public class AnomalyConfigJobService extends JobService { Log.i(TAG, "CurrentVersion: " + currentVersion + " new version: " + newVersion); if (newVersion > currentVersion) { - statsManager.removeConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY); + try { + statsManager.removeConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY); + } catch (StatsManager.StatsUnavailableException e) { + Log.i(TAG, "When updating anomaly config, failed to first remove the old config " + + StatsManagerConfig.ANOMALY_CONFIG_KEY, e); + } if (!TextUtils.isEmpty(rawConfig)) { try { final byte[] config = Base64.decode(rawConfig, Base64.DEFAULT); - if (statsManager.addConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY, - config)) { - Log.i(TAG, "Upload the anomaly config. configKey: " - + StatsManagerConfig.ANOMALY_CONFIG_KEY); - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putInt(KEY_ANOMALY_CONFIG_VERSION, newVersion); - editor.commit(); - } else { - Log.i(TAG, "Upload the anomaly config failed. configKey: " - + StatsManagerConfig.ANOMALY_CONFIG_KEY); - } + statsManager.addConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY, config); + Log.i(TAG, "Upload the anomaly config. configKey: " + + StatsManagerConfig.ANOMALY_CONFIG_KEY); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putInt(KEY_ANOMALY_CONFIG_VERSION, newVersion); + editor.commit(); } catch (IllegalArgumentException e) { Log.e(TAG, "Anomaly raw config is in wrong format", e); + } catch (StatsManager.StatsUnavailableException e) { + Log.i(TAG, "Upload of anomaly config failed for configKey " + + StatsManagerConfig.ANOMALY_CONFIG_KEY, e); } } } diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java index bad1c11b4fb..8e224470221 100644 --- a/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java +++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java @@ -41,7 +41,11 @@ public class AnomalyConfigReceiver extends BroadcastReceiver { // Check whether to update the config AnomalyConfigJobService.scheduleConfigUpdate(context); - BatteryTipUtils.uploadAnomalyPendingIntent(context, statsManager); + try { + BatteryTipUtils.uploadAnomalyPendingIntent(context, statsManager); + } catch (StatsManager.StatsUnavailableException e) { + Log.w(TAG, "Failed to uploadAnomalyPendingIntent.", e); + } if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { AnomalyCleanupJobService.scheduleCleanUp(context); diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java index a9e0fc87fa9..98ff244b0b8 100644 --- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java +++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java @@ -110,12 +110,14 @@ public class BatteryTipUtils { /** * Upload the {@link PendingIntent} to {@link StatsManager} for anomaly detection + * @throws StatsManager.StatsUnavailableException if failed to communicate with stats service */ - public static void uploadAnomalyPendingIntent(Context context, StatsManager statsManager) { + public static void uploadAnomalyPendingIntent(Context context, StatsManager statsManager) + throws StatsManager.StatsUnavailableException { final Intent extraIntent = new Intent(context, AnomalyDetectionReceiver.class); final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, extraIntent, PendingIntent.FLAG_UPDATE_CURRENT); - statsManager.setBroadcastSubscriber(StatsManagerConfig.ANOMALY_CONFIG_KEY, - StatsManagerConfig.SUBSCRIBER_ID, pendingIntent); + statsManager.setBroadcastSubscriber(pendingIntent, + StatsManagerConfig.ANOMALY_CONFIG_KEY, StatsManagerConfig.SUBSCRIBER_ID); } } diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobServiceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobServiceTest.java index 90af7b17c2a..35b6531a5b3 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobServiceTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobServiceTest.java @@ -104,7 +104,8 @@ public class AnomalyConfigJobServiceTest { } @Test - public void checkAnomalyConfig_newConfigExist_removeOldConfig() { + public void checkAnomalyConfig_newConfigExist_removeOldConfig() + throws StatsManager.StatsUnavailableException{ Settings.Global.putInt(application.getContentResolver(), Settings.Global.ANOMALY_CONFIG_VERSION, ANOMALY_CONFIG_VERSION); Settings.Global.putString(application.getContentResolver(), Settings.Global.ANOMALY_CONFIG, @@ -112,11 +113,12 @@ public class AnomalyConfigJobServiceTest { mJobService.checkAnomalyConfig(mStatsManager); - verify(mStatsManager).removeConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY); + verify(mStatsManager).removeConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY); } @Test - public void checkAnomalyConfig_newConfigExist_uploadNewConfig() { + public void checkAnomalyConfig_newConfigExist_uploadNewConfig() + throws StatsManager.StatsUnavailableException{ Settings.Global.putInt(application.getContentResolver(), Settings.Global.ANOMALY_CONFIG_VERSION, ANOMALY_CONFIG_VERSION); Settings.Global.putString(application.getContentResolver(), Settings.Global.ANOMALY_CONFIG, @@ -124,7 +126,7 @@ public class AnomalyConfigJobServiceTest { mJobService.checkAnomalyConfig(mStatsManager); - verify(mStatsManager).addConfiguration(eq(StatsManagerConfig.ANOMALY_CONFIG_KEY), any()); + verify(mStatsManager).addConfig(eq(StatsManagerConfig.ANOMALY_CONFIG_KEY), any()); } } From 8ca084e62b53ef3f84bb1317f2be22f1e3671565 Mon Sep 17 00:00:00 2001 From: Maurice Lam Date: Tue, 10 Apr 2018 19:53:41 -0700 Subject: [PATCH 03/14] Fix landscape pattern enroll crash Test: atest SetupChooseLockPatternTest.java Bug: 77878150 Change-Id: Ie54286765ea0d766bcc9e2c8e56cfbda919d5fd7 --- res/layout-land/choose_lock_pattern.xml | 8 +++++ .../choose_lock_pattern_common_footer.xml | 6 ++-- .../password/SetupChooseLockPatternTest.java | 30 +++++++++++++++---- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/res/layout-land/choose_lock_pattern.xml b/res/layout-land/choose_lock_pattern.xml index cba6173a77f..4d6f798c39c 100644 --- a/res/layout-land/choose_lock_pattern.xml +++ b/res/layout-land/choose_lock_pattern.xml @@ -120,6 +120,14 @@ android:clipToPadding="false" android:orientation="horizontal"> + +