Add new activity manager method to get list of running applications installed on sdcard.
Use new method in UsbStorageActivity.
Fix moving dex files.
moveDex should be suffixed with LI since it uses Installer
Change-Id: Id5ef0254578e84b9aae2c2ac44f722eb5a0fda1c
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index f734053..d1edc35 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -69,6 +69,7 @@
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.Uri;
@@ -122,6 +123,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
public final class ActivityManagerService extends ActivityManagerNative implements Watchdog.Monitor {
static final String TAG = "ActivityManager";
@@ -9352,6 +9354,32 @@
return runList;
}
+ public List<ApplicationInfo> getRunningExternalApplications() {
+ List<ActivityManager.RunningAppProcessInfo> runningApps = getRunningAppProcesses();
+ List<ApplicationInfo> retList = new ArrayList<ApplicationInfo>();
+ if (runningApps != null && runningApps.size() > 0) {
+ Set<String> extList = new HashSet<String>();
+ for (ActivityManager.RunningAppProcessInfo app : runningApps) {
+ if (app.pkgList != null) {
+ for (String pkg : app.pkgList) {
+ extList.add(pkg);
+ }
+ }
+ }
+ IPackageManager pm = ActivityThread.getPackageManager();
+ for (String pkg : extList) {
+ try {
+ ApplicationInfo info = pm.getApplicationInfo(pkg, 0);
+ if ((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
+ retList.add(info);
+ }
+ } catch (RemoteException e) {
+ }
+ }
+ }
+ return retList;
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (checkCallingPermission(android.Manifest.permission.DUMP)