Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74a2283d authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Finish trampoline activity for ConfirmDeviceCredential immediately

Make sure to finish ConfirmDeviceCredentialActivity directly, and use
Intent.FLAG_ACTIVITY_FORWARD_RESULT, so we can't even end up in a
state where we have the trampoline activity but not the real activity.

Bug: 23849216
Change-Id: I7a5be5af74ca85c11df1f61a69c3fd5cf558e1fb
parent 69671daf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1409,7 +1409,7 @@
        <!-- Lock screen settings -->
        <activity android:name="ConfirmDeviceCredentialActivity"
            android:exported="true"
            android:theme="@style/Transparent">
            android:theme="@android:style/Theme.NoDisplay">
            <intent-filter android:priority="1">
                <action android:name="android.app.action.CONFIRM_DEVICE_CREDENTIAL" />
                <category android:name="android.intent.category.DEFAULT" />
+12 −3
Original line number Diff line number Diff line
@@ -158,11 +158,20 @@ public final class ChooseLockSettingsHelper {
        intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, hasChallenge);
        intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
        intent.setClassName(ConfirmDeviceCredentialBaseFragment.PACKAGE, activityClass.getName());
        if (external) {
            intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
            if (mFragment != null) {
                mFragment.startActivity(intent);
            } else {
                mActivity.startActivity(intent);
            }
        } else {
            if (mFragment != null) {
                mFragment.startActivityForResult(intent, request);
            } else {
                mActivity.startActivityForResult(intent, request);
            }
        }
        return true;
    }
}
+5 −16
Original line number Diff line number Diff line
@@ -58,23 +58,12 @@ public class ConfirmDeviceCredentialActivity extends Activity {
        String title = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
        String details = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);

        // Ignore rotates and ensure we only launch this once
        if (savedInstanceState == null) {
        ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this);
        if (!helper.launchConfirmationActivity(0 /* request code */, null /* title */, title,
                details, false /* returnCredentials */, true /* isExternal */)) {
            Log.d(TAG, "No pattern, password or PIN set.");
            setResult(Activity.RESULT_OK);
                finish();
            }
        }
        }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        boolean credentialsConfirmed = (resultCode == Activity.RESULT_OK);
        Log.d(TAG, "Device credentials confirmed: " + credentialsConfirmed);
        setResult(credentialsConfirmed ? Activity.RESULT_OK : Activity.RESULT_CANCELED);
        finish();
    }
}