From 7767eac3232ba2fb9828766813cdb481d6a97584 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Thu, 23 Aug 2012 18:25:40 -0700 Subject: Keep track of whether an app is installed for each user. This add a new per-user state for an app, indicating whether it is installed for that user. All system apps are always installed for all users (we still use disable to "uninstall" them). Now when you call into the package manager to install an app, it will only install the app for that user unless you supply a flag saying to install for all users. Only being installed for the user is just the normal install state, but all other users have marked in their state for that app that it is not installed. When you call the package manager APIs for information about apps, uninstalled apps are treated as really being not visible (somewhat more-so than disabled apps), unless you use the GET_UNINSTALLED_PACKAGES flag. If another user calls to install an app that is already installed, just not for them, then the normal install process takes place but in addition that user's installed state is toggled on. The package manager will not send PACKAGE_ADDED, PACKAGE_REMOVED, PACKAGE_REPLACED etc broadcasts to users who don't have a package installed or not being involved in a change in the install state. There are a few things that are not quite right with this -- for example if you go through a full install (with a new apk) of an app for one user who doesn't have it already installed, you will still get the PACKAGED_REPLACED messages even though this is technically the first install for your user. I'm not sure how much of an issue this is. When you call the existing API to uninstall an app, this toggles the installed state of the app for that user to be off. Only if that is the last user user that has the app uinstalled will it actually be removed from the device. Again there is a new flag you can pass in to force the app to be uninstalled for all users. Also fixed issues with cleaning external storage of apps, which was not dealing with multiple users. We now keep track of cleaning each user for each package. Change-Id: I00e66452b149defc08c5e0183fa673f532465ed5 --- .../src/android/content/pm/PackageManagerTests.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core/tests/coretests') diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java index 6e1b9d6..a1fd14e 100755 --- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java +++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java @@ -864,7 +864,7 @@ public class PackageManagerTests extends AndroidTestCase { public void deleteFromRawResource(int iFlags, int dFlags) { InstallParams ip = sampleInstallFromRawResource(iFlags, false); - boolean retainData = ((dFlags & PackageManager.DONT_DELETE_DATA) != 0); + boolean retainData = ((dFlags & PackageManager.DELETE_KEEP_DATA) != 0); GenericReceiver receiver = new DeleteReceiver(ip.pkg.packageName); DeleteObserver observer = new DeleteObserver(); try { @@ -914,12 +914,12 @@ public class PackageManagerTests extends AndroidTestCase { @LargeTest public void testDeleteNormalInternalRetainData() { - deleteFromRawResource(0, PackageManager.DONT_DELETE_DATA); + deleteFromRawResource(0, PackageManager.DELETE_KEEP_DATA); } @LargeTest public void testDeleteFwdLockedInternalRetainData() { - deleteFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, PackageManager.DONT_DELETE_DATA); + deleteFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, PackageManager.DELETE_KEEP_DATA); } @LargeTest @@ -929,7 +929,7 @@ public class PackageManagerTests extends AndroidTestCase { return; } - deleteFromRawResource(PackageManager.INSTALL_EXTERNAL, PackageManager.DONT_DELETE_DATA); + deleteFromRawResource(PackageManager.INSTALL_EXTERNAL, PackageManager.DELETE_KEEP_DATA); } /* sdcard mount/unmount tests ******/ @@ -1656,7 +1656,7 @@ public class PackageManagerTests extends AndroidTestCase { false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED); // Delete the package now retaining data. GenericReceiver receiver = new DeleteReceiver(ip.pkg.packageName); - invokeDeletePackage(ip.pkg.packageName, PackageManager.DONT_DELETE_DATA, receiver); + invokeDeletePackage(ip.pkg.packageName, PackageManager.DELETE_KEEP_DATA, receiver); assertTrue(invokeMovePackageFail(ip.pkg.packageName, moveFlags, result)); } catch (Exception e) { failStr(e); @@ -2532,7 +2532,7 @@ public class PackageManagerTests extends AndroidTestCase { GenericReceiver receiver = new DeleteReceiver(ip.pkg.packageName); try { - invokeDeletePackage(ip.pkg.packageName, PackageManager.DONT_DELETE_DATA, receiver); + invokeDeletePackage(ip.pkg.packageName, PackageManager.DELETE_KEEP_DATA, receiver); } catch (Exception e) { failStr(e); } -- cgit v1.1