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