blob: 7af8f71aa4aa13da78355402e56960def7b94a17 [file] [log] [blame]
Yifan Hongbecc56d2017-04-05 14:42:05 -07001/*
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
17package android.os;
18
Yifan Hong58578702019-01-11 16:35:50 -080019import android.annotation.TestApi;
Yifan Hong12ebf362019-12-18 12:52:55 -080020import android.util.Slog;
Yifan Hongbecc56d2017-04-05 14:42:05 -070021
Yifan Hong58578702019-01-11 16:35:50 -080022import java.util.Map;
Yifan Hongbecc56d2017-04-05 14:42:05 -070023
Yifan Hong687113a2017-05-04 13:05:24 -070024/**
25 * Java API for libvintf.
Yifan Hong58578702019-01-11 16:35:50 -080026 *
Yifan Hong687113a2017-05-04 13:05:24 -070027 * @hide
28 */
Yifan Hong58578702019-01-11 16:35:50 -080029@TestApi
Yifan Hongbecc56d2017-04-05 14:42:05 -070030public class VintfObject {
31
Yifan Hong12ebf362019-12-18 12:52:55 -080032 private static final String LOG_TAG = "VintfObject";
33
Yifan Hongbecc56d2017-04-05 14:42:05 -070034 /**
Yifan Hong75ffd662017-05-01 18:43:36 -070035 * Slurps all device information (both manifests and both matrices)
36 * and report them.
Yifan Hongbecc56d2017-04-05 14:42:05 -070037 * If any error in getting one of the manifests, it is not included in
38 * the list.
Yifan Hong58578702019-01-11 16:35:50 -080039 *
40 * @hide
Yifan Hongbecc56d2017-04-05 14:42:05 -070041 */
Yifan Hong58578702019-01-11 16:35:50 -080042 @TestApi
Yifan Hong75ffd662017-05-01 18:43:36 -070043 public static native String[] report();
Yifan Hongbecc56d2017-04-05 14:42:05 -070044
45 /**
46 * Verify that the given metadata for an OTA package is compatible with
47 * this device.
48 *
Bowgo Tsai78934c92017-11-17 17:18:50 +080049 * @param packageInfo a list of serialized form of HalManifest's /
Yifan Hongbecc56d2017-04-05 14:42:05 -070050 * CompatibilityMatri'ces (XML).
51 * @return = 0 if success (compatible)
Yifan Hong12ebf362019-12-18 12:52:55 -080052 * > 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>
Yifan Hong58578702019-01-11 16:35:50 -080066 *
67 * @hide
Yifan Hongbecc56d2017-04-05 14:42:05 -070068 */
Yifan Hong12ebf362019-12-18 12:52:55 -080069 @Deprecated
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 }
Yifan Hongbecc56d2017-04-05 14:42:05 -070079
Bowgo Tsai78934c92017-11-17 17:18:50 +080080 /**
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.)
Yifan Hong58578702019-01-11 16:35:50 -080088 *
89 * @hide
Bowgo Tsai78934c92017-11-17 17:18:50 +080090 */
91 public static native int verifyWithoutAvb();
92
Yifan Hong687113a2017-05-04 13:05:24 -070093 /**
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.
Yifan Hong58578702019-01-11 16:35:50 -080098 *
Yifan Hong0cdba322019-09-10 19:59:24 -070099 * For AIDL HALs, the version is stripped away
100 * (e.g. "android.hardware.light").
Yifan Hong58578702019-01-11 16:35:50 -0800101 * @hide
Yifan Hong687113a2017-05-04 13:05:24 -0700102 */
Yifan Hong58578702019-01-11 16:35:50 -0800103 @TestApi
Yifan Hong687113a2017-05-04 13:05:24 -0700104 public static native String[] getHalNamesAndVersions();
105
106 /**
107 * @return the BOARD_SEPOLICY_VERS build flag available in device manifest.
Yifan Hong58578702019-01-11 16:35:50 -0800108 *
109 * @hide
Yifan Hong687113a2017-05-04 13:05:24 -0700110 */
Yifan Hong58578702019-01-11 16:35:50 -0800111 @TestApi
Yifan Hong687113a2017-05-04 13:05:24 -0700112 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,
Yifan Hong8da8798c2018-01-10 16:04:18 -0800117 * [("27", ["libjpeg.so", "libbase.so"]),
118 * ("28", ["libjpeg.so", "libbase.so"])]
Yifan Hong58578702019-01-11 16:35:50 -0800119 *
120 * @hide
Yifan Hong687113a2017-05-04 13:05:24 -0700121 */
Yifan Hong58578702019-01-11 16:35:50 -0800122 @TestApi
Yifan Hong687113a2017-05-04 13:05:24 -0700123 public static native Map<String, String[]> getVndkSnapshots();
Yifan Hong0e5e4722018-02-07 14:16:21 -0800124
125 /**
Yifan Hong58578702019-01-11 16:35:50 -0800126 * @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
Yifan Hong0e5e4722018-02-07 14:16:21 -0800132 */
Yifan Hong58578702019-01-11 16:35:50 -0800133 @TestApi
Yifan Hong0e5e4722018-02-07 14:16:21 -0800134 public static native Long getTargetFrameworkCompatibilityMatrixVersion();
Yifan Hong58578702019-01-11 16:35:50 -0800135
136 private VintfObject() {}
Yifan Hongbecc56d2017-04-05 14:42:05 -0700137}