Disable SetupRedactionInterstitial when complete

When RedactionInterstitial is complete, there is no need to show the
SetupRedactionInterstitial as optional step anymore. Disable it via
package manager when RedactionInterstatial completes.

Test: Manual
Bug: 36696006
Change-Id: I3fd421d6a8a0d24d7ebbe8c1e688a10e00067f2f
diff --git a/src/com/android/settings/SetupRedactionInterstitial.java b/src/com/android/settings/SetupRedactionInterstitial.java
index d527585..321040e 100644
--- a/src/com/android/settings/SetupRedactionInterstitial.java
+++ b/src/com/android/settings/SetupRedactionInterstitial.java
@@ -16,11 +16,11 @@
 
 package com.android.settings;
 
+import android.content.ComponentName;
+import android.content.Context;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.content.res.Resources;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
 
 import com.android.settings.notification.RedactionInterstitial;
 
@@ -33,6 +33,20 @@
  */
 public class SetupRedactionInterstitial extends RedactionInterstitial {
 
+    /**
+     * Set the enabled state of SetupRedactionInterstitial activity to configure whether it is shown
+     * as part of setup wizard's optional steps.
+     */
+    public static void setEnabled(Context context, boolean enabled) {
+        PackageManager packageManager = context.getPackageManager();
+        ComponentName componentName = new ComponentName(context, SetupRedactionInterstitial.class);
+        packageManager.setComponentEnabledSetting(
+                componentName,
+                enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
+                        : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+                PackageManager.DONT_KILL_APP);
+    }
+
     @Override
     public Intent getIntent() {
         Intent modIntent = new Intent(super.getIntent());