Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 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 | |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 19 | import android.annotation.TestApi; |
Yifan Hong | 12ebf36 | 2019-12-18 12:52:55 -0800 | [diff] [blame] | 20 | import android.util.Slog; |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 21 | |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 22 | import java.util.Map; |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 23 | |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Java API for libvintf. |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 26 | * |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 27 | * @hide |
| 28 | */ |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 29 | @TestApi |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 30 | public class VintfObject { |
| 31 | |
Yifan Hong | 12ebf36 | 2019-12-18 12:52:55 -0800 | [diff] [blame] | 32 | private static final String LOG_TAG = "VintfObject"; |
| 33 | |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 34 | /** |
Yifan Hong | 75ffd66 | 2017-05-01 18:43:36 -0700 | [diff] [blame] | 35 | * Slurps all device information (both manifests and both matrices) |
| 36 | * and report them. |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 37 | * If any error in getting one of the manifests, it is not included in |
| 38 | * the list. |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 39 | * |
| 40 | * @hide |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 41 | */ |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 42 | @TestApi |
Yifan Hong | 75ffd66 | 2017-05-01 18:43:36 -0700 | [diff] [blame] | 43 | public static native String[] report(); |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * Verify that the given metadata for an OTA package is compatible with |
| 47 | * this device. |
| 48 | * |
Bowgo Tsai | 78934c9 | 2017-11-17 17:18:50 +0800 | [diff] [blame] | 49 | * @param packageInfo a list of serialized form of HalManifest's / |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 50 | * CompatibilityMatri'ces (XML). |
| 51 | * @return = 0 if success (compatible) |
Yifan Hong | 12ebf36 | 2019-12-18 12:52:55 -0800 | [diff] [blame] | 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> |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 66 | * |
| 67 | * @hide |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 68 | */ |
Yifan Hong | 12ebf36 | 2019-12-18 12:52:55 -0800 | [diff] [blame] | 69 | @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 Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 79 | |
Bowgo Tsai | 78934c9 | 2017-11-17 17:18:50 +0800 | [diff] [blame] | 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.) |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 88 | * |
| 89 | * @hide |
Bowgo Tsai | 78934c9 | 2017-11-17 17:18:50 +0800 | [diff] [blame] | 90 | */ |
| 91 | public static native int verifyWithoutAvb(); |
| 92 | |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 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. |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 98 | * |
Yifan Hong | 0cdba32 | 2019-09-10 19:59:24 -0700 | [diff] [blame] | 99 | * For AIDL HALs, the version is stripped away |
| 100 | * (e.g. "android.hardware.light"). |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 101 | * @hide |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 102 | */ |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 103 | @TestApi |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 104 | public static native String[] getHalNamesAndVersions(); |
| 105 | |
| 106 | /** |
| 107 | * @return the BOARD_SEPOLICY_VERS build flag available in device manifest. |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 108 | * |
| 109 | * @hide |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 110 | */ |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 111 | @TestApi |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 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, |
Yifan Hong | 8da8798c | 2018-01-10 16:04:18 -0800 | [diff] [blame] | 117 | * [("27", ["libjpeg.so", "libbase.so"]), |
| 118 | * ("28", ["libjpeg.so", "libbase.so"])] |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 119 | * |
| 120 | * @hide |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 121 | */ |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 122 | @TestApi |
Yifan Hong | 687113a | 2017-05-04 13:05:24 -0700 | [diff] [blame] | 123 | public static native Map<String, String[]> getVndkSnapshots(); |
Yifan Hong | 0e5e472 | 2018-02-07 14:16:21 -0800 | [diff] [blame] | 124 | |
| 125 | /** |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 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 |
Yifan Hong | 0e5e472 | 2018-02-07 14:16:21 -0800 | [diff] [blame] | 132 | */ |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 133 | @TestApi |
Yifan Hong | 0e5e472 | 2018-02-07 14:16:21 -0800 | [diff] [blame] | 134 | public static native Long getTargetFrameworkCompatibilityMatrixVersion(); |
Yifan Hong | 5857870 | 2019-01-11 16:35:50 -0800 | [diff] [blame] | 135 | |
| 136 | private VintfObject() {} |
Yifan Hong | becc56d | 2017-04-05 14:42:05 -0700 | [diff] [blame] | 137 | } |