1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.ext.services.displayhash;
18 
19 import android.hardware.HardwareBuffer;
20 import android.os.Build;
21 
22 import androidx.annotation.NonNull;
23 import androidx.annotation.Nullable;
24 import androidx.annotation.RequiresApi;
25 import androidx.annotation.Size;
26 
27 @RequiresApi(Build.VERSION_CODES.S)
28 class ImageHashManager {
29     static {
30         System.loadLibrary("extservices_jni");
31     }
32 
ImageHashManager()33     ImageHashManager() {}
34 
nativeGenerateHash(HardwareBuffer hardwareBuffer, String hashAlgorithm)35     private static native byte[] nativeGenerateHash(HardwareBuffer hardwareBuffer,
36             String hashAlgorithm);
37 
38     @Nullable
generateHash(@onNull HardwareBuffer hardwareBuffer, String hashAlgorithm)39     @Size(8) byte[] generateHash(@NonNull HardwareBuffer hardwareBuffer, String hashAlgorithm) {
40         return nativeGenerateHash(hardwareBuffer, hashAlgorithm);
41     }
42 }
43