Merge "[Settings] Avoids disabled component when page start from setup wizard." into rvc-dev
diff --git a/src/com/android/settings/SetupRedactionInterstitial.java b/src/com/android/settings/SetupRedactionInterstitial.java
index 90f6c21..4747d84 100644
--- a/src/com/android/settings/SetupRedactionInterstitial.java
+++ b/src/com/android/settings/SetupRedactionInterstitial.java
@@ -20,9 +20,12 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.os.Bundle;
 
 import com.android.settings.notification.RedactionInterstitial;
 
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
 /**
  * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure
  * from RedactionInterstitial class, and should remain similar to that behaviorally. This class
@@ -47,6 +50,15 @@
     }
 
     @Override
+    protected void onCreate(Bundle savedInstance) {
+        // Only allow to start the activity from Setup Wizard.
+        if (!WizardManagerHelper.isAnySetupWizard(getIntent())) {
+            finish();
+        }
+        super.onCreate(savedInstance);
+    }
+
+    @Override
     public Intent getIntent() {
         Intent modIntent = new Intent(super.getIntent());
         modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index 14f99f3..ac648a5 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -48,6 +48,7 @@
 
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupcompat.util.WizardManagerHelper;
 import com.google.android.setupdesign.GlifLayout;
 
 public class RedactionInterstitial extends SettingsActivity {
@@ -144,7 +145,11 @@
         }
 
         private void onDoneButtonClicked(View view) {
-            SetupRedactionInterstitial.setEnabled(getContext(), false);
+            // If the activity starts by Setup Wizard, then skip disable component which avoids the
+            // framework force closing all activities on the same task when the system is busy.
+            if (!WizardManagerHelper.isAnySetupWizard(getIntent())) {
+                SetupRedactionInterstitial.setEnabled(getContext(), false);
+            }
             final RedactionInterstitial activity = (RedactionInterstitial) getActivity();
             if (activity != null) {
                 activity.setResult(RESULT_OK, null);