Move install component into config file.
This will allow for specifying the location of credential storage in a
resource overlay. The specific use case is for automotive builds in
which com.android.settings is replaced by com.android.car.settings.
Bug: 130199964
Bug: 139705828
Test:
-m cts-verifier
-adb install -g out/<path to apk>/CtsVerifier.apk
-adb shell setprop log.tag.KeyChainTest DEBUG
-Launch CTS Verifier from app launcher
-Scroll to "KeyChain Storage Test" in Security section
-Tap to begin test and follow prompts on screen
-Accept dialog prompt to install certificates
-Ensure toast is shown that certificates installed successfully
-Complete test steps and verify in logs that "Connection succeeded"
Change-Id: I77e69e934084059130b3b217992ef508e1c5f55c
Merged-In: I77e69e934084059130b3b217992ef508e1c5f55c
(cherry picked from commit 0045d56af4395ab26a30aa528ebfeadfec025e5d)
diff --git a/res/values/config.xml b/res/values/config.xml
index 918b499..062c1ce 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -16,5 +16,7 @@
<resources>
<bool name="config_auto_cert_approval">true</bool>
+
+ <string name="config_system_install_component" translatable="false">com.android.settings/com.android.settings.security.CredentialStorage</string>
</resources>
diff --git a/src/com/android/certinstaller/CredentialHelper.java b/src/com/android/certinstaller/CredentialHelper.java
index 2091226..4ec2e7e 100644
--- a/src/com/android/certinstaller/CredentialHelper.java
+++ b/src/com/android/certinstaller/CredentialHelper.java
@@ -18,6 +18,7 @@
import android.app.KeyguardManager;
import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -277,8 +278,8 @@
Intent intent = new Intent("com.android.credentials.INSTALL");
// To prevent the private key from being sniffed, we explicitly spell
// out the intent receiver class.
- intent.setClassName(
- Util.SETTINGS_PACKAGE, "com.android.settings.security.CredentialStorage");
+ intent.setComponent(ComponentName.unflattenFromString(
+ context.getString(R.string.config_system_install_component)));
intent.putExtra(Credentials.EXTRA_INSTALL_AS_UID, mUid);
try {
if (mUserKey != null) {
diff --git a/src/com/android/certinstaller/Util.java b/src/com/android/certinstaller/Util.java
index 6178c3c..00c14c4 100644
--- a/src/com/android/certinstaller/Util.java
+++ b/src/com/android/certinstaller/Util.java
@@ -30,8 +30,6 @@
class Util {
private static final String TAG = "certinstaller.Util";
- public static final String SETTINGS_PACKAGE = "com.android.settings";
-
static byte[] toBytes(Object object) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {