summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-11-14 00:14:08 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-11-14 00:14:08 +0000
commitca689352d5ad9845c12b0efbdf43d04e1803cd9f (patch)
tree08f2b69e40032d95ee3921dc983eec975b45086a
parente0c471f05a40c5dc60873d8a9e7214d947877283 (diff)
parent1f3f7be3dacc8afde521aed1ebaa0e883a46dc10 (diff)
Merge "WifiKeyStore: Handle existing config being null"
-rw-r--r--service/java/com/android/server/wifi/WifiKeyStore.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/service/java/com/android/server/wifi/WifiKeyStore.java b/service/java/com/android/server/wifi/WifiKeyStore.java
index 11a23e64f..87289fa68 100644
--- a/service/java/com/android/server/wifi/WifiKeyStore.java
+++ b/service/java/com/android/server/wifi/WifiKeyStore.java
@@ -123,8 +123,10 @@ public class WifiKeyStore {
caCertificateAliases.add(alias);
}
}
- // Remove old private keys.
- removeEntryFromKeyStore(existingAlias);
+ if (existingAlias != null) {
+ // Remove old private keys.
+ removeEntryFromKeyStore(existingAlias);
+ }
// Remove any old CA certs.
for (String oldAlias : oldCaCertificatesToRemove) {
removeEntryFromKeyStore(oldAlias);
@@ -245,21 +247,25 @@ public class WifiKeyStore {
public boolean updateNetworkKeys(WifiConfiguration config, WifiConfiguration existingConfig) {
Preconditions.checkNotNull(mKeyStore);
Preconditions.checkNotNull(config.enterpriseConfig);
- Preconditions.checkNotNull(existingConfig.enterpriseConfig);
WifiEnterpriseConfig enterpriseConfig = config.enterpriseConfig;
+ /* config passed may include only fields being updated.
+ * In order to generate the key id, fetch uninitialized
+ * fields from the currently tracked configuration
+ */
+ String keyId = config.getKeyIdForCredentials(existingConfig);
+ WifiEnterpriseConfig existingEnterpriseConfig = null;
+ String existingKeyId = null;
+ if (existingConfig != null) {
+ Preconditions.checkNotNull(existingConfig.enterpriseConfig);
+ existingEnterpriseConfig = existingConfig.enterpriseConfig;
+ existingKeyId = existingConfig.getKeyIdForCredentials(existingConfig);
+ }
if (!needsKeyStore(enterpriseConfig)) {
return true;
}
try {
- /* config passed may include only fields being updated.
- * In order to generate the key id, fetch uninitialized
- * fields from the currently tracked configuration
- */
- String keyId = config.getKeyIdForCredentials(existingConfig);
- String existingKeyId = existingConfig.getKeyIdForCredentials(existingConfig);
- if (!installKeys(existingConfig.enterpriseConfig, enterpriseConfig,
- existingKeyId, keyId)) {
+ if (!installKeys(existingEnterpriseConfig, enterpriseConfig, existingKeyId, keyId)) {
Log.e(TAG, config.SSID + ": failed to install keys");
return false;
}