When unmounting the sdcard, we are currently checking for apps that

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
This commit is contained in:
Suchi Amalapurapu
2010-03-24 09:05:59 -07:00
parent e4a318f15c
commit 3d503e356f

View File

@@ -231,24 +231,10 @@ 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) {
List<ApplicationInfo> list = am.getRunningExternalApplications();
if (list != null && list.size() > 0) {
return true;
}
} catch (NameNotFoundException e) {
}
}
}
}
return false;
}