am c928a11e
: Merge "Fix 2672155 Check the code path when enabling disabling packages." into froyo
Merge commit 'c928a11e34678296511d5ea34582292be7368618' into froyo-plus-aosp * commit 'c928a11e34678296511d5ea34582292be7368618': Fix 2672155
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
|
* The following series of tests are related to upgrading apps with
|
||||||
* different certificates.
|
* different certificates.
|
||||||
|
@ -5315,13 +5315,13 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SdInstallArgs(String cid) {
|
SdInstallArgs(String cid) {
|
||||||
super(null, null, PackageManager.INSTALL_EXTERNAL, null);
|
this((Uri)null, cid);
|
||||||
this.cid = cid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SdInstallArgs(Uri packageURI, String cid) {
|
SdInstallArgs(Uri packageURI, String cid) {
|
||||||
super(packageURI, null, PackageManager.INSTALL_EXTERNAL, null);
|
super(packageURI, null, PackageManager.INSTALL_EXTERNAL, null);
|
||||||
this.cid = cid;
|
this.cid = cid;
|
||||||
|
cachePath = PackageHelper.getSdDir(cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createCopyFile() {
|
void createCopyFile() {
|
||||||
@ -9565,7 +9565,10 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
if (DEBUG_SD_INSTALL) Log.i(TAG, "Looking for pkg : " + pkgName);
|
if (DEBUG_SD_INSTALL) Log.i(TAG, "Looking for pkg : " + pkgName);
|
||||||
PackageSetting ps = mSettings.mPackages.get(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 +
|
if (DEBUG_SD_INSTALL) Log.i(TAG, "Container : " + cid +
|
||||||
" corresponds to pkg : " + pkgName +
|
" corresponds to pkg : " + pkgName +
|
||||||
" at code path: " + ps.codePathString);
|
" at code path: " + ps.codePathString);
|
||||||
|
Reference in New Issue
Block a user