summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/TrustedCredentialsSettings.java
diff options
context:
space:
mode:
authorGeoffrey Borggaard <geoffreyb@google.com>2013-08-07 14:57:43 -0400
committerGeoffrey Borggaard <geoffreyb@google.com>2013-08-07 14:57:43 -0400
commit6e1102d9faf1b8f038857709412c291ef6140aa9 (patch)
tree5969c274c388cca35730010b4870ab060ad08305 /src/com/android/settings/TrustedCredentialsSettings.java
parent8a181dd0d1e710a2376488b158d71db915f73be6 (diff)
downloadpackages_apps_Settings-6e1102d9faf1b8f038857709412c291ef6140aa9.tar.gz
packages_apps_Settings-6e1102d9faf1b8f038857709412c291ef6140aa9.tar.bz2
packages_apps_Settings-6e1102d9faf1b8f038857709412c291ef6140aa9.zip
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
Diffstat (limited to 'src/com/android/settings/TrustedCredentialsSettings.java')
-rw-r--r--src/com/android/settings/TrustedCredentialsSettings.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/com/android/settings/TrustedCredentialsSettings.java b/src/com/android/settings/TrustedCredentialsSettings.java
index cdfe7cd30..b3716e36b 100644
--- a/src/com/android/settings/TrustedCredentialsSettings.java
+++ b/src/com/android/settings/TrustedCredentialsSettings.java
@@ -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) {