Loading cmds/pm/src/com/android/commands/pm/Pm.java +27 −3 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.content.pm.VerificationParams; import android.content.res.AssetManager; import android.content.res.Resources; import android.net.Uri; import android.os.Build; import android.os.IUserManager; import android.os.RemoteException; import android.os.ServiceManager; Loading @@ -54,7 +55,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.WeakHashMap; import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; Loading Loading @@ -801,6 +801,7 @@ public final class Pm { byte[] tag = null; String originatingUriString = null; String referrer = null; String abi = null; while ((opt=nextOption()) != null) { if (opt.equals("-l")) { Loading Loading @@ -871,12 +872,34 @@ public final class Pm { System.err.println("Error: must supply argument for --referrer"); return; } } else if (opt.equals("--abi")) { abi = nextOptionData(); if (abi == null) { System.err.println("Error: must supply argument for --abi"); return; } } else { System.err.println("Error: Unknown option: " + opt); 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; if (algo != null || iv != null || key != null || macAlgo != null || macKey != null || tag != null) { Loading Loading @@ -954,8 +977,9 @@ public final class Pm { VerificationParams verificationParams = new VerificationParams(verificationURI, originatingURI, referrerURI, VerificationParams.NO_UID, null); mPm.installPackageWithVerificationAndEncryption(apkURI, obs, installFlags, installerPackageName, verificationParams, encryptionParams); mPm.installPackageWithVerificationEncryptionAndAbiOverride(apkURI, obs, installFlags, installerPackageName, verificationParams, encryptionParams, abi); synchronized (obs) { while (!obs.finished) { Loading core/java/android/content/pm/IPackageManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,12 @@ interface IPackageManager { in VerificationParams verificationParams, 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); void verifyPendingInstall(int id, int verificationCode); Loading core/java/com/android/internal/app/IMediaContainerService.aidl +6 −4 Original line number Diff line number Diff line Loading @@ -25,16 +25,18 @@ import android.content.res.ObbInfo; interface IMediaContainerService { String copyResourceToContainer(in Uri packageURI, String containerId, String key, String resFileName, String publicResFileName, boolean isExternal, boolean isForwardLocked); boolean isForwardLocked, in String abiOverride); int copyResource(in Uri packageURI, in ContainerEncryptionParams encryptionParams, 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 checkExternalFreeStorage(in Uri fileUri, boolean isForwardLocked); boolean checkExternalFreeStorage(in Uri fileUri, boolean isForwardLocked, in String abiOverride); ObbInfo getObbInfo(in String filename); long calculateDirectorySize(in String directory); /** Return file system stats: [0] is total bytes, [1] is available bytes */ long[] getFileSystemStats(in String path); void clearDirectory(in String directory); long calculateInstalledSize(in String packagePath, boolean isForwardLocked); long calculateInstalledSize(in String packagePath, boolean isForwardLocked, in String abiOverride); } packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +25 −21 Original line number Diff line number Diff line Loading @@ -101,13 +101,13 @@ public class DefaultContainerService extends IntentService { */ public String copyResourceToContainer(final Uri packageURI, final String cid, final String key, final String resFileName, final String publicResFileName, boolean isExternal, boolean isForwardLocked) { boolean isExternal, boolean isForwardLocked, String abiOverride) { if (packageURI == null || cid == null) { return null; } return copyResourceInner(packageURI, cid, key, resFileName, publicResFileName, isExternal, isForwardLocked); isExternal, isForwardLocked, abiOverride); } /** Loading Loading @@ -153,13 +153,12 @@ public class DefaultContainerService extends IntentService { /** * Determine the recommended install location for package * specified by file uri location. * @param fileUri the uri of resource to be copied. Should be a * file uri * * @return Returns PackageInfoLite object containing * the package info and recommended app location. */ public PackageInfoLite getMinimalPackageInfo(final String packagePath, int flags, long threshold) { long threshold, String abiOverride) { PackageInfoLite ret = new PackageInfoLite(); if (packagePath == null) { Loading Loading @@ -191,7 +190,7 @@ public class DefaultContainerService extends IntentService { ret.verifiers = pkg.verifiers; ret.recommendedInstallLocation = recommendAppInstallLocation(pkg.installLocation, packagePath, flags, threshold); packagePath, flags, threshold, abiOverride); return ret; } Loading @@ -208,11 +207,11 @@ public class DefaultContainerService extends IntentService { } @Override public boolean checkExternalFreeStorage(Uri packageUri, boolean isForwardLocked) throws RemoteException { public boolean checkExternalFreeStorage(Uri packageUri, boolean isForwardLocked, String abiOverride) throws RemoteException { final File apkFile = new File(packageUri.getPath()); try { return isUnderExternalThreshold(apkFile, isForwardLocked); return isUnderExternalThreshold(apkFile, isForwardLocked, abiOverride); } catch (IOException e) { return true; } Loading Loading @@ -265,11 +264,11 @@ public class DefaultContainerService extends IntentService { } @Override public long calculateInstalledSize(String packagePath, boolean isForwardLocked) throws RemoteException { public long calculateInstalledSize(String packagePath, boolean isForwardLocked, String abiOverride) throws RemoteException { final File packageFile = new File(packagePath); try { return calculateContainerSize(packageFile, isForwardLocked) * 1024 * 1024; return calculateContainerSize(packageFile, isForwardLocked, abiOverride) * 1024 * 1024; } catch (IOException e) { /* * Okay, something failed, so let's just estimate it to be 2x Loading Loading @@ -328,7 +327,8 @@ public class DefaultContainerService extends IntentService { } 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) { // Make sure the sdcard is mounted. Loading @@ -342,8 +342,10 @@ public class DefaultContainerService extends IntentService { // The .apk file String codePath = packageURI.getPath(); File codeFile = new File(codePath); String[] abiList = (abiOverride != null) ? new String[] { abiOverride } : Build.SUPPORTED_ABIS; 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. final int sizeMb; Loading Loading @@ -414,7 +416,7 @@ public class DefaultContainerService extends IntentService { int ret = PackageManager.INSTALL_SUCCEEDED; if (abi >= 0) { ret = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle, sharedLibraryDir, Build.SUPPORTED_ABIS[abi]); sharedLibraryDir, abiList[abi]); } else if (abi != PackageManager.NO_NATIVE_LIBRARIES) { ret = abi; } Loading Loading @@ -672,7 +674,7 @@ public class DefaultContainerService extends IntentService { private static final int PREFER_EXTERNAL = 2; private int recommendAppInstallLocation(int installLocation, String archiveFilePath, int flags, long threshold) { long threshold, String abiOverride) { int prefer; boolean checkBoth = false; Loading Loading @@ -741,7 +743,7 @@ public class DefaultContainerService extends IntentService { boolean fitsOnSd = false; if (!emulated && (checkBoth || prefer == PREFER_EXTERNAL)) { try { fitsOnSd = isUnderExternalThreshold(apkFile, isForwardLocked); fitsOnSd = isUnderExternalThreshold(apkFile, isForwardLocked, abiOverride); } catch (IOException e) { return PackageHelper.RECOMMEND_FAILED_INVALID_URI; } Loading Loading @@ -812,13 +814,13 @@ public class DefaultContainerService extends IntentService { * @return true if file fits * @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 { if (Environment.isExternalStorageEmulated()) { return false; } final int sizeMb = calculateContainerSize(apkFile, isForwardLocked); final int sizeMb = calculateContainerSize(apkFile, isForwardLocked, abiOverride); final int availSdMb; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { Loading @@ -832,9 +834,11 @@ public class DefaultContainerService extends IntentService { 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); final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS); final int abi = NativeLibraryHelper.findSupportedAbi(handle, (abiOverride != null) ? new String[] { abiOverride } : Build.SUPPORTED_ABIS); try { return calculateContainerSize(handle, apkFile, abi, forwardLocked); Loading services/java/com/android/server/pm/PackageManagerService.java +103 −62 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
cmds/pm/src/com/android/commands/pm/Pm.java +27 −3 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.content.pm.VerificationParams; import android.content.res.AssetManager; import android.content.res.Resources; import android.net.Uri; import android.os.Build; import android.os.IUserManager; import android.os.RemoteException; import android.os.ServiceManager; Loading @@ -54,7 +55,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.WeakHashMap; import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; Loading Loading @@ -801,6 +801,7 @@ public final class Pm { byte[] tag = null; String originatingUriString = null; String referrer = null; String abi = null; while ((opt=nextOption()) != null) { if (opt.equals("-l")) { Loading Loading @@ -871,12 +872,34 @@ public final class Pm { System.err.println("Error: must supply argument for --referrer"); return; } } else if (opt.equals("--abi")) { abi = nextOptionData(); if (abi == null) { System.err.println("Error: must supply argument for --abi"); return; } } else { System.err.println("Error: Unknown option: " + opt); 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; if (algo != null || iv != null || key != null || macAlgo != null || macKey != null || tag != null) { Loading Loading @@ -954,8 +977,9 @@ public final class Pm { VerificationParams verificationParams = new VerificationParams(verificationURI, originatingURI, referrerURI, VerificationParams.NO_UID, null); mPm.installPackageWithVerificationAndEncryption(apkURI, obs, installFlags, installerPackageName, verificationParams, encryptionParams); mPm.installPackageWithVerificationEncryptionAndAbiOverride(apkURI, obs, installFlags, installerPackageName, verificationParams, encryptionParams, abi); synchronized (obs) { while (!obs.finished) { Loading
core/java/android/content/pm/IPackageManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,12 @@ interface IPackageManager { in VerificationParams verificationParams, 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); void verifyPendingInstall(int id, int verificationCode); Loading
core/java/com/android/internal/app/IMediaContainerService.aidl +6 −4 Original line number Diff line number Diff line Loading @@ -25,16 +25,18 @@ import android.content.res.ObbInfo; interface IMediaContainerService { String copyResourceToContainer(in Uri packageURI, String containerId, String key, String resFileName, String publicResFileName, boolean isExternal, boolean isForwardLocked); boolean isForwardLocked, in String abiOverride); int copyResource(in Uri packageURI, in ContainerEncryptionParams encryptionParams, 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 checkExternalFreeStorage(in Uri fileUri, boolean isForwardLocked); boolean checkExternalFreeStorage(in Uri fileUri, boolean isForwardLocked, in String abiOverride); ObbInfo getObbInfo(in String filename); long calculateDirectorySize(in String directory); /** Return file system stats: [0] is total bytes, [1] is available bytes */ long[] getFileSystemStats(in String path); void clearDirectory(in String directory); long calculateInstalledSize(in String packagePath, boolean isForwardLocked); long calculateInstalledSize(in String packagePath, boolean isForwardLocked, in String abiOverride); }
packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +25 −21 Original line number Diff line number Diff line Loading @@ -101,13 +101,13 @@ public class DefaultContainerService extends IntentService { */ public String copyResourceToContainer(final Uri packageURI, final String cid, final String key, final String resFileName, final String publicResFileName, boolean isExternal, boolean isForwardLocked) { boolean isExternal, boolean isForwardLocked, String abiOverride) { if (packageURI == null || cid == null) { return null; } return copyResourceInner(packageURI, cid, key, resFileName, publicResFileName, isExternal, isForwardLocked); isExternal, isForwardLocked, abiOverride); } /** Loading Loading @@ -153,13 +153,12 @@ public class DefaultContainerService extends IntentService { /** * Determine the recommended install location for package * specified by file uri location. * @param fileUri the uri of resource to be copied. Should be a * file uri * * @return Returns PackageInfoLite object containing * the package info and recommended app location. */ public PackageInfoLite getMinimalPackageInfo(final String packagePath, int flags, long threshold) { long threshold, String abiOverride) { PackageInfoLite ret = new PackageInfoLite(); if (packagePath == null) { Loading Loading @@ -191,7 +190,7 @@ public class DefaultContainerService extends IntentService { ret.verifiers = pkg.verifiers; ret.recommendedInstallLocation = recommendAppInstallLocation(pkg.installLocation, packagePath, flags, threshold); packagePath, flags, threshold, abiOverride); return ret; } Loading @@ -208,11 +207,11 @@ public class DefaultContainerService extends IntentService { } @Override public boolean checkExternalFreeStorage(Uri packageUri, boolean isForwardLocked) throws RemoteException { public boolean checkExternalFreeStorage(Uri packageUri, boolean isForwardLocked, String abiOverride) throws RemoteException { final File apkFile = new File(packageUri.getPath()); try { return isUnderExternalThreshold(apkFile, isForwardLocked); return isUnderExternalThreshold(apkFile, isForwardLocked, abiOverride); } catch (IOException e) { return true; } Loading Loading @@ -265,11 +264,11 @@ public class DefaultContainerService extends IntentService { } @Override public long calculateInstalledSize(String packagePath, boolean isForwardLocked) throws RemoteException { public long calculateInstalledSize(String packagePath, boolean isForwardLocked, String abiOverride) throws RemoteException { final File packageFile = new File(packagePath); try { return calculateContainerSize(packageFile, isForwardLocked) * 1024 * 1024; return calculateContainerSize(packageFile, isForwardLocked, abiOverride) * 1024 * 1024; } catch (IOException e) { /* * Okay, something failed, so let's just estimate it to be 2x Loading Loading @@ -328,7 +327,8 @@ public class DefaultContainerService extends IntentService { } 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) { // Make sure the sdcard is mounted. Loading @@ -342,8 +342,10 @@ public class DefaultContainerService extends IntentService { // The .apk file String codePath = packageURI.getPath(); File codeFile = new File(codePath); String[] abiList = (abiOverride != null) ? new String[] { abiOverride } : Build.SUPPORTED_ABIS; 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. final int sizeMb; Loading Loading @@ -414,7 +416,7 @@ public class DefaultContainerService extends IntentService { int ret = PackageManager.INSTALL_SUCCEEDED; if (abi >= 0) { ret = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle, sharedLibraryDir, Build.SUPPORTED_ABIS[abi]); sharedLibraryDir, abiList[abi]); } else if (abi != PackageManager.NO_NATIVE_LIBRARIES) { ret = abi; } Loading Loading @@ -672,7 +674,7 @@ public class DefaultContainerService extends IntentService { private static final int PREFER_EXTERNAL = 2; private int recommendAppInstallLocation(int installLocation, String archiveFilePath, int flags, long threshold) { long threshold, String abiOverride) { int prefer; boolean checkBoth = false; Loading Loading @@ -741,7 +743,7 @@ public class DefaultContainerService extends IntentService { boolean fitsOnSd = false; if (!emulated && (checkBoth || prefer == PREFER_EXTERNAL)) { try { fitsOnSd = isUnderExternalThreshold(apkFile, isForwardLocked); fitsOnSd = isUnderExternalThreshold(apkFile, isForwardLocked, abiOverride); } catch (IOException e) { return PackageHelper.RECOMMEND_FAILED_INVALID_URI; } Loading Loading @@ -812,13 +814,13 @@ public class DefaultContainerService extends IntentService { * @return true if file fits * @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 { if (Environment.isExternalStorageEmulated()) { return false; } final int sizeMb = calculateContainerSize(apkFile, isForwardLocked); final int sizeMb = calculateContainerSize(apkFile, isForwardLocked, abiOverride); final int availSdMb; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { Loading @@ -832,9 +834,11 @@ public class DefaultContainerService extends IntentService { 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); final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS); final int abi = NativeLibraryHelper.findSupportedAbi(handle, (abiOverride != null) ? new String[] { abiOverride } : Build.SUPPORTED_ABIS); try { return calculateContainerSize(handle, apkFile, abi, forwardLocked); Loading
services/java/com/android/server/pm/PackageManagerService.java +103 −62 File changed.Preview size limit exceeded, changes collapsed. Show changes