diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2af7b897a01..6c429a54cce 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -313,13 +313,20 @@
-
+
+
+
+
+
+
+
Updating Wi-Fi setting
Updating Bluetooth setting
+
+ Credential installer
+
VPN settings
diff --git a/src/com/android/settings/CredentialInstaller.java b/src/com/android/settings/CredentialInstaller.java
new file mode 100644
index 00000000000..5a457d7e65a
--- /dev/null
+++ b/src/com/android/settings/CredentialInstaller.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.security.Credentials;
+import android.security.KeyStore;
+import android.util.Log;
+
+/**
+ * Installs credentials to the system keystore. It reacts to the
+ * {@link Credentials#SYSTEM_INSTALL_ACTION} intent. All the key-value pairs in
+ * the intent are installed to the system keystore. For security reason, the
+ * current implementation limits that only com.android.certinstaller can use
+ * this service.
+ */
+public class CredentialInstaller extends Activity {
+ private static final String TAG = "CredentialInstaller";
+
+ private KeyStore mKeyStore = KeyStore.getInstance();
+ private boolean mUnlocking = false;
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ if (!"com.android.certinstaller".equals(getCallingPackage())) finish();
+
+ if (!isKeyStoreLocked()) {
+ install();
+ finish();
+ } else if (!mUnlocking) {
+ mUnlocking = true;
+ Credentials.getInstance().unlock(this);
+ } else {
+ finish();
+ }
+ }
+
+ private void install() {
+ Intent intent = getIntent();
+ Bundle bundle = (intent == null) ? null : intent.getExtras();
+ if (bundle == null) return;
+ for (String key : bundle.keySet()) {
+ byte[] data = bundle.getByteArray(key);
+ if (data == null) continue;
+ boolean success = mKeyStore.put(key.getBytes(), data);
+ Log.v(TAG, "install " + key + ": " + data.length + " success? " + success);
+ if (!success) return;
+ }
+ setResult(RESULT_OK);
+ }
+
+ private boolean isKeyStoreLocked() {
+ return (mKeyStore.test() != KeyStore.NO_ERROR);
+ }
+}
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index cdfd8bdd7a1..80300e09068 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -380,9 +380,6 @@ public class SecuritySettings extends PreferenceActivity {
mExternalIntent = intent;
showCstorDialog(mState == KeyStore.UNINITIALIZED
? CSTOR_INIT_DIALOG : CSTOR_UNLOCK_DIALOG);
- } else if (Credentials.SYSTEM_INSTALL_ACTION.equals(action)) {
- mExternalIntent = intent;
- // TODO: unlock and install.
}
}
@@ -460,12 +457,7 @@ public class SecuritySettings extends PreferenceActivity {
removeDialog(mDialogId);
if (mExternalIntent != null) {
- if (Credentials.SYSTEM_INSTALL_ACTION.equals(
- mExternalIntent.getAction())) {
- // TODO: install if unlocked.
- } else {
- finish();
- }
+ finish();
}
}
}