blob: d0657e5eb8ec319b3a16dd81e8d5214e57bac900 [file] [log] [blame]
Steven Morelandf36ad622018-09-04 13:20:22 -07001/*
2 * Copyright (C) 2018 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 */
16package android.content.pm;
17
18import static android.content.pm.SharedLibraryNames.ANDROID_HIDL_BASE;
19import static android.content.pm.SharedLibraryNames.ANDROID_HIDL_MANAGER;
20
21import android.content.pm.PackageParser.Package;
22import android.os.Build;
23
24import com.android.internal.annotations.VisibleForTesting;
25
26/**
27 * Updates a package to ensure that if it targets <= P that the android.hidl.base-V1.0-java
28 * and android.hidl.manager-V1.0-java libraries are included by default.
29 *
30 * @hide
31 */
32@VisibleForTesting
33public class AndroidHidlUpdater extends PackageSharedLibraryUpdater {
34
35 @Override
36 public void updatePackage(Package pkg) {
Steven Moreland24108212019-03-06 09:39:27 -080037 ApplicationInfo info = pkg.applicationInfo;
38
Steven Morelandf36ad622018-09-04 13:20:22 -070039 // This was the default <= P and is maintained for backwards compatibility.
Steven Moreland24108212019-03-06 09:39:27 -080040 boolean isLegacy = info.targetSdkVersion <= Build.VERSION_CODES.P;
41 // Only system apps use these libraries
42 boolean isSystem = info.isSystemApp() || info.isUpdatedSystemApp();
43
44 if (isLegacy && isSystem) {
Steven Morelandf36ad622018-09-04 13:20:22 -070045 prefixRequiredLibrary(pkg, ANDROID_HIDL_BASE);
46 prefixRequiredLibrary(pkg, ANDROID_HIDL_MANAGER);
Steven Morelandae888252018-10-17 18:16:51 -070047 } else {
48 removeLibrary(pkg, ANDROID_HIDL_BASE);
49 removeLibrary(pkg, ANDROID_HIDL_MANAGER);
Steven Morelandf36ad622018-09-04 13:20:22 -070050 }
51 }
52}