Add button to trust a CA cert
- Put Disable button for system cert and Remove button for user cert as action button in cert dialog - OK (dismiss) button is displayed when trust button is not shown - Showing chain of cert dialot will be in a later CL Bug: 18224038 Change-Id: Ieef70e12fd8bdf711be48dc0488f03dbe143d3c5
This commit is contained in:
@@ -5229,6 +5229,8 @@
|
|||||||
<string name="trusted_credentials_enable_label">Enable</string>
|
<string name="trusted_credentials_enable_label">Enable</string>
|
||||||
<!-- Button label for removing a user CA certificate. -->
|
<!-- Button label for removing a user CA certificate. -->
|
||||||
<string name="trusted_credentials_remove_label">Remove</string>
|
<string name="trusted_credentials_remove_label">Remove</string>
|
||||||
|
<!-- Button label for trusting a user CA certificate. -->
|
||||||
|
<string name="trusted_credentials_trust_label">Trust</string>
|
||||||
<!-- Alert dialog confirmation when enabling a system CA certificate. -->
|
<!-- Alert dialog confirmation when enabling a system CA certificate. -->
|
||||||
<string name="trusted_credentials_enable_confirmation">Enable the system CA certificate?</string>
|
<string name="trusted_credentials_enable_confirmation">Enable the system CA certificate?</string>
|
||||||
<!-- Alert dialog confirmation when disabling a system CA certificate. -->
|
<!-- Alert dialog confirmation when disabling a system CA certificate. -->
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@@ -717,6 +718,7 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment {
|
|||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setTitle(com.android.internal.R.string.ssl_certificate);
|
builder.setTitle(com.android.internal.R.string.ssl_certificate);
|
||||||
|
|
||||||
|
final DevicePolicyManager dpm = getActivity().getSystemService(DevicePolicyManager.class);
|
||||||
final ArrayList<View> views = new ArrayList<View>();
|
final ArrayList<View> views = new ArrayList<View>();
|
||||||
final ArrayList<String> titles = new ArrayList<String>();
|
final ArrayList<String> titles = new ArrayList<String>();
|
||||||
addCertChain(certHolder, views, titles);
|
addCertChain(certHolder, views, titles);
|
||||||
@@ -729,14 +731,15 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment {
|
|||||||
spinner.setAdapter(arrayAdapter);
|
spinner.setAdapter(arrayAdapter);
|
||||||
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
long id) {
|
for (int i = 0; i < views.size(); i++) {
|
||||||
for(int i = 0; i < views.size(); i++) {
|
|
||||||
views.get(i).setVisibility(i == position ? View.VISIBLE : View.GONE);
|
views.get(i).setVisibility(i == position ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> parent) { }
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
LinearLayout container = new LinearLayout(getActivity());
|
LinearLayout container = new LinearLayout(getActivity());
|
||||||
@@ -750,47 +753,47 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment {
|
|||||||
container.addView(certificateView);
|
container.addView(certificateView);
|
||||||
}
|
}
|
||||||
builder.setView(container);
|
builder.setView(container);
|
||||||
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override public void onClick(DialogInterface dialog, int id) {
|
if (certHolder.mTab == Tab.USER &&
|
||||||
dialog.dismiss();
|
!dpm.isCaCertApproved(certHolder.mAlias, certHolder.mProfileId)) {
|
||||||
|
builder.setPositiveButton(R.string.trusted_credentials_trust_label,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dpm.approveCaCert(certHolder.mAlias, certHolder.mProfileId, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final Dialog certDialog = builder.create();
|
} else {
|
||||||
|
// The ok button is optional. Display it only when trust button is not displayed.
|
||||||
|
// User can still dismiss the dialog by other means.
|
||||||
|
builder.setPositiveButton(android.R.string.ok, null);
|
||||||
|
}
|
||||||
|
|
||||||
ViewGroup body = (ViewGroup) container.findViewById(com.android.internal.R.id.body);
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
|
||||||
Button removeButton = (Button) inflater.inflate(R.layout.trusted_credential_details,
|
|
||||||
body,
|
|
||||||
false);
|
|
||||||
if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS,
|
if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS,
|
||||||
new UserHandle(certHolder.mProfileId))) {
|
new UserHandle(certHolder.mProfileId))) {
|
||||||
body.addView(removeButton);
|
builder.setNegativeButton(certHolder.mTab.getButtonLabel(certHolder),
|
||||||
}
|
new DialogInterface.OnClickListener() {
|
||||||
removeButton.setText(certHolder.mTab.getButtonLabel(certHolder));
|
@Override
|
||||||
removeButton.setOnClickListener(new View.OnClickListener() {
|
public void onClick(final DialogInterface parentDialog, int i) {
|
||||||
@Override public void onClick(View v) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setMessage(certHolder.mTab.getButtonConfirmation(certHolder));
|
builder.setMessage(certHolder.mTab.getButtonConfirmation(certHolder));
|
||||||
builder.setPositiveButton(
|
builder.setPositiveButton(android.R.string.yes,
|
||||||
android.R.string.yes, new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override public void onClick(DialogInterface dialog, int id) {
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
new AliasOperation(certHolder).execute();
|
new AliasOperation(certHolder).execute();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
certDialog.dismiss();
|
parentDialog.dismiss();
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(
|
|
||||||
android.R.string.no, new DialogInterface.OnClickListener() {
|
|
||||||
@Override public void onClick(DialogInterface dialog, int id) {
|
|
||||||
dialog.cancel();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
builder.setNegativeButton(android.R.string.no, null);
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
certDialog.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCertChain(final CertHolder certHolder,
|
private void addCertChain(final CertHolder certHolder,
|
||||||
|
Reference in New Issue
Block a user