diff options
| author | Yifan Hong <elsk@google.com> | 2017-04-05 14:42:05 -0700 |
|---|---|---|
| committer | Yifan Hong <elsk@google.com> | 2017-04-13 18:04:30 -0700 |
| commit | 4e01db8c12a497f4380a8e5855de98fbe25686e6 (patch) | |
| tree | e908a3ea4d7eae272fed9071bdd165d2b7f06580 /core/java/android | |
| parent | 183c93f6a09a879fbb0e079cb4cb351aa0fa9846 (diff) | |
Add Java API for libvintf.
android.os.VintfObject has two methods:
- report: return device info that can be reported to OTA server
- verify: verify that metadata for a given OTA package is
compatible.
Test: pass
Test: adb shell am instrument -w -e class android.os.VintfObjectTest \
com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Bug: 36814503
Change-Id: Iff8fae289eec8ae9cfc327d0d0d36a1cdd5e6800
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/os/VintfObject.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/core/java/android/os/VintfObject.java b/core/java/android/os/VintfObject.java new file mode 100644 index 000000000000..1ef3916a743f --- /dev/null +++ b/core/java/android/os/VintfObject.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.os; + +import java.util.ArrayList; + +import android.util.Log; + +/** @hide */ +public class VintfObject { + + private static final String LOG_TAG = "VintfObject"; + + /** + * Slurps all device information (both manifests) + * and report it. + * If any error in getting one of the manifests, it is not included in + * the list. + */ + public static String[] report() { + ArrayList<String> ret = new ArrayList<>(); + put(ret, getDeviceManifest(), "device manifest"); + put(ret, getFrameworkManifest(), "framework manifest"); + return ret.toArray(new String[0]); + } + + /** + * Verify that the given metadata for an OTA package is compatible with + * this device. + * + * @param packageInfo a list of serialized form of HalMaanifest's / + * CompatibilityMatri'ces (XML). + * @return = 0 if success (compatible) + * > 0 if incompatible + * < 0 if any error (mount partition fails, illformed XML, etc.) + */ + public static native int verify(String[] packageInfo); + + // return null if any error, otherwise XML string. + private static native String getDeviceManifest(); + private static native String getFrameworkManifest(); + + private static void put(ArrayList<String> list, String content, String message) { + if (content == null || content.length() == 0) { + Log.e(LOG_TAG, "Cannot get;" + message + "; check native logs for details."); + return; + } + list.add(content); + } +} |
