am 4e45d392
: Add certificate to keystore for the ADD intent
Merge commit '4e45d392ada4e84fbeed06874caebfd3c7759073' * commit '4e45d392ada4e84fbeed06874caebfd3c7759073': Add certificate to keystore for the ADD intent
This commit is contained in:
committed by
The Android Open Source Project
commit
acedb4b501
@@ -1997,6 +1997,7 @@ found in the list of installed applications.</string>
|
|||||||
<string name="cstor_is_enabled">Credential storage is enabled.</string>
|
<string name="cstor_is_enabled">Credential storage is enabled.</string>
|
||||||
<!-- toast message -->
|
<!-- toast message -->
|
||||||
<string name="cstor_is_added">%s is added.</string>
|
<string name="cstor_is_added">%s is added.</string>
|
||||||
|
<string name="cstor_add_error">Failed to add %s.</string>
|
||||||
|
|
||||||
<!-- Sound settings screen, setting check box label -->
|
<!-- Sound settings screen, setting check box label -->
|
||||||
<string name="emergency_tone_title">Emergency tone</string>
|
<string name="emergency_tone_title">Emergency tone</string>
|
||||||
|
@@ -81,9 +81,9 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
private static final String ASSISTED_GPS = "assisted_gps";
|
private static final String ASSISTED_GPS = "assisted_gps";
|
||||||
|
|
||||||
// Credential storage
|
// Credential storage
|
||||||
private static final String ACTION_ADD_CREDENTIAL =
|
public static final String ACTION_ADD_CREDENTIAL =
|
||||||
"android.security.ADD_CREDENTIAL";
|
"android.security.ADD_CREDENTIAL";
|
||||||
private static final String ACTION_UNLOCK_CREDENTIAL_STORAGE =
|
public static final String ACTION_UNLOCK_CREDENTIAL_STORAGE =
|
||||||
"android.security.UNLOCK_CREDENTIAL_STORAGE";
|
"android.security.UNLOCK_CREDENTIAL_STORAGE";
|
||||||
private static final String KEY_CSTOR_TYPE_NAME = "typeName";
|
private static final String KEY_CSTOR_TYPE_NAME = "typeName";
|
||||||
private static final String KEY_CSTOR_ITEM = "item";
|
private static final String KEY_CSTOR_ITEM = "item";
|
||||||
@@ -526,7 +526,10 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addCredential() {
|
private void addCredential() {
|
||||||
String message = String.format(getString(R.string.cstor_is_added),
|
String formatString = mCstorAddCredentialHelper.saveToStorage() < 0
|
||||||
|
? getString(R.string.cstor_add_error)
|
||||||
|
: getString(R.string.cstor_is_added);
|
||||||
|
String message = String.format(formatString,
|
||||||
mCstorAddCredentialHelper.getName());
|
mCstorAddCredentialHelper.getName());
|
||||||
Toast.makeText(SecuritySettings.this, message, Toast.LENGTH_SHORT)
|
Toast.makeText(SecuritySettings.this, message, Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
@@ -877,14 +880,6 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
return mTypeName;
|
return mTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] getItem(int i) {
|
|
||||||
return mItemList.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
String getNamespace(int i) {
|
|
||||||
return mNamespaceList.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
CharSequence getDescription() {
|
CharSequence getDescription() {
|
||||||
return Html.fromHtml(mDescription);
|
return Html.fromHtml(mDescription);
|
||||||
}
|
}
|
||||||
@@ -897,6 +892,16 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int saveToStorage() {
|
||||||
|
Keystore ks = Keystore.getInstance();
|
||||||
|
for (int i = 0, count = mItemList.size(); i < count; i++) {
|
||||||
|
byte[] blob = mItemList.get(i);
|
||||||
|
int ret = ks.put(mNamespaceList.get(i), mName, new String(blob));
|
||||||
|
if (ret < 0) return ret;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void parse(Intent intent) {
|
private void parse(Intent intent) {
|
||||||
mTypeName = intent.getStringExtra(KEY_CSTOR_TYPE_NAME);
|
mTypeName = intent.getStringExtra(KEY_CSTOR_TYPE_NAME);
|
||||||
mItemList = new ArrayList<byte[]>();
|
mItemList = new ArrayList<byte[]>();
|
||||||
|
Reference in New Issue
Block a user