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

Commit e0405fc4 authored by Tony Mak's avatar Tony Mak
Browse files

Use Activity.getActivityToken to align with mr2

Context.getActivityToken is introduced since O.
To align with MR2 and avoid unnecessary merge conflict,
pass the activity token from activity to controller.

Test: 1. make RunSettingsRoboTests
      2. Manual Test
      	a. Start SET_NEW_PASSWORD intent in user 0, set password.
         	User 0 password is set.
      	b. Start SET_NEW_PASSWORD intent in work profile, set password.
         	work profile password is set.

Bug: 32959373
Change-Id: I8577752d446a7c395ad30417f8c0c832f951d7b3
parent 1ff0a535
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ public class SetNewPasswordActivity extends Activity implements SetNewPasswordCo
            finish();
            return;
        }
        mSetNewPasswordController = SetNewPasswordController.create(this, this, getIntent());
        mSetNewPasswordController = SetNewPasswordController.create(
                this, this, getIntent(), getActivityToken());
        mSetNewPasswordController.dispatchSetNewPasswordIntent();
    }

+4 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.IBinder;
import android.os.UserManager;

import com.android.internal.annotations.VisibleForTesting;
@@ -60,14 +61,15 @@ final class SetNewPasswordController {
    private final DevicePolicyManager mDevicePolicyManager;
    private final Ui mUi;

    public static SetNewPasswordController create(Context context, Ui ui, Intent intent) {
    public static SetNewPasswordController create(Context context, Ui ui, Intent intent,
            IBinder activityToken) {
        // Trying to figure out which user is setting new password. If it is
        // ACTION_SET_NEW_PARENT_PROFILE_PASSWORD or the calling user is not allowed to set
        // separate profile challenge, it is the current user to set new password. Otherwise,
        // it is the user who starts this activity setting new password.
        int userId = ActivityManager.getCurrentUser();
        if (ACTION_SET_NEW_PASSWORD.equals(intent.getAction())) {
            final int callingUserId = Utils.getSecureTargetUser(context.getActivityToken(),
            final int callingUserId = Utils.getSecureTargetUser(activityToken,
                    UserManager.get(context), null, intent.getExtras()).getIdentifier();
            final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
            if (lockPatternUtils.isSeparateProfileChallengeAllowed(callingUserId)) {