1 /*
2  * Copyright (C) 2020 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.service.displayhash;
18 
19 import android.graphics.Rect;
20 import android.hardware.HardwareBuffer;
21 import android.os.RemoteCallback;
22 import android.view.displayhash.DisplayHash;
23 
24 /**
25  * Service used to handle DisplayHash requests.
26  *
27  * @hide
28  */
29 oneway interface IDisplayHashingService {
30     /**
31      * Generates the DisplayHash that can be used to validate that the system generated the token.
32      *
33      * @param salt The salt to use when generating the hmac. This should be unique to the caller so
34      *        the token cannot be verified by any other process.
35      * @param buffer The buffer to generate the hash for.
36      * @param bounds The size and position of the content being hashed in window space.
37      * @param hashAlgorithm The String for the hash algorithm to use based on values in
38      *        {@link #SERVICE_META_DATA_KEY_AVAILABLE_ALGORITHMS}.
39      * @param Callback The callback invoked to send back the DisplayHash.
40      */
generateDisplayHash(in byte[] salt, in HardwareBuffer buffer, in Rect bounds, in String hashAlgorithm, in RemoteCallback callback)41     void generateDisplayHash(in byte[] salt, in HardwareBuffer buffer, in Rect bounds,
42                                  in String hashAlgorithm, in RemoteCallback callback);
43 
44     /**
45      * Call to verify that the DisplayHash passed in was generated by the system. The result
46      * will be sent in the callback as a boolean with the key {@link #EXTRA_VERIFIED_DISPLAY_HASH}.
47      *
48      * @param salt The salt value to use when verifying the hmac. This should be the same value that
49      *        was passed to {@link generateDisplayHash()} to generate the DisplayHash.
50      * @param displayHash The hash to verify that it was generated by the system.
51      * @param callback The callback invoked to send back the VerifiedDisplayHash.
52      */
verifyDisplayHash(in byte[] salt, in DisplayHash displayHash, in RemoteCallback callback)53     void verifyDisplayHash(in byte[] salt, in DisplayHash displayHash, in RemoteCallback callback);
54 
55     /**
56      * Call to get a map of supported algorithms and their {@link DisplayHashParams}
57      *
58      * @param callback The callback invoked to send back the map of algorithms to DisplayHashParams.
59      */
getDisplayHashAlgorithms(in RemoteCallback callback)60     void getDisplayHashAlgorithms(in RemoteCallback callback);
61 
62     /**
63      * Call to get the interval required between display hash requests. Requests made faster than
64      * this will be throttled. The result will be sent in the callback as an int with the key
65      * {@link #EXTRA_INTERVAL_BETWEEN_REQUESTS}.
66      *
67      * @param callback The callback invoked to send back the interval duration.
68      */
getIntervalBetweenRequestsMillis(in RemoteCallback callback)69     void getIntervalBetweenRequestsMillis(in RemoteCallback callback);
70 }
71