Merge "Disable wifi display API when the adapter is not registered." into jb-mr1-dev
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 697d8ec..68f8400 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -403,37 +403,6 @@
}
}
-int protect(char *pkgname, gid_t gid)
-{
- struct stat s;
- char pkgpath[PKG_PATH_MAX];
-
- if (gid < AID_SYSTEM) return -1;
-
- if (create_pkg_path_in_dir(pkgpath, &android_app_private_dir, pkgname, ".apk"))
- return -1;
-
- if (stat(pkgpath, &s) < 0) return -1;
-
- if (chown(pkgpath, s.st_uid, gid) < 0) {
- ALOGE("failed to chgrp '%s': %s\n", pkgpath, strerror(errno));
- return -1;
- }
- if (chmod(pkgpath, S_IRUSR|S_IWUSR|S_IRGRP) < 0) {
- ALOGE("protect(): failed to chmod '%s': %s\n", pkgpath, strerror(errno));
- return -1;
- }
-
-#ifdef HAVE_SELINUX
- if (selinux_android_setfilecon(pkgpath, pkgname, s.st_uid) < 0) {
- ALOGE("cannot setfilecon dir '%s': %s\n", pkgpath, strerror(errno));
- return -1;
- }
-#endif
-
- return 0;
-}
-
int get_size(const char *pkgname, int persona, const char *apkpath,
const char *fwdlock_apkpath, const char *asecpath,
int64_t *_codesize, int64_t *_datasize, int64_t *_cachesize,
diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c
index 652543fd..cc8f014 100644
--- a/cmds/installd/installd.c
+++ b/cmds/installd/installd.c
@@ -75,11 +75,6 @@
return delete_cache(arg[0]); /* pkgname */
}
-static int do_protect(char **arg, char reply[REPLY_MAX])
-{
- return protect(arg[0], atoi(arg[1])); /* pkgname, gid */
-}
-
static int do_get_size(char **arg, char reply[REPLY_MAX])
{
int64_t codesize = 0;
@@ -153,7 +148,6 @@
{ "fixuid", 3, do_fixuid },
{ "freecache", 1, do_free_cache },
{ "rmcache", 1, do_rm_cache },
- { "protect", 2, do_protect },
{ "getsize", 5, do_get_size },
{ "rmuserdata", 2, do_rm_user_data },
{ "movefiles", 0, do_movefiles },
diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
index 607150a..f46478c 100755
--- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
+++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
@@ -55,19 +55,28 @@
public class PackageManagerTests extends AndroidTestCase {
private static final boolean localLOGV = true;
- public static final String TAG="PackageManagerTests";
- public final long MAX_WAIT_TIME = 25*1000;
- public final long WAIT_TIME_INCR = 5*1000;
- private static final String SECURE_CONTAINERS_PREFIX = "/mnt/asec";
+
+ public static final String TAG = "PackageManagerTests";
+
+ public final long MAX_WAIT_TIME = 25 * 1000;
+
+ public final long WAIT_TIME_INCR = 5 * 1000;
+
+ private static final String SECURE_CONTAINERS_PREFIX = "/mnt/asec/";
+
private static final int APP_INSTALL_AUTO = PackageHelper.APP_INSTALL_AUTO;
+
private static final int APP_INSTALL_DEVICE = PackageHelper.APP_INSTALL_INTERNAL;
+
private static final int APP_INSTALL_SDCARD = PackageHelper.APP_INSTALL_EXTERNAL;
+
private boolean mOrigState;
void failStr(String errMsg) {
- Log.w(TAG, "errMsg="+errMsg);
+ Log.w(TAG, "errMsg=" + errMsg);
fail(errMsg);
}
+
void failStr(Exception e) {
failStr(e.getMessage());
}
@@ -97,10 +106,11 @@
private class PackageInstallObserver extends IPackageInstallObserver.Stub {
public int returnCode;
+
private boolean doneFlag = false;
public void packageInstalled(String packageName, int returnCode) {
- synchronized(this) {
+ synchronized (this) {
this.returnCode = returnCode;
doneFlag = true;
notifyAll();
@@ -114,10 +124,15 @@
abstract class GenericReceiver extends BroadcastReceiver {
private boolean doneFlag = false;
+
boolean received = false;
+
Intent intent;
+
IntentFilter filter;
+
abstract boolean notifyNow(Intent intent);
+
@Override
public void onReceive(Context context, Intent intent) {
if (notifyNow(intent)) {
@@ -179,11 +194,11 @@
mContext.registerReceiver(receiver, receiver.filter);
try {
// Wait on observer
- synchronized(observer) {
+ synchronized (observer) {
synchronized (receiver) {
getPm().installPackage(packageURI, observer, flags, null);
long waitTime = 0;
- while((!observer.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
+ while ((!observer.isDone()) && (waitTime < MAX_WAIT_TIME)) {
try {
observer.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
@@ -191,7 +206,7 @@
Log.i(TAG, "Interrupted during sleep", e);
}
}
- if(!observer.isDone()) {
+ if (!observer.isDone()) {
fail("Timed out waiting for packageInstalled callback");
}
@@ -214,7 +229,7 @@
// Verify we received the broadcast
waitTime = 0;
- while((!receiver.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
+ while ((!receiver.isDone()) && (waitTime < MAX_WAIT_TIME)) {
try {
receiver.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
@@ -222,7 +237,7 @@
Log.i(TAG, "Interrupted during sleep", e);
}
}
- if(!receiver.isDone()) {
+ if (!receiver.isDone()) {
fail("Timed out waiting for PACKAGE_ADDED notification");
}
}
@@ -236,10 +251,10 @@
PackageInstallObserver observer = new PackageInstallObserver();
try {
// Wait on observer
- synchronized(observer) {
+ synchronized (observer) {
getPm().installPackage(packageURI, observer, flags, null);
long waitTime = 0;
- while((!observer.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
+ while ((!observer.isDone()) && (waitTime < MAX_WAIT_TIME)) {
try {
observer.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
@@ -247,7 +262,7 @@
Log.i(TAG, "Interrupted during sleep", e);
}
}
- if(!observer.isDone()) {
+ if (!observer.isDone()) {
fail("Timed out waiting for packageInstalled callback");
}
assertEquals(expectedResult, observer.returnCode);
@@ -280,39 +295,42 @@
File sourceFile = new File(archiveFilePath);
DisplayMetrics metrics = new DisplayMetrics();
metrics.setToDefaults();
- PackageParser.Package pkg = packageParser.parsePackage(sourceFile, archiveFilePath, metrics, 0);
+ PackageParser.Package pkg = packageParser.parsePackage(sourceFile, archiveFilePath,
+ metrics, 0);
packageParser = null;
return pkg;
}
+
private boolean checkSd(long pkgLen) {
String status = Environment.getExternalStorageState();
if (!status.equals(Environment.MEDIA_MOUNTED)) {
return false;
}
long sdSize = -1;
- StatFs sdStats = new StatFs(
- Environment.getExternalStorageDirectory().getPath());
- sdSize = (long)sdStats.getAvailableBlocks() *
- (long)sdStats.getBlockSize();
+ StatFs sdStats = new StatFs(Environment.getExternalStorageDirectory().getPath());
+ sdSize = (long) sdStats.getAvailableBlocks() * (long) sdStats.getBlockSize();
// TODO check for thresholds here
return pkgLen <= sdSize;
}
+
private boolean checkInt(long pkgLen) {
StatFs intStats = new StatFs(Environment.getDataDirectory().getPath());
- long intSize = (long)intStats.getBlockCount() *
- (long)intStats.getBlockSize();
- long iSize = (long)intStats.getAvailableBlocks() *
- (long)intStats.getBlockSize();
+ long intSize = (long) intStats.getBlockCount() * (long) intStats.getBlockSize();
+ long iSize = (long) intStats.getAvailableBlocks() * (long) intStats.getBlockSize();
// TODO check for thresholds here?
return pkgLen <= iSize;
}
+
private static final int INSTALL_LOC_INT = 1;
+
private static final int INSTALL_LOC_SD = 2;
+
private static final int INSTALL_LOC_ERR = -1;
+
private int getInstallLoc(int flags, int expInstallLocation, long pkgLen) {
// Flags explicitly over ride everything else.
- if ((flags & PackageManager.INSTALL_EXTERNAL) != 0 ) {
+ if ((flags & PackageManager.INSTALL_EXTERNAL) != 0) {
return INSTALL_LOC_SD;
} else if ((flags & PackageManager.INSTALL_INTERNAL) != 0) {
return INSTALL_LOC_INT;
@@ -320,7 +338,7 @@
// Manifest option takes precedence next
if (expInstallLocation == PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL) {
if (checkSd(pkgLen)) {
- return INSTALL_LOC_SD;
+ return INSTALL_LOC_SD;
}
if (checkInt(pkgLen)) {
return INSTALL_LOC_INT;
@@ -422,7 +440,7 @@
} catch (IOException e) {
fail("Can't read " + nativeLibDir.getPath());
}
- } else if (rLoc == INSTALL_LOC_SD){
+ } else if (rLoc == INSTALL_LOC_SD) {
if ((flags & PackageManager.INSTALL_FORWARD_LOCK) != 0) {
assertTrue("The application should be installed forward locked",
(info.flags & ApplicationInfo.FLAG_FORWARD_LOCK) != 0);
@@ -451,8 +469,8 @@
nativeLibSymLink.exists());
try {
assertEquals(nativeLibSymLink.getPath() + " should be a symlink to "
- + info.nativeLibraryDir, info.nativeLibraryDir, nativeLibSymLink
- .getCanonicalPath());
+ + info.nativeLibraryDir, info.nativeLibraryDir,
+ nativeLibSymLink.getCanonicalPath());
} catch (IOException e) {
fail("Can't read " + nativeLibSymLink.getPath());
}
@@ -475,30 +493,38 @@
class InstallParams {
Uri packageURI;
+
PackageParser.Package pkg;
+
InstallParams(String outFileName, int rawResId) {
this.pkg = getParsedPackage(outFileName, rawResId);
this.packageURI = Uri.fromFile(new File(pkg.mScanPath));
}
+
InstallParams(PackageParser.Package pkg) {
this.packageURI = Uri.fromFile(new File(pkg.mScanPath));
this.pkg = pkg;
}
+
long getApkSize() {
File file = new File(pkg.mScanPath);
return file.length();
}
}
- private InstallParams sampleInstallFromRawResource(int flags, boolean cleanUp) {
- return installFromRawResource("install.apk", R.raw.install, flags, cleanUp,
- false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
+ private InstallParams sampleInstallFromRawResource(int flags, boolean cleanUp) throws Exception {
+ return installFromRawResource("install.apk", R.raw.install, flags, cleanUp, false, -1,
+ PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
}
static final String PERM_PACKAGE = "package";
+
static final String PERM_DEFINED = "defined";
+
static final String PERM_UNDEFINED = "undefined";
+
static final String PERM_USED = "used";
+
static final String PERM_NOTUSED = "notused";
private void assertPermissions(String[] cmds) {
@@ -530,7 +556,7 @@
assertEquals(pi.name, cmd);
assertNotNull(pkgInfo);
boolean found = false;
- for (int j=0; j<pkgInfo.permissions.length && !found; j++) {
+ for (int j = 0; j < pkgInfo.permissions.length && !found; j++) {
if (pkgInfo.permissions[j].name.equals(cmd)) {
found = true;
}
@@ -549,7 +575,7 @@
}
if (pkgInfo != null) {
boolean found = false;
- for (int j=0; j<pkgInfo.permissions.length && !found; j++) {
+ for (int j = 0; j < pkgInfo.permissions.length && !found; j++) {
if (pkgInfo.permissions[j].name.equals(cmd)) {
found = true;
}
@@ -560,7 +586,7 @@
}
} else if (mode == PERM_USED || mode == PERM_NOTUSED) {
boolean found = false;
- for (int j=0; j<pkgInfo.requestedPermissions.length && !found; j++) {
+ for (int j = 0; j < pkgInfo.requestedPermissions.length && !found; j++) {
if (pkgInfo.requestedPermissions[j].equals(cmd)) {
found = true;
}
@@ -569,13 +595,11 @@
fail("Permission not requested: " + cmd);
}
if (mode == PERM_USED) {
- if (pm.checkPermission(cmd, pkg)
- != PackageManager.PERMISSION_GRANTED) {
+ if (pm.checkPermission(cmd, pkg) != PackageManager.PERMISSION_GRANTED) {
fail("Permission not granted: " + cmd);
}
} else {
- if (pm.checkPermission(cmd, pkg)
- != PackageManager.PERMISSION_DENIED) {
+ if (pm.checkPermission(cmd, pkg) != PackageManager.PERMISSION_DENIED) {
fail("Permission granted: " + cmd);
}
}
@@ -598,9 +622,8 @@
* copies it into own data directory and invokes
* PackageManager api to install it.
*/
- private void installFromRawResource(InstallParams ip,
- int flags, boolean cleanUp, boolean fail, int result,
- int expInstallLocation) {
+ private void installFromRawResource(InstallParams ip, int flags, boolean cleanUp, boolean fail,
+ int result, int expInstallLocation) throws Exception {
PackageManager pm = mContext.getPackageManager();
PackageParser.Package pkg = ip.pkg;
Uri packageURI = ip.packageURI;
@@ -640,26 +663,25 @@
* copies it into own data directory and invokes
* PackageManager api to install it.
*/
- private InstallParams installFromRawResource(String outFileName,
- int rawResId, int flags, boolean cleanUp, boolean fail, int result,
- int expInstallLocation) {
+ private InstallParams installFromRawResource(String outFileName, int rawResId, int flags,
+ boolean cleanUp, boolean fail, int result, int expInstallLocation) throws Exception {
InstallParams ip = new InstallParams(outFileName, rawResId);
installFromRawResource(ip, flags, cleanUp, fail, result, expInstallLocation);
return ip;
}
@LargeTest
- public void testInstallNormalInternal() {
+ public void testInstallNormalInternal() throws Exception {
sampleInstallFromRawResource(0, true);
}
@LargeTest
- public void testInstallFwdLockedInternal() {
+ public void testInstallFwdLockedInternal() throws Exception {
sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, true);
}
@LargeTest
- public void testInstallSdcard() {
+ public void testInstallSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -669,14 +691,20 @@
sampleInstallFromRawResource(PackageManager.INSTALL_EXTERNAL, true);
}
- /* ------------------------- Test replacing packages --------------*/
+ /* ------------------------- Test replacing packages -------------- */
class ReplaceReceiver extends GenericReceiver {
String pkgName;
+
final static int INVALID = -1;
+
final static int REMOVED = 1;
+
final static int ADDED = 2;
+
final static int REPLACED = 3;
+
int removed = INVALID;
+
// for updated system apps only
boolean update = false;
@@ -729,7 +757,7 @@
* PackageManager api to install first and then replace it
* again.
*/
- private void sampleReplaceFromRawResource(int flags) {
+ private void sampleReplaceFromRawResource(int flags) throws Exception {
InstallParams ip = sampleInstallFromRawResource(flags, false);
boolean replace = ((flags & PackageManager.INSTALL_REPLACE_EXISTING) != 0);
Log.i(TAG, "replace=" + replace);
@@ -751,17 +779,17 @@
}
@LargeTest
- public void testReplaceFailNormalInternal() {
+ public void testReplaceFailNormalInternal() throws Exception {
sampleReplaceFromRawResource(0);
}
@LargeTest
- public void testReplaceFailFwdLockedInternal() {
+ public void testReplaceFailFwdLockedInternal() throws Exception {
sampleReplaceFromRawResource(PackageManager.INSTALL_FORWARD_LOCK);
}
@LargeTest
- public void testReplaceFailSdcard() {
+ public void testReplaceFailSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -771,29 +799,29 @@
}
@LargeTest
- public void testReplaceNormalInternal() {
+ public void testReplaceNormalInternal() throws Exception {
sampleReplaceFromRawResource(PackageManager.INSTALL_REPLACE_EXISTING);
}
@LargeTest
- public void testReplaceFwdLockedInternal() {
- sampleReplaceFromRawResource(PackageManager.INSTALL_REPLACE_EXISTING |
- PackageManager.INSTALL_FORWARD_LOCK);
+ public void testReplaceFwdLockedInternal() throws Exception {
+ sampleReplaceFromRawResource(PackageManager.INSTALL_REPLACE_EXISTING
+ | PackageManager.INSTALL_FORWARD_LOCK);
}
@LargeTest
- public void testReplaceSdcard() {
+ public void testReplaceSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
}
- sampleReplaceFromRawResource(PackageManager.INSTALL_REPLACE_EXISTING |
- PackageManager.INSTALL_EXTERNAL);
+ sampleReplaceFromRawResource(PackageManager.INSTALL_REPLACE_EXISTING
+ | PackageManager.INSTALL_EXTERNAL);
}
/* -------------- Delete tests ---*/
- class DeleteObserver extends IPackageDeleteObserver.Stub {
+ private static class DeleteObserver extends IPackageDeleteObserver.Stub {
public boolean succeeded;
private boolean doneFlag = false;
@@ -870,18 +898,17 @@
}
}
- public void deleteFromRawResource(int iFlags, int dFlags) {
+ public void deleteFromRawResource(int iFlags, int dFlags) throws Exception {
InstallParams ip = sampleInstallFromRawResource(iFlags, false);
boolean retainData = ((dFlags & PackageManager.DELETE_KEEP_DATA) != 0);
GenericReceiver receiver = new DeleteReceiver(ip.pkg.packageName);
- DeleteObserver observer = new DeleteObserver();
try {
assertTrue(invokeDeletePackage(ip.pkg.packageName, dFlags, receiver));
ApplicationInfo info = null;
Log.i(TAG, "okay4");
try {
- info = getPm().getApplicationInfo(ip.pkg.packageName,
- PackageManager.GET_UNINSTALLED_PACKAGES);
+ info = getPm().getApplicationInfo(ip.pkg.packageName,
+ PackageManager.GET_UNINSTALLED_PACKAGES);
} catch (NameNotFoundException e) {
info = null;
}
@@ -901,17 +928,17 @@
}
@LargeTest
- public void testDeleteNormalInternal() {
+ public void testDeleteNormalInternal() throws Exception {
deleteFromRawResource(0, 0);
}
@LargeTest
- public void testDeleteFwdLockedInternal() {
+ public void testDeleteFwdLockedInternal() throws Exception {
deleteFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, 0);
}
@LargeTest
- public void testDeleteSdcard() {
+ public void testDeleteSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -921,17 +948,17 @@
}
@LargeTest
- public void testDeleteNormalInternalRetainData() {
+ public void testDeleteNormalInternalRetainData() throws Exception {
deleteFromRawResource(0, PackageManager.DELETE_KEEP_DATA);
}
@LargeTest
- public void testDeleteFwdLockedInternalRetainData() {
+ public void testDeleteFwdLockedInternalRetainData() throws Exception {
deleteFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, PackageManager.DELETE_KEEP_DATA);
}
@LargeTest
- public void testDeleteSdcardRetainData() {
+ public void testDeleteSdcardRetainData() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -940,10 +967,11 @@
deleteFromRawResource(PackageManager.INSTALL_EXTERNAL, PackageManager.DELETE_KEEP_DATA);
}
- /* sdcard mount/unmount tests ******/
+ /* sdcard mount/unmount tests ***** */
class SdMountReceiver extends GenericReceiver {
String pkgNames[];
+
boolean status = true;
SdMountReceiver(String[] pkgNames) {
@@ -978,6 +1006,7 @@
class SdUnMountReceiver extends GenericReceiver {
String pkgNames[];
+
boolean status = true;
SdUnMountReceiver(String[] pkgNames) {
@@ -1089,14 +1118,14 @@
sm.registerListener(observer);
try {
// Wait on observer
- synchronized(observer) {
+ synchronized (observer) {
getMs().unmountVolume(path, true, false);
long waitTime = 0;
- while((!observer.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
+ while ((!observer.isDone()) && (waitTime < MAX_WAIT_TIME)) {
observer.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
}
- if(!observer.isDone()) {
+ if (!observer.isDone()) {
throw new Exception("Timed out waiting for unmount media notification");
}
return true;
@@ -1109,7 +1138,7 @@
}
}
- private boolean mountFromRawResource() {
+ private boolean mountFromRawResource() throws Exception {
// Install pkg on sdcard
InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_EXTERNAL, false);
if (localLOGV) Log.i(TAG, "Installed pkg on sdcard");
@@ -1136,7 +1165,7 @@
long waitTime = 0;
// Verify we received the broadcast
waitTime = 0;
- while((!receiver.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
+ while ((!receiver.isDone()) && (waitTime < MAX_WAIT_TIME)) {
receiver.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
}
@@ -1149,7 +1178,9 @@
failStr(e);
return false;
} finally {
- if (registeredReceiver) mContext.unregisterReceiver(receiver);
+ if (registeredReceiver) {
+ mContext.unregisterReceiver(receiver);
+ }
// Restore original media state
if (origState) {
mountMedia();
@@ -1167,7 +1198,7 @@
* Make sure the installed package is available.
*/
@LargeTest
- public void testMountSdNormalInternal() {
+ public void testMountSdNormalInternal() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1176,7 +1207,7 @@
assertTrue(mountFromRawResource());
}
- void cleanUpInstall(InstallParams ip) {
+ void cleanUpInstall(InstallParams ip) throws Exception {
if (ip == null) {
return;
}
@@ -1188,7 +1219,8 @@
outFile.delete();
}
}
- void cleanUpInstall(String pkgName) {
+
+ private void cleanUpInstall(String pkgName) throws Exception {
if (pkgName == null) {
return;
}
@@ -1196,20 +1228,22 @@
try {
ApplicationInfo info = getPm().getApplicationInfo(pkgName,
PackageManager.GET_UNINSTALLED_PACKAGES);
+
if (info != null) {
getPm().deletePackage(pkgName, null, 0);
}
- } catch (NameNotFoundException e) {}
+ } catch (NameNotFoundException e) {
+ }
}
@LargeTest
- public void testManifestInstallLocationInternal() {
+ public void testManifestInstallLocationInternal() throws Exception {
installFromRawResource("install.apk", R.raw.install_loc_internal,
0, true, false, -1, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
}
@LargeTest
- public void testManifestInstallLocationSdcard() {
+ public void testManifestInstallLocationSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1220,19 +1254,19 @@
}
@LargeTest
- public void testManifestInstallLocationAuto() {
+ public void testManifestInstallLocationAuto() throws Exception {
installFromRawResource("install.apk", R.raw.install_loc_auto,
0, true, false, -1, PackageInfo.INSTALL_LOCATION_AUTO);
}
@LargeTest
- public void testManifestInstallLocationUnspecified() {
+ public void testManifestInstallLocationUnspecified() throws Exception {
installFromRawResource("install.apk", R.raw.install_loc_unspecified,
0, true, false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
}
@LargeTest
- public void testManifestInstallLocationFwdLockedFlagSdcard() {
+ public void testManifestInstallLocationFwdLockedFlagSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1245,15 +1279,14 @@
}
@LargeTest
- public void testManifestInstallLocationFwdLockedSdcard() {
+ public void testManifestInstallLocationFwdLockedSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
}
installFromRawResource("install.apk", R.raw.install_loc_sdcard,
- PackageManager.INSTALL_FORWARD_LOCK, true, false,
- -1,
+ PackageManager.INSTALL_FORWARD_LOCK, true, false, -1,
PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
}
@@ -1263,7 +1296,7 @@
* the old install location.
*/
@LargeTest
- public void testReplaceFlagInternalSdcard() {
+ public void testReplaceFlagInternalSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1290,7 +1323,7 @@
* install location is retained.
*/
@LargeTest
- public void testReplaceFlagSdcardInternal() {
+ public void testReplaceFlagSdcardInternal() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1312,7 +1345,7 @@
}
@LargeTest
- public void testManifestInstallLocationReplaceInternalSdcard() {
+ public void testManifestInstallLocationReplaceInternalSdcard() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1340,7 +1373,7 @@
}
@LargeTest
- public void testManifestInstallLocationReplaceSdcardInternal() {
+ public void testManifestInstallLocationReplaceSdcardInternal() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1368,9 +1401,13 @@
class MoveReceiver extends GenericReceiver {
String pkgName;
+
final static int INVALID = -1;
+
final static int REMOVED = 1;
+
final static int ADDED = 2;
+
int removed = INVALID;
MoveReceiver(String pkgName) {
@@ -1414,17 +1451,21 @@
private class PackageMoveObserver extends IPackageMoveObserver.Stub {
public int returnCode;
+
private boolean doneFlag = false;
+
public String packageName;
+
public PackageMoveObserver(String pkgName) {
packageName = pkgName;
}
+
public void packageMoved(String packageName, int returnCode) {
Log.i("DEBUG_MOVE::", "pkg = " + packageName + ", " + "ret = " + returnCode);
if (!packageName.equals(this.packageName)) {
return;
}
- synchronized(this) {
+ synchronized (this) {
this.returnCode = returnCode;
doneFlag = true;
notifyAll();
@@ -1436,22 +1477,22 @@
}
}
- public boolean invokeMovePackage(String pkgName, int flags,
- GenericReceiver receiver) throws Exception {
+ public boolean invokeMovePackage(String pkgName, int flags, GenericReceiver receiver)
+ throws Exception {
PackageMoveObserver observer = new PackageMoveObserver(pkgName);
final boolean received = false;
mContext.registerReceiver(receiver, receiver.filter);
try {
// Wait on observer
- synchronized(observer) {
+ synchronized (observer) {
synchronized (receiver) {
getPm().movePackage(pkgName, observer, flags);
long waitTime = 0;
- while((!observer.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
+ while ((!observer.isDone()) && (waitTime < MAX_WAIT_TIME)) {
observer.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
}
- if(!observer.isDone()) {
+ if (!observer.isDone()) {
throw new Exception("Timed out waiting for pkgmove callback");
}
if (observer.returnCode != PackageManager.MOVE_SUCCEEDED) {
@@ -1459,11 +1500,11 @@
}
// Verify we received the broadcast
waitTime = 0;
- while((!receiver.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
+ while ((!receiver.isDone()) && (waitTime < MAX_WAIT_TIME)) {
receiver.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
}
- if(!receiver.isDone()) {
+ if (!receiver.isDone()) {
throw new Exception("Timed out waiting for MOVE notifications");
}
return receiver.received;
@@ -1473,18 +1514,19 @@
mContext.unregisterReceiver(receiver);
}
}
+
private boolean invokeMovePackageFail(String pkgName, int flags, int errCode) throws Exception {
PackageMoveObserver observer = new PackageMoveObserver(pkgName);
try {
// Wait on observer
- synchronized(observer) {
+ synchronized (observer) {
getPm().movePackage(pkgName, observer, flags);
long waitTime = 0;
- while((!observer.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
+ while ((!observer.isDone()) && (waitTime < MAX_WAIT_TIME)) {
observer.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
}
- if(!observer.isDone()) {
+ if (!observer.isDone()) {
throw new Exception("Timed out waiting for pkgmove callback");
}
assertEquals(errCode, observer.returnCode);
@@ -1497,7 +1539,8 @@
private int getDefaultInstallLoc() {
int origDefaultLoc = PackageInfo.INSTALL_LOCATION_AUTO;
try {
- origDefaultLoc = Settings.System.getInt(mContext.getContentResolver(), Settings.Secure.DEFAULT_INSTALL_LOCATION);
+ origDefaultLoc = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.Secure.DEFAULT_INSTALL_LOCATION);
} catch (SettingNotFoundException e1) {
}
return origDefaultLoc;
@@ -1507,6 +1550,7 @@
Settings.System.putInt(mContext.getContentResolver(),
Settings.Secure.DEFAULT_INSTALL_LOCATION, loc);
}
+
/*
* Tests for moving apps between internal and external storage
*/
@@ -1517,9 +1561,8 @@
* again.
*/
- private void moveFromRawResource(String outFileName,
- int rawResId, int installFlags, int moveFlags, boolean cleanUp,
- boolean fail, int result) {
+ private void moveFromRawResource(String outFileName, int rawResId, int installFlags,
+ int moveFlags, boolean cleanUp, boolean fail, int result) throws Exception {
int origDefaultLoc = getDefaultInstallLoc();
InstallParams ip = null;
try {
@@ -1536,8 +1579,7 @@
} else {
// Create receiver based on expRetCode
MoveReceiver receiver = new MoveReceiver(ip.pkg.packageName);
- boolean retCode = invokeMovePackage(ip.pkg.packageName, moveFlags,
- receiver);
+ boolean retCode = invokeMovePackage(ip.pkg.packageName, moveFlags, receiver);
assertTrue(retCode);
ApplicationInfo info = getPm().getApplicationInfo(ip.pkg.packageName, 0);
assertNotNull("ApplicationInfo for recently installed application should exist",
@@ -1569,15 +1611,16 @@
setInstallLoc(origDefaultLoc);
}
}
+
private void sampleMoveFromRawResource(int installFlags, int moveFlags, boolean fail,
- int result) {
+ int result) throws Exception {
moveFromRawResource("install.apk",
R.raw.install, installFlags, moveFlags, true,
fail, result);
}
@LargeTest
- public void testMoveAppInternalToExternal() {
+ public void testMoveAppInternalToExternal() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1591,7 +1634,7 @@
}
@LargeTest
- public void testMoveAppInternalToInternal() {
+ public void testMoveAppInternalToInternal() throws Exception {
int installFlags = PackageManager.INSTALL_INTERNAL;
int moveFlags = PackageManager.MOVE_INTERNAL;
boolean fail = true;
@@ -1600,7 +1643,7 @@
}
@LargeTest
- public void testMoveAppExternalToExternal() {
+ public void testMoveAppExternalToExternal() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1614,7 +1657,7 @@
}
@LargeTest
- public void testMoveAppExternalToInternal() {
+ public void testMoveAppExternalToInternal() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1628,7 +1671,7 @@
}
@LargeTest
- public void testMoveAppForwardLocked() {
+ public void testMoveAppForwardLocked() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1642,7 +1685,7 @@
}
@LargeTest
- public void testMoveAppFailInternalToExternalDelete() {
+ public void testMoveAppFailInternalToExternalDelete() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1682,7 +1725,7 @@
* and package installed on sdcard via package manager flag.
*/
@LargeTest
- public void testInstallSdcardUnmount() {
+ public void testInstallSdcardUnmount() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1712,7 +1755,7 @@
* on sdcard. Make sure it gets installed on internal flash.
*/
@LargeTest
- public void testInstallManifestSdcardUnmount() {
+ public void testInstallManifestSdcardUnmount() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1735,22 +1778,22 @@
}
}
- /*---------- Recommended install location tests ----*/
- /* Precedence: FlagManifestExistingUser
- * PrecedenceSuffixes:
- * Flag : FlagI, FlagE, FlagF
- * I - internal, E - external, F - forward locked, Flag suffix absent if not using any option.
- * Manifest: ManifestI, ManifestE, ManifestA, Manifest suffix absent if not using any option.
- * Existing: Existing suffix absent if not existing.
- * User: UserI, UserE, UserA, User suffix absent if not existing.
- *
- */
+ /*---------- Recommended install location tests ----*/
+ /*
+ * PrecedenceSuffixes:
+ * Flag : FlagI, FlagE, FlagF
+ * I - internal, E - external, F - forward locked, Flag suffix absent if not using any option.
+ * Manifest: ManifestI, ManifestE, ManifestA, Manifest suffix absent if not using any option.
+ * Existing: Existing suffix absent if not existing.
+ * User: UserI, UserE, UserA, User suffix absent if not existing.
+ *
+ */
/*
* Install an app on internal flash
*/
@LargeTest
- public void testFlagI() {
+ public void testFlagI() throws Exception {
sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, true);
}
@@ -1758,7 +1801,7 @@
* Install an app on sdcard.
*/
@LargeTest
- public void testFlagE() {
+ public void testFlagE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1771,7 +1814,7 @@
* Install an app forward-locked.
*/
@LargeTest
- public void testFlagF() {
+ public void testFlagF() throws Exception {
sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, true);
}
@@ -1779,7 +1822,7 @@
* Install an app with both internal and external flags set. should fail
*/
@LargeTest
- public void testFlagIE() {
+ public void testFlagIE() throws Exception {
installFromRawResource("install.apk", R.raw.install,
PackageManager.INSTALL_EXTERNAL | PackageManager.INSTALL_INTERNAL,
false,
@@ -1791,7 +1834,7 @@
* Install an app with both internal and forward-lock flags set.
*/
@LargeTest
- public void testFlagIF() {
+ public void testFlagIF() throws Exception {
sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK
| PackageManager.INSTALL_INTERNAL, true);
}
@@ -1800,7 +1843,7 @@
* Install an app with both external and forward-lock flags set.
*/
@LargeTest
- public void testFlagEF() {
+ public void testFlagEF() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1815,7 +1858,7 @@
* lock. Should fail.
*/
@LargeTest
- public void testFlagIEF() {
+ public void testFlagIEF() throws Exception {
installFromRawResource("install.apk", R.raw.install,
PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_INTERNAL |
PackageManager.INSTALL_EXTERNAL,
@@ -1824,66 +1867,66 @@
PackageInfo.INSTALL_LOCATION_AUTO);
}
- /*
- * Install an app with both internal and manifest option set.
- * should install on internal.
- */
- @LargeTest
- public void testFlagIManifestI() {
- installFromRawResource("install.apk", R.raw.install_loc_internal,
- PackageManager.INSTALL_INTERNAL,
- true,
- false, -1,
- PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
- }
- /*
- * Install an app with both internal and manifest preference for
- * preferExternal. Should install on internal.
- */
- @LargeTest
- public void testFlagIManifestE() {
- installFromRawResource("install.apk", R.raw.install_loc_sdcard,
- PackageManager.INSTALL_INTERNAL,
- true,
- false, -1,
- PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
- }
- /*
- * Install an app with both internal and manifest preference for
- * auto. should install internal.
- */
- @LargeTest
- public void testFlagIManifestA() {
- installFromRawResource("install.apk", R.raw.install_loc_auto,
- PackageManager.INSTALL_INTERNAL,
- true,
- false, -1,
- PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
- }
- /*
- * Install an app with both external and manifest option set.
- * should install externally.
- */
- @LargeTest
- public void testFlagEManifestI() {
+ /*
+ * Install an app with both internal and manifest option set.
+ * should install on internal.
+ */
+ @LargeTest
+ public void testFlagIManifestI() throws Exception {
+ installFromRawResource("install.apk", R.raw.install_loc_internal,
+ PackageManager.INSTALL_INTERNAL,
+ true,
+ false, -1,
+ PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+ }
+ /*
+ * Install an app with both internal and manifest preference for
+ * preferExternal. Should install on internal.
+ */
+ @LargeTest
+ public void testFlagIManifestE() throws Exception {
+ installFromRawResource("install.apk", R.raw.install_loc_sdcard,
+ PackageManager.INSTALL_INTERNAL,
+ true,
+ false, -1,
+ PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+ }
+ /*
+ * Install an app with both internal and manifest preference for
+ * auto. should install internal.
+ */
+ @LargeTest
+ public void testFlagIManifestA() throws Exception {
+ installFromRawResource("install.apk", R.raw.install_loc_auto,
+ PackageManager.INSTALL_INTERNAL,
+ true,
+ false, -1,
+ PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+ }
+ /*
+ * Install an app with both external and manifest option set.
+ * should install externally.
+ */
+ @LargeTest
+ public void testFlagEManifestI() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
}
- installFromRawResource("install.apk", R.raw.install_loc_internal,
- PackageManager.INSTALL_EXTERNAL,
- true,
- false, -1,
- PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
- }
+ installFromRawResource("install.apk", R.raw.install_loc_internal,
+ PackageManager.INSTALL_EXTERNAL,
+ true,
+ false, -1,
+ PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+ }
- /*
- * Install an app with both external and manifest preference for
- * preferExternal. Should install externally.
- */
- @LargeTest
- public void testFlagEManifestE() {
+ /*
+ * Install an app with both external and manifest preference for
+ * preferExternal. Should install externally.
+ */
+ @LargeTest
+ public void testFlagEManifestE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1901,7 +1944,7 @@
* auto. should install on external media.
*/
@LargeTest
- public void testFlagEManifestA() {
+ public void testFlagEManifestA() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1919,7 +1962,7 @@
* internal. should install internally.
*/
@LargeTest
- public void testFlagFManifestI() {
+ public void testFlagFManifestI() throws Exception {
installFromRawResource("install.apk", R.raw.install_loc_internal,
PackageManager.INSTALL_FORWARD_LOCK,
true,
@@ -1932,7 +1975,7 @@
* preferExternal. Should install externally.
*/
@LargeTest
- public void testFlagFManifestE() {
+ public void testFlagFManifestE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1950,7 +1993,7 @@
* should install externally.
*/
@LargeTest
- public void testFlagFManifestA() {
+ public void testFlagFManifestA() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -1963,7 +2006,8 @@
PackageInfo.INSTALL_LOCATION_AUTO);
}
- /* The following test functions verify install location for existing apps.
+ /*
+ * The following test functions verify install location for existing apps.
* ie existing app can be installed internally or externally. If install
* flag is explicitly set it should override current location. If manifest location
* is set, that should over ride current location too. if not the existing install
@@ -1971,7 +2015,7 @@
* testFlagI/E/F/ExistingI/E -
*/
@LargeTest
- public void testFlagIExistingI() {
+ public void testFlagIExistingI() throws Exception {
int iFlags = PackageManager.INSTALL_INTERNAL;
int rFlags = PackageManager.INSTALL_INTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
// First install.
@@ -1989,7 +2033,7 @@
}
@LargeTest
- public void testFlagIExistingE() {
+ public void testFlagIExistingE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2012,7 +2056,7 @@
}
@LargeTest
- public void testFlagEExistingI() {
+ public void testFlagEExistingI() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2035,7 +2079,7 @@
}
@LargeTest
- public void testFlagEExistingE() {
+ public void testFlagEExistingE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2058,7 +2102,7 @@
}
@LargeTest
- public void testFlagFExistingI() {
+ public void testFlagFExistingI() throws Exception {
int iFlags = PackageManager.INSTALL_INTERNAL;
int rFlags = PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_REPLACE_EXISTING;
// First install.
@@ -2076,7 +2120,7 @@
}
@LargeTest
- public void testFlagFExistingE() {
+ public void testFlagFExistingE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2106,7 +2150,7 @@
* TODO out of memory fall back behaviour.
*/
@LargeTest
- public void testManifestI() {
+ public void testManifestI() throws Exception {
installFromRawResource("install.apk", R.raw.install_loc_internal,
0,
true,
@@ -2115,7 +2159,7 @@
}
@LargeTest
- public void testManifestE() {
+ public void testManifestE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2129,7 +2173,7 @@
}
@LargeTest
- public void testManifestA() {
+ public void testManifestA() throws Exception {
installFromRawResource("install.apk", R.raw.install_loc_auto,
0,
true,
@@ -2145,7 +2189,7 @@
* testManifestI/E/AExistingI/E
*/
@LargeTest
- public void testManifestIExistingI() {
+ public void testManifestIExistingI() throws Exception {
int iFlags = PackageManager.INSTALL_INTERNAL;
int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
// First install.
@@ -2163,7 +2207,7 @@
}
@LargeTest
- public void testManifestIExistingE() {
+ public void testManifestIExistingE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2186,7 +2230,7 @@
}
@LargeTest
- public void testManifestEExistingI() {
+ public void testManifestEExistingI() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2209,7 +2253,7 @@
}
@LargeTest
- public void testManifestEExistingE() {
+ public void testManifestEExistingE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2232,7 +2276,7 @@
}
@LargeTest
- public void testManifestAExistingI() {
+ public void testManifestAExistingI() throws Exception {
int iFlags = PackageManager.INSTALL_INTERNAL;
int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
// First install.
@@ -2250,7 +2294,7 @@
}
@LargeTest
- public void testManifestAExistingE() {
+ public void testManifestAExistingE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2272,55 +2316,56 @@
PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
}
- /*
- * The following set of tests check install location for existing
- * application based on user setting.
- */
- private int getExpectedInstallLocation(int userSetting) {
- int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
- boolean enable = getUserSettingSetInstallLocation();
- if (enable) {
- if (userSetting == PackageHelper.APP_INSTALL_AUTO) {
- iloc = PackageInfo.INSTALL_LOCATION_AUTO;
- } else if (userSetting == PackageHelper.APP_INSTALL_EXTERNAL) {
- iloc = PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL;
- } else if (userSetting == PackageHelper.APP_INSTALL_INTERNAL) {
- iloc = PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY;
- }
- }
- return iloc;
- }
- private void setExistingXUserX(int userSetting, int iFlags, int iloc) {
- int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
- // First install.
- installFromRawResource("install.apk", R.raw.install,
- iFlags,
- false,
- false, -1,
- PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
- int origSetting = getDefaultInstallLoc();
- try {
- // Set user setting
- setInstallLoc(userSetting);
- // Replace now
- installFromRawResource("install.apk", R.raw.install,
- rFlags,
- true,
- false, -1,
- iloc);
- } finally {
- setInstallLoc(origSetting);
- }
- }
- @LargeTest
- public void testExistingIUserI() {
- int userSetting = PackageHelper.APP_INSTALL_INTERNAL;
- int iFlags = PackageManager.INSTALL_INTERNAL;
- setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
- }
+ /*
+ * The following set of tests check install location for existing
+ * application based on user setting.
+ */
+ private int getExpectedInstallLocation(int userSetting) {
+ int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
+ boolean enable = getUserSettingSetInstallLocation();
+ if (enable) {
+ if (userSetting == PackageHelper.APP_INSTALL_AUTO) {
+ iloc = PackageInfo.INSTALL_LOCATION_AUTO;
+ } else if (userSetting == PackageHelper.APP_INSTALL_EXTERNAL) {
+ iloc = PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL;
+ } else if (userSetting == PackageHelper.APP_INSTALL_INTERNAL) {
+ iloc = PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY;
+ }
+ }
+ return iloc;
+ }
+
+ private void setExistingXUserX(int userSetting, int iFlags, int iloc) throws Exception {
+ int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
+ // First install.
+ installFromRawResource("install.apk", R.raw.install,
+ iFlags,
+ false,
+ false, -1,
+ PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
+ int origSetting = getDefaultInstallLoc();
+ try {
+ // Set user setting
+ setInstallLoc(userSetting);
+ // Replace now
+ installFromRawResource("install.apk", R.raw.install,
+ rFlags,
+ true,
+ false, -1,
+ iloc);
+ } finally {
+ setInstallLoc(origSetting);
+ }
+ }
+ @LargeTest
+ public void testExistingIUserI() throws Exception {
+ int userSetting = PackageHelper.APP_INSTALL_INTERNAL;
+ int iFlags = PackageManager.INSTALL_INTERNAL;
+ setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+ }
@LargeTest
- public void testExistingIUserE() {
+ public void testExistingIUserE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2331,15 +2376,15 @@
setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
}
- @LargeTest
- public void testExistingIUserA() {
- int userSetting = PackageHelper.APP_INSTALL_AUTO;
- int iFlags = PackageManager.INSTALL_INTERNAL;
- setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
- }
+ @LargeTest
+ public void testExistingIUserA() throws Exception {
+ int userSetting = PackageHelper.APP_INSTALL_AUTO;
+ int iFlags = PackageManager.INSTALL_INTERNAL;
+ setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+ }
@LargeTest
- public void testExistingEUserI() {
+ public void testExistingEUserI() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2351,7 +2396,7 @@
}
@LargeTest
- public void testExistingEUserE() {
+ public void testExistingEUserE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2363,7 +2408,7 @@
}
@LargeTest
- public void testExistingEUserA() {
+ public void testExistingEUserA() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2374,52 +2419,53 @@
setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
}
- /*
- * The following set of tests verify that the user setting defines
- * the install location.
- *
- */
- private boolean getUserSettingSetInstallLocation() {
- try {
- return Settings.System.getInt(mContext.getContentResolver(), Settings.Secure.SET_INSTALL_LOCATION) != 0;
+ /*
+ * The following set of tests verify that the user setting defines
+ * the install location.
+ *
+ */
+ private boolean getUserSettingSetInstallLocation() {
+ try {
+ return Settings.System.getInt(mContext.getContentResolver(), Settings.Secure.SET_INSTALL_LOCATION) != 0;
- } catch (SettingNotFoundException e1) {
- }
- return false;
- }
+ } catch (SettingNotFoundException e1) {
+ }
+ return false;
+ }
- private void setUserSettingSetInstallLocation(boolean value) {
- Settings.System.putInt(mContext.getContentResolver(),
- Settings.Secure.SET_INSTALL_LOCATION, value ? 1 : 0);
- }
- private void setUserX(boolean enable, int userSetting, int iloc) {
- boolean origUserSetting = getUserSettingSetInstallLocation();
- int origSetting = getDefaultInstallLoc();
- try {
- setUserSettingSetInstallLocation(enable);
- // Set user setting
- setInstallLoc(userSetting);
- // Replace now
- installFromRawResource("install.apk", R.raw.install,
- 0,
- true,
- false, -1,
- iloc);
- } finally {
- // Restore original setting
- setUserSettingSetInstallLocation(origUserSetting);
- setInstallLoc(origSetting);
- }
- }
- @LargeTest
- public void testUserI() {
- int userSetting = PackageHelper.APP_INSTALL_INTERNAL;
- int iloc = getExpectedInstallLocation(userSetting);
- setUserX(true, userSetting, iloc);
- }
+ private void setUserSettingSetInstallLocation(boolean value) {
+ Settings.System.putInt(mContext.getContentResolver(),
+ Settings.Secure.SET_INSTALL_LOCATION, value ? 1 : 0);
+ }
+
+ private void setUserX(boolean enable, int userSetting, int iloc) throws Exception {
+ boolean origUserSetting = getUserSettingSetInstallLocation();
+ int origSetting = getDefaultInstallLoc();
+ try {
+ setUserSettingSetInstallLocation(enable);
+ // Set user setting
+ setInstallLoc(userSetting);
+ // Replace now
+ installFromRawResource("install.apk", R.raw.install,
+ 0,
+ true,
+ false, -1,
+ iloc);
+ } finally {
+ // Restore original setting
+ setUserSettingSetInstallLocation(origUserSetting);
+ setInstallLoc(origSetting);
+ }
+ }
+ @LargeTest
+ public void testUserI() throws Exception {
+ int userSetting = PackageHelper.APP_INSTALL_INTERNAL;
+ int iloc = getExpectedInstallLocation(userSetting);
+ setUserX(true, userSetting, iloc);
+ }
@LargeTest
- public void testUserE() {
+ public void testUserE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2430,25 +2476,26 @@
setUserX(true, userSetting, iloc);
}
- @LargeTest
- public void testUserA() {
- int userSetting = PackageHelper.APP_INSTALL_AUTO;
- int iloc = getExpectedInstallLocation(userSetting);
- setUserX(true, userSetting, iloc);
- }
- /*
- * The following set of tests turn on/off the basic
- * user setting for turning on install location.
- */
- @LargeTest
- public void testUserPrefOffUserI() {
- int userSetting = PackageHelper.APP_INSTALL_INTERNAL;
- int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
- setUserX(false, userSetting, iloc);
- }
+ @LargeTest
+ public void testUserA() throws Exception {
+ int userSetting = PackageHelper.APP_INSTALL_AUTO;
+ int iloc = getExpectedInstallLocation(userSetting);
+ setUserX(true, userSetting, iloc);
+ }
+
+ /*
+ * The following set of tests turn on/off the basic
+ * user setting for turning on install location.
+ */
+ @LargeTest
+ public void testUserPrefOffUserI() throws Exception {
+ int userSetting = PackageHelper.APP_INSTALL_INTERNAL;
+ int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
+ setUserX(false, userSetting, iloc);
+ }
@LargeTest
- public void testUserPrefOffUserE() {
+ public void testUserPrefOffUserE() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2459,12 +2506,12 @@
setUserX(false, userSetting, iloc);
}
- @LargeTest
- public void testUserPrefOffA() {
- int userSetting = PackageHelper.APP_INSTALL_AUTO;
- int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
- setUserX(false, userSetting, iloc);
- }
+ @LargeTest
+ public void testUserPrefOffA() throws Exception {
+ int userSetting = PackageHelper.APP_INSTALL_AUTO;
+ int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
+ setUserX(false, userSetting, iloc);
+ }
static final String BASE_PERMISSIONS_DEFINED[] = new String[] {
PERM_PACKAGE, "com.android.unit_tests.install_decl_perm",
@@ -2511,7 +2558,7 @@
* Ensure that permissions are properly declared.
*/
@LargeTest
- public void testInstallDeclaresPermissions() {
+ public void testInstallDeclaresPermissions() throws Exception {
InstallParams ip = null;
InstallParams ip2 = null;
try {
@@ -2637,7 +2684,7 @@
* Ensure that permissions are properly declared.
*/
@LargeTest
- public void testInstallOnSdPermissionsUnmount() {
+ public void testInstallOnSdPermissionsUnmount() throws Exception {
InstallParams ip = null;
boolean origMediaState = checkMediaState(Environment.MEDIA_MOUNTED);
try {
@@ -2669,7 +2716,7 @@
* naming convention for secure containers.
*/
@LargeTest
- public void testInstallSdcardStaleContainer() {
+ public void testInstallSdcardStaleContainer() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2718,7 +2765,7 @@
* and verified that the re-installation on internal storage takes precedence.
*/
@LargeTest
- public void testInstallSdcardStaleContainerReinstall() {
+ public void testInstallSdcardStaleContainerReinstall() throws Exception {
// Do not run on devices with emulated external storage.
if (Environment.isExternalStorageEmulated()) {
return;
@@ -2748,7 +2795,7 @@
false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
mountMedia();
// Verify that the app installed is on internal storage.
- assertInstall(pkg, 0, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+ assertInstall(pkg, 0, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
} catch (Exception e) {
failStr(e.getMessage());
} finally {
@@ -2765,18 +2812,29 @@
* different certificates.
*/
private int APP1_UNSIGNED = R.raw.install_app1_unsigned;
+
private int APP1_CERT1 = R.raw.install_app1_cert1;
+
private int APP1_CERT2 = R.raw.install_app1_cert2;
+
private int APP1_CERT1_CERT2 = R.raw.install_app1_cert1_cert2;
+
private int APP1_CERT3_CERT4 = R.raw.install_app1_cert3_cert4;
+
private int APP1_CERT3 = R.raw.install_app1_cert3;
+
private int APP2_UNSIGNED = R.raw.install_app2_unsigned;
+
private int APP2_CERT1 = R.raw.install_app2_cert1;
+
private int APP2_CERT2 = R.raw.install_app2_cert2;
+
private int APP2_CERT1_CERT2 = R.raw.install_app2_cert1_cert2;
+
private int APP2_CERT3 = R.raw.install_app2_cert3;
- private InstallParams replaceCerts(int apk1, int apk2, boolean cleanUp, boolean fail, int retCode) {
+ private InstallParams replaceCerts(int apk1, int apk2, boolean cleanUp, boolean fail,
+ int retCode) throws Exception {
int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
String apk1Name = "install1.apk";
String apk2Name = "install2.apk";
@@ -2796,12 +2854,13 @@
}
return null;
}
+
/*
* Test that an app signed with two certificates can be upgraded by the
* same app signed with two certificates.
*/
@LargeTest
- public void testReplaceMatchAllCerts() {
+ public void testReplaceMatchAllCerts() throws Exception {
replaceCerts(APP1_CERT1_CERT2, APP1_CERT1_CERT2, true, false, -1);
}
@@ -2810,53 +2869,58 @@
* by an app signed with a different certificate.
*/
@LargeTest
- public void testReplaceMatchNoCerts1() {
+ public void testReplaceMatchNoCerts1() throws Exception {
replaceCerts(APP1_CERT1_CERT2, APP1_CERT3, true, true,
PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES);
}
+
/*
* Test that an app signed with two certificates cannot be upgraded
* by an app signed with a different certificate.
*/
@LargeTest
- public void testReplaceMatchNoCerts2() {
+ public void testReplaceMatchNoCerts2() throws Exception {
replaceCerts(APP1_CERT1_CERT2, APP1_CERT3_CERT4, true, true,
PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES);
}
+
/*
* Test that an app signed with two certificates cannot be upgraded by
* an app signed with a subset of initial certificates.
*/
@LargeTest
- public void testReplaceMatchSomeCerts1() {
+ public void testReplaceMatchSomeCerts1() throws Exception {
replaceCerts(APP1_CERT1_CERT2, APP1_CERT1, true, true,
PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES);
}
+
/*
* Test that an app signed with two certificates cannot be upgraded by
* an app signed with the last certificate.
*/
@LargeTest
- public void testReplaceMatchSomeCerts2() {
+ public void testReplaceMatchSomeCerts2() throws Exception {
replaceCerts(APP1_CERT1_CERT2, APP1_CERT2, true, true,
PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES);
}
+
/*
* Test that an app signed with a certificate can be upgraded by app
* signed with a superset of certificates.
*/
@LargeTest
- public void testReplaceMatchMoreCerts() {
+ public void testReplaceMatchMoreCerts() throws Exception {
replaceCerts(APP1_CERT1, APP1_CERT1_CERT2, true, true,
PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES);
}
+
/*
* Test that an app signed with a certificate can be upgraded by app
* signed with a superset of certificates. Then verify that the an app
* signed with the original set of certs cannot upgrade the new one.
*/
@LargeTest
- public void testReplaceMatchMoreCertsReplaceSomeCerts() {
+ public void testReplaceMatchMoreCertsReplaceSomeCerts() throws Exception {
InstallParams ip = replaceCerts(APP1_CERT1, APP1_CERT1_CERT2, false, true,
PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES);
try {
@@ -2872,45 +2936,51 @@
}
}
}
- /*
- * The following tests are related to testing the checkSignatures
- * api.
+
+ /**
+ * The following tests are related to testing the checkSignatures api.
*/
- private void checkSignatures(int apk1, int apk2, int expMatchResult) {
+ private void checkSignatures(int apk1, int apk2, int expMatchResult) throws Exception {
checkSharedSignatures(apk1, apk2, true, false, -1, expMatchResult);
}
+
@LargeTest
- public void testCheckSignaturesAllMatch() {
+ public void testCheckSignaturesAllMatch() throws Exception {
int apk1 = APP1_CERT1_CERT2;
int apk2 = APP2_CERT1_CERT2;
checkSignatures(apk1, apk2, PackageManager.SIGNATURE_MATCH);
}
+
@LargeTest
- public void testCheckSignaturesNoMatch() {
+ public void testCheckSignaturesNoMatch() throws Exception {
int apk1 = APP1_CERT1;
int apk2 = APP2_CERT2;
checkSignatures(apk1, apk2, PackageManager.SIGNATURE_NO_MATCH);
}
+
@LargeTest
- public void testCheckSignaturesSomeMatch1() {
+ public void testCheckSignaturesSomeMatch1() throws Exception {
int apk1 = APP1_CERT1_CERT2;
int apk2 = APP2_CERT1;
checkSignatures(apk1, apk2, PackageManager.SIGNATURE_NO_MATCH);
}
+
@LargeTest
- public void testCheckSignaturesSomeMatch2() {
+ public void testCheckSignaturesSomeMatch2() throws Exception {
int apk1 = APP1_CERT1_CERT2;
int apk2 = APP2_CERT2;
checkSignatures(apk1, apk2, PackageManager.SIGNATURE_NO_MATCH);
}
+
@LargeTest
- public void testCheckSignaturesMoreMatch() {
+ public void testCheckSignaturesMoreMatch() throws Exception {
int apk1 = APP1_CERT1;
int apk2 = APP2_CERT1_CERT2;
checkSignatures(apk1, apk2, PackageManager.SIGNATURE_NO_MATCH);
}
+
@LargeTest
- public void testCheckSignaturesUnknown() {
+ public void testCheckSignaturesUnknown() throws Exception {
int apk1 = APP1_CERT1_CERT2;
int apk2 = APP2_CERT1_CERT2;
String apk1Name = "install1.apk";
@@ -2938,8 +3008,9 @@
}
}
}
+
@LargeTest
- public void testInstallNoCertificates() {
+ public void testInstallNoCertificates() throws Exception {
int apk1 = APP1_UNSIGNED;
String apk1Name = "install1.apk";
InstallParams ip1 = null;
@@ -2951,18 +3022,29 @@
} finally {
}
}
- /* The following tests are related to apps using shared uids signed
- * with different certs.
+
+ /*
+ * The following tests are related to apps using shared uids signed with
+ * different certs.
*/
private int SHARED1_UNSIGNED = R.raw.install_shared1_unsigned;
+
private int SHARED1_CERT1 = R.raw.install_shared1_cert1;
+
private int SHARED1_CERT2 = R.raw.install_shared1_cert2;
+
private int SHARED1_CERT1_CERT2 = R.raw.install_shared1_cert1_cert2;
+
private int SHARED2_UNSIGNED = R.raw.install_shared2_unsigned;
+
private int SHARED2_CERT1 = R.raw.install_shared2_cert1;
+
private int SHARED2_CERT2 = R.raw.install_shared2_cert2;
+
private int SHARED2_CERT1_CERT2 = R.raw.install_shared2_cert1_cert2;
- private void checkSharedSignatures(int apk1, int apk2, boolean cleanUp, boolean fail, int retCode, int expMatchResult) {
+
+ private void checkSharedSignatures(int apk1, int apk2, boolean cleanUp, boolean fail,
+ int retCode, int expMatchResult) throws Exception {
String apk1Name = "install1.apk";
String apk2Name = "install2.apk";
PackageParser.Package pkg1 = getParsedPackage(apk1Name, apk1);
@@ -2972,16 +3054,16 @@
// Clean up before testing first.
cleanUpInstall(pkg1.packageName);
cleanUpInstall(pkg2.packageName);
- installFromRawResource(apk1Name, apk1, 0, false,
- false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
+ installFromRawResource(apk1Name, apk1, 0, false, false, -1,
+ PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
if (fail) {
- installFromRawResource(apk2Name, apk2, 0, false,
- true, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
+ installFromRawResource(apk2Name, apk2, 0, false, true, retCode,
+ PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
} else {
- installFromRawResource(apk2Name, apk2, 0, false,
- false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
- int match = mContext.getPackageManager().checkSignatures(
- pkg1.packageName, pkg2.packageName);
+ installFromRawResource(apk2Name, apk2, 0, false, false, -1,
+ PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
+ int match = mContext.getPackageManager().checkSignatures(pkg1.packageName,
+ pkg2.packageName);
assertEquals(expMatchResult, match);
}
} finally {
@@ -2991,8 +3073,9 @@
}
}
}
+
@LargeTest
- public void testCheckSignaturesSharedAllMatch() {
+ public void testCheckSignaturesSharedAllMatch() throws Exception {
int apk1 = SHARED1_CERT1_CERT2;
int apk2 = SHARED2_CERT1_CERT2;
boolean fail = false;
@@ -3000,8 +3083,9 @@
int expMatchResult = PackageManager.SIGNATURE_MATCH;
checkSharedSignatures(apk1, apk2, true, fail, retCode, expMatchResult);
}
+
@LargeTest
- public void testCheckSignaturesSharedNoMatch() {
+ public void testCheckSignaturesSharedNoMatch() throws Exception {
int apk1 = SHARED1_CERT1;
int apk2 = SHARED2_CERT2;
boolean fail = true;
@@ -3009,11 +3093,13 @@
int expMatchResult = -1;
checkSharedSignatures(apk1, apk2, true, fail, retCode, expMatchResult);
}
+
/*
- * Test that an app signed with cert1 and cert2 cannot be replaced when signed with cert1 alone.
+ * Test that an app signed with cert1 and cert2 cannot be replaced when
+ * signed with cert1 alone.
*/
@LargeTest
- public void testCheckSignaturesSharedSomeMatch1() {
+ public void testCheckSignaturesSharedSomeMatch1() throws Exception {
int apk1 = SHARED1_CERT1_CERT2;
int apk2 = SHARED2_CERT1;
boolean fail = true;
@@ -3021,11 +3107,13 @@
int expMatchResult = -1;
checkSharedSignatures(apk1, apk2, true, fail, retCode, expMatchResult);
}
+
/*
- * Test that an app signed with cert1 and cert2 cannot be replaced when signed with cert2 alone.
+ * Test that an app signed with cert1 and cert2 cannot be replaced when
+ * signed with cert2 alone.
*/
@LargeTest
- public void testCheckSignaturesSharedSomeMatch2() {
+ public void testCheckSignaturesSharedSomeMatch2() throws Exception {
int apk1 = SHARED1_CERT1_CERT2;
int apk2 = SHARED2_CERT2;
boolean fail = true;
@@ -3033,8 +3121,9 @@
int expMatchResult = -1;
checkSharedSignatures(apk1, apk2, true, fail, retCode, expMatchResult);
}
+
@LargeTest
- public void testCheckSignaturesSharedUnknown() {
+ public void testCheckSignaturesSharedUnknown() throws Exception {
int apk1 = SHARED1_CERT1_CERT2;
int apk2 = SHARED2_CERT1_CERT2;
String apk1Name = "install1.apk";
@@ -3060,23 +3149,25 @@
}
@LargeTest
- public void testReplaceFirstSharedMatchAllCerts() {
+ public void testReplaceFirstSharedMatchAllCerts() throws Exception {
int apk1 = SHARED1_CERT1;
int apk2 = SHARED2_CERT1;
int rapk1 = SHARED1_CERT1;
checkSignatures(apk1, apk2, PackageManager.SIGNATURE_MATCH);
replaceCerts(apk1, rapk1, true, false, -1);
}
+
@LargeTest
- public void testReplaceSecondSharedMatchAllCerts() {
+ public void testReplaceSecondSharedMatchAllCerts() throws Exception {
int apk1 = SHARED1_CERT1;
int apk2 = SHARED2_CERT1;
int rapk2 = SHARED2_CERT1;
checkSignatures(apk1, apk2, PackageManager.SIGNATURE_MATCH);
replaceCerts(apk2, rapk2, true, false, -1);
}
+
@LargeTest
- public void testReplaceFirstSharedMatchSomeCerts() {
+ public void testReplaceFirstSharedMatchSomeCerts() throws Exception {
int apk1 = SHARED1_CERT1_CERT2;
int apk2 = SHARED2_CERT1_CERT2;
int rapk1 = SHARED1_CERT1;
@@ -3086,8 +3177,9 @@
installFromRawResource("install.apk", rapk1, PackageManager.INSTALL_REPLACE_EXISTING, true,
fail, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
}
+
@LargeTest
- public void testReplaceSecondSharedMatchSomeCerts() {
+ public void testReplaceSecondSharedMatchSomeCerts() throws Exception {
int apk1 = SHARED1_CERT1_CERT2;
int apk2 = SHARED2_CERT1_CERT2;
int rapk2 = SHARED2_CERT1;
@@ -3097,8 +3189,9 @@
installFromRawResource("install.apk", rapk2, PackageManager.INSTALL_REPLACE_EXISTING, true,
fail, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
}
+
@LargeTest
- public void testReplaceFirstSharedMatchNoCerts() {
+ public void testReplaceFirstSharedMatchNoCerts() throws Exception {
int apk1 = SHARED1_CERT1;
int apk2 = SHARED2_CERT1;
int rapk1 = SHARED1_CERT2;
@@ -3108,8 +3201,9 @@
installFromRawResource("install.apk", rapk1, PackageManager.INSTALL_REPLACE_EXISTING, true,
fail, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
}
+
@LargeTest
- public void testReplaceSecondSharedMatchNoCerts() {
+ public void testReplaceSecondSharedMatchNoCerts() throws Exception {
int apk1 = SHARED1_CERT1;
int apk2 = SHARED2_CERT1;
int rapk2 = SHARED2_CERT2;
@@ -3119,8 +3213,9 @@
installFromRawResource("install.apk", rapk2, PackageManager.INSTALL_REPLACE_EXISTING, true,
fail, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
}
+
@LargeTest
- public void testReplaceFirstSharedMatchMoreCerts() {
+ public void testReplaceFirstSharedMatchMoreCerts() throws Exception {
int apk1 = SHARED1_CERT1;
int apk2 = SHARED2_CERT1;
int rapk1 = SHARED1_CERT1_CERT2;
@@ -3130,8 +3225,9 @@
installFromRawResource("install.apk", rapk1, PackageManager.INSTALL_REPLACE_EXISTING, true,
fail, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
}
+
@LargeTest
- public void testReplaceSecondSharedMatchMoreCerts() {
+ public void testReplaceSecondSharedMatchMoreCerts() throws Exception {
int apk1 = SHARED1_CERT1;
int apk2 = SHARED2_CERT1;
int rapk2 = SHARED2_CERT1_CERT2;
@@ -3152,34 +3248,34 @@
* features.
*/
@LargeTest
- public void testUsesFeatureUnknownFeature() {
+ public void testUsesFeatureUnknownFeature() throws Exception {
int retCode = PackageManager.INSTALL_SUCCEEDED;
installFromRawResource("install.apk", R.raw.install_uses_feature, 0, true, false, retCode,
PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
}
@LargeTest
- public void testInstallNonexistentFile() {
+ public void testInstallNonexistentFile() throws Exception {
int retCode = PackageManager.INSTALL_FAILED_INVALID_URI;
File invalidFile = new File("/nonexistent-file.apk");
invokeInstallPackageFail(Uri.fromFile(invalidFile), 0, retCode);
}
@SmallTest
- public void testGetVerifierDeviceIdentity() {
+ public void testGetVerifierDeviceIdentity() throws Exception {
PackageManager pm = getPm();
VerifierDeviceIdentity id = pm.getVerifierDeviceIdentity();
assertNotNull("Verifier device identity should not be null", id);
}
- public void testGetInstalledPackages() {
+ public void testGetInstalledPackages() throws Exception {
List<PackageInfo> packages = getPm().getInstalledPackages(0);
assertNotNull("installed packages cannot be null", packages);
assertTrue("installed packages cannot be empty", packages.size() > 0);
}
- public void testGetUnInstalledPackages() {
+ public void testGetUnInstalledPackages() throws Exception {
List<PackageInfo> packages = getPm().getInstalledPackages(
PackageManager.GET_UNINSTALLED_PACKAGES);
assertNotNull("installed packages cannot be null", packages);
@@ -3187,10 +3283,9 @@
}
/**
- * Test that getInstalledPackages returns all the data specified in
- * flags.
+ * Test that getInstalledPackages returns all the data specified in flags.
*/
- public void testGetInstalledPackagesAll() {
+ public void testGetInstalledPackagesAll() throws Exception {
int flags = PackageManager.GET_ACTIVITIES | PackageManager.GET_GIDS
| PackageManager.GET_CONFIGURATIONS | PackageManager.GET_INSTRUMENTATION
| PackageManager.GET_PERMISSIONS | PackageManager.GET_PROVIDERS
@@ -3226,7 +3321,7 @@
* Test that getInstalledPackages returns all the data specified in
* flags when the GET_UNINSTALLED_PACKAGES flag is set.
*/
- public void testGetUnInstalledPackagesAll() {
+ public void testGetUnInstalledPackagesAll() throws Exception {
int flags = PackageManager.GET_UNINSTALLED_PACKAGES
| PackageManager.GET_ACTIVITIES | PackageManager.GET_GIDS
| PackageManager.GET_CONFIGURATIONS | PackageManager.GET_INSTRUMENTATION
diff --git a/services/java/com/android/server/accessibility/ScreenMagnifier.java b/services/java/com/android/server/accessibility/ScreenMagnifier.java
index 78092dd..f33517b 100644
--- a/services/java/com/android/server/accessibility/ScreenMagnifier.java
+++ b/services/java/com/android/server/accessibility/ScreenMagnifier.java
@@ -236,7 +236,6 @@
mDetectingStateHandler.clear();
mStateViewportDraggingHandler.clear();
mGestureDetector.clear();
-
if (mNext != null) {
mNext.clear();
}
@@ -244,6 +243,9 @@
@Override
public void onDestroy() {
+ mMagnificationController.setScaleAndMagnifiedRegionCenter(1.0f,
+ 0, 0, true);
+ mViewport.setFrameShown(false, true);
mDisplayProvider.destroy();
mDisplayContentObserver.destroy();
}
diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java
index d4fe3fb..3329acb 100644
--- a/services/java/com/android/server/pm/Installer.java
+++ b/services/java/com/android/server/pm/Installer.java
@@ -324,20 +324,6 @@
return execute(builder.toString());
}
- /*
- * @param packagePathSuffix The name of the path relative to install
- * directory. Say if the path name is /data/app/com.test-1.apk, the package
- * suffix path will be com.test-1
- */
- public int setForwardLockPerm(String packagePathSuffix, int gid) {
- StringBuilder builder = new StringBuilder("protect");
- builder.append(' ');
- builder.append(packagePathSuffix);
- builder.append(' ');
- builder.append(gid);
- return execute(builder.toString());
- }
-
public int getSizeInfo(String pkgName, int persona, String apkPath, String fwdLockApkPath,
String asecPath, PackageStats pStats) {
StringBuilder builder = new StringBuilder("getsize");