OSDN Git Service

When unmounting the sdcard, we are currently checking for apps that
authorSuchi Amalapurapu <asuchitra@google.com>
Wed, 24 Mar 2010 16:05:59 +0000 (09:05 -0700)
committerSuchi Amalapurapu <asuchitra@google.com>
Wed, 24 Mar 2010 16:08:40 +0000 (09:08 -0700)
have open file references on the sdcard. We also have to check for apps on sd
that are currently running. Use the new ActivityManager api to get a list of these apps before deciding to show the dialog.

Change-Id: Idb00fcbd0a3f314d75ee1662cb2b10a84569527a

src/com/android/settings/deviceinfo/Memory.java

index 1f7f29d..b574849 100644 (file)
@@ -231,23 +231,9 @@ public class Memory extends PreferenceActivity implements OnCancelListener {
             return true;
         }
         ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
-        PackageManager pm = getPackageManager();
-        List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();
-        if (runningApps != null && runningApps.size() > 0) {
-            for (ActivityManager.RunningAppProcessInfo app : runningApps) {
-                if (app.pkgList == null) {
-                    continue;
-                }
-                for (String pkg : app.pkgList) {
-                    try {
-                        ApplicationInfo info = pm.getApplicationInfo(pkg, 0);
-                        if ((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
-                            return true;
-                        }
-                    } catch (NameNotFoundException e) {
-                    }
-                }
-            }
+        List<ApplicationInfo> list = am.getRunningExternalApplications();
+        if (list != null && list.size() > 0) {
+            return true;
         }
         return false;
     }