am 3f5ed04f
: am b63ea5f7
: am c928a11e
: Merge "Fix 2672155 Check the code path when enabling disabling packages." into froyo
This commit is contained in:
@ -2346,6 +2346,49 @@ public class PackageManagerTests extends AndroidTestCase {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* This test installs an application on sdcard and unmounts media.
|
||||
* The app is then re-installed on internal storage. The sdcard is mounted
|
||||
* and verified that the re-installation on internal storage takes precedence.
|
||||
*/
|
||||
@MediumTest
|
||||
public void testInstallSdcardStaleContainerReinstall() {
|
||||
boolean origMediaState = getMediaState();
|
||||
try {
|
||||
// Mount media first
|
||||
mountMedia();
|
||||
String outFileName = "install.apk";
|
||||
int rawResId = R.raw.install;
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
File filesDir = mContext.getFilesDir();
|
||||
File outFile = new File(filesDir, outFileName);
|
||||
Uri packageURI = getInstallablePackage(rawResId, outFile);
|
||||
PackageParser.Package pkg = parsePackage(packageURI);
|
||||
assertNotNull(pkg);
|
||||
// Install an app on sdcard.
|
||||
installFromRawResource(outFileName, rawResId,
|
||||
PackageManager.INSTALL_EXTERNAL, false,
|
||||
false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
|
||||
// Unmount sdcard
|
||||
unmountMedia();
|
||||
// Reinstall the app and make sure it gets installed on internal storage.
|
||||
installFromRawResource(outFileName, rawResId,
|
||||
PackageManager.INSTALL_REPLACE_EXISTING, false,
|
||||
false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
|
||||
mountMedia();
|
||||
// Verify that the app installed is on internal storage.
|
||||
assertInstall(pkg, 0, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
|
||||
} catch (Exception e) {
|
||||
failStr(e.getMessage());
|
||||
} finally {
|
||||
if (origMediaState) {
|
||||
mountMedia();
|
||||
} else {
|
||||
unmountMedia();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
* The following series of tests are related to upgrading apps with
|
||||
* different certificates.
|
||||
|
@ -5340,13 +5340,13 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
SdInstallArgs(String cid) {
|
||||
super(null, null, PackageManager.INSTALL_EXTERNAL, null);
|
||||
this.cid = cid;
|
||||
this((Uri)null, cid);
|
||||
}
|
||||
|
||||
SdInstallArgs(Uri packageURI, String cid) {
|
||||
super(packageURI, null, PackageManager.INSTALL_EXTERNAL, null);
|
||||
this.cid = cid;
|
||||
cachePath = PackageHelper.getSdDir(cid);
|
||||
}
|
||||
|
||||
void createCopyFile() {
|
||||
@ -9608,7 +9608,10 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
if (DEBUG_SD_INSTALL) Log.i(TAG, "Looking for pkg : " + pkgName);
|
||||
PackageSetting ps = mSettings.mPackages.get(pkgName);
|
||||
if (ps != null && ps.codePathString != null) {
|
||||
// The package status is changed only if the code path
|
||||
// matches between settings and the container id.
|
||||
if (ps != null && ps.codePathString != null &&
|
||||
ps.codePathString.equals(args.getCodePath())) {
|
||||
if (DEBUG_SD_INSTALL) Log.i(TAG, "Container : " + cid +
|
||||
" corresponds to pkg : " + pkgName +
|
||||
" at code path: " + ps.codePathString);
|
||||
|
Reference in New Issue
Block a user