1 /* 2 * Copyright (C) 2022 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.transparency; 18 19 import android.annotation.NonNull; 20 import android.annotation.SystemService; 21 import android.content.Context; 22 import android.os.RemoteException; 23 import android.util.Slog; 24 25 import com.android.internal.os.IBinaryTransparencyService; 26 27 import java.util.Map; 28 29 /** 30 * BinaryTransparencyManager defines a number of system interfaces that other system apps or 31 * services can make use of, when trying to get more information about the various binaries 32 * that are installed on this device. 33 * @hide 34 */ 35 @SystemService(Context.BINARY_TRANSPARENCY_SERVICE) 36 public class BinaryTransparencyManager { 37 private static final String TAG = "TransparencyManager"; 38 39 private final Context mContext; 40 private final IBinaryTransparencyService mService; 41 42 /** 43 * Constructor 44 * @param context The calling context. 45 * @param service A valid instance of IBinaryTransparencyService. 46 * @hide 47 */ BinaryTransparencyManager(Context context, IBinaryTransparencyService service)48 public BinaryTransparencyManager(Context context, IBinaryTransparencyService service) { 49 mContext = context; 50 mService = service; 51 } 52 53 54 /** 55 * Obtains a string containing information that describes the signed images that are installed 56 * on this device. Currently, this piece of information is identified as the VBMeta digest. 57 * @return A String containing the VBMeta Digest of the signed partitions loaded on this device. 58 */ 59 @NonNull getSignedImageInfo()60 public String getSignedImageInfo() { 61 try { 62 return mService.getSignedImageInfo(); 63 } catch (RemoteException e) { 64 throw e.rethrowFromSystemServer(); 65 } 66 } 67 68 /** 69 * Returns a map of all installed APEXs consisting of package name to SHA256 hash of the 70 * package. 71 * @return A Map with the following entries: {apex package name : sha256 digest of package} 72 */ 73 @NonNull getApexInfo()74 public Map getApexInfo() { 75 try { 76 Slog.d(TAG, "Calling backend's getApexInfo()"); 77 return mService.getApexInfo(); 78 } catch (RemoteException e) { 79 throw e.rethrowFromSystemServer(); 80 } 81 } 82 83 } 84