1 /* 2 * Copyright (C) 2017 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.os; 18 19 import android.annotation.TestApi; 20 import android.util.Slog; 21 22 import java.util.Map; 23 24 /** 25 * Java API for libvintf. 26 * 27 * @hide 28 */ 29 @TestApi 30 public class VintfObject { 31 32 private static final String LOG_TAG = "VintfObject"; 33 34 /** 35 * Slurps all device information (both manifests and both matrices) 36 * and report them. 37 * If any error in getting one of the manifests, it is not included in 38 * the list. 39 * 40 * @hide 41 */ 42 @TestApi report()43 public static native String[] report(); 44 45 /** 46 * Verify that the given metadata for an OTA package is compatible with 47 * this device. 48 * 49 * @param packageInfo a list of serialized form of HalManifest's / 50 * CompatibilityMatri'ces (XML). 51 * @return = 0 if success (compatible) 52 * > 0 if incompatible 53 * < 0 if any error (mount partition fails, illformed XML, etc.) 54 * 55 * @deprecated Checking compatibility against an OTA package is no longer 56 * supported because the format of VINTF metadata in the OTA package may not 57 * be recognized by the current system. 58 * 59 * <p> 60 * <ul> 61 * <li>This function always returns 0 for non-empty {@code packageInfo}. 62 * </li> 63 * <li>This function returns the result of {@link #verifyWithoutAvb} for 64 * null or empty {@code packageInfo}.</li> 65 * </ul> 66 * 67 * @hide 68 */ 69 @Deprecated verify(String[] packageInfo)70 public static int verify(String[] packageInfo) { 71 if (packageInfo != null && packageInfo.length > 0) { 72 Slog.w(LOG_TAG, "VintfObject.verify() with non-empty packageInfo is deprecated. " 73 + "Skipping compatibility checks for update package."); 74 return 0; 75 } 76 Slog.w(LOG_TAG, "VintfObject.verify() is deprecated. Call verifyWithoutAvb() instead."); 77 return verifyWithoutAvb(); 78 } 79 80 /** 81 * Verify Vintf compatibility on the device without checking AVB 82 * (Android Verified Boot). It is useful to verify a running system 83 * image where AVB check is irrelevant. 84 * 85 * @return = 0 if success (compatible) 86 * > 0 if incompatible 87 * < 0 if any error (mount partition fails, illformed XML, etc.) 88 * 89 * @hide 90 */ verifyWithoutAvb()91 public static native int verifyWithoutAvb(); 92 93 /** 94 * @return a list of HAL names and versions that is supported by this 95 * device as stated in device and framework manifests. For example, 96 * ["android.hidl.manager@1.0", "android.hardware.camera.device@1.0", 97 * "android.hardware.camera.device@3.2"]. There are no duplicates. 98 * 99 * For AIDL HALs, the version is stripped away 100 * (e.g. "android.hardware.light"). 101 * @hide 102 */ 103 @TestApi getHalNamesAndVersions()104 public static native String[] getHalNamesAndVersions(); 105 106 /** 107 * @return the BOARD_SEPOLICY_VERS build flag available in device manifest. 108 * 109 * @hide 110 */ 111 @TestApi getSepolicyVersion()112 public static native String getSepolicyVersion(); 113 114 /** 115 * @return a list of VNDK snapshots supported by the framework, as 116 * specified in framework manifest. For example, 117 * [("27", ["libjpeg.so", "libbase.so"]), 118 * ("28", ["libjpeg.so", "libbase.so"])] 119 * 120 * @hide 121 */ 122 @TestApi getVndkSnapshots()123 public static native Map<String, String[]> getVndkSnapshots(); 124 125 /** 126 * @return Target Framework Compatibility Matrix (FCM) version, a number 127 * specified in the device manifest indicating the FCM version that the 128 * device manifest implements. Null if device manifest doesn't specify this 129 * number (for legacy devices). 130 * 131 * @hide 132 */ 133 @TestApi getTargetFrameworkCompatibilityMatrixVersion()134 public static native Long getTargetFrameworkCompatibilityMatrixVersion(); 135 VintfObject()136 private VintfObject() {} 137 } 138