Fix restricted fragment dialogs

The dialog for a setting being restricted was showing even when the
password was being entered correctly. This CL makes it so that
if the password is correctly entered we dismiss the dialog if it
is up.

Test: robotests
Bug: 77722622
Change-Id: Ifc82bc1e5800afff2a0883a13bf316f84169d80d
This commit is contained in:
Salvador Martinez
2018-04-18 17:38:46 -07:00
parent 68f331d452
commit 8c975b7bc0
2 changed files with 74 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.support.annotation.VisibleForTesting;
import android.view.View;
import android.widget.TextView;
@@ -56,7 +57,7 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
protected static final String RESTRICT_IF_OVERRIDABLE = "restrict_if_overridable";
// No RestrictedSettingsFragment screens should use this number in startActivityForResult.
private static final int REQUEST_PIN_CHALLENGE = 12309;
@VisibleForTesting static final int REQUEST_PIN_CHALLENGE = 12309;
private static final String KEY_CHALLENGE_SUCCEEDED = "chsc";
private static final String KEY_CHALLENGE_REQUESTED = "chrq";
@@ -86,7 +87,8 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
}
};
private AlertDialog mActionDisabledDialog;
@VisibleForTesting
AlertDialog mActionDisabledDialog;
/**
* @param restrictionKey The restriction key to check before pin protecting
@@ -153,6 +155,10 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
if (resultCode == Activity.RESULT_OK) {
mChallengeSucceeded = true;
mChallengeRequested = false;
if (mActionDisabledDialog != null && mActionDisabledDialog.isShowing()) {
mActionDisabledDialog.setOnDismissListener(null);
mActionDisabledDialog.dismiss();
}
} else {
mChallengeSucceeded = false;
}