RESTRICT AUTOMERGE
Allow LockScreenPattern to be launched in the pinning screen

If work profile lock is enabled and work app is pinned, users will get a
black/white screen on the phone. That's because Settings is prevented
from other apps launch any pages of Settings in the pinning mode.

In order to launch some pages of Settings from other apps, we add a
condition to the preventive mechanism and allow the activity inherited
from SettingsBaseActivity to override the condition to have the activity
to be launched from other apps in the pinning mode.

Bug: 137015265
Bug: 135604684
Test: manual test
Change-Id: I8070de79a83350d1658efcb19e983669dad0e673
Merged-In: I8070de79a83350d1658efcb19e983669dad0e673
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 3bfafbb..00cf069 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -235,7 +235,7 @@
         super.onCreate(savedState);
         Log.d(LOG_TAG, "Starting onCreate");
 
-        if (isLockTaskModePinned() && !isSettingsRunOnTop()) {
+        if (isLockTaskModePinned() && !isSettingsRunOnTop() && !isLaunchableInTaskModePinned()) {
             Log.w(LOG_TAG, "Devices lock task mode pinned.");
             finish();
         }
@@ -804,6 +804,13 @@
         return mNextButton;
     }
 
+    /**
+     * @return whether or not the activity can be launched from other apps in the pinning screen.
+     */
+    public boolean isLaunchableInTaskModePinned() {
+        return false;
+    }
+
     @VisibleForTesting
     Bitmap getBitmapFromXmlResource(int drawableRes) {
         Drawable drawable = getResources().getDrawable(drawableRes, getTheme());
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index 1775394..2290fc0 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -139,6 +139,11 @@
         }
     }
 
+    @Override
+    public boolean isLaunchableInTaskModePinned() {
+        return true;
+    }
+
     public void prepareEnterAnimation() {
         getFragment().prepareEnterAnimation();
     }