Merge "Add an --abi argument to "pm install""
This commit is contained in:
@@ -38,6 +38,7 @@ import android.content.pm.VerificationParams;
|
|||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.IUserManager;
|
import android.os.IUserManager;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
@@ -54,7 +55,6 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
@@ -801,6 +801,7 @@ public final class Pm {
|
|||||||
byte[] tag = null;
|
byte[] tag = null;
|
||||||
String originatingUriString = null;
|
String originatingUriString = null;
|
||||||
String referrer = null;
|
String referrer = null;
|
||||||
|
String abi = null;
|
||||||
|
|
||||||
while ((opt=nextOption()) != null) {
|
while ((opt=nextOption()) != null) {
|
||||||
if (opt.equals("-l")) {
|
if (opt.equals("-l")) {
|
||||||
@@ -871,12 +872,34 @@ public final class Pm {
|
|||||||
System.err.println("Error: must supply argument for --referrer");
|
System.err.println("Error: must supply argument for --referrer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (opt.equals("--abi")) {
|
||||||
|
abi = nextOptionData();
|
||||||
|
if (abi == null) {
|
||||||
|
System.err.println("Error: must supply argument for --abi");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Error: Unknown option: " + opt);
|
System.err.println("Error: Unknown option: " + opt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (abi != null) {
|
||||||
|
final String[] supportedAbis = Build.SUPPORTED_ABIS;
|
||||||
|
boolean matched = false;
|
||||||
|
for (String supportedAbi : supportedAbis) {
|
||||||
|
if (supportedAbi.equals(abi)) {
|
||||||
|
matched = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!matched) {
|
||||||
|
System.err.println("Error: abi " + abi + " not supported on this device.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final ContainerEncryptionParams encryptionParams;
|
final ContainerEncryptionParams encryptionParams;
|
||||||
if (algo != null || iv != null || key != null || macAlgo != null || macKey != null
|
if (algo != null || iv != null || key != null || macAlgo != null || macKey != null
|
||||||
|| tag != null) {
|
|| tag != null) {
|
||||||
@@ -954,8 +977,9 @@ public final class Pm {
|
|||||||
VerificationParams verificationParams = new VerificationParams(verificationURI,
|
VerificationParams verificationParams = new VerificationParams(verificationURI,
|
||||||
originatingURI, referrerURI, VerificationParams.NO_UID, null);
|
originatingURI, referrerURI, VerificationParams.NO_UID, null);
|
||||||
|
|
||||||
mPm.installPackageWithVerificationAndEncryption(apkURI, obs, installFlags,
|
mPm.installPackageWithVerificationEncryptionAndAbiOverride(apkURI, obs,
|
||||||
installerPackageName, verificationParams, encryptionParams);
|
installFlags, installerPackageName, verificationParams,
|
||||||
|
encryptionParams, abi);
|
||||||
|
|
||||||
synchronized (obs) {
|
synchronized (obs) {
|
||||||
while (!obs.finished) {
|
while (!obs.finished) {
|
||||||
|
|||||||
@@ -402,6 +402,12 @@ interface IPackageManager {
|
|||||||
in VerificationParams verificationParams,
|
in VerificationParams verificationParams,
|
||||||
in ContainerEncryptionParams encryptionParams);
|
in ContainerEncryptionParams encryptionParams);
|
||||||
|
|
||||||
|
void installPackageWithVerificationEncryptionAndAbiOverride(in Uri packageURI,
|
||||||
|
in IPackageInstallObserver observer, int flags, in String installerPackageName,
|
||||||
|
in VerificationParams verificationParams,
|
||||||
|
in ContainerEncryptionParams encryptionParams,
|
||||||
|
in String packageAbiOverride);
|
||||||
|
|
||||||
int installExistingPackageAsUser(String packageName, int userId);
|
int installExistingPackageAsUser(String packageName, int userId);
|
||||||
|
|
||||||
void verifyPendingInstall(int id, int verificationCode);
|
void verifyPendingInstall(int id, int verificationCode);
|
||||||
|
|||||||
@@ -25,16 +25,18 @@ import android.content.res.ObbInfo;
|
|||||||
interface IMediaContainerService {
|
interface IMediaContainerService {
|
||||||
String copyResourceToContainer(in Uri packageURI, String containerId, String key,
|
String copyResourceToContainer(in Uri packageURI, String containerId, String key,
|
||||||
String resFileName, String publicResFileName, boolean isExternal,
|
String resFileName, String publicResFileName, boolean isExternal,
|
||||||
boolean isForwardLocked);
|
boolean isForwardLocked, in String abiOverride);
|
||||||
int copyResource(in Uri packageURI, in ContainerEncryptionParams encryptionParams,
|
int copyResource(in Uri packageURI, in ContainerEncryptionParams encryptionParams,
|
||||||
in ParcelFileDescriptor outStream);
|
in ParcelFileDescriptor outStream);
|
||||||
PackageInfoLite getMinimalPackageInfo(in String packagePath, in int flags, in long threshold);
|
PackageInfoLite getMinimalPackageInfo(in String packagePath, in int flags, in long threshold,
|
||||||
|
in String abiOverride);
|
||||||
boolean checkInternalFreeStorage(in Uri fileUri, boolean isForwardLocked, in long threshold);
|
boolean checkInternalFreeStorage(in Uri fileUri, boolean isForwardLocked, in long threshold);
|
||||||
boolean checkExternalFreeStorage(in Uri fileUri, boolean isForwardLocked);
|
boolean checkExternalFreeStorage(in Uri fileUri, boolean isForwardLocked, in String abiOverride);
|
||||||
ObbInfo getObbInfo(in String filename);
|
ObbInfo getObbInfo(in String filename);
|
||||||
long calculateDirectorySize(in String directory);
|
long calculateDirectorySize(in String directory);
|
||||||
/** Return file system stats: [0] is total bytes, [1] is available bytes */
|
/** Return file system stats: [0] is total bytes, [1] is available bytes */
|
||||||
long[] getFileSystemStats(in String path);
|
long[] getFileSystemStats(in String path);
|
||||||
void clearDirectory(in String directory);
|
void clearDirectory(in String directory);
|
||||||
long calculateInstalledSize(in String packagePath, boolean isForwardLocked);
|
long calculateInstalledSize(in String packagePath, boolean isForwardLocked,
|
||||||
|
in String abiOverride);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,13 +101,13 @@ public class DefaultContainerService extends IntentService {
|
|||||||
*/
|
*/
|
||||||
public String copyResourceToContainer(final Uri packageURI, final String cid,
|
public String copyResourceToContainer(final Uri packageURI, final String cid,
|
||||||
final String key, final String resFileName, final String publicResFileName,
|
final String key, final String resFileName, final String publicResFileName,
|
||||||
boolean isExternal, boolean isForwardLocked) {
|
boolean isExternal, boolean isForwardLocked, String abiOverride) {
|
||||||
if (packageURI == null || cid == null) {
|
if (packageURI == null || cid == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return copyResourceInner(packageURI, cid, key, resFileName, publicResFileName,
|
return copyResourceInner(packageURI, cid, key, resFileName, publicResFileName,
|
||||||
isExternal, isForwardLocked);
|
isExternal, isForwardLocked, abiOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,13 +153,12 @@ public class DefaultContainerService extends IntentService {
|
|||||||
/**
|
/**
|
||||||
* Determine the recommended install location for package
|
* Determine the recommended install location for package
|
||||||
* specified by file uri location.
|
* specified by file uri location.
|
||||||
* @param fileUri the uri of resource to be copied. Should be a
|
*
|
||||||
* file uri
|
|
||||||
* @return Returns PackageInfoLite object containing
|
* @return Returns PackageInfoLite object containing
|
||||||
* the package info and recommended app location.
|
* the package info and recommended app location.
|
||||||
*/
|
*/
|
||||||
public PackageInfoLite getMinimalPackageInfo(final String packagePath, int flags,
|
public PackageInfoLite getMinimalPackageInfo(final String packagePath, int flags,
|
||||||
long threshold) {
|
long threshold, String abiOverride) {
|
||||||
PackageInfoLite ret = new PackageInfoLite();
|
PackageInfoLite ret = new PackageInfoLite();
|
||||||
|
|
||||||
if (packagePath == null) {
|
if (packagePath == null) {
|
||||||
@@ -191,7 +190,7 @@ public class DefaultContainerService extends IntentService {
|
|||||||
ret.verifiers = pkg.verifiers;
|
ret.verifiers = pkg.verifiers;
|
||||||
|
|
||||||
ret.recommendedInstallLocation = recommendAppInstallLocation(pkg.installLocation,
|
ret.recommendedInstallLocation = recommendAppInstallLocation(pkg.installLocation,
|
||||||
packagePath, flags, threshold);
|
packagePath, flags, threshold, abiOverride);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -208,11 +207,11 @@ public class DefaultContainerService extends IntentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkExternalFreeStorage(Uri packageUri, boolean isForwardLocked)
|
public boolean checkExternalFreeStorage(Uri packageUri, boolean isForwardLocked,
|
||||||
throws RemoteException {
|
String abiOverride) throws RemoteException {
|
||||||
final File apkFile = new File(packageUri.getPath());
|
final File apkFile = new File(packageUri.getPath());
|
||||||
try {
|
try {
|
||||||
return isUnderExternalThreshold(apkFile, isForwardLocked);
|
return isUnderExternalThreshold(apkFile, isForwardLocked, abiOverride);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -265,11 +264,11 @@ public class DefaultContainerService extends IntentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long calculateInstalledSize(String packagePath, boolean isForwardLocked)
|
public long calculateInstalledSize(String packagePath, boolean isForwardLocked,
|
||||||
throws RemoteException {
|
String abiOverride) throws RemoteException {
|
||||||
final File packageFile = new File(packagePath);
|
final File packageFile = new File(packagePath);
|
||||||
try {
|
try {
|
||||||
return calculateContainerSize(packageFile, isForwardLocked) * 1024 * 1024;
|
return calculateContainerSize(packageFile, isForwardLocked, abiOverride) * 1024 * 1024;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
/*
|
/*
|
||||||
* Okay, something failed, so let's just estimate it to be 2x
|
* Okay, something failed, so let's just estimate it to be 2x
|
||||||
@@ -328,7 +327,8 @@ public class DefaultContainerService extends IntentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String copyResourceInner(Uri packageURI, String newCid, String key, String resFileName,
|
private String copyResourceInner(Uri packageURI, String newCid, String key, String resFileName,
|
||||||
String publicResFileName, boolean isExternal, boolean isForwardLocked) {
|
String publicResFileName, boolean isExternal, boolean isForwardLocked,
|
||||||
|
String abiOverride) {
|
||||||
|
|
||||||
if (isExternal) {
|
if (isExternal) {
|
||||||
// Make sure the sdcard is mounted.
|
// Make sure the sdcard is mounted.
|
||||||
@@ -342,8 +342,10 @@ public class DefaultContainerService extends IntentService {
|
|||||||
// The .apk file
|
// The .apk file
|
||||||
String codePath = packageURI.getPath();
|
String codePath = packageURI.getPath();
|
||||||
File codeFile = new File(codePath);
|
File codeFile = new File(codePath);
|
||||||
|
String[] abiList = (abiOverride != null) ? new String[] { abiOverride }
|
||||||
|
: Build.SUPPORTED_ABIS;
|
||||||
NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(codePath);
|
NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(codePath);
|
||||||
final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
|
final int abi = NativeLibraryHelper.findSupportedAbi(handle, abiList);
|
||||||
|
|
||||||
// Calculate size of container needed to hold base APK.
|
// Calculate size of container needed to hold base APK.
|
||||||
final int sizeMb;
|
final int sizeMb;
|
||||||
@@ -414,7 +416,7 @@ public class DefaultContainerService extends IntentService {
|
|||||||
int ret = PackageManager.INSTALL_SUCCEEDED;
|
int ret = PackageManager.INSTALL_SUCCEEDED;
|
||||||
if (abi >= 0) {
|
if (abi >= 0) {
|
||||||
ret = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle,
|
ret = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle,
|
||||||
sharedLibraryDir, Build.SUPPORTED_ABIS[abi]);
|
sharedLibraryDir, abiList[abi]);
|
||||||
} else if (abi != PackageManager.NO_NATIVE_LIBRARIES) {
|
} else if (abi != PackageManager.NO_NATIVE_LIBRARIES) {
|
||||||
ret = abi;
|
ret = abi;
|
||||||
}
|
}
|
||||||
@@ -672,7 +674,7 @@ public class DefaultContainerService extends IntentService {
|
|||||||
private static final int PREFER_EXTERNAL = 2;
|
private static final int PREFER_EXTERNAL = 2;
|
||||||
|
|
||||||
private int recommendAppInstallLocation(int installLocation, String archiveFilePath, int flags,
|
private int recommendAppInstallLocation(int installLocation, String archiveFilePath, int flags,
|
||||||
long threshold) {
|
long threshold, String abiOverride) {
|
||||||
int prefer;
|
int prefer;
|
||||||
boolean checkBoth = false;
|
boolean checkBoth = false;
|
||||||
|
|
||||||
@@ -741,7 +743,7 @@ public class DefaultContainerService extends IntentService {
|
|||||||
boolean fitsOnSd = false;
|
boolean fitsOnSd = false;
|
||||||
if (!emulated && (checkBoth || prefer == PREFER_EXTERNAL)) {
|
if (!emulated && (checkBoth || prefer == PREFER_EXTERNAL)) {
|
||||||
try {
|
try {
|
||||||
fitsOnSd = isUnderExternalThreshold(apkFile, isForwardLocked);
|
fitsOnSd = isUnderExternalThreshold(apkFile, isForwardLocked, abiOverride);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return PackageHelper.RECOMMEND_FAILED_INVALID_URI;
|
return PackageHelper.RECOMMEND_FAILED_INVALID_URI;
|
||||||
}
|
}
|
||||||
@@ -812,13 +814,13 @@ public class DefaultContainerService extends IntentService {
|
|||||||
* @return true if file fits
|
* @return true if file fits
|
||||||
* @throws IOException when file does not exist
|
* @throws IOException when file does not exist
|
||||||
*/
|
*/
|
||||||
private boolean isUnderExternalThreshold(File apkFile, boolean isForwardLocked)
|
private boolean isUnderExternalThreshold(File apkFile, boolean isForwardLocked, String abiOverride)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (Environment.isExternalStorageEmulated()) {
|
if (Environment.isExternalStorageEmulated()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int sizeMb = calculateContainerSize(apkFile, isForwardLocked);
|
final int sizeMb = calculateContainerSize(apkFile, isForwardLocked, abiOverride);
|
||||||
|
|
||||||
final int availSdMb;
|
final int availSdMb;
|
||||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||||
@@ -832,9 +834,11 @@ public class DefaultContainerService extends IntentService {
|
|||||||
return availSdMb > sizeMb;
|
return availSdMb > sizeMb;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateContainerSize(File apkFile, boolean forwardLocked) throws IOException {
|
private int calculateContainerSize(File apkFile, boolean forwardLocked,
|
||||||
|
String abiOverride) throws IOException {
|
||||||
NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(apkFile);
|
NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(apkFile);
|
||||||
final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
|
final int abi = NativeLibraryHelper.findSupportedAbi(handle,
|
||||||
|
(abiOverride != null) ? new String[] { abiOverride } : Build.SUPPORTED_ABIS);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return calculateContainerSize(handle, apkFile, abi, forwardLocked);
|
return calculateContainerSize(handle, apkFile, abi, forwardLocked);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.android.internal.R;
|
|||||||
import com.android.internal.app.IMediaContainerService;
|
import com.android.internal.app.IMediaContainerService;
|
||||||
import com.android.internal.app.ResolverActivity;
|
import com.android.internal.app.ResolverActivity;
|
||||||
import com.android.internal.content.NativeLibraryHelper;
|
import com.android.internal.content.NativeLibraryHelper;
|
||||||
|
import com.android.internal.content.NativeLibraryHelper.ApkHandle;
|
||||||
import com.android.internal.content.PackageHelper;
|
import com.android.internal.content.PackageHelper;
|
||||||
import com.android.internal.util.FastPrintWriter;
|
import com.android.internal.util.FastPrintWriter;
|
||||||
import com.android.internal.util.FastXmlSerializer;
|
import com.android.internal.util.FastXmlSerializer;
|
||||||
@@ -3800,7 +3801,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PackageParser.Package pkg = scanPackageLI(file,
|
PackageParser.Package pkg = scanPackageLI(file,
|
||||||
flags|PackageParser.PARSE_MUST_BE_APK, scanMode, currentTime, null);
|
flags|PackageParser.PARSE_MUST_BE_APK, scanMode, currentTime, null, null);
|
||||||
// Don't mess around with apps in system partition.
|
// Don't mess around with apps in system partition.
|
||||||
if (pkg == null && (flags & PackageParser.PARSE_IS_SYSTEM) == 0 &&
|
if (pkg == null && (flags & PackageParser.PARSE_IS_SYSTEM) == 0 &&
|
||||||
mLastScanError == PackageManager.INSTALL_FAILED_INVALID_APK) {
|
mLastScanError == PackageManager.INSTALL_FAILED_INVALID_APK) {
|
||||||
@@ -3868,7 +3869,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
* Returns null in case of errors and the error code is stored in mLastScanError
|
* Returns null in case of errors and the error code is stored in mLastScanError
|
||||||
*/
|
*/
|
||||||
private PackageParser.Package scanPackageLI(File scanFile,
|
private PackageParser.Package scanPackageLI(File scanFile,
|
||||||
int parseFlags, int scanMode, long currentTime, UserHandle user) {
|
int parseFlags, int scanMode, long currentTime, UserHandle user, String abiOverride) {
|
||||||
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
||||||
String scanPath = scanFile.getPath();
|
String scanPath = scanFile.getPath();
|
||||||
if (DEBUG_INSTALL) Slog.d(TAG, "Parsing: " + scanPath);
|
if (DEBUG_INSTALL) Slog.d(TAG, "Parsing: " + scanPath);
|
||||||
@@ -3936,7 +3937,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
mLastScanError = PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE;
|
mLastScanError = PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE;
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
// The current app on the system partion is better than
|
// The current app on the system partition is better than
|
||||||
// what we have updated to on the data partition; switch
|
// what we have updated to on the data partition; switch
|
||||||
// back to the system partition version.
|
// back to the system partition version.
|
||||||
// At this point, its safely assumed that package installation for
|
// At this point, its safely assumed that package installation for
|
||||||
@@ -4055,7 +4056,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
setApplicationInfoPaths(pkg, codePath, resPath);
|
setApplicationInfoPaths(pkg, codePath, resPath);
|
||||||
// Note that we invoke the following method only if we are about to unpack an application
|
// Note that we invoke the following method only if we are about to unpack an application
|
||||||
PackageParser.Package scannedPkg = scanPackageLI(pkg, parseFlags, scanMode
|
PackageParser.Package scannedPkg = scanPackageLI(pkg, parseFlags, scanMode
|
||||||
| SCAN_UPDATE_SIGNATURE, currentTime, user);
|
| SCAN_UPDATE_SIGNATURE, currentTime, user, abiOverride);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the system app should be overridden by a previously installed
|
* If the system app should be overridden by a previously installed
|
||||||
@@ -4588,7 +4589,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PackageParser.Package scanPackageLI(PackageParser.Package pkg,
|
private PackageParser.Package scanPackageLI(PackageParser.Package pkg,
|
||||||
int parseFlags, int scanMode, long currentTime, UserHandle user) {
|
int parseFlags, int scanMode, long currentTime, UserHandle user, String abiOverride) {
|
||||||
File scanFile = new File(pkg.mScanPath);
|
File scanFile = new File(pkg.mScanPath);
|
||||||
if (scanFile == null || pkg.applicationInfo.sourceDir == null ||
|
if (scanFile == null || pkg.applicationInfo.sourceDir == null ||
|
||||||
pkg.applicationInfo.publicSourceDir == null) {
|
pkg.applicationInfo.publicSourceDir == null) {
|
||||||
@@ -5038,10 +5039,14 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
* only for non-system apps and system app upgrades.
|
* only for non-system apps and system app upgrades.
|
||||||
*/
|
*/
|
||||||
if (pkg.applicationInfo.nativeLibraryDir != null) {
|
if (pkg.applicationInfo.nativeLibraryDir != null) {
|
||||||
|
final NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(scanFile);
|
||||||
try {
|
try {
|
||||||
File nativeLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
|
File nativeLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
|
||||||
final String dataPathString = dataPath.getCanonicalPath();
|
final String dataPathString = dataPath.getCanonicalPath();
|
||||||
|
|
||||||
|
final String[] abiList = (abiOverride != null) ? new String[] { abiOverride } :
|
||||||
|
Build.SUPPORTED_ABIS;
|
||||||
|
|
||||||
if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) {
|
if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) {
|
||||||
/*
|
/*
|
||||||
* Upgrading from a previous version of the OS sometimes
|
* Upgrading from a previous version of the OS sometimes
|
||||||
@@ -5054,8 +5059,11 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
Log.i(TAG, "removed obsolete native libraries for system package "
|
Log.i(TAG, "removed obsolete native libraries for system package "
|
||||||
+ path);
|
+ path);
|
||||||
}
|
}
|
||||||
|
if (abiOverride != null) {
|
||||||
setInternalAppAbi(pkg, pkgSetting);
|
pkg.applicationInfo.cpuAbi = abiOverride;
|
||||||
|
} else {
|
||||||
|
setInternalAppAbi(pkg, pkgSetting);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isForwardLocked(pkg) && !isExternal(pkg)) {
|
if (!isForwardLocked(pkg) && !isExternal(pkg)) {
|
||||||
/*
|
/*
|
||||||
@@ -5068,7 +5076,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int copyRet = copyNativeLibrariesForInternalApp(scanFile, nativeLibraryDir);
|
int copyRet = copyNativeLibrariesForInternalApp(handle,
|
||||||
|
nativeLibraryDir, abiList);
|
||||||
if (copyRet < 0 && copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
|
if (copyRet < 0 && copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
|
||||||
Slog.e(TAG, "Unable to copy native libraries");
|
Slog.e(TAG, "Unable to copy native libraries");
|
||||||
mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
|
mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
|
||||||
@@ -5078,7 +5087,9 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
// We've successfully copied native libraries across, so we make a
|
// We've successfully copied native libraries across, so we make a
|
||||||
// note of what ABI we're using
|
// note of what ABI we're using
|
||||||
if (copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
|
if (copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
|
||||||
pkg.applicationInfo.cpuAbi = Build.SUPPORTED_ABIS[copyRet];
|
pkg.applicationInfo.cpuAbi = abiList[copyRet];
|
||||||
|
} else if (abiOverride != null) {
|
||||||
|
pkg.applicationInfo.cpuAbi = abiOverride;
|
||||||
} else {
|
} else {
|
||||||
pkg.applicationInfo.cpuAbi = null;
|
pkg.applicationInfo.cpuAbi = null;
|
||||||
}
|
}
|
||||||
@@ -5095,20 +5106,22 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
// to clean this up but we'll need to change the interface between this service
|
// to clean this up but we'll need to change the interface between this service
|
||||||
// and IMediaContainerService (but doing so will spread this logic out, rather
|
// and IMediaContainerService (but doing so will spread this logic out, rather
|
||||||
// than centralizing it).
|
// than centralizing it).
|
||||||
final NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(scanFile);
|
final int abi = NativeLibraryHelper.findSupportedAbi(handle, abiList);
|
||||||
final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
|
|
||||||
if (abi >= 0) {
|
if (abi >= 0) {
|
||||||
pkg.applicationInfo.cpuAbi = Build.SUPPORTED_ABIS[abi];
|
pkg.applicationInfo.cpuAbi = abiList[abi];
|
||||||
} else if (abi == PackageManager.NO_NATIVE_LIBRARIES) {
|
} else if (abi == PackageManager.NO_NATIVE_LIBRARIES) {
|
||||||
// Note that (non upgraded) system apps will not have any native
|
// Note that (non upgraded) system apps will not have any native
|
||||||
// libraries bundled in their APK, but we're guaranteed not to be
|
// libraries bundled in their APK, but we're guaranteed not to be
|
||||||
// such an app at this point.
|
// such an app at this point.
|
||||||
pkg.applicationInfo.cpuAbi = null;
|
if (abiOverride != null) {
|
||||||
|
pkg.applicationInfo.cpuAbi = abiOverride;
|
||||||
|
} else {
|
||||||
|
pkg.applicationInfo.cpuAbi = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
|
mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
handle.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG_INSTALL) Slog.i(TAG, "Linking native library dir for " + path);
|
if (DEBUG_INSTALL) Slog.i(TAG, "Linking native library dir for " + path);
|
||||||
@@ -5125,8 +5138,12 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pkgSetting.cpuAbiString = pkg.applicationInfo.cpuAbi;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Slog.e(TAG, "Unable to get canonical file " + ioe.toString());
|
Slog.e(TAG, "Unable to get canonical file " + ioe.toString());
|
||||||
|
} finally {
|
||||||
|
handle.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pkg.mScanPath = path;
|
pkg.mScanPath = path;
|
||||||
@@ -5812,8 +5829,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int copyNativeLibrariesForInternalApp(File scanFile, final File nativeLibraryDir)
|
private static int copyNativeLibrariesForInternalApp(ApkHandle handle,
|
||||||
throws IOException {
|
final File nativeLibraryDir, String[] abiList) throws IOException {
|
||||||
if (!nativeLibraryDir.isDirectory()) {
|
if (!nativeLibraryDir.isDirectory()) {
|
||||||
nativeLibraryDir.delete();
|
nativeLibraryDir.delete();
|
||||||
|
|
||||||
@@ -5835,21 +5852,16 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
* If this is an internal application or our nativeLibraryPath points to
|
* If this is an internal application or our nativeLibraryPath points to
|
||||||
* the app-lib directory, unpack the libraries if necessary.
|
* the app-lib directory, unpack the libraries if necessary.
|
||||||
*/
|
*/
|
||||||
final NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(scanFile);
|
int abi = NativeLibraryHelper.findSupportedAbi(handle, abiList);
|
||||||
try {
|
if (abi >= 0) {
|
||||||
int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
|
int copyRet = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle,
|
||||||
if (abi >= 0) {
|
nativeLibraryDir, Build.SUPPORTED_ABIS[abi]);
|
||||||
int copyRet = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle,
|
if (copyRet != PackageManager.INSTALL_SUCCEEDED) {
|
||||||
nativeLibraryDir, Build.SUPPORTED_ABIS[abi]);
|
return copyRet;
|
||||||
if (copyRet != PackageManager.INSTALL_SUCCEEDED) {
|
|
||||||
return copyRet;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return abi;
|
|
||||||
} finally {
|
|
||||||
handle.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return abi;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void killApplication(String pkgName, int appId, String reason) {
|
private void killApplication(String pkgName, int appId, String reason) {
|
||||||
@@ -7168,7 +7180,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
p = scanPackageLI(fullPath, flags,
|
p = scanPackageLI(fullPath, flags,
|
||||||
SCAN_MONITOR | SCAN_NO_PATHS | SCAN_UPDATE_TIME,
|
SCAN_MONITOR | SCAN_NO_PATHS | SCAN_UPDATE_TIME,
|
||||||
System.currentTimeMillis(), UserHandle.ALL);
|
System.currentTimeMillis(), UserHandle.ALL, null);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
/*
|
/*
|
||||||
* TODO this seems dangerous as the package may have
|
* TODO this seems dangerous as the package may have
|
||||||
@@ -7241,6 +7253,15 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
public void installPackageWithVerificationAndEncryption(Uri packageURI,
|
public void installPackageWithVerificationAndEncryption(Uri packageURI,
|
||||||
IPackageInstallObserver observer, int flags, String installerPackageName,
|
IPackageInstallObserver observer, int flags, String installerPackageName,
|
||||||
VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
|
VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
|
||||||
|
installPackageWithVerificationEncryptionAndAbiOverride(packageURI, observer, flags,
|
||||||
|
installerPackageName, verificationParams, encryptionParams, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void installPackageWithVerificationEncryptionAndAbiOverride(Uri packageURI,
|
||||||
|
IPackageInstallObserver observer, int flags, String installerPackageName,
|
||||||
|
VerificationParams verificationParams, ContainerEncryptionParams encryptionParams,
|
||||||
|
String packageAbiOverride) {
|
||||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.INSTALL_PACKAGES,
|
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.INSTALL_PACKAGES,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
@@ -7275,7 +7296,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
|
|
||||||
final Message msg = mHandler.obtainMessage(INIT_COPY);
|
final Message msg = mHandler.obtainMessage(INIT_COPY);
|
||||||
msg.obj = new InstallParams(packageURI, observer, filteredFlags, installerPackageName,
|
msg.obj = new InstallParams(packageURI, observer, filteredFlags, installerPackageName,
|
||||||
verificationParams, encryptionParams, user);
|
verificationParams, encryptionParams, user,
|
||||||
|
packageAbiOverride);
|
||||||
mHandler.sendMessage(msg);
|
mHandler.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7975,11 +7997,14 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
private int mRet;
|
private int mRet;
|
||||||
private File mTempPackage;
|
private File mTempPackage;
|
||||||
final ContainerEncryptionParams encryptionParams;
|
final ContainerEncryptionParams encryptionParams;
|
||||||
|
final String packageAbiOverride;
|
||||||
|
final String packageInstructionSetOverride;
|
||||||
|
|
||||||
InstallParams(Uri packageURI,
|
InstallParams(Uri packageURI,
|
||||||
IPackageInstallObserver observer, int flags,
|
IPackageInstallObserver observer, int flags,
|
||||||
String installerPackageName, VerificationParams verificationParams,
|
String installerPackageName, VerificationParams verificationParams,
|
||||||
ContainerEncryptionParams encryptionParams, UserHandle user) {
|
ContainerEncryptionParams encryptionParams, UserHandle user,
|
||||||
|
String packageAbiOverride) {
|
||||||
super(user);
|
super(user);
|
||||||
this.mPackageURI = packageURI;
|
this.mPackageURI = packageURI;
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
@@ -7987,6 +8012,9 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
this.installerPackageName = installerPackageName;
|
this.installerPackageName = installerPackageName;
|
||||||
this.verificationParams = verificationParams;
|
this.verificationParams = verificationParams;
|
||||||
this.encryptionParams = encryptionParams;
|
this.encryptionParams = encryptionParams;
|
||||||
|
this.packageAbiOverride = packageAbiOverride;
|
||||||
|
this.packageInstructionSetOverride = (packageAbiOverride == null) ?
|
||||||
|
packageAbiOverride : VMRuntime.getInstructionSet(packageAbiOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -8129,7 +8157,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
// Remote call to find out default install location
|
// Remote call to find out default install location
|
||||||
final String packageFilePath = packageFile.getAbsolutePath();
|
final String packageFilePath = packageFile.getAbsolutePath();
|
||||||
pkgLite = mContainerService.getMinimalPackageInfo(packageFilePath, flags,
|
pkgLite = mContainerService.getMinimalPackageInfo(packageFilePath, flags,
|
||||||
lowThreshold);
|
lowThreshold, packageAbiOverride);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have too little free space, try to free cache
|
* If we have too little free space, try to free cache
|
||||||
@@ -8138,10 +8166,10 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
if (pkgLite.recommendedInstallLocation
|
if (pkgLite.recommendedInstallLocation
|
||||||
== PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE) {
|
== PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE) {
|
||||||
final long size = mContainerService.calculateInstalledSize(
|
final long size = mContainerService.calculateInstalledSize(
|
||||||
packageFilePath, isForwardLocked());
|
packageFilePath, isForwardLocked(), packageAbiOverride);
|
||||||
if (mInstaller.freeCache(size + lowThreshold) >= 0) {
|
if (mInstaller.freeCache(size + lowThreshold) >= 0) {
|
||||||
pkgLite = mContainerService.getMinimalPackageInfo(packageFilePath,
|
pkgLite = mContainerService.getMinimalPackageInfo(packageFilePath,
|
||||||
flags, lowThreshold);
|
flags, lowThreshold, packageAbiOverride);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* The cache free must have deleted the file we
|
* The cache free must have deleted the file we
|
||||||
@@ -8560,10 +8588,11 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
final ManifestDigest manifestDigest;
|
final ManifestDigest manifestDigest;
|
||||||
final UserHandle user;
|
final UserHandle user;
|
||||||
final String instructionSet;
|
final String instructionSet;
|
||||||
|
final String abiOverride;
|
||||||
|
|
||||||
InstallArgs(Uri packageURI, IPackageInstallObserver observer, int flags,
|
InstallArgs(Uri packageURI, IPackageInstallObserver observer, int flags,
|
||||||
String installerPackageName, ManifestDigest manifestDigest,
|
String installerPackageName, ManifestDigest manifestDigest,
|
||||||
UserHandle user, String instructionSet) {
|
UserHandle user, String instructionSet, String abiOverride) {
|
||||||
this.packageURI = packageURI;
|
this.packageURI = packageURI;
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
this.observer = observer;
|
this.observer = observer;
|
||||||
@@ -8571,6 +8600,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
this.manifestDigest = manifestDigest;
|
this.manifestDigest = manifestDigest;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.instructionSet = instructionSet;
|
this.instructionSet = instructionSet;
|
||||||
|
this.abiOverride = abiOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void createCopyFile();
|
abstract void createCopyFile();
|
||||||
@@ -8626,12 +8656,13 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
FileInstallArgs(InstallParams params) {
|
FileInstallArgs(InstallParams params) {
|
||||||
super(params.getPackageUri(), params.observer, params.flags,
|
super(params.getPackageUri(), params.observer, params.flags,
|
||||||
params.installerPackageName, params.getManifestDigest(),
|
params.installerPackageName, params.getManifestDigest(),
|
||||||
params.getUser(), null /* instruction set */);
|
params.getUser(), params.packageInstructionSetOverride,
|
||||||
|
params.packageAbiOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInstallArgs(String fullCodePath, String fullResourcePath, String nativeLibraryPath,
|
FileInstallArgs(String fullCodePath, String fullResourcePath, String nativeLibraryPath,
|
||||||
String instructionSet) {
|
String instructionSet) {
|
||||||
super(null, null, 0, null, null, null, instructionSet);
|
super(null, null, 0, null, null, null, instructionSet, null);
|
||||||
File codeFile = new File(fullCodePath);
|
File codeFile = new File(fullCodePath);
|
||||||
installDir = codeFile.getParentFile();
|
installDir = codeFile.getParentFile();
|
||||||
codeFileName = fullCodePath;
|
codeFileName = fullCodePath;
|
||||||
@@ -8640,7 +8671,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileInstallArgs(Uri packageURI, String pkgName, String dataDir, String instructionSet) {
|
FileInstallArgs(Uri packageURI, String pkgName, String dataDir, String instructionSet) {
|
||||||
super(packageURI, null, 0, null, null, null, instructionSet);
|
super(packageURI, null, 0, null, null, null, instructionSet, null);
|
||||||
installDir = isFwdLocked() ? mDrmAppPrivateInstallDir : mAppInstallDir;
|
installDir = isFwdLocked() ? mDrmAppPrivateInstallDir : mAppInstallDir;
|
||||||
String apkName = getNextCodePath(null, pkgName, ".apk");
|
String apkName = getNextCodePath(null, pkgName, ".apk");
|
||||||
codeFileName = new File(installDir, apkName + ".apk").getPath();
|
codeFileName = new File(installDir, apkName + ".apk").getPath();
|
||||||
@@ -8744,14 +8775,20 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
NativeLibraryHelper.removeNativeBinariesFromDirLI(nativeLibraryFile);
|
NativeLibraryHelper.removeNativeBinariesFromDirLI(nativeLibraryFile);
|
||||||
nativeLibraryFile.delete();
|
nativeLibraryFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(codeFile);
|
||||||
|
final String[] abiList = (abiOverride != null) ?
|
||||||
|
new String[] { abiOverride } : Build.SUPPORTED_ABIS;
|
||||||
try {
|
try {
|
||||||
int copyRet = copyNativeLibrariesForInternalApp(codeFile, nativeLibraryFile);
|
int copyRet = copyNativeLibrariesForInternalApp(handle, nativeLibraryFile, abiList);
|
||||||
if (copyRet < 0 && copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
|
if (copyRet < 0 && copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
|
||||||
return copyRet;
|
return copyRet;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, "Copying native libraries failed", e);
|
Slog.e(TAG, "Copying native libraries failed", e);
|
||||||
ret = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
|
ret = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
|
||||||
|
} finally {
|
||||||
|
handle.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -8966,14 +9003,15 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
AsecInstallArgs(InstallParams params) {
|
AsecInstallArgs(InstallParams params) {
|
||||||
super(params.getPackageUri(), params.observer, params.flags,
|
super(params.getPackageUri(), params.observer, params.flags,
|
||||||
params.installerPackageName, params.getManifestDigest(),
|
params.installerPackageName, params.getManifestDigest(),
|
||||||
params.getUser(), null /* instruction set */);
|
params.getUser(), params.packageInstructionSetOverride,
|
||||||
|
params.packageAbiOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
AsecInstallArgs(String fullCodePath, String fullResourcePath, String nativeLibraryPath,
|
AsecInstallArgs(String fullCodePath, String fullResourcePath, String nativeLibraryPath,
|
||||||
String instructionSet, boolean isExternal, boolean isForwardLocked) {
|
String instructionSet, boolean isExternal, boolean isForwardLocked) {
|
||||||
super(null, null, (isExternal ? PackageManager.INSTALL_EXTERNAL : 0)
|
super(null, null, (isExternal ? PackageManager.INSTALL_EXTERNAL : 0)
|
||||||
| (isForwardLocked ? PackageManager.INSTALL_FORWARD_LOCK : 0),
|
| (isForwardLocked ? PackageManager.INSTALL_FORWARD_LOCK : 0),
|
||||||
null, null, null, instructionSet);
|
null, null, null, instructionSet, null);
|
||||||
// Extract cid from fullCodePath
|
// Extract cid from fullCodePath
|
||||||
int eidx = fullCodePath.lastIndexOf("/");
|
int eidx = fullCodePath.lastIndexOf("/");
|
||||||
String subStr1 = fullCodePath.substring(0, eidx);
|
String subStr1 = fullCodePath.substring(0, eidx);
|
||||||
@@ -8985,7 +9023,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
AsecInstallArgs(String cid, String instructionSet, boolean isForwardLocked) {
|
AsecInstallArgs(String cid, String instructionSet, boolean isForwardLocked) {
|
||||||
super(null, null, (isAsecExternal(cid) ? PackageManager.INSTALL_EXTERNAL : 0)
|
super(null, null, (isAsecExternal(cid) ? PackageManager.INSTALL_EXTERNAL : 0)
|
||||||
| (isForwardLocked ? PackageManager.INSTALL_FORWARD_LOCK : 0),
|
| (isForwardLocked ? PackageManager.INSTALL_FORWARD_LOCK : 0),
|
||||||
null, null, null, instructionSet);
|
null, null, null, instructionSet, null);
|
||||||
this.cid = cid;
|
this.cid = cid;
|
||||||
setCachePath(PackageHelper.getSdDir(cid));
|
setCachePath(PackageHelper.getSdDir(cid));
|
||||||
}
|
}
|
||||||
@@ -8994,7 +9032,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
boolean isExternal, boolean isForwardLocked) {
|
boolean isExternal, boolean isForwardLocked) {
|
||||||
super(packageURI, null, (isExternal ? PackageManager.INSTALL_EXTERNAL : 0)
|
super(packageURI, null, (isExternal ? PackageManager.INSTALL_EXTERNAL : 0)
|
||||||
| (isForwardLocked ? PackageManager.INSTALL_FORWARD_LOCK : 0),
|
| (isForwardLocked ? PackageManager.INSTALL_FORWARD_LOCK : 0),
|
||||||
null, null, null, instructionSet);
|
null, null, null, instructionSet, null);
|
||||||
this.cid = cid;
|
this.cid = cid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9006,7 +9044,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
try {
|
try {
|
||||||
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
||||||
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
return imcs.checkExternalFreeStorage(packageURI, isFwdLocked());
|
return imcs.checkExternalFreeStorage(packageURI, isFwdLocked(), abiOverride);
|
||||||
} finally {
|
} finally {
|
||||||
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
}
|
}
|
||||||
@@ -9032,7 +9070,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
||||||
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
newCachePath = imcs.copyResourceToContainer(packageURI, cid, getEncryptKey(),
|
newCachePath = imcs.copyResourceToContainer(packageURI, cid, getEncryptKey(),
|
||||||
RES_FILE_NAME, PUBLIC_RES_FILE_NAME, isExternal(), isFwdLocked());
|
RES_FILE_NAME, PUBLIC_RES_FILE_NAME, isExternal(), isFwdLocked(),
|
||||||
|
abiOverride);
|
||||||
} finally {
|
} finally {
|
||||||
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
}
|
}
|
||||||
@@ -9336,7 +9375,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
*/
|
*/
|
||||||
private void installNewPackageLI(PackageParser.Package pkg,
|
private void installNewPackageLI(PackageParser.Package pkg,
|
||||||
int parseFlags, int scanMode, UserHandle user,
|
int parseFlags, int scanMode, UserHandle user,
|
||||||
String installerPackageName, PackageInstalledInfo res) {
|
String installerPackageName, PackageInstalledInfo res, String abiOverride) {
|
||||||
// Remember this for later, in case we need to rollback this install
|
// Remember this for later, in case we need to rollback this install
|
||||||
String pkgName = pkg.packageName;
|
String pkgName = pkg.packageName;
|
||||||
|
|
||||||
@@ -9364,7 +9403,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
||||||
PackageParser.Package newPackage = scanPackageLI(pkg, parseFlags, scanMode,
|
PackageParser.Package newPackage = scanPackageLI(pkg, parseFlags, scanMode,
|
||||||
System.currentTimeMillis(), user);
|
System.currentTimeMillis(), user, abiOverride);
|
||||||
if (newPackage == null) {
|
if (newPackage == null) {
|
||||||
Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
|
Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
|
||||||
if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
|
if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
|
||||||
@@ -9391,7 +9430,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
|
|
||||||
private void replacePackageLI(PackageParser.Package pkg,
|
private void replacePackageLI(PackageParser.Package pkg,
|
||||||
int parseFlags, int scanMode, UserHandle user,
|
int parseFlags, int scanMode, UserHandle user,
|
||||||
String installerPackageName, PackageInstalledInfo res) {
|
String installerPackageName, PackageInstalledInfo res, String abiOverride) {
|
||||||
|
|
||||||
PackageParser.Package oldPackage;
|
PackageParser.Package oldPackage;
|
||||||
String pkgName = pkg.packageName;
|
String pkgName = pkg.packageName;
|
||||||
@@ -9420,17 +9459,19 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
boolean sysPkg = (isSystemApp(oldPackage));
|
boolean sysPkg = (isSystemApp(oldPackage));
|
||||||
if (sysPkg) {
|
if (sysPkg) {
|
||||||
replaceSystemPackageLI(oldPackage, pkg, parseFlags, scanMode,
|
replaceSystemPackageLI(oldPackage, pkg, parseFlags, scanMode,
|
||||||
user, allUsers, perUserInstalled, installerPackageName, res);
|
user, allUsers, perUserInstalled, installerPackageName, res,
|
||||||
|
abiOverride);
|
||||||
} else {
|
} else {
|
||||||
replaceNonSystemPackageLI(oldPackage, pkg, parseFlags, scanMode,
|
replaceNonSystemPackageLI(oldPackage, pkg, parseFlags, scanMode,
|
||||||
user, allUsers, perUserInstalled, installerPackageName, res);
|
user, allUsers, perUserInstalled, installerPackageName, res,
|
||||||
|
abiOverride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceNonSystemPackageLI(PackageParser.Package deletedPackage,
|
private void replaceNonSystemPackageLI(PackageParser.Package deletedPackage,
|
||||||
PackageParser.Package pkg, int parseFlags, int scanMode, UserHandle user,
|
PackageParser.Package pkg, int parseFlags, int scanMode, UserHandle user,
|
||||||
int[] allUsers, boolean[] perUserInstalled,
|
int[] allUsers, boolean[] perUserInstalled,
|
||||||
String installerPackageName, PackageInstalledInfo res) {
|
String installerPackageName, PackageInstalledInfo res, String abiOverride) {
|
||||||
PackageParser.Package newPackage = null;
|
PackageParser.Package newPackage = null;
|
||||||
String pkgName = deletedPackage.packageName;
|
String pkgName = deletedPackage.packageName;
|
||||||
boolean deletedPkg = true;
|
boolean deletedPkg = true;
|
||||||
@@ -9455,7 +9496,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
// Successfully deleted the old package. Now proceed with re-installation
|
// Successfully deleted the old package. Now proceed with re-installation
|
||||||
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
||||||
newPackage = scanPackageLI(pkg, parseFlags, scanMode | SCAN_UPDATE_TIME,
|
newPackage = scanPackageLI(pkg, parseFlags, scanMode | SCAN_UPDATE_TIME,
|
||||||
System.currentTimeMillis(), user);
|
System.currentTimeMillis(), user, abiOverride);
|
||||||
if (newPackage == null) {
|
if (newPackage == null) {
|
||||||
Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
|
Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
|
||||||
if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
|
if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
|
||||||
@@ -9484,7 +9525,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
// Since we failed to install the new package we need to restore the old
|
// Since we failed to install the new package we need to restore the old
|
||||||
// package that we deleted.
|
// package that we deleted.
|
||||||
if(deletedPkg) {
|
if (deletedPkg) {
|
||||||
if (DEBUG_INSTALL) Slog.d(TAG, "Install failed, reinstalling: " + deletedPackage);
|
if (DEBUG_INSTALL) Slog.d(TAG, "Install failed, reinstalling: " + deletedPackage);
|
||||||
File restoreFile = new File(deletedPackage.mPath);
|
File restoreFile = new File(deletedPackage.mPath);
|
||||||
// Parse old package
|
// Parse old package
|
||||||
@@ -9495,7 +9536,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
int oldScanMode = (oldOnSd ? 0 : SCAN_MONITOR) | SCAN_UPDATE_SIGNATURE
|
int oldScanMode = (oldOnSd ? 0 : SCAN_MONITOR) | SCAN_UPDATE_SIGNATURE
|
||||||
| SCAN_UPDATE_TIME;
|
| SCAN_UPDATE_TIME;
|
||||||
if (scanPackageLI(restoreFile, oldParseFlags, oldScanMode,
|
if (scanPackageLI(restoreFile, oldParseFlags, oldScanMode,
|
||||||
origUpdateTime, null) == null) {
|
origUpdateTime, null, null) == null) {
|
||||||
Slog.e(TAG, "Failed to restore package : " + pkgName + " after failed upgrade");
|
Slog.e(TAG, "Failed to restore package : " + pkgName + " after failed upgrade");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -9515,7 +9556,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
private void replaceSystemPackageLI(PackageParser.Package deletedPackage,
|
private void replaceSystemPackageLI(PackageParser.Package deletedPackage,
|
||||||
PackageParser.Package pkg, int parseFlags, int scanMode, UserHandle user,
|
PackageParser.Package pkg, int parseFlags, int scanMode, UserHandle user,
|
||||||
int[] allUsers, boolean[] perUserInstalled,
|
int[] allUsers, boolean[] perUserInstalled,
|
||||||
String installerPackageName, PackageInstalledInfo res) {
|
String installerPackageName, PackageInstalledInfo res, String abiOverride) {
|
||||||
if (DEBUG_INSTALL) Slog.d(TAG, "replaceSystemPackageLI: new=" + pkg
|
if (DEBUG_INSTALL) Slog.d(TAG, "replaceSystemPackageLI: new=" + pkg
|
||||||
+ ", old=" + deletedPackage);
|
+ ", old=" + deletedPackage);
|
||||||
PackageParser.Package newPackage = null;
|
PackageParser.Package newPackage = null;
|
||||||
@@ -9569,7 +9610,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
// Successfully disabled the old package. Now proceed with re-installation
|
// Successfully disabled the old package. Now proceed with re-installation
|
||||||
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
mLastScanError = PackageManager.INSTALL_SUCCEEDED;
|
||||||
pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
|
pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
|
||||||
newPackage = scanPackageLI(pkg, parseFlags, scanMode, 0, user);
|
newPackage = scanPackageLI(pkg, parseFlags, scanMode, 0, user, abiOverride);
|
||||||
if (newPackage == null) {
|
if (newPackage == null) {
|
||||||
Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
|
Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
|
||||||
if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
|
if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
|
||||||
@@ -9592,7 +9633,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
removeInstalledPackageLI(newPackage, true);
|
removeInstalledPackageLI(newPackage, true);
|
||||||
}
|
}
|
||||||
// Add back the old system package
|
// Add back the old system package
|
||||||
scanPackageLI(oldPkg, parseFlags, SCAN_MONITOR | SCAN_UPDATE_SIGNATURE, 0, user);
|
scanPackageLI(oldPkg, parseFlags, SCAN_MONITOR | SCAN_UPDATE_SIGNATURE, 0, user, null);
|
||||||
// Restore the old system information in Settings
|
// Restore the old system information in Settings
|
||||||
synchronized(mPackages) {
|
synchronized(mPackages) {
|
||||||
if (updatedSettings) {
|
if (updatedSettings) {
|
||||||
@@ -9805,10 +9846,10 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
pkg.applicationInfo.nativeLibraryDir = args.getNativeLibraryPath();
|
pkg.applicationInfo.nativeLibraryDir = args.getNativeLibraryPath();
|
||||||
if (replace) {
|
if (replace) {
|
||||||
replacePackageLI(pkg, parseFlags, scanMode, args.user,
|
replacePackageLI(pkg, parseFlags, scanMode, args.user,
|
||||||
installerPackageName, res);
|
installerPackageName, res, args.abiOverride);
|
||||||
} else {
|
} else {
|
||||||
installNewPackageLI(pkg, parseFlags, scanMode | SCAN_DELETE_DATA_ON_FAILURES, args.user,
|
installNewPackageLI(pkg, parseFlags, scanMode | SCAN_DELETE_DATA_ON_FAILURES, args.user,
|
||||||
installerPackageName, res);
|
installerPackageName, res, args.abiOverride);
|
||||||
}
|
}
|
||||||
synchronized (mPackages) {
|
synchronized (mPackages) {
|
||||||
final PackageSetting ps = mSettings.mPackages.get(pkgName);
|
final PackageSetting ps = mSettings.mPackages.get(pkgName);
|
||||||
@@ -10225,7 +10266,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
parseFlags |= PackageParser.PARSE_IS_PRIVILEGED;
|
parseFlags |= PackageParser.PARSE_IS_PRIVILEGED;
|
||||||
}
|
}
|
||||||
PackageParser.Package newPkg = scanPackageLI(disabledPs.codePath,
|
PackageParser.Package newPkg = scanPackageLI(disabledPs.codePath,
|
||||||
parseFlags, SCAN_MONITOR | SCAN_NO_PATHS, 0, null);
|
parseFlags, SCAN_MONITOR | SCAN_NO_PATHS, 0, null, null);
|
||||||
|
|
||||||
if (newPkg == null) {
|
if (newPkg == null) {
|
||||||
Slog.w(TAG, "Failed to restore system package:" + newPs.name
|
Slog.w(TAG, "Failed to restore system package:" + newPs.name
|
||||||
@@ -11908,7 +11949,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
doGc = true;
|
doGc = true;
|
||||||
synchronized (mInstallLock) {
|
synchronized (mInstallLock) {
|
||||||
final PackageParser.Package pkg = scanPackageLI(new File(codePath), parseFlags,
|
final PackageParser.Package pkg = scanPackageLI(new File(codePath), parseFlags,
|
||||||
0, 0, null);
|
0, 0, null, null);
|
||||||
// Scan the package
|
// Scan the package
|
||||||
if (pkg != null) {
|
if (pkg != null) {
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user