Merge "[NAN] Remove builder API using String to translate to byte[]"
diff --git a/api/current.txt b/api/current.txt
index fc08523..125e113 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -52022,7 +52022,7 @@
   }
 
   public final class Parameter implements java.lang.reflect.AnnotatedElement {
-    method public T getAnnotation(java.lang.Class<T>);
+    method public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T>);
     method public java.lang.annotation.Annotation[] getAnnotations();
     method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
     method public java.lang.reflect.Executable getDeclaringExecutable();
diff --git a/api/system-current.txt b/api/system-current.txt
index 497bf58..6dc2bcf 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -55379,7 +55379,7 @@
   }
 
   public final class Parameter implements java.lang.reflect.AnnotatedElement {
-    method public T getAnnotation(java.lang.Class<T>);
+    method public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T>);
     method public java.lang.annotation.Annotation[] getAnnotations();
     method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
     method public java.lang.reflect.Executable getDeclaringExecutable();
diff --git a/api/test-current.txt b/api/test-current.txt
index 16feecd..941790e 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -52102,7 +52102,7 @@
   }
 
   public final class Parameter implements java.lang.reflect.AnnotatedElement {
-    method public T getAnnotation(java.lang.Class<T>);
+    method public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T>);
     method public java.lang.annotation.Annotation[] getAnnotations();
     method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
     method public java.lang.reflect.Executable getDeclaringExecutable();
diff --git a/core/java/android/os/HwBlob.java b/core/java/android/os/HwBlob.java
index 153c6e6..88226f0a 100644
--- a/core/java/android/os/HwBlob.java
+++ b/core/java/android/os/HwBlob.java
@@ -16,6 +16,8 @@
 
 package android.os;
 
+import android.annotation.NonNull;
+
 import libcore.util.NativeAllocationRegistry;
 
 /** @hide */
@@ -54,6 +56,69 @@
 
     public native final long handle();
 
+    public static Boolean[] wrapArray(@NonNull boolean[] array) {
+        final int n = array.length;
+        Boolean[] wrappedArray = new Boolean[n];
+        for (int i = 0; i < n; ++i) {
+          wrappedArray[i] = array[i];
+        }
+        return wrappedArray;
+    }
+
+    public static Long[] wrapArray(@NonNull long[] array) {
+        final int n = array.length;
+        Long[] wrappedArray = new Long[n];
+        for (int i = 0; i < n; ++i) {
+          wrappedArray[i] = array[i];
+        }
+        return wrappedArray;
+    }
+
+    public static Byte[] wrapArray(@NonNull byte[] array) {
+        final int n = array.length;
+        Byte[] wrappedArray = new Byte[n];
+        for (int i = 0; i < n; ++i) {
+          wrappedArray[i] = array[i];
+        }
+        return wrappedArray;
+    }
+
+    public static Short[] wrapArray(@NonNull short[] array) {
+        final int n = array.length;
+        Short[] wrappedArray = new Short[n];
+        for (int i = 0; i < n; ++i) {
+          wrappedArray[i] = array[i];
+        }
+        return wrappedArray;
+    }
+
+    public static Integer[] wrapArray(@NonNull int[] array) {
+        final int n = array.length;
+        Integer[] wrappedArray = new Integer[n];
+        for (int i = 0; i < n; ++i) {
+          wrappedArray[i] = array[i];
+        }
+        return wrappedArray;
+    }
+
+    public static Float[] wrapArray(@NonNull float[] array) {
+        final int n = array.length;
+        Float[] wrappedArray = new Float[n];
+        for (int i = 0; i < n; ++i) {
+          wrappedArray[i] = array[i];
+        }
+        return wrappedArray;
+    }
+
+    public static Double[] wrapArray(@NonNull double[] array) {
+        final int n = array.length;
+        Double[] wrappedArray = new Double[n];
+        for (int i = 0; i < n; ++i) {
+          wrappedArray[i] = array[i];
+        }
+        return wrappedArray;
+    }
+
     // Returns address of the "freeFunction".
     private static native final long native_init();
 
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index 028e30a..2d5a144 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -93,6 +93,14 @@
      */
     public static final File UNCRYPT_PACKAGE_FILE = new File(RECOVERY_DIR, "uncrypt_file");
 
+    /**
+     * UNCRYPT_STATUS_FILE stores the time cost (and error code in the case of a failure)
+     * of uncrypt.
+     *
+     * @hide
+     */
+    public static final File UNCRYPT_STATUS_FILE = new File(RECOVERY_DIR, "uncrypt_status");
+
     // Length limits for reading files.
     private static final int LOG_FILE_MAX_LENGTH = 64 * 1024;
 
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index 5b9d139..f7f79f3 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -716,6 +716,14 @@
         }
         if (!done[0]) {
             Log.w(TAG, "Timed out waiting for uncrypt.");
+            final int uncryptTimeoutError = 100;
+            String timeoutMessage = String.format("uncrypt_time: %d\n" + "uncrypt_error: %d\n",
+                    MAX_UNCRYPT_WAIT_TIME / 1000, uncryptTimeoutError);
+            try {
+                FileUtils.stringToFile(RecoverySystem.UNCRYPT_STATUS_FILE, timeoutMessage);
+            } catch (IOException e) {
+                Log.e(TAG, "Failed to write timeout message to uncrypt status", e);
+            }
         }
     }
 }