Don't provide read logs for shell-initiated installations.
Only if the application is profileable. Bug: 158238023 Fixes: 158238023 Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest PackageParserTest Change-Id: I8575830ec3f29850297fdbfbaa157072d6350a28 Merged-In: I8575830ec3f29850297fdbfbaa157072d6350a28
This commit is contained in:
@@ -205,6 +205,7 @@ public class PackageParser {
|
||||
public static final String TAG_USES_PERMISSION_SDK_M = "uses-permission-sdk-m";
|
||||
public static final String TAG_USES_SDK = "uses-sdk";
|
||||
public static final String TAG_USES_SPLIT = "uses-split";
|
||||
public static final String TAG_PROFILEABLE = "profileable";
|
||||
|
||||
public static final String METADATA_MAX_ASPECT_RATIO = "android.max_aspect";
|
||||
public static final String METADATA_SUPPORTS_SIZE_CHANGES = "android.supports_size_changes";
|
||||
@@ -459,6 +460,9 @@ public class PackageParser {
|
||||
public final SigningDetails signingDetails;
|
||||
public final boolean coreApp;
|
||||
public final boolean debuggable;
|
||||
// This does not represent the actual manifest structure since the 'profilable' tag
|
||||
// could be used with attributes other than 'shell'. Extend if necessary.
|
||||
public final boolean profilableByShell;
|
||||
public final boolean multiArch;
|
||||
public final boolean use32bitAbi;
|
||||
public final boolean extractNativeLibs;
|
||||
@@ -470,15 +474,13 @@ public class PackageParser {
|
||||
public final int overlayPriority;
|
||||
|
||||
public ApkLite(String codePath, String packageName, String splitName,
|
||||
boolean isFeatureSplit,
|
||||
String configForSplit, String usesSplitName, boolean isSplitRequired,
|
||||
int versionCode, int versionCodeMajor,
|
||||
int revisionCode, int installLocation, List<VerifierInfo> verifiers,
|
||||
SigningDetails signingDetails, boolean coreApp,
|
||||
boolean debuggable, boolean multiArch, boolean use32bitAbi,
|
||||
boolean useEmbeddedDex, boolean extractNativeLibs, boolean isolatedSplits,
|
||||
String targetPackageName, boolean overlayIsStatic, int overlayPriority,
|
||||
int minSdkVersion, int targetSdkVersion) {
|
||||
boolean isFeatureSplit, String configForSplit, String usesSplitName,
|
||||
boolean isSplitRequired, int versionCode, int versionCodeMajor, int revisionCode,
|
||||
int installLocation, List<VerifierInfo> verifiers, SigningDetails signingDetails,
|
||||
boolean coreApp, boolean debuggable, boolean profilableByShell, boolean multiArch,
|
||||
boolean use32bitAbi, boolean useEmbeddedDex, boolean extractNativeLibs,
|
||||
boolean isolatedSplits, String targetPackageName, boolean overlayIsStatic,
|
||||
int overlayPriority, int minSdkVersion, int targetSdkVersion) {
|
||||
this.codePath = codePath;
|
||||
this.packageName = packageName;
|
||||
this.splitName = splitName;
|
||||
@@ -493,6 +495,7 @@ public class PackageParser {
|
||||
this.verifiers = verifiers.toArray(new VerifierInfo[verifiers.size()]);
|
||||
this.coreApp = coreApp;
|
||||
this.debuggable = debuggable;
|
||||
this.profilableByShell = profilableByShell;
|
||||
this.multiArch = multiArch;
|
||||
this.use32bitAbi = use32bitAbi;
|
||||
this.useEmbeddedDex = useEmbeddedDex;
|
||||
@@ -1573,6 +1576,7 @@ public class PackageParser {
|
||||
int revisionCode = 0;
|
||||
boolean coreApp = false;
|
||||
boolean debuggable = false;
|
||||
boolean profilableByShell = false;
|
||||
boolean multiArch = false;
|
||||
boolean use32bitAbi = false;
|
||||
boolean extractNativeLibs = true;
|
||||
@@ -1638,6 +1642,10 @@ public class PackageParser {
|
||||
final String attr = attrs.getAttributeName(i);
|
||||
if ("debuggable".equals(attr)) {
|
||||
debuggable = attrs.getAttributeBooleanValue(i, false);
|
||||
if (debuggable) {
|
||||
// Debuggable implies profileable
|
||||
profilableByShell = true;
|
||||
}
|
||||
}
|
||||
if ("multiArch".equals(attr)) {
|
||||
multiArch = attrs.getAttributeBooleanValue(i, false);
|
||||
@@ -1690,6 +1698,13 @@ public class PackageParser {
|
||||
minSdkVersion = attrs.getAttributeIntValue(i, DEFAULT_MIN_SDK_VERSION);
|
||||
}
|
||||
}
|
||||
} else if (TAG_PROFILEABLE.equals(parser.getName())) {
|
||||
for (int i = 0; i < attrs.getAttributeCount(); ++i) {
|
||||
final String attr = attrs.getAttributeName(i);
|
||||
if ("shell".equals(attr)) {
|
||||
profilableByShell = attrs.getAttributeBooleanValue(i, profilableByShell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1707,8 +1722,9 @@ public class PackageParser {
|
||||
return new ApkLite(codePath, packageSplit.first, packageSplit.second, isFeatureSplit,
|
||||
configForSplit, usesSplitName, isSplitRequired, versionCode, versionCodeMajor,
|
||||
revisionCode, installLocation, verifiers, signingDetails, coreApp, debuggable,
|
||||
multiArch, use32bitAbi, useEmbeddedDex, extractNativeLibs, isolatedSplits,
|
||||
targetPackage, overlayIsStatic, overlayPriority, minSdkVersion, targetSdkVersion);
|
||||
profilableByShell, multiArch, use32bitAbi, useEmbeddedDex, extractNativeLibs,
|
||||
isolatedSplits, targetPackage, overlayIsStatic, overlayPriority, minSdkVersion,
|
||||
targetSdkVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,6 @@ import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_BAD_PACKAGE
|
||||
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
|
||||
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
|
||||
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageParser;
|
||||
@@ -303,6 +302,7 @@ public class ApkLiteParseUtils {
|
||||
int revisionCode = 0;
|
||||
boolean coreApp = false;
|
||||
boolean debuggable = false;
|
||||
boolean profilableByShell = false;
|
||||
boolean multiArch = false;
|
||||
boolean use32bitAbi = false;
|
||||
boolean extractNativeLibs = true;
|
||||
@@ -379,6 +379,10 @@ public class ApkLiteParseUtils {
|
||||
switch (attr) {
|
||||
case "debuggable":
|
||||
debuggable = attrs.getAttributeBooleanValue(i, false);
|
||||
if (debuggable) {
|
||||
// Debuggable implies profileable
|
||||
profilableByShell = true;
|
||||
}
|
||||
break;
|
||||
case "multiArch":
|
||||
multiArch = attrs.getAttributeBooleanValue(i, false);
|
||||
@@ -431,6 +435,13 @@ public class ApkLiteParseUtils {
|
||||
minSdkVersion = attrs.getAttributeIntValue(i, DEFAULT_MIN_SDK_VERSION);
|
||||
}
|
||||
}
|
||||
} else if (PackageParser.TAG_PROFILEABLE.equals(parser.getName())) {
|
||||
for (int i = 0; i < attrs.getAttributeCount(); ++i) {
|
||||
final String attr = attrs.getAttributeName(i);
|
||||
if ("shell".equals(attr)) {
|
||||
profilableByShell = attrs.getAttributeBooleanValue(i, profilableByShell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,12 +456,13 @@ public class ApkLiteParseUtils {
|
||||
overlayPriority = 0;
|
||||
}
|
||||
|
||||
return input.success(new PackageParser.ApkLite(codePath, packageSplit.first,
|
||||
packageSplit.second, isFeatureSplit, configForSplit, usesSplitName, isSplitRequired,
|
||||
versionCode, versionCodeMajor, revisionCode, installLocation, verifiers,
|
||||
signingDetails, coreApp, debuggable, multiArch, use32bitAbi, useEmbeddedDex,
|
||||
extractNativeLibs, isolatedSplits, targetPackage, overlayIsStatic, overlayPriority,
|
||||
minSdkVersion, targetSdkVersion));
|
||||
return input.success(
|
||||
new PackageParser.ApkLite(codePath, packageSplit.first, packageSplit.second,
|
||||
isFeatureSplit, configForSplit, usesSplitName, isSplitRequired, versionCode,
|
||||
versionCodeMajor, revisionCode, installLocation, verifiers, signingDetails,
|
||||
coreApp, debuggable, profilableByShell, multiArch, use32bitAbi,
|
||||
useEmbeddedDex, extractNativeLibs, isolatedSplits, targetPackage,
|
||||
overlayIsStatic, overlayPriority, minSdkVersion, targetSdkVersion));
|
||||
}
|
||||
|
||||
public static ParseResult<Pair<String, String>> parsePackageSplitNames(ParseInput input,
|
||||
|
||||
@@ -110,6 +110,11 @@ interface IIncrementalService {
|
||||
*/
|
||||
void deleteStorage(int storageId);
|
||||
|
||||
/**
|
||||
* Permanently disable readlogs reporting for a storage given its ID.
|
||||
*/
|
||||
void disableReadLogs(int storageId);
|
||||
|
||||
/**
|
||||
* Setting up native library directories and extract native libs onto a storage if needed.
|
||||
*/
|
||||
|
||||
@@ -152,6 +152,13 @@ public final class IncrementalFileStorages {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently disables readlogs.
|
||||
*/
|
||||
public void disableReadLogs() {
|
||||
mDefaultStorage.disableReadLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the states and unbinds storage instances for an installation session.
|
||||
* TODO(b/136132412): make sure unnecessary binds are removed but useful storages are kept
|
||||
|
||||
@@ -417,6 +417,17 @@ public final class IncrementalStorage {
|
||||
private static final int INCFS_MAX_HASH_SIZE = 32; // SHA256
|
||||
private static final int INCFS_MAX_ADD_DATA_SIZE = 128;
|
||||
|
||||
/**
|
||||
* Permanently disable readlogs collection.
|
||||
*/
|
||||
public void disableReadLogs() {
|
||||
try {
|
||||
mService.disableReadLogs(mId);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize and validate v4 signature bytes.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user