Merge cherrypicks of [6117971, 6117954, 6117972, 6112663, 6112664, 6118388, 6119070, 6111429, 6114218] into pi-b4s4-release

Change-Id: I836b2d3232038060dc1169c63f96f5e43f71d0a7
diff --git a/robotests/src/com/android/storagemanager/automatic/AutomaticStorageManagementJobServiceTest.java b/robotests/src/com/android/storagemanager/automatic/AutomaticStorageManagementJobServiceTest.java
index 736d7b4..27bd7c8 100644
--- a/robotests/src/com/android/storagemanager/automatic/AutomaticStorageManagementJobServiceTest.java
+++ b/robotests/src/com/android/storagemanager/automatic/AutomaticStorageManagementJobServiceTest.java
@@ -191,8 +191,8 @@
     }
 
     @Test
-    public void testASMJobRunsWithValidConditionsIfOptInNotShownButUnactivated() {
-        StorageManagerShadowSystemProperties.put("ro.storage_manager.show_opt_in", "false");
+    public void testASMJobRunsWithValidConditionsIfEnabledByDefaultAndUnset() {
+        StorageManagerShadowSystemProperties.put("ro.storage_manager.enabled", "true");
         assertThat(mJobService.onStartJob(mJobParameters)).isFalse();
         assertStorageManagerJobRan();
     }
diff --git a/src/com/android/storagemanager/automatic/NotificationController.java b/src/com/android/storagemanager/automatic/NotificationController.java
index 58c99d8..18e4533 100644
--- a/src/com/android/storagemanager/automatic/NotificationController.java
+++ b/src/com/android/storagemanager/automatic/NotificationController.java
@@ -98,12 +98,14 @@
     public void onReceive(Context context, Intent intent) {
         switch (intent.getAction()) {
             case INTENT_ACTION_ACTIVATE_ASM:
-                Settings.Secure.putInt(context.getContentResolver(),
+                Settings.Secure.putInt(
+                        context.getContentResolver(),
                         Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED,
                         1);
                 // Provide a warning if storage manager is not defaulted on.
                 if (!SystemProperties.getBoolean(STORAGE_MANAGER_PROPERTY, false)) {
                     Intent warningIntent = new Intent(context, WarningDialogActivity.class);
+                    warningIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                     context.startActivity(warningIntent);
                 }
                 break;