Restriction pin changes.
Fixed bug in WirelessSettings where it was asking users for a PIN when they weren't restricted. Did this by refactoring the preference level pin checking into the superclass, where it checks for the restricted mode first. Also pin protected changes to certificates for restricted users. Change-Id: I8310fd39f0862159668318fc1360ec6859cc00d5
This commit is contained in:
@@ -16,14 +16,18 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.http.SslCertificate;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserManager;
|
||||
import android.security.IKeyChainService;
|
||||
import android.security.KeyChain;
|
||||
import android.security.KeyChain.KeyChainConnection;
|
||||
@@ -52,6 +56,14 @@ public class TrustedCredentialsSettings extends Fragment {
|
||||
|
||||
private static final String TAG = "TrustedCredentialsSettings";
|
||||
|
||||
private UserManager mUserManager;
|
||||
|
||||
private static final int REQUEST_PIN_CHALLENGE = 12309;
|
||||
// If the restriction PIN is entered correctly.
|
||||
private boolean mChallengeSucceeded;
|
||||
private boolean mChallengeRequested;
|
||||
|
||||
|
||||
private enum Tab {
|
||||
SYSTEM("system",
|
||||
R.string.trusted_credentials_system_tab,
|
||||
@@ -142,6 +154,13 @@ public class TrustedCredentialsSettings extends Fragment {
|
||||
|
||||
private TabHost mTabHost;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mUserManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
@Override public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
||||
mTabHost = (TabHost) inflater.inflate(R.layout.trusted_credentials, parent, false);
|
||||
@@ -355,6 +374,11 @@ public class TrustedCredentialsSettings extends Fragment {
|
||||
removeButton.setText(certHolder.mTab.getButtonLabel(certHolder));
|
||||
removeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
if (mUserManager.hasRestrictionsPin() && !mChallengeSucceeded) {
|
||||
ensurePin();
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(certHolder.mTab.getButtonConfirmation(certHolder));
|
||||
builder.setPositiveButton(
|
||||
@@ -379,6 +403,35 @@ public class TrustedCredentialsSettings extends Fragment {
|
||||
certDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_PIN_CHALLENGE) {
|
||||
mChallengeRequested = false;
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
mChallengeSucceeded = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
private void ensurePin() {
|
||||
if (!mChallengeSucceeded) {
|
||||
final UserManager um = UserManager.get(getActivity());
|
||||
if (!mChallengeRequested) {
|
||||
if (um.hasRestrictionsPin()) {
|
||||
Intent requestPin =
|
||||
new Intent(Intent.ACTION_RESTRICTIONS_PIN_CHALLENGE);
|
||||
startActivityForResult(requestPin, REQUEST_PIN_CHALLENGE);
|
||||
mChallengeRequested = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
mChallengeSucceeded = false;
|
||||
}
|
||||
|
||||
|
||||
private class AliasOperation extends AsyncTask<Void, Void, Boolean> {
|
||||
private final CertHolder mCertHolder;
|
||||
private AliasOperation(CertHolder certHolder) {
|
||||
|
Reference in New Issue
Block a user