Merge changes from topic "hidl-updater-system"
* changes: pm: AndroidHidlUpdater: system only pm: PackageBackwardCompatibility -> applyPolicy
This commit is contained in:
@@ -34,8 +34,14 @@ public class AndroidHidlUpdater extends PackageSharedLibraryUpdater {
|
||||
|
||||
@Override
|
||||
public void updatePackage(Package pkg) {
|
||||
ApplicationInfo info = pkg.applicationInfo;
|
||||
|
||||
// This was the default <= P and is maintained for backwards compatibility.
|
||||
if (pkg.applicationInfo.targetSdkVersion <= Build.VERSION_CODES.P) {
|
||||
boolean isLegacy = info.targetSdkVersion <= Build.VERSION_CODES.P;
|
||||
// Only system apps use these libraries
|
||||
boolean isSystem = info.isSystemApp() || info.isUpdatedSystemApp();
|
||||
|
||||
if (isLegacy && isSystem) {
|
||||
prefixRequiredLibrary(pkg, ANDROID_HIDL_BASE);
|
||||
prefixRequiredLibrary(pkg, ANDROID_HIDL_MANAGER);
|
||||
} else {
|
||||
|
||||
@@ -3857,8 +3857,6 @@ public class PackageParser {
|
||||
// every activity info has had a chance to set it from its attributes.
|
||||
setMaxAspectRatio(owner);
|
||||
|
||||
PackageBackwardCompatibility.modifySharedLibraries(owner);
|
||||
|
||||
if (hasDomainURLs(owner)) {
|
||||
owner.applicationInfo.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS;
|
||||
} else {
|
||||
|
||||
@@ -40,8 +40,17 @@ public class AndroidHidlUpdaterTest extends PackageSharedLibraryUpdaterTest {
|
||||
PackageBuilder before = builder()
|
||||
.targetSdkVersion(Build.VERSION_CODES.P);
|
||||
|
||||
// no change, not system
|
||||
checkBackwardsCompatibility(before, before);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void targeted_at_P_system() {
|
||||
PackageBuilder before = builder().asSystemApp()
|
||||
.targetSdkVersion(Build.VERSION_CODES.P);
|
||||
|
||||
// Should add both HIDL libraries
|
||||
PackageBuilder after = builder()
|
||||
PackageBuilder after = builder().asSystemApp()
|
||||
.targetSdkVersion(Build.VERSION_CODES.P)
|
||||
.requiredLibraries(ANDROID_HIDL_MANAGER, ANDROID_HIDL_BASE);
|
||||
|
||||
@@ -54,9 +63,19 @@ public class AndroidHidlUpdaterTest extends PackageSharedLibraryUpdaterTest {
|
||||
.targetSdkVersion(Build.VERSION_CODES.P)
|
||||
.requiredLibraries(OTHER_LIBRARY);
|
||||
|
||||
// no change, not system
|
||||
checkBackwardsCompatibility(before, before);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void targeted_at_P_not_empty_usesLibraries_system() {
|
||||
PackageBuilder before = builder().asSystemApp()
|
||||
.targetSdkVersion(Build.VERSION_CODES.P)
|
||||
.requiredLibraries(OTHER_LIBRARY);
|
||||
|
||||
// The hidl jars should be added at the start of the list because it
|
||||
// is not on the bootclasspath and the package targets pre-P.
|
||||
PackageBuilder after = builder()
|
||||
PackageBuilder after = builder().asSystemApp()
|
||||
.targetSdkVersion(Build.VERSION_CODES.P)
|
||||
.requiredLibraries(ANDROID_HIDL_MANAGER, ANDROID_HIDL_BASE, OTHER_LIBRARY);
|
||||
|
||||
@@ -69,8 +88,21 @@ public class AndroidHidlUpdaterTest extends PackageSharedLibraryUpdaterTest {
|
||||
.targetSdkVersion(Build.VERSION_CODES.P)
|
||||
.requiredLibraries(ANDROID_HIDL_MANAGER, ANDROID_HIDL_BASE);
|
||||
|
||||
// No change is required because although the HIDL libraries has been removed from
|
||||
// the bootclasspath the package explicitly requests it.
|
||||
PackageBuilder after = builder()
|
||||
.targetSdkVersion(Build.VERSION_CODES.P);
|
||||
|
||||
// Libraries are removed because they are not available for non-system apps
|
||||
checkBackwardsCompatibility(before, after);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void targeted_at_P_in_usesLibraries_system() {
|
||||
PackageBuilder before = builder().asSystemApp()
|
||||
.targetSdkVersion(Build.VERSION_CODES.P)
|
||||
.requiredLibraries(ANDROID_HIDL_MANAGER, ANDROID_HIDL_BASE);
|
||||
|
||||
// No change is required because the package explicitly requests the HIDL libraries
|
||||
// and is targeted at the current version so does not need backwards compatibility.
|
||||
checkBackwardsCompatibility(before, before);
|
||||
}
|
||||
|
||||
@@ -81,8 +113,7 @@ public class AndroidHidlUpdaterTest extends PackageSharedLibraryUpdaterTest {
|
||||
// Dependency is removed, it is not available.
|
||||
PackageBuilder after = builder();
|
||||
|
||||
// No change is required because the package explicitly requests the HIDL libraries
|
||||
// and is targeted at the current version so does not need backwards compatibility.
|
||||
// Libraries are removed because they are not available for apps targetting Q+
|
||||
checkBackwardsCompatibility(before, after);
|
||||
}
|
||||
|
||||
@@ -93,8 +124,7 @@ public class AndroidHidlUpdaterTest extends PackageSharedLibraryUpdaterTest {
|
||||
// Dependency is removed, it is not available.
|
||||
PackageBuilder after = builder();
|
||||
|
||||
// No change is required because the package explicitly requests the HIDL libraries
|
||||
// and is targeted at the current version so does not need backwards compatibility.
|
||||
// Libraries are removed because they are not available for apps targetting Q+
|
||||
checkBackwardsCompatibility(before, after);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ class PackageBuilder {
|
||||
|
||||
private int mTargetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT;
|
||||
|
||||
private int mFlags = 0;
|
||||
|
||||
private ArrayList<String> mRequiredLibraries;
|
||||
|
||||
private ArrayList<String> mOptionalLibraries;
|
||||
@@ -41,6 +43,7 @@ class PackageBuilder {
|
||||
public PackageParser.Package build() {
|
||||
PackageParser.Package pkg = new PackageParser.Package("org.package.name");
|
||||
pkg.applicationInfo.targetSdkVersion = mTargetSdkVersion;
|
||||
pkg.applicationInfo.flags = mFlags;
|
||||
pkg.usesLibraries = mRequiredLibraries;
|
||||
pkg.usesOptionalLibraries = mOptionalLibraries;
|
||||
return pkg;
|
||||
@@ -51,6 +54,11 @@ class PackageBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
PackageBuilder asSystemApp() {
|
||||
this.mFlags |= ApplicationInfo.FLAG_SYSTEM;
|
||||
return this;
|
||||
}
|
||||
|
||||
PackageBuilder requiredLibraries(String... names) {
|
||||
this.mRequiredLibraries = arrayListOrNull(names);
|
||||
return this;
|
||||
|
||||
@@ -168,6 +168,7 @@ import android.content.pm.InstantAppRequest;
|
||||
import android.content.pm.InstantAppResolveInfo;
|
||||
import android.content.pm.InstrumentationInfo;
|
||||
import android.content.pm.IntentFilterVerificationInfo;
|
||||
import android.content.pm.PackageBackwardCompatibility;
|
||||
import android.content.pm.KeySet;
|
||||
import android.content.pm.PackageCleanItem;
|
||||
import android.content.pm.PackageInfo;
|
||||
@@ -11043,6 +11044,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
pkg.mRealPackage = null;
|
||||
pkg.mAdoptPermissions = null;
|
||||
}
|
||||
|
||||
PackageBackwardCompatibility.modifySharedLibraries(pkg);
|
||||
}
|
||||
|
||||
private static @NonNull <T> T assertNotNull(@Nullable T object, String message)
|
||||
|
||||
Reference in New Issue
Block a user