Separate ParsingPackage into core and ParsedPackage into server
PackageParser exists in the core framework SDK, and so callers to it would not not expect a call into the system server. However, some planned features require parts of parsing to exist in the server so that package state/settings contained in the server can be applied to the package. To resolve this, separate ParsingPackage and ParsedPackage through a hard boundary, where ParsingPackageImpl is roughly equivalent to the previous PackageImpl, and the new PackageImpl is everything that should exist in the server and not core. This also copies over documentation and cleans up the data models significantly. The fields have been moved to @NonNull, and in preparation for true immutability, all Collection structures have moved to generic types and assigned Collections#empty_(). This begins moving away from @hide AppInfo fields, so internal use of flags/privateFlags is deprecated. It is now replaced by straight booleans. For simplicity's sake, existing flags have also been migrated. This is split for readability and will not compile without the followup commits. Bug: 135203078 Test: atest com.android.server.pm.parsing Test: atest PackageParserTest Test: atest PackageParserLegacyCoreTest Test: atest ScanTests Test: atest ParallelPackageParserTest Test: manual toggle and run AndroidPackageParsingTestBase Change-Id: Ib4fe51d729a56bfb0ea1316e577358ba0dfceccf
This commit is contained in:
@@ -1,497 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.content.pm.parsing;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.ConfigurationInfo;
|
||||
import android.content.pm.FeatureGroupInfo;
|
||||
import android.content.pm.FeatureInfo;
|
||||
import android.content.pm.PackageParser;
|
||||
import android.content.pm.PackageUserState;
|
||||
import android.content.pm.SharedLibraryInfo;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedActivity;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedActivityIntentInfo;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedFeature;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedInstrumentation;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedPermission;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedPermissionGroup;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedProvider;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedService;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The last state of a package during parsing/install before it is available in
|
||||
* {@link com.android.server.pm.PackageManagerService#mPackages}.
|
||||
*
|
||||
* It is the responsibility of the caller to understand what data is available at what step of the
|
||||
* parsing or install process.
|
||||
*
|
||||
* TODO(b/135203078): Nullability annotations
|
||||
* TODO(b/135203078): Remove get/setAppInfo differences
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public interface AndroidPackage extends Parcelable {
|
||||
|
||||
/**
|
||||
* This will eventually be removed. Avoid calling this at all costs.
|
||||
*/
|
||||
@Deprecated
|
||||
AndroidPackageWrite mutate();
|
||||
|
||||
boolean canHaveOatDir();
|
||||
|
||||
boolean cantSaveState();
|
||||
|
||||
List<String> getAdoptPermissions();
|
||||
|
||||
List<String> getAllCodePaths();
|
||||
|
||||
List<String> getAllCodePathsExcludingResourceOnly();
|
||||
|
||||
String getAppComponentFactory();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #getClassLoaderName()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getAppInfoClassLoaderName();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #getCodePath()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getAppInfoCodePath();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #getName()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getAppInfoName();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #getPackageName()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getAppInfoPackageName();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #getProcessName()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getAppInfoProcessName();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #getCodePath()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getAppInfoResourcePath();
|
||||
|
||||
Bundle getAppMetaData();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #getVolumeUuid()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getApplicationInfoVolumeUuid();
|
||||
|
||||
String getBackupAgentName();
|
||||
|
||||
int getBanner();
|
||||
|
||||
String getBaseCodePath();
|
||||
|
||||
int getBaseRevisionCode();
|
||||
|
||||
int getCategory();
|
||||
|
||||
String getClassLoaderName();
|
||||
|
||||
String getClassName();
|
||||
|
||||
String getCodePath();
|
||||
|
||||
int getCompatibleWidthLimitDp();
|
||||
|
||||
int getCompileSdkVersion();
|
||||
|
||||
String getCompileSdkVersionCodeName();
|
||||
|
||||
@Nullable
|
||||
List<ConfigurationInfo> getConfigPreferences();
|
||||
|
||||
String getCpuAbiOverride();
|
||||
|
||||
String getCredentialProtectedDataDir();
|
||||
|
||||
String getDataDir();
|
||||
|
||||
int getDescriptionRes();
|
||||
|
||||
String getDeviceProtectedDataDir();
|
||||
|
||||
List<FeatureGroupInfo> getFeatureGroups();
|
||||
|
||||
int getFlags();
|
||||
|
||||
int getFullBackupContent();
|
||||
|
||||
int getHiddenApiEnforcementPolicy();
|
||||
|
||||
int getIcon();
|
||||
|
||||
int getIconRes();
|
||||
|
||||
List<String> getImplicitPermissions();
|
||||
|
||||
int getInstallLocation();
|
||||
|
||||
Map<String, ArraySet<PublicKey>> getKeySetMapping();
|
||||
|
||||
int getLabelRes();
|
||||
|
||||
int getLargestWidthLimitDp();
|
||||
|
||||
long[] getLastPackageUsageTimeInMills();
|
||||
|
||||
long getLatestForegroundPackageUseTimeInMills();
|
||||
|
||||
long getLatestPackageUseTimeInMills();
|
||||
|
||||
List<String> getLibraryNames();
|
||||
|
||||
int getLogo();
|
||||
|
||||
long getLongVersionCode();
|
||||
|
||||
String getManageSpaceActivityName();
|
||||
|
||||
String getManifestPackageName();
|
||||
|
||||
float getMaxAspectRatio();
|
||||
|
||||
Bundle getMetaData(); // TODO(b/135203078): Make all the Bundles immutable
|
||||
|
||||
@Nullable
|
||||
Set<String> getMimeGroups();
|
||||
|
||||
float getMinAspectRatio();
|
||||
|
||||
int getMinSdkVersion();
|
||||
|
||||
String getName();
|
||||
|
||||
String getNativeLibraryDir();
|
||||
|
||||
String getNativeLibraryRootDir();
|
||||
|
||||
int getNetworkSecurityConfigRes();
|
||||
|
||||
CharSequence getNonLocalizedLabel();
|
||||
|
||||
@Nullable
|
||||
List<String> getOriginalPackages();
|
||||
|
||||
String getOverlayCategory();
|
||||
|
||||
int getOverlayPriority();
|
||||
|
||||
String getOverlayTarget();
|
||||
|
||||
String getOverlayTargetName();
|
||||
|
||||
/**
|
||||
* Map of overlayable name to actor name.
|
||||
*/
|
||||
Map<String, String> getOverlayables();
|
||||
|
||||
// TODO(b/135203078): Does this and getAppInfoPackageName have to be separate methods?
|
||||
// The refactor makes them the same value with no known consequences, so should be redundant.
|
||||
String getPackageName();
|
||||
|
||||
@Nullable
|
||||
List<ParsedActivity> getActivities();
|
||||
|
||||
@Nullable
|
||||
List<ParsedInstrumentation> getInstrumentations();
|
||||
|
||||
@Nullable
|
||||
List<ParsedFeature> getFeatures();
|
||||
|
||||
@Nullable
|
||||
List<ParsedPermissionGroup> getPermissionGroups();
|
||||
|
||||
@Nullable
|
||||
List<ParsedPermission> getPermissions();
|
||||
|
||||
@Nullable
|
||||
List<ParsedProvider> getProviders();
|
||||
|
||||
@Nullable
|
||||
List<ParsedActivity> getReceivers();
|
||||
|
||||
@Nullable
|
||||
List<ParsedService> getServices();
|
||||
|
||||
String getPermission();
|
||||
|
||||
@Nullable
|
||||
List<ParsedActivityIntentInfo> getPreferredActivityFilters();
|
||||
|
||||
int getPreferredOrder();
|
||||
|
||||
String getPrimaryCpuAbi();
|
||||
|
||||
int getPrivateFlags();
|
||||
|
||||
String getProcessName();
|
||||
|
||||
@Nullable
|
||||
List<String> getProtectedBroadcasts();
|
||||
|
||||
String getPublicSourceDir();
|
||||
|
||||
List<Intent> getQueriesIntents();
|
||||
|
||||
List<String> getQueriesPackages();
|
||||
|
||||
Set<String> getQueriesProviders();
|
||||
|
||||
String getRealPackage();
|
||||
|
||||
// TODO(b/135203078): Rename to getRequiredFeatures? Somewhat ambiguous whether "Req" is
|
||||
// required or requested.
|
||||
@Nullable
|
||||
List<FeatureInfo> getReqFeatures();
|
||||
|
||||
List<String> getRequestedPermissions();
|
||||
|
||||
String getRequiredAccountType();
|
||||
|
||||
int getRequiresSmallestWidthDp();
|
||||
|
||||
byte[] getRestrictUpdateHash();
|
||||
|
||||
String getRestrictedAccountType();
|
||||
|
||||
int getRoundIconRes();
|
||||
|
||||
String getScanPublicSourceDir();
|
||||
|
||||
String getScanSourceDir();
|
||||
|
||||
String getSeInfo();
|
||||
|
||||
String getSeInfoUser();
|
||||
|
||||
String getSecondaryCpuAbi();
|
||||
|
||||
String getSecondaryNativeLibraryDir();
|
||||
|
||||
String getSharedUserId();
|
||||
|
||||
int getSharedUserLabel();
|
||||
|
||||
PackageParser.SigningDetails getSigningDetails();
|
||||
|
||||
String[] getSplitClassLoaderNames();
|
||||
|
||||
@Nullable
|
||||
String[] getSplitCodePaths();
|
||||
|
||||
@Nullable
|
||||
SparseArray<int[]> getSplitDependencies();
|
||||
|
||||
int[] getSplitFlags();
|
||||
|
||||
String[] getSplitNames();
|
||||
|
||||
String[] getSplitPublicSourceDirs();
|
||||
|
||||
int[] getSplitRevisionCodes();
|
||||
|
||||
String getStaticSharedLibName();
|
||||
|
||||
long getStaticSharedLibVersion();
|
||||
|
||||
// TODO(b/135203078): Return String directly
|
||||
UUID getStorageUuid();
|
||||
|
||||
int getTargetSandboxVersion();
|
||||
|
||||
int getTargetSdkVersion();
|
||||
|
||||
String getTaskAffinity();
|
||||
|
||||
int getTheme();
|
||||
|
||||
int getUiOptions();
|
||||
|
||||
int getUid();
|
||||
|
||||
Set<String> getUpgradeKeySets();
|
||||
|
||||
@Nullable
|
||||
List<String> getUsesLibraries();
|
||||
|
||||
@Nullable
|
||||
String[] getUsesLibraryFiles();
|
||||
|
||||
List<SharedLibraryInfo> getUsesLibraryInfos();
|
||||
|
||||
@Nullable
|
||||
List<String> getUsesOptionalLibraries();
|
||||
|
||||
@Nullable
|
||||
List<String> getUsesStaticLibraries();
|
||||
|
||||
@Nullable
|
||||
String[][] getUsesStaticLibrariesCertDigests();
|
||||
|
||||
@Nullable
|
||||
long[] getUsesStaticLibrariesVersions();
|
||||
|
||||
@Nullable
|
||||
ArrayMap<String, ComponentParseUtils.ParsedProcess> getProcesses();
|
||||
|
||||
int getVersionCode();
|
||||
|
||||
int getVersionCodeMajor();
|
||||
|
||||
String getVersionName();
|
||||
|
||||
String getVolumeUuid();
|
||||
|
||||
String getZygotePreloadName();
|
||||
|
||||
boolean hasComponentClassName(String className);
|
||||
|
||||
boolean hasPreserveLegacyExternalStorage();
|
||||
|
||||
// App Info
|
||||
|
||||
boolean hasRequestedLegacyExternalStorage();
|
||||
|
||||
boolean isBaseHardwareAccelerated();
|
||||
|
||||
boolean isCoreApp();
|
||||
|
||||
boolean isDefaultToDeviceProtectedStorage();
|
||||
|
||||
boolean isDirectBootAware();
|
||||
|
||||
boolean isEmbeddedDexUsed();
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
boolean isCrossProfile();
|
||||
|
||||
boolean isEncryptionAware();
|
||||
|
||||
boolean isExternal();
|
||||
|
||||
boolean isForceQueryable();
|
||||
|
||||
boolean isForwardLocked();
|
||||
|
||||
boolean isHiddenUntilInstalled();
|
||||
|
||||
boolean isInstantApp();
|
||||
|
||||
boolean isInternal();
|
||||
|
||||
boolean isLibrary();
|
||||
|
||||
// TODO(b/135203078): Should probably be in a utility class
|
||||
boolean isMatch(int flags);
|
||||
|
||||
boolean isNativeLibraryRootRequiresIsa();
|
||||
|
||||
boolean isOem();
|
||||
|
||||
boolean isOverlayIsStatic();
|
||||
|
||||
boolean isPrivileged();
|
||||
|
||||
boolean isProduct();
|
||||
|
||||
boolean isProfileableByShell();
|
||||
|
||||
boolean isRequiredForAllUsers();
|
||||
|
||||
boolean isStaticSharedLibrary();
|
||||
|
||||
boolean isStub();
|
||||
|
||||
boolean isSystem(); // TODO(b/135203078): Collapse with isSystemApp, should be exactly the same.
|
||||
|
||||
boolean isSystemApp();
|
||||
|
||||
boolean isSystemExt();
|
||||
|
||||
boolean isUpdatedSystemApp();
|
||||
|
||||
boolean isUse32BitAbi();
|
||||
|
||||
boolean isVendor();
|
||||
|
||||
boolean isVisibleToInstantApps();
|
||||
|
||||
List<String> makeListAllCodePaths(); // TODO(b/135203078): Collapse with getAllCodePaths
|
||||
|
||||
boolean requestsIsolatedSplitLoading();
|
||||
|
||||
/**
|
||||
* Generates an {@link ApplicationInfo} object with only the data available in this object.
|
||||
*
|
||||
* This does not contain any system or user state data, and should be avoided. Prefer
|
||||
* {@link PackageInfoUtils#generateApplicationInfo(AndroidPackage, int, PackageUserState, int)}.
|
||||
*/
|
||||
ApplicationInfo toAppInfoWithoutState();
|
||||
|
||||
Creator<PackageImpl> CREATOR = new Creator<PackageImpl>() {
|
||||
@Override
|
||||
public PackageImpl createFromParcel(Parcel source) {
|
||||
return new PackageImpl(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl[] newArray(int size) {
|
||||
return new PackageImpl[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* Copyright (C) 2020 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.content.pm.parsing;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ConfigurationInfo;
|
||||
@@ -28,23 +29,23 @@ import android.content.pm.parsing.ComponentParseUtils.ParsedFeature;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedInstrumentation;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedPermission;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedPermissionGroup;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedProcess;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedProvider;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedService;
|
||||
import android.os.Bundle;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Methods used for mutation during direct package parsing.
|
||||
*
|
||||
* Java disallows defining this as an inner interface, so this must be a separate file.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public interface ParsingPackage extends AndroidPackage {
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public interface ParsingPackage extends ParsingPackageRead {
|
||||
|
||||
ParsingPackage addActivity(ParsedActivity parsedActivity);
|
||||
|
||||
@@ -66,18 +67,18 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage addOverlayable(String overlayableName, String actorName);
|
||||
|
||||
ParsingPackage addFeature(ParsedFeature permission);
|
||||
|
||||
ParsingPackage addPermission(ParsedPermission permission);
|
||||
|
||||
ParsingPackage addPermissionGroup(ParsedPermissionGroup permissionGroup);
|
||||
|
||||
ParsingPackage addPreferredActivityFilter(ParsedActivityIntentInfo activityIntentInfo);
|
||||
ParsingPackage addPreferredActivityFilter(ParsedActivityIntentInfo intentInfo);
|
||||
|
||||
ParsingPackage addProtectedBroadcast(String protectedBroadcast);
|
||||
|
||||
ParsingPackage addProvider(ParsedProvider parsedProvider);
|
||||
|
||||
ParsingPackage addFeature(ParsedFeature permission);
|
||||
|
||||
ParsingPackage addReceiver(ParsedActivity parsedReceiver);
|
||||
|
||||
ParsingPackage addReqFeature(FeatureInfo reqFeature);
|
||||
@@ -102,7 +103,7 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage addQueriesProvider(String authority);
|
||||
|
||||
ParsingPackage setProcesses(ArrayMap<String, ComponentParseUtils.ParsedProcess> processes);
|
||||
ParsingPackage setProcesses(@NonNull Map<String, ParsedProcess> processes);
|
||||
|
||||
ParsingPackage asSplit(
|
||||
String[] splitNames,
|
||||
@@ -111,7 +112,7 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
@Nullable SparseArray<int[]> splitDependencies
|
||||
);
|
||||
|
||||
ParsingPackage setAppMetaData(Bundle appMetaData);
|
||||
ParsingPackage setMetaData(Bundle metaData);
|
||||
|
||||
ParsingPackage setForceQueryable(boolean forceQueryable);
|
||||
|
||||
@@ -119,8 +120,6 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage setMinAspectRatio(float minAspectRatio);
|
||||
|
||||
ParsingPackage setName(String name);
|
||||
|
||||
ParsingPackage setPermission(String permission);
|
||||
|
||||
ParsingPackage setProcessName(String processName);
|
||||
@@ -137,9 +136,9 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage setBaseHardwareAccelerated(boolean baseHardwareAccelerated);
|
||||
|
||||
ParsingPackage setActivitiesResizeModeResizeable(boolean resizeable);
|
||||
ParsingPackage setResizeableActivity(Boolean resizeable);
|
||||
|
||||
ParsingPackage setActivitiesResizeModeResizeableViaSdkVersion(boolean resizeableViaSdkVersion);
|
||||
ParsingPackage setResizeableActivityViaSdkVersion(boolean resizeableViaSdkVersion);
|
||||
|
||||
ParsingPackage setAllowAudioPlaybackCapture(boolean allowAudioPlaybackCapture);
|
||||
|
||||
@@ -151,7 +150,7 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage setAllowTaskReparenting(boolean allowTaskReparenting);
|
||||
|
||||
ParsingPackage setIsOverlay(boolean isOverlay);
|
||||
ParsingPackage setOverlay(boolean isOverlay);
|
||||
|
||||
ParsingPackage setBackupInForeground(boolean backupInForeground);
|
||||
|
||||
@@ -173,7 +172,7 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage setHasFragileUserData(boolean hasFragileUserData);
|
||||
|
||||
ParsingPackage setIsGame(boolean isGame);
|
||||
ParsingPackage setGame(boolean isGame);
|
||||
|
||||
ParsingPackage setIsolatedSplitLoading(boolean isolatedSplitLoading);
|
||||
|
||||
@@ -221,8 +220,6 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage setAppComponentFactory(String appComponentFactory);
|
||||
|
||||
ParsingPackage setApplicationVolumeUuid(String applicationVolumeUuid);
|
||||
|
||||
ParsingPackage setBackupAgentName(String backupAgentName);
|
||||
|
||||
ParsingPackage setBanner(int banner);
|
||||
@@ -233,8 +230,6 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage setClassName(String className);
|
||||
|
||||
ParsingPackage setCodePath(String codePath);
|
||||
|
||||
ParsingPackage setCompatibleWidthLimitDp(int compatibleWidthLimitDp);
|
||||
|
||||
ParsingPackage setDescriptionRes(int descriptionRes);
|
||||
@@ -247,8 +242,6 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage setHasDomainUrls(boolean hasDomainUrls);
|
||||
|
||||
ParsingPackage setIcon(int icon);
|
||||
|
||||
ParsingPackage setIconRes(int iconRes);
|
||||
|
||||
ParsingPackage setInstallLocation(int installLocation);
|
||||
@@ -307,17 +300,17 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage setSupportsSmallScreens(int supportsSmallScreens);
|
||||
|
||||
ParsingPackage setSupportsXLargeScreens(int supportsXLargeScreens);
|
||||
ParsingPackage setSupportsExtraLargeScreens(int supportsExtraLargeScreens);
|
||||
|
||||
ParsingPackage setTargetSandboxVersion(int targetSandboxVersion);
|
||||
|
||||
ParsingPackage setTheme(int theme);
|
||||
|
||||
ParsingPackage setUpgradeKeySets(ArraySet<String> upgradeKeySets);
|
||||
ParsingPackage setUpgradeKeySets(@NonNull Set<String> upgradeKeySets);
|
||||
|
||||
ParsingPackage setUse32BitAbi(boolean use32BitAbi);
|
||||
|
||||
ParsingPackage setVolumeUuid(String volumeUuid);
|
||||
ParsingPackage setVolumeUuid(@Nullable String volumeUuid);
|
||||
|
||||
ParsingPackage setZygotePreloadName(String zygotePreloadName);
|
||||
|
||||
@@ -327,17 +320,24 @@ public interface ParsingPackage extends AndroidPackage {
|
||||
|
||||
ParsingPackage sortServices();
|
||||
|
||||
ParsedPackage hideAsParsed();
|
||||
|
||||
ParsingPackage setBaseRevisionCode(int baseRevisionCode);
|
||||
|
||||
ParsingPackage setPreferredOrder(int preferredOrder);
|
||||
|
||||
ParsingPackage setVersionName(String versionName);
|
||||
|
||||
ParsingPackage setCompileSdkVersion(int compileSdkVersion);
|
||||
|
||||
ParsingPackage setCompileSdkVersionCodename(String compileSdkVersionCodename);
|
||||
|
||||
boolean usesCompatibilityMode();
|
||||
// TODO(b/135203078): This class no longer has access to ParsedPackage, find a replacement
|
||||
// for moving to the next step
|
||||
@Deprecated
|
||||
Object hideAsParsed();
|
||||
|
||||
//TODO(b/135203078): Remove in favor of individual methods
|
||||
@Deprecated
|
||||
int getFlags();
|
||||
|
||||
//TODO(b/135203078): Remove in favor of individual methods
|
||||
@Deprecated
|
||||
int getPrivateFlags();
|
||||
}
|
||||
|
||||
2585
core/java/android/content/pm/parsing/ParsingPackageImpl.java
Normal file
2585
core/java/android/content/pm/parsing/ParsingPackageImpl.java
Normal file
File diff suppressed because it is too large
Load Diff
844
core/java/android/content/pm/parsing/ParsingPackageRead.java
Normal file
844
core/java/android/content/pm/parsing/ParsingPackageRead.java
Normal file
@@ -0,0 +1,844 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.content.pm.parsing;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.ConfigurationInfo;
|
||||
import android.content.pm.FeatureGroupInfo;
|
||||
import android.content.pm.FeatureInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageParser;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedActivity;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedActivityIntentInfo;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedFeature;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedInstrumentation;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedPermission;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedPermissionGroup;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedProcess;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedProvider;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedService;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.ArraySet;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Everything written by {@link ParsingPackage} and readable back.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public interface ParsingPackageRead extends Parcelable {
|
||||
|
||||
/**
|
||||
* @see ActivityInfo
|
||||
* @see PackageInfo#activities
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedActivity> getActivities();
|
||||
|
||||
/**
|
||||
* The names of packages to adopt ownership of permissions from, parsed under
|
||||
* {@link PackageParser#TAG_ADOPT_PERMISSIONS}.
|
||||
* @see R.styleable#AndroidManifestOriginalPackage_name
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getAdoptPermissions();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#configPreferences
|
||||
* @see R.styleable#AndroidManifestUsesConfiguration
|
||||
*/
|
||||
@NonNull
|
||||
List<ConfigurationInfo> getConfigPreferences();
|
||||
|
||||
@NonNull
|
||||
List<ParsedFeature> getFeatures();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#featureGroups
|
||||
* @see R.styleable#AndroidManifestUsesFeature
|
||||
*/
|
||||
@NonNull
|
||||
List<FeatureGroupInfo> getFeatureGroups();
|
||||
|
||||
/**
|
||||
* Permissions requested but not in the manifest. These may have been split or migrated from
|
||||
* previous versions/definitions.
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getImplicitPermissions();
|
||||
|
||||
/**
|
||||
* @see android.content.pm.InstrumentationInfo
|
||||
* @see PackageInfo#instrumentation
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedInstrumentation> getInstrumentations();
|
||||
|
||||
/**
|
||||
* For use with {@link com.android.server.pm.KeySetManagerService}. Parsed in
|
||||
* {@link PackageParser#TAG_KEY_SETS}.
|
||||
* @see R.styleable#AndroidManifestKeySet
|
||||
* @see R.styleable#AndroidManifestPublicKey
|
||||
*/
|
||||
@NonNull
|
||||
Map<String, ArraySet<PublicKey>> getKeySetMapping();
|
||||
|
||||
/**
|
||||
* Library names this package is declared as, for use by other packages with "uses-library".
|
||||
* @see R.styleable#AndroidManifestLibrary
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getLibraryNames();
|
||||
|
||||
/**
|
||||
* For system use to migrate from an old package name to a new one, moving over data
|
||||
* if available.
|
||||
* @see R.styleable#AndroidManifestOriginalPackage}
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getOriginalPackages();
|
||||
|
||||
/**
|
||||
* Map of overlayable name to actor name.
|
||||
*/
|
||||
@NonNull
|
||||
Map<String, String> getOverlayables();
|
||||
|
||||
/**
|
||||
* @see android.content.pm.PermissionInfo
|
||||
* @see PackageInfo#permissions
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedPermission> getPermissions();
|
||||
|
||||
/**
|
||||
* @see android.content.pm.PermissionGroupInfo
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedPermissionGroup> getPermissionGroups();
|
||||
|
||||
/**
|
||||
* Used to determine the default preferred handler of an {@link Intent}.
|
||||
*
|
||||
* Map of component className to intent info inside that component.
|
||||
* TODO(b/135203078): Is this actually used/working?
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedActivityIntentInfo> getPreferredActivityFilters();
|
||||
|
||||
/**
|
||||
* System protected broadcasts.
|
||||
* @see R.styleable#AndroidManifestProtectedBroadcast
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getProtectedBroadcasts();
|
||||
|
||||
/**
|
||||
* @see android.content.pm.ProviderInfo
|
||||
* @see PackageInfo#providers
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedProvider> getProviders();
|
||||
|
||||
/**
|
||||
* @see android.content.pm.ProcessInfo
|
||||
*/
|
||||
@NonNull
|
||||
Map<String, ParsedProcess> getProcesses();
|
||||
|
||||
/**
|
||||
* Since they share several attributes, receivers are parsed as {@link ParsedActivity}, even
|
||||
* though they represent different functionality.
|
||||
* TODO(b/135203078): Reconsider this and maybe make ParsedReceiver so it's not so confusing
|
||||
* @see ActivityInfo
|
||||
* @see PackageInfo#receivers
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedActivity> getReceivers();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#reqFeatures
|
||||
* @see R.styleable#AndroidManifestUsesFeature
|
||||
*/
|
||||
@NonNull
|
||||
List<FeatureInfo> getReqFeatures();
|
||||
|
||||
/**
|
||||
* All the permissions declared. This is an effective set, and may include permissions
|
||||
* transformed from split/migrated permissions from previous versions, so may not be exactly
|
||||
* what the package declares in its manifest.
|
||||
* @see PackageInfo#requestedPermissions
|
||||
* @see R.styleable#AndroidManifestUsesPermission
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getRequestedPermissions();
|
||||
|
||||
/**
|
||||
* Whether or not the app requested explicitly resizeable Activities.
|
||||
* A null value means nothing was explicitly requested.
|
||||
*/
|
||||
@Nullable
|
||||
Boolean getResizeableActivity();
|
||||
|
||||
/**
|
||||
* @see ServiceInfo
|
||||
* @see PackageInfo#services
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedService> getServices();
|
||||
|
||||
/** @see R.styleable#AndroidManifestUsesLibrary */
|
||||
@NonNull
|
||||
List<String> getUsesLibraries();
|
||||
|
||||
/**
|
||||
* Like {@link #getUsesLibraries()}, but marked optional by setting
|
||||
* {@link R.styleable#AndroidManifestUsesLibrary_required} to false . Application is expected
|
||||
* to handle absence manually.
|
||||
* @see R.styleable#AndroidManifestUsesLibrary
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getUsesOptionalLibraries();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Move static library stuff to an inner data class
|
||||
* @see R.styleable#AndroidManifestUsesStaticLibrary
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getUsesStaticLibraries();
|
||||
|
||||
/** @see R.styleable#AndroidManifestUsesStaticLibrary_certDigest */
|
||||
@Nullable
|
||||
String[][] getUsesStaticLibrariesCertDigests();
|
||||
|
||||
/** @see R.styleable#AndroidManifestUsesStaticLibrary_version */
|
||||
@Nullable
|
||||
long[] getUsesStaticLibrariesVersions();
|
||||
|
||||
/**
|
||||
* Intents that this package may query or require and thus requires visibility into.
|
||||
* @see R.styleable#AndroidManifestQueriesIntent
|
||||
*/
|
||||
@NonNull
|
||||
List<Intent> getQueriesIntents();
|
||||
|
||||
/**
|
||||
* Other packages that this package may query or require and thus requires visibility into.
|
||||
* @see R.styleable#AndroidManifestQueriesPackage
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getQueriesPackages();
|
||||
|
||||
/**
|
||||
* Authorities that this package may query or require and thus requires visibility into.
|
||||
* @see R.styleable#AndroidManifestQueriesProvider
|
||||
*/
|
||||
@NonNull
|
||||
Set<String> getQueriesProviders();
|
||||
|
||||
/**
|
||||
* We store the application meta-data independently to avoid multiple unwanted references
|
||||
* TODO(b/135203078): What does this comment mean?
|
||||
* TODO(b/135203078): Make all the Bundles immutable (and non-null by shared empty reference?)
|
||||
*/
|
||||
@Nullable
|
||||
Bundle getMetaData();
|
||||
|
||||
/** @see R.styleable#AndroidManifestApplication_forceQueryable */
|
||||
boolean isForceQueryable();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#maxAspectRatio
|
||||
* @see R.styleable#AndroidManifestApplication_maxAspectRatio
|
||||
*/
|
||||
float getMaxAspectRatio();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#minAspectRatio
|
||||
* @see R.styleable#AndroidManifestApplication_minAspectRatio
|
||||
*/
|
||||
float getMinAspectRatio();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#permission
|
||||
* @see R.styleable#AndroidManifestApplication_permission
|
||||
*/
|
||||
@Nullable
|
||||
String getPermission();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#processName
|
||||
* @see R.styleable#AndroidManifestApplication_process
|
||||
*/
|
||||
@NonNull
|
||||
String getProcessName();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#sharedUserId
|
||||
* @see R.styleable#AndroidManifest_sharedUserId
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String getSharedUserId();
|
||||
|
||||
/** @see R.styleable#AndroidManifestStaticLibrary_name */
|
||||
@Nullable
|
||||
String getStaticSharedLibName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#taskAffinity
|
||||
* @see R.styleable#AndroidManifestApplication_taskAffinity
|
||||
*/
|
||||
@Nullable
|
||||
String getTaskAffinity();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#targetSdkVersion
|
||||
* @see R.styleable#AndroidManifestUsesSdk_targetSdkVersion
|
||||
*/
|
||||
int getTargetSdkVersion();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#uiOptions
|
||||
* @see R.styleable#AndroidManifestApplication_uiOptions
|
||||
*/
|
||||
int getUiOptions();
|
||||
|
||||
boolean isCrossProfile();
|
||||
|
||||
boolean isResizeableActivityViaSdkVersion();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_HARDWARE_ACCELERATED */
|
||||
boolean isBaseHardwareAccelerated();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#DONUT}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_resizeable
|
||||
* @see ApplicationInfo#FLAG_RESIZEABLE_FOR_SCREENS
|
||||
*/
|
||||
boolean isResizeable();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE */
|
||||
boolean isAllowAudioPlaybackCapture();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_ALLOW_BACKUP */
|
||||
boolean isAllowBackup();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_ALLOW_CLEAR_USER_DATA */
|
||||
boolean isAllowClearUserData();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE */
|
||||
boolean isAllowClearUserDataOnFailedRestore();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_ALLOW_TASK_REPARENTING */
|
||||
boolean isAllowTaskReparenting();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#PRIVATE_FLAG_IS_RESOURCE_OVERLAY
|
||||
* @see ApplicationInfo#isResourceOverlay()
|
||||
*/
|
||||
boolean isOverlay();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_BACKUP_IN_FOREGROUND */
|
||||
boolean isBackupInForeground();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_CANT_SAVE_STATE */
|
||||
boolean isCantSaveState();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_DEBUGGABLE */
|
||||
boolean isDebuggable();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE */
|
||||
boolean isDefaultToDeviceProtectedStorage();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_DIRECT_BOOT_AWARE */
|
||||
boolean isDirectBootAware();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_EXTERNAL_STORAGE */
|
||||
boolean isExternalStorage();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_EXTRACT_NATIVE_LIBS */
|
||||
boolean isExtractNativeLibs();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_FULL_BACKUP_ONLY */
|
||||
boolean isFullBackupOnly();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_HAS_CODE */
|
||||
boolean isHasCode();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_HAS_FRAGILE_USER_DATA */
|
||||
boolean isHasFragileUserData();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_IS_GAME */
|
||||
@Deprecated
|
||||
boolean isGame();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ISOLATED_SPLIT_LOADING */
|
||||
boolean isIsolatedSplitLoading();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_KILL_AFTER_RESTORE */
|
||||
boolean isKillAfterRestore();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_LARGE_HEAP */
|
||||
boolean isLargeHeap();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_MULTIARCH */
|
||||
boolean isMultiArch();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE */
|
||||
boolean isPartiallyDirectBootAware();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_PERSISTENT */
|
||||
boolean isPersistent();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_PROFILEABLE_BY_SHELL */
|
||||
boolean isProfileableByShell();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE */
|
||||
boolean isRequestLegacyExternalStorage();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_RESTORE_ANY_VERSION */
|
||||
boolean isRestoreAnyVersion();
|
||||
|
||||
// ParsingPackageRead setSplitHasCode(int splitIndex, boolean splitHasCode);
|
||||
|
||||
/** Flags of any split APKs; ordered by parsed splitName */
|
||||
@Nullable
|
||||
int[] getSplitFlags();
|
||||
|
||||
/** @see ApplicationInfo#splitSourceDirs */
|
||||
@Nullable
|
||||
String[] getSplitCodePaths();
|
||||
|
||||
/** @see ApplicationInfo#splitDependencies */
|
||||
@Nullable
|
||||
SparseArray<int[]> getSplitDependencies();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#splitNames
|
||||
* @see PackageInfo#splitNames
|
||||
*/
|
||||
@Nullable
|
||||
String[] getSplitNames();
|
||||
|
||||
/** @see PackageInfo#splitRevisionCodes */
|
||||
int[] getSplitRevisionCodes();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_STATIC_SHARED_LIBRARY */
|
||||
boolean isStaticSharedLibrary();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_SUPPORTS_RTL */
|
||||
boolean isSupportsRtl();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_TEST_ONLY */
|
||||
boolean isTestOnly();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_USE_EMBEDDED_DEX */
|
||||
boolean isUseEmbeddedDex();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_USES_CLEARTEXT_TRAFFIC */
|
||||
boolean isUsesCleartextTraffic();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_USES_NON_SDK_API */
|
||||
boolean isUsesNonSdkApi();
|
||||
|
||||
/**
|
||||
* Set if the any of components are visible to instant applications.
|
||||
* @see R.styleable#AndroidManifestActivity_visibleToInstantApps
|
||||
* @see R.styleable#AndroidManifestProvider_visibleToInstantApps
|
||||
* @see R.styleable#AndroidManifestService_visibleToInstantApps
|
||||
*/
|
||||
boolean isVisibleToInstantApps();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_VM_SAFE_MODE */
|
||||
boolean isVmSafeMode();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#DONUT}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_anyDensity
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_SCREEN_DENSITIES
|
||||
*/
|
||||
boolean isAnyDensity();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#appComponentFactory
|
||||
* @see R.styleable#AndroidManifestApplication_appComponentFactory
|
||||
*/
|
||||
@Nullable
|
||||
String getAppComponentFactory();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#backupAgentName
|
||||
* @see R.styleable#AndroidManifestApplication_backupAgent
|
||||
*/
|
||||
@Nullable
|
||||
String getBackupAgentName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#banner
|
||||
* @see R.styleable#AndroidManifestApplication_banner
|
||||
*/
|
||||
int getBanner();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#category
|
||||
* @see R.styleable#AndroidManifestApplication_appCategory
|
||||
*/
|
||||
int getCategory();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#classLoaderName
|
||||
* @see R.styleable#AndroidManifestApplication_classLoader
|
||||
*/
|
||||
@Nullable
|
||||
String getClassLoaderName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#className
|
||||
* @see R.styleable#AndroidManifestApplication_name
|
||||
*/
|
||||
@Nullable
|
||||
String getClassName();
|
||||
|
||||
String getPackageName();
|
||||
|
||||
/** Path of base APK */
|
||||
String getBaseCodePath();
|
||||
|
||||
/**
|
||||
* Path where this package was found on disk. For monolithic packages
|
||||
* this is path to single base APK file; for cluster packages this is
|
||||
* path to the cluster directory.
|
||||
*/
|
||||
@NonNull
|
||||
String getCodePath();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#compatibleWidthLimitDp
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
|
||||
*/
|
||||
int getCompatibleWidthLimitDp();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#descriptionRes
|
||||
* @see R.styleable#AndroidManifestApplication_description
|
||||
*/
|
||||
int getDescriptionRes();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#enabled
|
||||
* @see R.styleable#AndroidManifestApplication_enabled
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#fullBackupContent
|
||||
* @see R.styleable#AndroidManifestApplication_fullBackupContent
|
||||
*/
|
||||
int getFullBackupContent();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_HAS_DOMAIN_URLS */
|
||||
boolean isHasDomainUrls();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#iconRes
|
||||
* @see R.styleable#AndroidManifestApplication_icon
|
||||
*/
|
||||
int getIconRes();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#installLocation
|
||||
* @see R.styleable#AndroidManifest_installLocation
|
||||
*/
|
||||
int getInstallLocation();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#labelRes
|
||||
* @see R.styleable#AndroidManifestApplication_label
|
||||
*/
|
||||
int getLabelRes();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#largestWidthLimitDp
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
|
||||
*/
|
||||
int getLargestWidthLimitDp();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#logo
|
||||
* @see R.styleable#AndroidManifestApplication_logo
|
||||
*/
|
||||
int getLogo();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#manageSpaceActivityName
|
||||
* @see R.styleable#AndroidManifestApplication_manageSpaceActivity
|
||||
*/
|
||||
@Nullable
|
||||
String getManageSpaceActivityName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#minSdkVersion
|
||||
* @see R.styleable#AndroidManifestUsesSdk_minSdkVersion
|
||||
*/
|
||||
int getMinSdkVersion();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#networkSecurityConfigRes
|
||||
* @see R.styleable#AndroidManifestApplication_networkSecurityConfig
|
||||
*/
|
||||
int getNetworkSecurityConfigRes();
|
||||
|
||||
/**
|
||||
* If {@link R.styleable#AndroidManifestApplication_label} is a string literal, this is it.
|
||||
* Otherwise, it's stored as {@link #getLabelRes()}.
|
||||
* @see ApplicationInfo#nonLocalizedLabel
|
||||
* @see R.styleable#AndroidManifestApplication_label
|
||||
*/
|
||||
@Nullable
|
||||
CharSequence getNonLocalizedLabel();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#overlayCategory
|
||||
* @see R.styleable#AndroidManifestResourceOverlay_category
|
||||
*/
|
||||
@Nullable
|
||||
String getOverlayCategory();
|
||||
|
||||
/** @see PackageInfo#mOverlayIsStatic */
|
||||
boolean isOverlayIsStatic();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#overlayPriority
|
||||
* @see R.styleable#AndroidManifestResourceOverlay_priority
|
||||
*/
|
||||
int getOverlayPriority();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#overlayTarget
|
||||
* @see R.styleable#AndroidManifestResourceOverlay_targetPackage
|
||||
*/
|
||||
@Nullable
|
||||
String getOverlayTarget();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#targetOverlayableName
|
||||
* @see R.styleable#AndroidManifestResourceOverlay_targetName
|
||||
*/
|
||||
@Nullable
|
||||
String getOverlayTargetName();
|
||||
|
||||
/**
|
||||
* If a system app declares {@link #getOriginalPackages()}, and the app was previously installed
|
||||
* under one of those original package names, the {@link #getPackageName()} system identifier
|
||||
* will be changed to that previously installed name. This will then be non-null, set to the
|
||||
* manifest package name, for tracking the package under its true name.
|
||||
*
|
||||
* TODO(b/135203078): Remove this in favor of checking originalPackages.isEmpty and
|
||||
* getManifestPackageName
|
||||
*/
|
||||
@Nullable
|
||||
String getRealPackage();
|
||||
|
||||
/**
|
||||
* The required account type without which this application will not function.
|
||||
*
|
||||
* @see PackageInfo#requiredAccountType
|
||||
* @see R.styleable#AndroidManifestApplication_requiredAccountType
|
||||
*/
|
||||
@Nullable
|
||||
String getRequiredAccountType();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#requiredForAllUsers
|
||||
* @see R.styleable#AndroidManifestApplication_requiredForAllUsers
|
||||
*/
|
||||
boolean isRequiredForAllUsers();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#requiresSmallestWidthDp
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
|
||||
*/
|
||||
int getRequiresSmallestWidthDp();
|
||||
|
||||
/**
|
||||
* SHA-512 hash of the only APK that can be used to update a system package.
|
||||
* @see R.styleable#AndroidManifestRestrictUpdate
|
||||
*/
|
||||
@Nullable
|
||||
byte[] getRestrictUpdateHash();
|
||||
|
||||
/**
|
||||
* The restricted account authenticator type that is used by this application
|
||||
*
|
||||
* @see PackageInfo#restrictedAccountType
|
||||
* @see R.styleable#AndroidManifestApplication_restrictedAccountType
|
||||
*/
|
||||
@Nullable
|
||||
String getRestrictedAccountType();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#roundIconRes
|
||||
* @see R.styleable#AndroidManifestApplication_roundIcon
|
||||
*/
|
||||
int getRoundIconRes();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#sharedUserLabel
|
||||
* @see R.styleable#AndroidManifest_sharedUserLabel
|
||||
*/
|
||||
@Deprecated
|
||||
int getSharedUserLabel();
|
||||
|
||||
/**
|
||||
* The signature data of all APKs in this package, which must be exactly the same across the
|
||||
* base and splits.
|
||||
*/
|
||||
PackageParser.SigningDetails getSigningDetails();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#splitClassLoaderNames
|
||||
* @see R.styleable#AndroidManifestApplication_classLoader
|
||||
*/
|
||||
@Nullable
|
||||
String[] getSplitClassLoaderNames();
|
||||
|
||||
/** @see R.styleable#AndroidManifestStaticLibrary_version */
|
||||
long getStaticSharedLibVersion();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#DONUT}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_largeScreens
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_LARGE_SCREENS
|
||||
*/
|
||||
boolean isSupportsLargeScreens();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_normalScreens
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_NORMAL_SCREENS
|
||||
*/
|
||||
boolean isSupportsNormalScreens();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#DONUT}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_smallScreens
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_SMALL_SCREENS
|
||||
*/
|
||||
boolean isSupportsSmallScreens();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#GINGERBREAD}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_xlargeScreens
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_XLARGE_SCREENS
|
||||
*/
|
||||
boolean isSupportsExtraLargeScreens();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ALLOW_NATIVE_HEAP_POINTER_TAGGING */
|
||||
boolean isAllowNativeHeapPointerTagging();
|
||||
|
||||
boolean hasPreserveLegacyExternalStorage();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#targetSandboxVersion
|
||||
* @see R.styleable#AndroidManifest_targetSandboxVersion
|
||||
*/
|
||||
@Deprecated
|
||||
int getTargetSandboxVersion();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#theme
|
||||
* @see R.styleable#AndroidManifestApplication_theme
|
||||
*/
|
||||
int getTheme();
|
||||
|
||||
/**
|
||||
* For use with {@link com.android.server.pm.KeySetManagerService}. Parsed in
|
||||
* {@link PackageParser#TAG_KEY_SETS}.
|
||||
* @see R.styleable#AndroidManifestUpgradeKeySet
|
||||
*/
|
||||
@NonNull
|
||||
Set<String> getUpgradeKeySets();
|
||||
|
||||
/**
|
||||
* The install time abi override to choose 32bit abi's when multiple abi's
|
||||
* are present. This is only meaningfull for multiarch applications.
|
||||
* The use32bitAbi attribute is ignored if cpuAbiOverride is also set.
|
||||
*/
|
||||
boolean isUse32BitAbi();
|
||||
|
||||
/** @see ApplicationInfo#volumeUuid */
|
||||
@Nullable
|
||||
String getVolumeUuid();
|
||||
|
||||
/** @see ApplicationInfo#zygotePreloadName */
|
||||
@Nullable
|
||||
String getZygotePreloadName();
|
||||
|
||||
/** Revision code of base APK */
|
||||
int getBaseRevisionCode();
|
||||
|
||||
/** @see PackageInfo#versionName */
|
||||
@Nullable
|
||||
String getVersionName();
|
||||
|
||||
/** @see PackageInfo#versionCodeMajor */
|
||||
@Nullable
|
||||
int getVersionCode();
|
||||
|
||||
/** @see PackageInfo#versionCodeMajor */
|
||||
@Nullable
|
||||
int getVersionCodeMajor();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#compileSdkVersion
|
||||
* @see R.styleable#AndroidManifest_compileSdkVersion
|
||||
*/
|
||||
int getCompileSdkVersion();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#compileSdkVersionCodename
|
||||
* @see R.styleable#AndroidManifest_compileSdkVersionCodename
|
||||
*/
|
||||
@Nullable
|
||||
String getCompileSdkVersionCodeName();
|
||||
|
||||
@Nullable
|
||||
Set<String> getMimeGroups();
|
||||
|
||||
// TODO(b/135203078): Hide and enforce going through PackageInfoUtils
|
||||
ApplicationInfo toAppInfoWithoutState();
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 com.android.server.pm.parsing.pkg;
|
||||
|
||||
import static android.content.pm.parsing.ComponentParseUtils.ParsedActivityIntentInfo;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageParser;
|
||||
import android.content.pm.PermissionGroupInfo;
|
||||
import android.content.pm.SharedLibraryInfo;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedFeature;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedPermissionGroup;
|
||||
import android.content.pm.parsing.ParsingPackageRead;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.ArraySet;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The last state of a package during parsing/install before it is available in
|
||||
* {@link com.android.server.pm.PackageManagerService#mPackages}.
|
||||
*
|
||||
* It is the responsibility of the caller to understand what data is available at what step of the
|
||||
* parsing or install process.
|
||||
*
|
||||
* TODO(b/135203078): Nullability annotations
|
||||
* TODO(b/135203078): Remove get/setAppInfo differences
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public interface AndroidPackage extends PkgAppInfo, PkgPackageInfo, ParsingPackageRead, Parcelable {
|
||||
|
||||
//TODO(b/135203078): Remove in favor of individual methods
|
||||
@Deprecated
|
||||
int getFlags();
|
||||
|
||||
//TODO(b/135203078): Remove in favor of individual methods
|
||||
@Deprecated
|
||||
int getPrivateFlags();
|
||||
|
||||
//TODO(b/135203078): Move to PackageSetting
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String[] getUsesLibraryFiles();
|
||||
|
||||
//TODO(b/135203078): Move to PackageSetting
|
||||
@Deprecated
|
||||
List<SharedLibraryInfo> getUsesLibraryInfos();
|
||||
|
||||
/**
|
||||
* This will eventually be removed. Avoid calling this at all costs.
|
||||
*/
|
||||
@Deprecated
|
||||
AndroidPackageWrite mutate();
|
||||
|
||||
@Deprecated
|
||||
String getCredentialProtectedDataDir();
|
||||
|
||||
@Deprecated
|
||||
String getDataDir();
|
||||
|
||||
@Deprecated
|
||||
String getDeviceProtectedDataDir();
|
||||
|
||||
/**
|
||||
* The names of packages to adopt ownership of permissions from, parsed under
|
||||
* {@link PackageParser#TAG_ADOPT_PERMISSIONS}.
|
||||
* @see R.styleable#AndroidManifestOriginalPackage_name
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getAdoptPermissions();
|
||||
|
||||
/** Path of base APK */
|
||||
@NonNull
|
||||
String getBaseCodePath();
|
||||
|
||||
/** Revision code of base APK */
|
||||
int getBaseRevisionCode();
|
||||
|
||||
/**
|
||||
* Path where this package was found on disk. For monolithic packages
|
||||
* this is path to single base APK file; for cluster packages this is
|
||||
* path to the cluster directory.
|
||||
*/
|
||||
@NonNull
|
||||
String getCodePath();
|
||||
|
||||
/**
|
||||
* The install time abi override for this package, if any.
|
||||
*
|
||||
* TODO(b/135203078): This seems like a horrible place to put the abiOverride because
|
||||
* this isn't something the packageParser parsers.
|
||||
*/
|
||||
@Nullable
|
||||
String getCpuAbiOverride();
|
||||
|
||||
/**
|
||||
* Permissions requested but not in the manifest. These may have been split or migrated from
|
||||
* previous versions/definitions.
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getImplicitPermissions();
|
||||
|
||||
/**
|
||||
* For use with {@link com.android.server.pm.KeySetManagerService}. Parsed in
|
||||
* {@link PackageParser#TAG_KEY_SETS}.
|
||||
* @see R.styleable#AndroidManifestKeySet
|
||||
* @see R.styleable#AndroidManifestPublicKey
|
||||
*/
|
||||
@NonNull
|
||||
Map<String, ArraySet<PublicKey>> getKeySetMapping();
|
||||
|
||||
/**
|
||||
* Library names this package is declared as, for use by other packages with "uses-library".
|
||||
* @see R.styleable#AndroidManifestLibrary
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getLibraryNames();
|
||||
|
||||
/**
|
||||
* The package name as declared in the manifest, since the package can be renamed. For example,
|
||||
* static shared libs use synthetic package names.
|
||||
*/
|
||||
@NonNull
|
||||
String getManifestPackageName();
|
||||
|
||||
/**
|
||||
* We store the application meta-data independently to avoid multiple unwanted references
|
||||
* TODO(b/135203078): What does this comment mean?
|
||||
* TODO(b/135203078): Make all the Bundles immutable (and non-null by shared empty reference?)
|
||||
*/
|
||||
@Nullable
|
||||
Bundle getMetaData();
|
||||
|
||||
/**
|
||||
* For system use to migrate from an old package name to a new one, moving over data
|
||||
* if available.
|
||||
* @see R.styleable#AndroidManifestOriginalPackage}
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getOriginalPackages();
|
||||
|
||||
/**
|
||||
* Map of overlayable name to actor name.
|
||||
*/
|
||||
@NonNull
|
||||
Map<String, String> getOverlayables();
|
||||
|
||||
/**
|
||||
* The name of the package as used to identify it in the system. This may be adjusted by the
|
||||
* system from the value declared in the manifest, and may not correspond to a Java code
|
||||
* package.
|
||||
* @see ApplicationInfo#packageName
|
||||
* @see PackageInfo#packageName
|
||||
*/
|
||||
@NonNull
|
||||
String getPackageName();
|
||||
|
||||
/**
|
||||
* @see PermissionGroupInfo
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedPermissionGroup> getPermissionGroups();
|
||||
|
||||
@Nullable
|
||||
List<ParsedFeature> getFeatures();
|
||||
|
||||
/**
|
||||
* Used to determine the default preferred handler of an {@link Intent}.
|
||||
*
|
||||
* Map of component className to intent info inside that component.
|
||||
* TODO(b/135203078): Is this actually used/working?
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedActivityIntentInfo> getPreferredActivityFilters();
|
||||
|
||||
/**
|
||||
* System protected broadcasts.
|
||||
* @see R.styleable#AndroidManifestProtectedBroadcast
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getProtectedBroadcasts();
|
||||
|
||||
/**
|
||||
* Intents that this package may query or require and thus requires visibility into.
|
||||
* @see R.styleable#AndroidManifestQueriesIntent
|
||||
*/
|
||||
@NonNull
|
||||
List<Intent> getQueriesIntents();
|
||||
|
||||
/**
|
||||
* Other packages that this package may query or require and thus requires visibility into.
|
||||
* @see R.styleable#AndroidManifestQueriesPackage
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getQueriesPackages();
|
||||
|
||||
/**
|
||||
* If a system app declares {@link #getOriginalPackages()}, and the app was previously installed
|
||||
* under one of those original package names, the {@link #getPackageName()} system identifier
|
||||
* will be changed to that previously installed name. This will then be non-null, set to the
|
||||
* manifest package name, for tracking the package under its true name.
|
||||
*
|
||||
* TODO(b/135203078): Remove this in favor of checking originalPackages.isEmpty and
|
||||
* getManifestPackageName
|
||||
*/
|
||||
@Nullable
|
||||
String getRealPackage();
|
||||
|
||||
/**
|
||||
* SHA-512 hash of the only APK that can be used to update a system package.
|
||||
* @see R.styleable#AndroidManifestRestrictUpdate
|
||||
*/
|
||||
@Nullable
|
||||
byte[] getRestrictUpdateHash();
|
||||
|
||||
/**
|
||||
* The signature data of all APKs in this package, which must be exactly the same across the
|
||||
* base and splits.
|
||||
*/
|
||||
PackageParser.SigningDetails getSigningDetails();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Move split stuff to an inner data class
|
||||
* @see ApplicationInfo#splitNames
|
||||
* @see PackageInfo#splitNames
|
||||
*/
|
||||
@Nullable
|
||||
String[] getSplitNames();
|
||||
|
||||
/** Flags of any split APKs; ordered by parsed splitName */
|
||||
@Nullable
|
||||
int[] getSplitFlags();
|
||||
|
||||
/** @see R.styleable#AndroidManifestStaticLibrary_name */
|
||||
@Nullable
|
||||
String getStaticSharedLibName();
|
||||
|
||||
/** @see R.styleable#AndroidManifestStaticLibrary_version */
|
||||
long getStaticSharedLibVersion();
|
||||
|
||||
/**
|
||||
* {@link android.os.storage.StorageManager#convert(String)} version of
|
||||
* {@link #getVolumeUuid()}.
|
||||
* TODO(b/135203078): All usages call toString() on this. Can the string be returned directly,
|
||||
* or does the parsing logic in StorageManager have to run?
|
||||
*/
|
||||
UUID getStorageUuid();
|
||||
|
||||
/**
|
||||
* For use with {@link com.android.server.pm.KeySetManagerService}. Parsed in
|
||||
* {@link PackageParser#TAG_KEY_SETS}.
|
||||
* @see R.styleable#AndroidManifestUpgradeKeySet
|
||||
*/
|
||||
@NonNull
|
||||
Set<String> getUpgradeKeySets();
|
||||
|
||||
/** @see R.styleable#AndroidManifestUsesLibrary */
|
||||
@NonNull
|
||||
List<String> getUsesLibraries();
|
||||
|
||||
/**
|
||||
* Like {@link #getUsesLibraries()}, but marked optional by setting
|
||||
* {@link R.styleable#AndroidManifestUsesLibrary_required} to false . Application is expected
|
||||
* to handle absence manually.
|
||||
* @see R.styleable#AndroidManifestUsesLibrary
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getUsesOptionalLibraries();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Move static library stuff to an inner data class
|
||||
* @see R.styleable#AndroidManifestUsesStaticLibrary
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getUsesStaticLibraries();
|
||||
|
||||
/** @see R.styleable#AndroidManifestUsesStaticLibrary_certDigest */
|
||||
@Nullable
|
||||
String[][] getUsesStaticLibrariesCertDigests();
|
||||
|
||||
/** @see R.styleable#AndroidManifestUsesStaticLibrary_version */
|
||||
@Nullable
|
||||
long[] getUsesStaticLibrariesVersions();
|
||||
|
||||
/** @see R.styleable#AndroidManifestApplication_forceQueryable */
|
||||
boolean isForceQueryable();
|
||||
|
||||
boolean isCrossProfile();
|
||||
|
||||
/**
|
||||
* The install time abi override to choose 32bit abi's when multiple abi's
|
||||
* are present. This is only meaningfull for multiarch applications.
|
||||
* The use32bitAbi attribute is ignored if cpuAbiOverride is also set.
|
||||
*/
|
||||
boolean isUse32BitAbi();
|
||||
|
||||
/**
|
||||
* Set if the any of components are visible to instant applications.
|
||||
* @see R.styleable#AndroidManifestActivity_visibleToInstantApps
|
||||
* @see R.styleable#AndroidManifestProvider_visibleToInstantApps
|
||||
* @see R.styleable#AndroidManifestService_visibleToInstantApps
|
||||
*/
|
||||
boolean isVisibleToInstantApps();
|
||||
|
||||
/**
|
||||
* Generates an {@link ApplicationInfo} object with only the data available in this object.
|
||||
*
|
||||
* TODO(b/135203078): Actually add this
|
||||
* This does not contain any system or user state data, and should be avoided. Prefer
|
||||
* com.android.server.pm.parsing.PackageInfoUtils#generateApplicationInfo(
|
||||
* AndroidPackage, int, PackageUserState, int, com.android.server.pm.PackageSetting)
|
||||
*
|
||||
* @deprecated Access AndroidPackage fields directly.
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
ApplicationInfo toAppInfoWithoutState();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Remove usages?
|
||||
* @return a mock of what the previous package.applicationInfo would've returned for logging
|
||||
* @deprecated don't use this in any new code, just print package name directly
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
String toAppInfoToString();
|
||||
|
||||
@Deprecated
|
||||
boolean isUpdatedSystemApp();
|
||||
|
||||
@Deprecated
|
||||
boolean isHiddenUntilInstalled();
|
||||
|
||||
@Deprecated
|
||||
long[] getLastPackageUsageTimeInMills();
|
||||
|
||||
@Deprecated
|
||||
long getLatestForegroundPackageUseTimeInMills();
|
||||
|
||||
@Deprecated
|
||||
long getLatestPackageUseTimeInMills();
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 com.android.server.pm.parsing.pkg;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageParser;
|
||||
import android.content.pm.PackageParser.PackageParserException;
|
||||
import android.content.pm.SharedLibraryInfo;
|
||||
import android.content.pm.VersionedPackage;
|
||||
import android.content.pm.dex.DexMetadataHelper;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedActivity;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedInstrumentation;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedProvider;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedService;
|
||||
import android.content.pm.parsing.ParsingPackageRead;
|
||||
|
||||
import com.android.internal.content.NativeLibraryHelper;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.server.SystemConfig;
|
||||
import com.android.server.pm.PackageSetting;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/** @hide */
|
||||
public class AndroidPackageUtils {
|
||||
|
||||
private AndroidPackageUtils() {
|
||||
}
|
||||
|
||||
public static List<String> getAllCodePathsExcludingResourceOnly(
|
||||
AndroidPackage aPkg) {
|
||||
PackageImpl pkg = (PackageImpl) aPkg;
|
||||
ArrayList<String> paths = new ArrayList<>();
|
||||
if (pkg.isHasCode()) {
|
||||
paths.add(pkg.getBaseCodePath());
|
||||
}
|
||||
String[] splitCodePaths = pkg.getSplitCodePaths();
|
||||
if (!ArrayUtils.isEmpty(splitCodePaths)) {
|
||||
for (int i = 0; i < splitCodePaths.length; i++) {
|
||||
if ((pkg.getSplitFlags()[i] & ApplicationInfo.FLAG_HAS_CODE) != 0) {
|
||||
paths.add(splitCodePaths[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of the base and split code paths.
|
||||
*/
|
||||
public static List<String> getAllCodePaths(AndroidPackage aPkg) {
|
||||
PackageImpl pkg = (PackageImpl) aPkg;
|
||||
ArrayList<String> paths = new ArrayList<>();
|
||||
paths.add(pkg.getBaseCodePath());
|
||||
|
||||
String[] splitCodePaths = pkg.getSplitCodePaths();
|
||||
if (!ArrayUtils.isEmpty(splitCodePaths)) {
|
||||
Collections.addAll(paths, splitCodePaths);
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
public static SharedLibraryInfo createSharedLibraryForStatic(AndroidPackage pkg) {
|
||||
return new SharedLibraryInfo(null, pkg.getPackageName(),
|
||||
AndroidPackageUtils.getAllCodePaths(pkg),
|
||||
pkg.getStaticSharedLibName(),
|
||||
pkg.getStaticSharedLibVersion(),
|
||||
SharedLibraryInfo.TYPE_STATIC,
|
||||
new VersionedPackage(pkg.getManifestPackageName(),
|
||||
pkg.getLongVersionCode()),
|
||||
null, null);
|
||||
}
|
||||
|
||||
public static SharedLibraryInfo createSharedLibraryForDynamic(AndroidPackage pkg, String name) {
|
||||
return new SharedLibraryInfo(null, pkg.getPackageName(),
|
||||
AndroidPackageUtils.getAllCodePaths(pkg), name,
|
||||
SharedLibraryInfo.VERSION_UNDEFINED,
|
||||
SharedLibraryInfo.TYPE_DYNAMIC, new VersionedPackage(pkg.getPackageName(),
|
||||
pkg.getLongVersionCode()),
|
||||
null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the dex metadata files for the given package as a map
|
||||
* [code path -> dex metadata path].
|
||||
*
|
||||
* NOTE: involves I/O checks.
|
||||
*/
|
||||
public static Map<String, String> getPackageDexMetadata(AndroidPackage pkg) {
|
||||
return DexMetadataHelper.buildPackageApkToDexMetadataMap
|
||||
(AndroidPackageUtils.getAllCodePaths(pkg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the dex metadata files installed for the given package.
|
||||
*
|
||||
* @throws PackageParserException in case of errors.
|
||||
*/
|
||||
public static void validatePackageDexMetadata(AndroidPackage pkg)
|
||||
throws PackageParserException {
|
||||
Collection<String> apkToDexMetadataList = getPackageDexMetadata(pkg).values();
|
||||
for (String dexMetadata : apkToDexMetadataList) {
|
||||
DexMetadataHelper.validateDexMetadataFile(dexMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
public static NativeLibraryHelper.Handle createNativeLibraryHandle(AndroidPackage pkg)
|
||||
throws IOException {
|
||||
return NativeLibraryHelper.Handle.create(
|
||||
AndroidPackageUtils.getAllCodePaths(pkg),
|
||||
pkg.isMultiArch(),
|
||||
pkg.isExtractNativeLibs(),
|
||||
pkg.isDebuggable()
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean canHaveOatDir(AndroidPackage pkg, boolean isUpdatedSystemApp) {
|
||||
// The following app types CANNOT have oat directory
|
||||
// - non-updated system apps
|
||||
return !pkg.isSystem() || isUpdatedSystemApp;
|
||||
}
|
||||
|
||||
public static boolean hasComponentClassName(AndroidPackage pkg, String className) {
|
||||
List<ParsedActivity> activities = pkg.getActivities();
|
||||
int activitiesSize = activities.size();
|
||||
for (int index = 0; index < activitiesSize; index++) {
|
||||
if (Objects.equals(className, activities.get(index).getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
List<ParsedActivity> receivers = pkg.getReceivers();
|
||||
int receiversSize = receivers.size();
|
||||
for (int index = 0; index < receiversSize; index++) {
|
||||
if (Objects.equals(className, receivers.get(index).getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
List<ParsedProvider> providers = pkg.getProviders();
|
||||
int providersSize = providers.size();
|
||||
for (int index = 0; index < providersSize; index++) {
|
||||
if (Objects.equals(className, providers.get(index).getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
List<ParsedService> services = pkg.getServices();
|
||||
int servicesSize = services.size();
|
||||
for (int index = 0; index < servicesSize; index++) {
|
||||
if (Objects.equals(className, services.get(index).getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
List<ParsedInstrumentation> instrumentations = pkg.getInstrumentations();
|
||||
int instrumentationsSize = instrumentations.size();
|
||||
for (int index = 0; index < instrumentationsSize; index++) {
|
||||
if (Objects.equals(className, instrumentations.get(index).getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEncryptionAware(AndroidPackage pkg) {
|
||||
return pkg.isDirectBootAware() || pkg.isPartiallyDirectBootAware();
|
||||
}
|
||||
|
||||
public static boolean isLibrary(AndroidPackage pkg) {
|
||||
// TODO(b/135203078): Can parsing just enforce these always match?
|
||||
return pkg.getStaticSharedLibName() != null || !pkg.getLibraryNames().isEmpty();
|
||||
}
|
||||
|
||||
public static int getHiddenApiEnforcementPolicy(AndroidPackage pkg) {
|
||||
boolean isAllowedToUseHiddenApis;
|
||||
if (pkg.isSignedWithPlatformKey()) {
|
||||
isAllowedToUseHiddenApis = true;
|
||||
} else if (pkg.isSystem() || pkg.isUpdatedSystemApp()) {
|
||||
isAllowedToUseHiddenApis = pkg.isUsesNonSdkApi()
|
||||
|| SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(
|
||||
pkg.getPackageName());
|
||||
} else {
|
||||
isAllowedToUseHiddenApis = false;
|
||||
}
|
||||
|
||||
if (isAllowedToUseHiddenApis) {
|
||||
return ApplicationInfo.HIDDEN_API_ENFORCEMENT_DISABLED;
|
||||
}
|
||||
|
||||
// TODO(b/135203078): Handle maybeUpdateHiddenApiEnforcementPolicy. Right now it's done
|
||||
// entirely through ApplicationInfo and shouldn't touch this specific class, but that
|
||||
// may not always hold true.
|
||||
// if (mHiddenApiPolicy != ApplicationInfo.HIDDEN_API_ENFORCEMENT_DEFAULT) {
|
||||
// return mHiddenApiPolicy;
|
||||
// }
|
||||
return ApplicationInfo.HIDDEN_API_ENFORCEMENT_ENABLED;
|
||||
}
|
||||
|
||||
public static int getIcon(ParsingPackageRead pkg) {
|
||||
return (PackageParser.sUseRoundIcon && pkg.getRoundIconRes() != 0)
|
||||
? pkg.getRoundIconRes() : pkg.getIconRes();
|
||||
}
|
||||
|
||||
public static long getLongVersionCode(AndroidPackage pkg) {
|
||||
return PackageInfo.composeLongVersionCode(pkg.getVersionCodeMajor(), pkg.getVersionCode());
|
||||
}
|
||||
|
||||
public static boolean isMatchForSystemOnly(AndroidPackage pkg, int flags) {
|
||||
if ((flags & PackageManager.MATCH_SYSTEM_ONLY) != 0) {
|
||||
return pkg.isSystem();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* Copyright (C) 2020 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.content.pm.parsing;
|
||||
package com.android.server.pm.parsing.pkg;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.pm.PackageParser;
|
||||
@@ -0,0 +1,968 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 com.android.server.pm.parsing.pkg;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageParser;
|
||||
import android.content.pm.SharedLibraryInfo;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedActivity;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedProvider;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedService;
|
||||
import android.content.pm.parsing.ParsingPackage;
|
||||
import android.content.pm.parsing.ParsingPackageImpl;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Environment;
|
||||
import android.os.Parcel;
|
||||
import android.os.UserHandle;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.CollectionUtils;
|
||||
import com.android.internal.util.DataClass;
|
||||
import com.android.internal.util.Parcelling;
|
||||
import com.android.internal.util.Parcelling.BuiltIn.ForInternedString;
|
||||
import com.android.server.pm.parsing.PackageInfoUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Extensions to {@link ParsingPackageImpl} including fields/state contained in the system server
|
||||
* and not exposed to the core SDK.
|
||||
*
|
||||
* Many of the fields contained here will eventually be moved inside
|
||||
* {@link com.android.server.pm.PackageSetting} or {@link android.content.pm.PackageUserState}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class PackageImpl extends ParsingPackageImpl implements ParsedPackage,
|
||||
AndroidPackageWrite, AndroidPackage {
|
||||
|
||||
public static PackageImpl forParsing(@NonNull String packageName, @NonNull String baseCodePath,
|
||||
@NonNull String codePath, @NonNull TypedArray manifestArray, boolean isCoreApp) {
|
||||
return new PackageImpl(packageName, baseCodePath, codePath, manifestArray, isCoreApp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mock an unavailable {@link AndroidPackage} to use when
|
||||
* removing
|
||||
* a package from the system.
|
||||
* This can occur if the package was installed on a storage device that has since been removed.
|
||||
* Since the infrastructure uses {@link AndroidPackage}, but
|
||||
* for
|
||||
* this case only cares about
|
||||
* volumeUuid, just fake it rather than having separate method paths.
|
||||
*/
|
||||
public static AndroidPackage buildFakeForDeletion(String packageName, String volumeUuid) {
|
||||
return ((ParsedPackage) PackageImpl.forTesting(packageName)
|
||||
.setVolumeUuid(volumeUuid)
|
||||
.hideAsParsed())
|
||||
.hideAsFinal();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static ParsingPackage forTesting(String packageName) {
|
||||
return forTesting(packageName, "");
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static ParsingPackage forTesting(String packageName, String baseCodePath) {
|
||||
return new PackageImpl(packageName, baseCodePath, baseCodePath, null, false);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private long[] lastPackageUsageTimeInMills =
|
||||
new long[PackageManager.NOTIFY_PACKAGE_USE_REASONS_COUNT];
|
||||
|
||||
@NonNull
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
private final String manifestPackageName;
|
||||
|
||||
private boolean updatedSystemApp;
|
||||
|
||||
@Nullable
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
protected String cpuAbiOverride;
|
||||
|
||||
private boolean stub;
|
||||
|
||||
@Nullable
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
protected String nativeLibraryDir;
|
||||
|
||||
@Nullable
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
protected String nativeLibraryRootDir;
|
||||
|
||||
private boolean nativeLibraryRootRequiresIsa;
|
||||
|
||||
@Nullable
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
protected String primaryCpuAbi;
|
||||
@Nullable
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
protected String secondaryCpuAbi;
|
||||
@Nullable
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
protected String secondaryNativeLibraryDir;
|
||||
|
||||
@Nullable
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
protected String seInfo;
|
||||
@Nullable
|
||||
@DataClass.ParcelWith(ForInternedString.class)
|
||||
protected String seInfoUser;
|
||||
|
||||
private boolean coreApp;
|
||||
|
||||
private boolean system;
|
||||
private boolean factoryTest;
|
||||
|
||||
private boolean systemExt;
|
||||
private boolean privileged;
|
||||
private boolean oem;
|
||||
private boolean vendor;
|
||||
private boolean product;
|
||||
private boolean odm;
|
||||
|
||||
private boolean signedWithPlatformKey;
|
||||
|
||||
@Deprecated
|
||||
private boolean hiddenUntilInstalled;
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
private String credentialProtectedDataDir;
|
||||
@Deprecated
|
||||
@Nullable
|
||||
private String dataDir;
|
||||
@Deprecated
|
||||
@Nullable
|
||||
private String deviceProtectedDataDir;
|
||||
|
||||
/**
|
||||
* This is an appId, the uid if the userId is == USER_SYSTEM
|
||||
*/
|
||||
private int uid = -1;
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
private String[] usesLibraryFiles;
|
||||
@Deprecated
|
||||
@Nullable
|
||||
private List<SharedLibraryInfo> usesLibraryInfos;
|
||||
|
||||
@VisibleForTesting
|
||||
public PackageImpl(@NonNull String packageName, @NonNull String baseCodePath,
|
||||
@NonNull String codePath, @Nullable TypedArray manifestArray, boolean isCoreApp) {
|
||||
super(packageName, baseCodePath, codePath, manifestArray);
|
||||
this.manifestPackageName = this.packageName;
|
||||
this.coreApp = isCoreApp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParsedPackage hideAsParsed() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AndroidPackage hideAsFinal() {
|
||||
// TODO(b/135203078): Lock as immutable
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return PackageInfoUtils.appInfoFlags(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrivateFlags() {
|
||||
return PackageInfoUtils.appInfoPrivateFlags(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AndroidPackageWrite mutate() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLongVersionCode() {
|
||||
return PackageInfo.composeLongVersionCode(versionCodeMajor, versionCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl removePermission(int index) {
|
||||
this.permissions.remove(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl addUsesOptionalLibrary(int index, String libraryName) {
|
||||
this.usesOptionalLibraries = CollectionUtils.add(usesOptionalLibraries, index,
|
||||
TextUtils.safeIntern(libraryName));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl addUsesLibrary(int index, String libraryName) {
|
||||
this.usesLibraries = CollectionUtils.add(usesLibraries, index,
|
||||
TextUtils.safeIntern(libraryName));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl removeUsesLibrary(String libraryName) {
|
||||
this.usesLibraries = CollectionUtils.remove(this.usesLibraries, libraryName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl removeUsesOptionalLibrary(String libraryName) {
|
||||
super.removeUsesOptionalLibrary(libraryName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSigningDetails(@Nullable PackageParser.SigningDetails value) {
|
||||
super.setSigningDetails(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setRestrictUpdateHash(@Nullable byte... value) {
|
||||
super.setRestrictUpdateHash(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setRealPackage(@Nullable String realPackage) {
|
||||
super.setRealPackage(realPackage);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setPersistent(boolean value) {
|
||||
super.setPersistent(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setDefaultToDeviceProtectedStorage(boolean value) {
|
||||
super.setDefaultToDeviceProtectedStorage(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setDirectBootAware(boolean value) {
|
||||
super.setDirectBootAware(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl clearProtectedBroadcasts() {
|
||||
protectedBroadcasts.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl clearOriginalPackages() {
|
||||
originalPackages.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl clearAdoptPermissions() {
|
||||
adoptPermissions.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setCodePath(@NonNull String value) {
|
||||
this.codePath = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO(b/135203078): Move PackageManagerService#renameStaticSharedLibraryPackage
|
||||
// into initial package parsing
|
||||
@Override
|
||||
public PackageImpl setPackageName(@NonNull String packageName) {
|
||||
this.packageName = TextUtils.safeIntern(packageName);
|
||||
|
||||
int permissionsSize = permissions.size();
|
||||
for (int index = 0; index < permissionsSize; index++) {
|
||||
permissions.get(index).setPackageName(this.packageName);
|
||||
}
|
||||
|
||||
int permissionGroupsSize = permissionGroups.size();
|
||||
for (int index = 0; index < permissionGroupsSize; index++) {
|
||||
permissionGroups.get(index).setPackageName(this.packageName);
|
||||
}
|
||||
|
||||
int activitiesSize = activities.size();
|
||||
for (int index = 0; index < activitiesSize; index++) {
|
||||
activities.get(index).setPackageName(this.packageName);
|
||||
}
|
||||
|
||||
int receiversSize = receivers.size();
|
||||
for (int index = 0; index < receiversSize; index++) {
|
||||
receivers.get(index).setPackageName(this.packageName);
|
||||
}
|
||||
|
||||
int providersSize = providers.size();
|
||||
for (int index = 0; index < providersSize; index++) {
|
||||
providers.get(index).setPackageName(this.packageName);
|
||||
}
|
||||
|
||||
int servicesSize = services.size();
|
||||
for (int index = 0; index < servicesSize; index++) {
|
||||
services.get(index).setPackageName(this.packageName);
|
||||
}
|
||||
|
||||
int instrumentationsSize = instrumentations.size();
|
||||
for (int index = 0; index < instrumentationsSize; index++) {
|
||||
instrumentations.get(index).setPackageName(this.packageName);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setAllComponentsDirectBootAware(boolean allComponentsDirectBootAware) {
|
||||
int activitiesSize = activities.size();
|
||||
for (int index = 0; index < activitiesSize; index++) {
|
||||
activities.get(index).directBootAware = allComponentsDirectBootAware;
|
||||
}
|
||||
|
||||
int receiversSize = receivers.size();
|
||||
for (int index = 0; index < receiversSize; index++) {
|
||||
receivers.get(index).directBootAware = allComponentsDirectBootAware;
|
||||
}
|
||||
|
||||
int providersSize = providers.size();
|
||||
for (int index = 0; index < providersSize; index++) {
|
||||
providers.get(index).directBootAware = allComponentsDirectBootAware;
|
||||
}
|
||||
|
||||
int servicesSize = services.size();
|
||||
for (int index = 0; index < servicesSize; index++) {
|
||||
services.get(index).directBootAware = allComponentsDirectBootAware;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setBaseCodePath(@NonNull String baseCodePath) {
|
||||
this.baseCodePath = TextUtils.safeIntern(baseCodePath);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setCpuAbiOverride(@Nullable String cpuAbiOverride) {
|
||||
this.cpuAbiOverride = TextUtils.safeIntern(cpuAbiOverride);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setNativeLibraryDir(@Nullable String nativeLibraryDir) {
|
||||
this.nativeLibraryDir = TextUtils.safeIntern(nativeLibraryDir);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setNativeLibraryRootDir(@Nullable String nativeLibraryRootDir) {
|
||||
this.nativeLibraryRootDir = TextUtils.safeIntern(nativeLibraryRootDir);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setPrimaryCpuAbi(@Nullable String primaryCpuAbi) {
|
||||
this.primaryCpuAbi = TextUtils.safeIntern(primaryCpuAbi);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSecondaryCpuAbi(@Nullable String secondaryCpuAbi) {
|
||||
this.secondaryCpuAbi = TextUtils.safeIntern(secondaryCpuAbi);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSecondaryNativeLibraryDir(@Nullable String secondaryNativeLibraryDir) {
|
||||
this.secondaryNativeLibraryDir = TextUtils.safeIntern(secondaryNativeLibraryDir);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSeInfo(@Nullable String seInfo) {
|
||||
this.seInfo = TextUtils.safeIntern(seInfo);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSeInfoUser(@Nullable String seInfoUser) {
|
||||
this.seInfoUser = TextUtils.safeIntern(seInfoUser);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSplitCodePaths(@Nullable String[] splitCodePaths) {
|
||||
this.splitCodePaths = splitCodePaths;
|
||||
if (splitCodePaths != null) {
|
||||
int size = splitCodePaths.length;
|
||||
for (int index = 0; index < size; index++) {
|
||||
this.splitCodePaths[index] = TextUtils.safeIntern(this.splitCodePaths[index]);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl capPermissionPriorities() {
|
||||
int size = permissionGroups.size();
|
||||
for (int index = size - 1; index >= 0; --index) {
|
||||
// TODO(b/135203078): Builder/immutability
|
||||
permissionGroups.get(index).priority = 0;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl markNotActivitiesAsNotExportedIfSingleUser() {
|
||||
// ignore export request for single user receivers
|
||||
int receiversSize = receivers.size();
|
||||
for (int index = 0; index < receiversSize; index++) {
|
||||
ParsedActivity receiver = receivers.get(index);
|
||||
if ((receiver.flags & ActivityInfo.FLAG_SINGLE_USER) != 0) {
|
||||
receiver.exported = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ignore export request for single user services
|
||||
int servicesSize = services.size();
|
||||
for (int index = 0; index < servicesSize; index++) {
|
||||
ParsedService service = services.get(index);
|
||||
if ((service.flags & ActivityInfo.FLAG_SINGLE_USER) != 0) {
|
||||
service.exported = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ignore export request for single user providers
|
||||
int providersSize = providers.size();
|
||||
for (int index = 0; index < providersSize; index++) {
|
||||
ParsedProvider provider = providers.get(index);
|
||||
if ((provider.getFlags() & ActivityInfo.FLAG_SINGLE_USER) != 0) {
|
||||
provider.setExported(false);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getStorageUuid() {
|
||||
return StorageManager.convert(volumeUuid);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public String toAppInfoToString() {
|
||||
return "ApplicationInfo{"
|
||||
+ Integer.toHexString(System.identityHashCode(this))
|
||||
+ " " + getPackageName() + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl initForUser(int userId) {
|
||||
// TODO(b/135203078): Move this user state to some other data structure
|
||||
this.uid = UserHandle.getUid(userId, UserHandle.getAppId(this.uid));
|
||||
|
||||
if ("android".equals(packageName)) {
|
||||
dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
|
||||
return this;
|
||||
}
|
||||
|
||||
deviceProtectedDataDir = Environment
|
||||
.getDataUserDePackageDirectory(volumeUuid, userId, packageName)
|
||||
.getAbsolutePath();
|
||||
credentialProtectedDataDir = Environment
|
||||
.getDataUserCePackageDirectory(volumeUuid, userId, packageName)
|
||||
.getAbsolutePath();
|
||||
|
||||
if (isDefaultToDeviceProtectedStorage()
|
||||
&& PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
|
||||
dataDir = deviceProtectedDataDir;
|
||||
} else {
|
||||
dataDir = credentialProtectedDataDir;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setLastPackageUsageTimeInMills(int reason, long time) {
|
||||
lastPackageUsageTimeInMills[reason] = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLatestPackageUseTimeInMills() {
|
||||
long latestUse = 0L;
|
||||
for (long use : lastPackageUsageTimeInMills) {
|
||||
latestUse = Math.max(latestUse, use);
|
||||
}
|
||||
return latestUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLatestForegroundPackageUseTimeInMills() {
|
||||
int[] foregroundReasons = {
|
||||
PackageManager.NOTIFY_PACKAGE_USE_ACTIVITY,
|
||||
PackageManager.NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE
|
||||
};
|
||||
|
||||
long latestUse = 0L;
|
||||
for (int reason : foregroundReasons) {
|
||||
latestUse = Math.max(latestUse, lastPackageUsageTimeInMills[reason]);
|
||||
}
|
||||
return latestUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getLastPackageUsageTimeInMills() {
|
||||
return lastPackageUsageTimeInMills;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setUsesLibraryInfos(
|
||||
@Nullable List<SharedLibraryInfo> usesLibraryInfos) {
|
||||
this.usesLibraryInfos = usesLibraryInfos;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setUsesLibraryFiles(@Nullable String[] usesLibraryFiles) {
|
||||
this.usesLibraryFiles = usesLibraryFiles;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParsedPackage setCoreApp(boolean coreApp) {
|
||||
this.coreApp = coreApp;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParsedPackage setVersionCode(int versionCode) {
|
||||
this.versionCode = versionCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParsedPackage setVersionCodeMajor(int versionCodeMajor) {
|
||||
this.versionCodeMajor = versionCodeMajor;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationInfo toAppInfoWithoutState() {
|
||||
ApplicationInfo appInfo = super.toAppInfoWithoutState();
|
||||
appInfo.flags = PackageInfoUtils.appInfoFlags(this, null);
|
||||
appInfo.privateFlags = PackageInfoUtils.appInfoPrivateFlags(this, null);
|
||||
appInfo.hiddenUntilInstalled = hiddenUntilInstalled;
|
||||
appInfo.nativeLibraryDir = nativeLibraryDir;
|
||||
appInfo.nativeLibraryRootDir = nativeLibraryRootDir;
|
||||
appInfo.nativeLibraryRootRequiresIsa = nativeLibraryRootRequiresIsa;
|
||||
appInfo.primaryCpuAbi = primaryCpuAbi;
|
||||
appInfo.secondaryCpuAbi = secondaryCpuAbi;
|
||||
appInfo.secondaryNativeLibraryDir = secondaryNativeLibraryDir;
|
||||
appInfo.seInfo = seInfo;
|
||||
appInfo.seInfoUser = seInfoUser;
|
||||
appInfo.uid = uid;
|
||||
appInfo.sharedLibraryFiles = usesLibraryFiles;
|
||||
appInfo.sharedLibraryInfos = usesLibraryInfos;
|
||||
appInfo.credentialProtectedDataDir = credentialProtectedDataDir;
|
||||
appInfo.dataDir = dataDir;
|
||||
appInfo.deviceProtectedDataDir = deviceProtectedDataDir;
|
||||
return appInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeBoolean(this.updatedSystemApp);
|
||||
sForString.parcel(this.manifestPackageName, dest, flags);
|
||||
sForString.parcel(this.cpuAbiOverride, dest, flags);
|
||||
dest.writeBoolean(this.stub);
|
||||
sForString.parcel(this.nativeLibraryDir, dest, flags);
|
||||
sForString.parcel(this.nativeLibraryRootDir, dest, flags);
|
||||
dest.writeBoolean(this.nativeLibraryRootRequiresIsa);
|
||||
sForString.parcel(this.primaryCpuAbi, dest, flags);
|
||||
sForString.parcel(this.secondaryCpuAbi, dest, flags);
|
||||
sForString.parcel(this.secondaryNativeLibraryDir, dest, flags);
|
||||
sForString.parcel(this.seInfo, dest, flags);
|
||||
sForString.parcel(this.seInfoUser, dest, flags);
|
||||
dest.writeInt(this.uid);
|
||||
dest.writeBoolean(this.coreApp);
|
||||
dest.writeBoolean(this.system);
|
||||
dest.writeBoolean(this.factoryTest);
|
||||
dest.writeBoolean(this.systemExt);
|
||||
dest.writeBoolean(this.privileged);
|
||||
dest.writeBoolean(this.oem);
|
||||
dest.writeBoolean(this.vendor);
|
||||
dest.writeBoolean(this.product);
|
||||
dest.writeBoolean(this.odm);
|
||||
dest.writeBoolean(this.signedWithPlatformKey);
|
||||
dest.writeBoolean(this.hiddenUntilInstalled);
|
||||
dest.writeString(this.credentialProtectedDataDir);
|
||||
dest.writeString(this.dataDir);
|
||||
dest.writeString(this.deviceProtectedDataDir);
|
||||
dest.writeLongArray(this.lastPackageUsageTimeInMills);
|
||||
dest.writeStringArray(this.usesLibraryFiles);
|
||||
dest.writeTypedList(this.usesLibraryInfos);
|
||||
}
|
||||
|
||||
public PackageImpl(Parcel in) {
|
||||
super(in);
|
||||
this.updatedSystemApp = in.readBoolean();
|
||||
this.manifestPackageName = sForString.unparcel(in);
|
||||
this.cpuAbiOverride = sForString.unparcel(in);
|
||||
this.stub = in.readBoolean();
|
||||
this.nativeLibraryDir = sForString.unparcel(in);
|
||||
this.nativeLibraryRootDir = sForString.unparcel(in);
|
||||
this.nativeLibraryRootRequiresIsa = in.readBoolean();
|
||||
this.primaryCpuAbi = sForString.unparcel(in);
|
||||
this.secondaryCpuAbi = sForString.unparcel(in);
|
||||
this.secondaryNativeLibraryDir = sForString.unparcel(in);
|
||||
this.seInfo = sForString.unparcel(in);
|
||||
this.seInfoUser = sForString.unparcel(in);
|
||||
this.uid = in.readInt();
|
||||
this.coreApp = in.readBoolean();
|
||||
this.system = in.readBoolean();
|
||||
this.factoryTest = in.readBoolean();
|
||||
this.systemExt = in.readBoolean();
|
||||
this.privileged = in.readBoolean();
|
||||
this.oem = in.readBoolean();
|
||||
this.vendor = in.readBoolean();
|
||||
this.product = in.readBoolean();
|
||||
this.odm = in.readBoolean();
|
||||
this.signedWithPlatformKey = in.readBoolean();
|
||||
this.hiddenUntilInstalled = in.readBoolean();
|
||||
this.credentialProtectedDataDir = in.readString();
|
||||
this.dataDir = in.readString();
|
||||
this.deviceProtectedDataDir = in.readString();
|
||||
this.lastPackageUsageTimeInMills = in.createLongArray();
|
||||
this.usesLibraryFiles = in.createStringArray();
|
||||
this.usesLibraryInfos = in.createTypedArrayList(SharedLibraryInfo.CREATOR);
|
||||
}
|
||||
|
||||
public static final Creator<PackageImpl> CREATOR = new Creator<PackageImpl>() {
|
||||
@Override
|
||||
public PackageImpl createFromParcel(Parcel source) {
|
||||
return new PackageImpl(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl[] newArray(int size) {
|
||||
return new PackageImpl[size];
|
||||
}
|
||||
};
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getManifestPackageName() {
|
||||
return manifestPackageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpdatedSystemApp() {
|
||||
return updatedSystemApp;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCpuAbiOverride() {
|
||||
return cpuAbiOverride;
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public boolean isStub() {
|
||||
return stub;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getNativeLibraryDir() {
|
||||
return nativeLibraryDir;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getNativeLibraryRootDir() {
|
||||
return nativeLibraryRootDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNativeLibraryRootRequiresIsa() {
|
||||
return nativeLibraryRootRequiresIsa;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPrimaryCpuAbi() {
|
||||
return primaryCpuAbi;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSecondaryCpuAbi() {
|
||||
return secondaryCpuAbi;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSecondaryNativeLibraryDir() {
|
||||
return secondaryNativeLibraryDir;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSeInfo() {
|
||||
return seInfo;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSeInfoUser() {
|
||||
return seInfoUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCoreApp() {
|
||||
return coreApp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSystem() {
|
||||
return system;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFactoryTest() {
|
||||
return factoryTest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSystemExt() {
|
||||
return systemExt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrivileged() {
|
||||
return privileged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOem() {
|
||||
return oem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOdm() {
|
||||
return odm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSignedWithPlatformKey() {
|
||||
return signedWithPlatformKey;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isHiddenUntilInstalled() {
|
||||
return hiddenUntilInstalled;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCredentialProtectedDataDir() {
|
||||
return credentialProtectedDataDir;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDataDir() {
|
||||
return dataDir;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDeviceProtectedDataDir() {
|
||||
return deviceProtectedDataDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an appId, the uid if the userId is == USER_SYSTEM
|
||||
*/
|
||||
@Override
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
@Override
|
||||
public String[] getUsesLibraryFiles() {
|
||||
return usesLibraryFiles;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
@Override
|
||||
public List<SharedLibraryInfo> getUsesLibraryInfos() {
|
||||
return usesLibraryInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setUpdatedSystemApp(boolean value) {
|
||||
updatedSystemApp = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public PackageImpl setStub(boolean value) {
|
||||
stub = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setNativeLibraryRootRequiresIsa(boolean value) {
|
||||
nativeLibraryRootRequiresIsa = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSystem(boolean value) {
|
||||
system = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setFactoryTest(boolean value) {
|
||||
factoryTest = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSystemExt(boolean value) {
|
||||
systemExt = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setPrivileged(boolean value) {
|
||||
privileged = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setOem(boolean value) {
|
||||
oem = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setVendor(boolean value) {
|
||||
vendor = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setProduct(boolean value) {
|
||||
product = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setOdm(boolean value) {
|
||||
odm = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageImpl setSignedWithPlatformKey(boolean value) {
|
||||
signedWithPlatformKey = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public PackageImpl setHiddenUntilInstalled(@Deprecated boolean value) {
|
||||
hiddenUntilInstalled = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public PackageImpl setCredentialProtectedDataDir(@Deprecated @Nullable String value) {
|
||||
credentialProtectedDataDir = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public PackageImpl setDataDir(@Deprecated @Nullable String value) {
|
||||
dataDir = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public PackageImpl setDeviceProtectedDataDir(@Deprecated @Nullable String value) {
|
||||
deviceProtectedDataDir = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an appId, the uid if the userId is == USER_SYSTEM
|
||||
*/
|
||||
@Override
|
||||
public PackageImpl setUid(int value) {
|
||||
uid = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* Copyright (C) 2020 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.
|
||||
@@ -14,8 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.content.pm.parsing;
|
||||
package com.android.server.pm.parsing.pkg;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.pm.PackageParser;
|
||||
|
||||
/**
|
||||
@@ -42,20 +43,6 @@ public interface ParsedPackage extends AndroidPackage {
|
||||
|
||||
ParsedPackage clearProtectedBroadcasts();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #setCodePath(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
ParsedPackage setApplicationInfoCodePath(String applicationInfoCodePath);
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Use non-AppInfo method
|
||||
* @deprecated use {@link #setCodePath(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
ParsedPackage setApplicationInfoResourcePath(String applicationInfoResourcePath);
|
||||
|
||||
ParsedPackage setBaseCodePath(String baseCodePath);
|
||||
|
||||
ParsedPackage setCodePath(String codePath);
|
||||
@@ -70,9 +57,7 @@ public interface ParsedPackage extends AndroidPackage {
|
||||
|
||||
ParsedPackage setPrimaryCpuAbi(String primaryCpuAbi);
|
||||
|
||||
ParsedPackage setProcessName(String processName);
|
||||
|
||||
ParsedPackage setRealPackage(String realPackage);
|
||||
ParsedPackage setRealPackage(@Nullable String realPackage);
|
||||
|
||||
ParsedPackage setSecondaryCpuAbi(String secondaryCpuAbi);
|
||||
|
||||
@@ -80,6 +65,7 @@ public interface ParsedPackage extends AndroidPackage {
|
||||
|
||||
ParsedPackage setSplitCodePaths(String[] splitCodePaths);
|
||||
|
||||
@Deprecated
|
||||
ParsedPackage initForUser(int userId);
|
||||
|
||||
ParsedPackage setNativeLibraryRootRequiresIsa(boolean nativeLibraryRootRequiresIsa);
|
||||
@@ -104,8 +90,6 @@ public interface ParsedPackage extends AndroidPackage {
|
||||
|
||||
ParsedPackage setSystemExt(boolean systemExt);
|
||||
|
||||
ParsedPackage setUpdatedSystemApp(boolean updatedSystemApp);
|
||||
|
||||
ParsedPackage setVendor(boolean vendor);
|
||||
|
||||
ParsedPackage removePermission(int index);
|
||||
@@ -114,19 +98,9 @@ public interface ParsedPackage extends AndroidPackage {
|
||||
|
||||
ParsedPackage removeUsesOptionalLibrary(String libraryName);
|
||||
|
||||
ParsedPackage setApplicationInfoBaseResourcePath(String applicationInfoBaseResourcePath);
|
||||
|
||||
ParsedPackage setApplicationInfoSplitResourcePaths(
|
||||
String[] applicationInfoSplitResourcePaths);
|
||||
|
||||
ParsedPackage setApplicationVolumeUuid(String applicationVolumeUuid);
|
||||
|
||||
ParsedPackage setCoreApp(boolean coreApp);
|
||||
|
||||
ParsedPackage setIsStub(boolean isStub);
|
||||
|
||||
// TODO(b/135203078): Remove entirely
|
||||
ParsedPackage setPackageSettingCallback(PackageSettingCallback packageSettingCallback);
|
||||
ParsedPackage setStub(boolean isStub);
|
||||
|
||||
ParsedPackage setRestrictUpdateHash(byte[] restrictUpdateHash);
|
||||
|
||||
@@ -149,7 +123,6 @@ public interface ParsedPackage extends AndroidPackage {
|
||||
|
||||
ParsedPackage setPersistent(boolean persistent);
|
||||
|
||||
interface PackageSettingCallback {
|
||||
default void setAndroidPackage(AndroidPackage pkg){}
|
||||
}
|
||||
@Deprecated
|
||||
ParsedPackage setUpdatedSystemApp(boolean updatedSystemApp);
|
||||
}
|
||||
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 com.android.server.pm.parsing.pkg;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
/**
|
||||
* Container for fields that are eventually exposed through {@link ApplicationInfo}.
|
||||
*
|
||||
* Done to separate the meaningless, re-directed JavaDoc for methods and to separate what's
|
||||
* exposed vs not exposed to core.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
interface PkgAppInfo {
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_CANT_SAVE_STATE */
|
||||
boolean isCantSaveState();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#appComponentFactory
|
||||
* @see R.styleable#AndroidManifestApplication_appComponentFactory
|
||||
*/
|
||||
@Nullable
|
||||
String getAppComponentFactory();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#backupAgentName
|
||||
* @see R.styleable#AndroidManifestApplication_backupAgent
|
||||
*/
|
||||
@Nullable
|
||||
String getBackupAgentName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#banner
|
||||
* @see R.styleable#AndroidManifestApplication_banner
|
||||
*/
|
||||
int getBanner();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#category
|
||||
* @see R.styleable#AndroidManifestApplication_appCategory
|
||||
*/
|
||||
int getCategory();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#classLoaderName
|
||||
* @see R.styleable#AndroidManifestApplication_classLoader
|
||||
*/
|
||||
@Nullable
|
||||
String getClassLoaderName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#className
|
||||
* @see R.styleable#AndroidManifestApplication_name
|
||||
*/
|
||||
@Nullable
|
||||
String getClassName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#compatibleWidthLimitDp
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
|
||||
*/
|
||||
int getCompatibleWidthLimitDp();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#compileSdkVersion
|
||||
* @see R.styleable#AndroidManifest_compileSdkVersion
|
||||
*/
|
||||
int getCompileSdkVersion();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#compileSdkVersionCodename
|
||||
* @see R.styleable#AndroidManifest_compileSdkVersionCodename
|
||||
*/
|
||||
@Nullable
|
||||
String getCompileSdkVersionCodeName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#descriptionRes
|
||||
* @see R.styleable#AndroidManifestApplication_description
|
||||
*/
|
||||
int getDescriptionRes();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#fullBackupContent
|
||||
* @see R.styleable#AndroidManifestApplication_fullBackupContent
|
||||
*/
|
||||
int getFullBackupContent();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#iconRes
|
||||
* @see R.styleable#AndroidManifestApplication_icon
|
||||
*/
|
||||
int getIconRes();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#labelRes
|
||||
* @see R.styleable#AndroidManifestApplication_label
|
||||
*/
|
||||
int getLabelRes();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#largestWidthLimitDp
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
|
||||
*/
|
||||
int getLargestWidthLimitDp();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#logo
|
||||
* @see R.styleable#AndroidManifestApplication_logo
|
||||
*/
|
||||
int getLogo();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#manageSpaceActivityName
|
||||
* @see R.styleable#AndroidManifestApplication_manageSpaceActivity
|
||||
*/
|
||||
@Nullable
|
||||
String getManageSpaceActivityName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#maxAspectRatio
|
||||
* @see R.styleable#AndroidManifestApplication_maxAspectRatio
|
||||
*/
|
||||
float getMaxAspectRatio();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#minAspectRatio
|
||||
* @see R.styleable#AndroidManifestApplication_minAspectRatio
|
||||
*/
|
||||
float getMinAspectRatio();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#minSdkVersion
|
||||
* @see R.styleable#AndroidManifestUsesSdk_minSdkVersion
|
||||
*/
|
||||
int getMinSdkVersion();
|
||||
|
||||
/** @see ApplicationInfo#nativeLibraryDir */
|
||||
@Nullable
|
||||
String getNativeLibraryDir();
|
||||
|
||||
/** @see ApplicationInfo#nativeLibraryRootDir */
|
||||
@Nullable
|
||||
String getNativeLibraryRootDir();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#networkSecurityConfigRes
|
||||
* @see R.styleable#AndroidManifestApplication_networkSecurityConfig
|
||||
*/
|
||||
int getNetworkSecurityConfigRes();
|
||||
|
||||
/**
|
||||
* If {@link R.styleable#AndroidManifestApplication_label} is a string literal, this is it.
|
||||
* Otherwise, it's stored as {@link #getLabelRes()}.
|
||||
* @see ApplicationInfo#nonLocalizedLabel
|
||||
* @see R.styleable#AndroidManifestApplication_label
|
||||
*/
|
||||
@Nullable
|
||||
CharSequence getNonLocalizedLabel();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#permission
|
||||
* @see R.styleable#AndroidManifestApplication_permission
|
||||
*/
|
||||
@Nullable
|
||||
String getPermission();
|
||||
|
||||
/**
|
||||
* TODO(b/135203078): Hide this in the utility, should never be accessed directly
|
||||
* @see ApplicationInfo#primaryCpuAbi
|
||||
*/
|
||||
@Nullable
|
||||
String getPrimaryCpuAbi();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#processName
|
||||
* @see R.styleable#AndroidManifestApplication_process
|
||||
*/
|
||||
@NonNull
|
||||
String getProcessName();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#requiresSmallestWidthDp
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
|
||||
*/
|
||||
int getRequiresSmallestWidthDp();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#roundIconRes
|
||||
* @see R.styleable#AndroidManifestApplication_roundIcon
|
||||
*/
|
||||
int getRoundIconRes();
|
||||
|
||||
/** @see ApplicationInfo#seInfo */
|
||||
@Nullable
|
||||
String getSeInfo();
|
||||
|
||||
/** @see ApplicationInfo#seInfoUser */
|
||||
@Nullable
|
||||
String getSeInfoUser();
|
||||
|
||||
/** @see ApplicationInfo#secondaryCpuAbi */
|
||||
@Nullable
|
||||
String getSecondaryCpuAbi();
|
||||
|
||||
/** @see ApplicationInfo#secondaryNativeLibraryDir */
|
||||
@Nullable
|
||||
String getSecondaryNativeLibraryDir();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#installLocation
|
||||
* @see R.styleable#AndroidManifest_installLocation
|
||||
*/
|
||||
int getInstallLocation();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#splitClassLoaderNames
|
||||
* @see R.styleable#AndroidManifestApplication_classLoader
|
||||
*/
|
||||
@Nullable
|
||||
String[] getSplitClassLoaderNames();
|
||||
|
||||
/** @see ApplicationInfo#splitSourceDirs */
|
||||
@Nullable
|
||||
String[] getSplitCodePaths();
|
||||
|
||||
/** @see ApplicationInfo#splitDependencies */
|
||||
@Nullable
|
||||
SparseArray<int[]> getSplitDependencies();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#targetSandboxVersion
|
||||
* @see R.styleable#AndroidManifest_targetSandboxVersion
|
||||
*/
|
||||
@Deprecated
|
||||
int getTargetSandboxVersion();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#targetSdkVersion
|
||||
* @see R.styleable#AndroidManifestUsesSdk_targetSdkVersion
|
||||
*/
|
||||
int getTargetSdkVersion();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#taskAffinity
|
||||
* @see R.styleable#AndroidManifestApplication_taskAffinity
|
||||
*/
|
||||
@Nullable
|
||||
String getTaskAffinity();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#theme
|
||||
* @see R.styleable#AndroidManifestApplication_theme
|
||||
*/
|
||||
int getTheme();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#uiOptions
|
||||
* @see R.styleable#AndroidManifestApplication_uiOptions
|
||||
*/
|
||||
int getUiOptions();
|
||||
|
||||
/** @see ApplicationInfo#uid */
|
||||
int getUid();
|
||||
|
||||
/** @see ApplicationInfo#longVersionCode */
|
||||
long getLongVersionCode();
|
||||
|
||||
/** @see ApplicationInfo#versionCode */
|
||||
@Deprecated
|
||||
int getVersionCode();
|
||||
|
||||
/** @see ApplicationInfo#volumeUuid */
|
||||
@Nullable
|
||||
String getVolumeUuid();
|
||||
|
||||
/** @see ApplicationInfo#zygotePreloadName */
|
||||
@Nullable
|
||||
String getZygotePreloadName();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_HAS_CODE */
|
||||
boolean isHasCode();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_ALLOW_TASK_REPARENTING */
|
||||
boolean isAllowTaskReparenting();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_MULTIARCH */
|
||||
boolean isMultiArch();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_EXTRACT_NATIVE_LIBS */
|
||||
boolean isExtractNativeLibs();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_DEBUGGABLE */
|
||||
boolean isDebuggable();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_VM_SAFE_MODE */
|
||||
boolean isVmSafeMode();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_PERSISTENT */
|
||||
boolean isPersistent();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_ALLOW_BACKUP */
|
||||
boolean isAllowBackup();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_TEST_ONLY */
|
||||
boolean isTestOnly();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION */
|
||||
boolean isResizeableActivityViaSdkVersion();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_HAS_DOMAIN_URLS */
|
||||
boolean isHasDomainUrls();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE */
|
||||
boolean isRequestLegacyExternalStorage();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_HARDWARE_ACCELERATED */
|
||||
boolean isBaseHardwareAccelerated();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE */
|
||||
boolean isDefaultToDeviceProtectedStorage();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_DIRECT_BOOT_AWARE */
|
||||
boolean isDirectBootAware();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE */
|
||||
boolean isPartiallyDirectBootAware();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_USE_EMBEDDED_DEX */
|
||||
boolean isUseEmbeddedDex();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_EXTERNAL_STORAGE */
|
||||
boolean isExternalStorage();
|
||||
|
||||
/** @see ApplicationInfo#nativeLibraryRootRequiresIsa */
|
||||
boolean isNativeLibraryRootRequiresIsa();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ODM */
|
||||
boolean isOdm();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_OEM */
|
||||
boolean isOem();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_PRIVILEGED */
|
||||
boolean isPrivileged();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_PRODUCT */
|
||||
boolean isProduct();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_PROFILEABLE_BY_SHELL */
|
||||
boolean isProfileableByShell();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_STATIC_SHARED_LIBRARY */
|
||||
boolean isStaticSharedLibrary();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_SYSTEM */
|
||||
boolean isSystem();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_SYSTEM_EXT */
|
||||
boolean isSystemExt();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_VENDOR */
|
||||
boolean isVendor();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ISOLATED_SPLIT_LOADING */
|
||||
boolean isIsolatedSplitLoading();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#enabled
|
||||
* @see R.styleable#AndroidManifestApplication_enabled
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#PRIVATE_FLAG_IS_RESOURCE_OVERLAY
|
||||
* @see ApplicationInfo#isResourceOverlay()
|
||||
*/
|
||||
boolean isOverlay();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_USES_NON_SDK_API */
|
||||
boolean isUsesNonSdkApi();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY */
|
||||
boolean isSignedWithPlatformKey();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_KILL_AFTER_RESTORE */
|
||||
boolean isKillAfterRestore();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_RESTORE_ANY_VERSION */
|
||||
boolean isRestoreAnyVersion();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_FULL_BACKUP_ONLY */
|
||||
boolean isFullBackupOnly();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_ALLOW_CLEAR_USER_DATA */
|
||||
boolean isAllowClearUserData();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_LARGE_HEAP */
|
||||
boolean isLargeHeap();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_USES_CLEARTEXT_TRAFFIC */
|
||||
boolean isUsesCleartextTraffic();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_SUPPORTS_RTL */
|
||||
boolean isSupportsRtl();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_IS_GAME */
|
||||
@Deprecated
|
||||
boolean isGame();
|
||||
|
||||
/** @see ApplicationInfo#FLAG_FACTORY_TEST */
|
||||
boolean isFactoryTest();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#DONUT}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_smallScreens
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_SMALL_SCREENS
|
||||
*/
|
||||
boolean isSupportsSmallScreens();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_normalScreens
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_NORMAL_SCREENS
|
||||
*/
|
||||
boolean isSupportsNormalScreens();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#DONUT}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_largeScreens
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_LARGE_SCREENS
|
||||
*/
|
||||
boolean isSupportsLargeScreens();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#GINGERBREAD}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_xlargeScreens
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_XLARGE_SCREENS
|
||||
*/
|
||||
boolean isSupportsExtraLargeScreens();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#DONUT}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_resizeable
|
||||
* @see ApplicationInfo#FLAG_RESIZEABLE_FOR_SCREENS
|
||||
*/
|
||||
boolean isResizeable();
|
||||
|
||||
/**
|
||||
* If omitted from manifest, returns true if {@link #getTargetSdkVersion()} >=
|
||||
* {@link android.os.Build.VERSION_CODES#DONUT}.
|
||||
* @see R.styleable#AndroidManifestSupportsScreens_anyDensity
|
||||
* @see ApplicationInfo#FLAG_SUPPORTS_SCREEN_DENSITIES
|
||||
*/
|
||||
boolean isAnyDensity();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_BACKUP_IN_FOREGROUND */
|
||||
boolean isBackupInForeground();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE */
|
||||
boolean isAllowClearUserDataOnFailedRestore();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE */
|
||||
boolean isAllowAudioPlaybackCapture();
|
||||
|
||||
/** @see ApplicationInfo#PRIVATE_FLAG_HAS_FRAGILE_USER_DATA */
|
||||
boolean isHasFragileUserData();
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 com.android.server.pm.parsing.pkg;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ConfigurationInfo;
|
||||
import android.content.pm.FeatureGroupInfo;
|
||||
import android.content.pm.FeatureInfo;
|
||||
import android.content.pm.InstrumentationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PermissionInfo;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedActivity;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedInstrumentation;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedPermission;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedProvider;
|
||||
import android.content.pm.parsing.ComponentParseUtils.ParsedService;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Container for fields that are eventually exposed through {@link PackageInfo}.
|
||||
*
|
||||
* Done to separate the meaningless, re-directed JavaDoc for methods and to separate what's
|
||||
* exposed vs not exposed to core.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
interface PkgPackageInfo {
|
||||
|
||||
/**
|
||||
* @see PackageInfo#overlayCategory
|
||||
* @see R.styleable#AndroidManifestResourceOverlay_category
|
||||
*/
|
||||
@Nullable
|
||||
String getOverlayCategory();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#overlayPriority
|
||||
* @see R.styleable#AndroidManifestResourceOverlay_priority
|
||||
*/
|
||||
int getOverlayPriority();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#overlayTarget
|
||||
* @see R.styleable#AndroidManifestResourceOverlay_targetPackage
|
||||
*/
|
||||
@Nullable
|
||||
String getOverlayTarget();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#targetOverlayableName
|
||||
* @see R.styleable#AndroidManifestResourceOverlay_targetName
|
||||
*/
|
||||
@Nullable
|
||||
String getOverlayTargetName();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#sharedUserId
|
||||
* @see R.styleable#AndroidManifest_sharedUserId
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String getSharedUserId();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#sharedUserLabel
|
||||
* @see R.styleable#AndroidManifest_sharedUserLabel
|
||||
*/
|
||||
@Deprecated
|
||||
int getSharedUserLabel();
|
||||
|
||||
/**
|
||||
* The required account type without which this application will not function.
|
||||
*
|
||||
* @see PackageInfo#requiredAccountType
|
||||
* @see R.styleable#AndroidManifestApplication_requiredAccountType
|
||||
*/
|
||||
@Nullable
|
||||
String getRequiredAccountType();
|
||||
|
||||
/**
|
||||
* The restricted account authenticator type that is used by this application
|
||||
*
|
||||
* @see PackageInfo#restrictedAccountType
|
||||
* @see R.styleable#AndroidManifestApplication_restrictedAccountType
|
||||
*/
|
||||
@Nullable
|
||||
String getRestrictedAccountType();
|
||||
|
||||
/** @see PackageInfo#splitRevisionCodes */
|
||||
int[] getSplitRevisionCodes();
|
||||
|
||||
/** @see PackageInfo#getLongVersionCode() */
|
||||
long getLongVersionCode();
|
||||
|
||||
/** @see PackageInfo#versionCode */
|
||||
@Deprecated
|
||||
int getVersionCode();
|
||||
|
||||
/** @see PackageInfo#versionCodeMajor */
|
||||
int getVersionCodeMajor();
|
||||
|
||||
/** @see PackageInfo#versionName */
|
||||
@Nullable
|
||||
String getVersionName();
|
||||
|
||||
/** @see PackageInfo#mOverlayIsStatic */
|
||||
boolean isOverlayIsStatic();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#requiredForAllUsers
|
||||
* @see R.styleable#AndroidManifestApplication_requiredForAllUsers
|
||||
*/
|
||||
boolean isRequiredForAllUsers();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#reqFeatures
|
||||
* @see R.styleable#AndroidManifestUsesFeature
|
||||
*/
|
||||
@NonNull
|
||||
List<FeatureInfo> getReqFeatures();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#configPreferences
|
||||
* @see R.styleable#AndroidManifestUsesConfiguration
|
||||
*/
|
||||
@NonNull
|
||||
List<ConfigurationInfo> getConfigPreferences();
|
||||
|
||||
/**
|
||||
* @see PackageInfo#featureGroups
|
||||
* @see R.styleable#AndroidManifestUsesFeature
|
||||
*/
|
||||
@NonNull
|
||||
List<FeatureGroupInfo> getFeatureGroups();
|
||||
|
||||
/**
|
||||
* Whether or not the package is a stub and must be replaced by the full version.
|
||||
*
|
||||
* @see PackageInfo#isStub
|
||||
*/
|
||||
boolean isStub();
|
||||
|
||||
/**
|
||||
* For marking packages required for a minimal boot state, through the "coreApp" manifest
|
||||
* attribute.
|
||||
* @see PackageInfo#coreApp
|
||||
*/
|
||||
boolean isCoreApp();
|
||||
|
||||
/**
|
||||
* All the permissions declared. This is an effective set, and may include permissions
|
||||
* transformed from split/migrated permissions from previous versions, so may not be exactly
|
||||
* what the package declares in its manifest.
|
||||
* @see PackageInfo#requestedPermissions
|
||||
* @see R.styleable#AndroidManifestUsesPermission
|
||||
*/
|
||||
@NonNull
|
||||
List<String> getRequestedPermissions();
|
||||
|
||||
/**
|
||||
* @see ActivityInfo
|
||||
* @see PackageInfo#activities
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedActivity> getActivities();
|
||||
|
||||
/**
|
||||
* @see InstrumentationInfo
|
||||
* @see PackageInfo#instrumentation
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedInstrumentation> getInstrumentations();
|
||||
|
||||
/**
|
||||
* @see PermissionInfo
|
||||
* @see PackageInfo#permissions
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedPermission> getPermissions();
|
||||
|
||||
/**
|
||||
* @see ProviderInfo
|
||||
* @see PackageInfo#providers
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedProvider> getProviders();
|
||||
|
||||
/**
|
||||
* Since they share several attributes, receivers are parsed as {@link ParsedActivity}, even
|
||||
* though they represent different functionality.
|
||||
* TODO(b/135203078): Reconsider this and maybe make ParsedReceiver so it's not so confusing
|
||||
* @see ActivityInfo
|
||||
* @see PackageInfo#receivers
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedActivity> getReceivers();
|
||||
|
||||
/**
|
||||
* @see ServiceInfo
|
||||
* @see PackageInfo#services
|
||||
*/
|
||||
@NonNull
|
||||
List<ParsedService> getServices();
|
||||
}
|
||||
Reference in New Issue
Block a user