diff options
author | Shawn Willden <swillden@google.com> | 2016-11-16 06:01:06 -0700 |
---|---|---|
committer | Shawn Willden <swillden@google.com> | 2016-11-16 06:06:36 -0700 |
commit | dea66146038a28e9c7da2ad04a6119cfd83de2f8 (patch) | |
tree | e3b8f683d3f5e5722a11b94a96a5a160d945d1c5 /keystore/java/android/security/KeyChain.java | |
parent | ebd8b62cfe53192c967dc4a9822d5668d3bec8a0 (diff) |
Test for null context in getPrivateKey
In N, passing a null context to getPrivateKey provoked a
NullPointerException, which is validated by a CTS test. In commit
28d68b1 this behavior was changed (inadvertently, I believe) causing
getPrivateKey to wrap the NPE in a KeyChainException. This CL restores
the previous behavior, fixing the test and avoiding breaking any apps
that were catching the NPE.
Test: Fixing broken test
Change-Id: Icb0c75b03efc478b7310998cf3e7108a2c419107
Diffstat (limited to 'keystore/java/android/security/KeyChain.java')
-rw-r--r-- | keystore/java/android/security/KeyChain.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java index 5e59a64b23d4..e566b9d75846 100644 --- a/keystore/java/android/security/KeyChain.java +++ b/keystore/java/android/security/KeyChain.java @@ -414,6 +414,9 @@ public final class KeyChain { if (alias == null) { throw new NullPointerException("alias == null"); } + if (context == null) { + throw new NullPointerException("context == null"); + } final String keyId; try (KeyChainConnection keyChainConnection = bind(context.getApplicationContext())) { |