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:
@@ -231,23 +231,9 @@ public class Memory extends PreferenceActivity implements OnCancelListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
|
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
PackageManager pm = getPackageManager();
|
List<ApplicationInfo> list = am.getRunningExternalApplications();
|
||||||
List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();
|
if (list != null && list.size() > 0) {
|
||||||
if (runningApps != null && runningApps.size() > 0) {
|
return true;
|
||||||
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) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user