diff options
author | Suchi Amalapurapu <asuchitra@google.com> | 2010-01-29 19:37:00 -0800 |
---|---|---|
committer | Suchi Amalapurapu <asuchitra@google.com> | 2010-02-03 11:21:49 -0800 |
commit | a833d10e3e36414f39a12c3891a90e67cdf8f339 (patch) | |
tree | dd9cbef6e9c279fde3d23f098dd8a913959ffe36 /src/com/android/settings/ManageApplications.java | |
parent | 431fa27d646a471189f39f4457f3b042665ae9d4 (diff) | |
download | packages_apps_Settings-a833d10e3e36414f39a12c3891a90e67cdf8f339.tar.gz packages_apps_Settings-a833d10e3e36414f39a12c3891a90e67cdf8f339.tar.bz2 packages_apps_Settings-a833d10e3e36414f39a12c3891a90e67cdf8f339.zip |
Add new broadcast to pick up apps from sdcard
Diffstat (limited to 'src/com/android/settings/ManageApplications.java')
-rw-r--r-- | src/com/android/settings/ManageApplications.java | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/com/android/settings/ManageApplications.java b/src/com/android/settings/ManageApplications.java index 96459c160..0525dab23 100644 --- a/src/com/android/settings/ManageApplications.java +++ b/src/com/android/settings/ManageApplications.java @@ -1557,17 +1557,39 @@ public class ManageApplications extends TabActivity implements filter.addAction(Intent.ACTION_PACKAGE_CHANGED); filter.addDataScheme("package"); ManageApplications.this.registerReceiver(this, filter); + // Register for events related to sdcard installation. + IntentFilter sdFilter = new IntentFilter(); + sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_AVAILABLE); + sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE); + ManageApplications.this.registerReceiver(this, sdFilter); + } + @Override + public void onReceive(Context context, Intent intent) { + // technically we dont have to invoke handler since onReceive is invoked on + // the main thread but doing it here for better clarity + String actionStr = intent.getAction(); + if (Intent.ACTION_PACKAGE_ADDED.equals(actionStr) || + Intent.ACTION_PACKAGE_REMOVED.equals(actionStr)) { + Uri data = intent.getData(); + String pkgName = data.getEncodedSchemeSpecificPart(); + updatePackageList(actionStr, pkgName); + } else if (Intent.ACTION_MEDIA_RESOURCES_AVAILABLE.equals(actionStr) || + Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE.equals(actionStr)) { + boolean available = Intent.ACTION_MEDIA_RESOURCES_AVAILABLE.equals(actionStr); + String pkgList[] = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); + if (pkgList == null || pkgList.length == 0) { + // Ignore + return; + } + String msg = available ? Intent.ACTION_PACKAGE_ADDED : + Intent.ACTION_PACKAGE_REMOVED; + for (String pkgName : pkgList) { + updatePackageList(msg, pkgName); + } + } } - @Override - public void onReceive(Context context, Intent intent) { - String actionStr = intent.getAction(); - Uri data = intent.getData(); - String pkgName = data.getEncodedSchemeSpecificPart(); - if (localLOGV) Log.i(TAG, "action:"+actionStr+", for package:"+pkgName); - updatePackageList(actionStr, pkgName); - } } - + private void updatePackageList(String actionStr, String pkgName) { // technically we dont have to invoke handler since onReceive is invoked on // the main thread but doing it here for better clarity |