OSDN Git Service

AndroidKeyStore: return error code on error
authorKenny Root <kroot@google.com>
Mon, 4 Feb 2013 23:49:11 +0000 (15:49 -0800)
committerKenny Root <kroot@google.com>
Mon, 4 Feb 2013 23:50:58 +0000 (15:50 -0800)
Instead of blindly multiplying return value by 1000 to convert to
milliseconds, check to see if it's an error condition first.

Change-Id: I8eab1e7a86d78c13458fcbbc79d590e452fc9791

keystore/java/android/security/KeyStore.java

index 444dc1d..ceaff37 100644 (file)
@@ -243,7 +243,12 @@ public class KeyStore {
      */
     public long getmtime(String key) {
         try {
-            return mBinder.getmtime(key) * 1000L;
+            final long millis = mBinder.getmtime(key);
+            if (millis == -1L) {
+                return -1L;
+            }
+
+            return millis * 1000L;
         } catch (RemoteException e) {
             Log.w(TAG, "Cannot connect to keystore", e);
             return -1L;