Example #1
0
  public static List<EnableappInfo> getInstalledAppsEnabled(Context context) {
    List<EnableappInfo> res = new ArrayList<EnableappInfo>();
    if (context != null) {
      List<PackageInfo> packs = null;
      try {
        packs = context.getPackageManager().getInstalledPackages(0);
      } catch (Exception e) {

      }
      if (packs != null && packs.size() != 0) {
        for (PackageInfo p : packs) {

          ApplicationInfo newInfo = p.applicationInfo;
          if (newInfo == null) {
            continue;
          }

          EnableappInfo info = new EnableappInfo();
          info.info = newInfo;
          info.enabled = true;

          if (newInfo.sourceDir.contains("/system/app/")) {
            info.type = 0;
          } else if (newInfo.sourceDir.contains("/system/priv-app/")) {
            info.type = 3;
          } else if (newInfo.sourceDir.contains("/data/app/")) {
            info.type = 1;
          } else {
            info.type = 2;
          }

          res.add(info);
        }
      }
    }
    return res;
  }
Example #2
0
  public static List<EnableappInfo> getInstalledAppsDisabled(Context context) {
    List<EnableappInfo> res = new ArrayList<EnableappInfo>();
    File fDisableSystem = new File(DirHelper.ENABLEAPP_DIR_SYSTEM);
    if (fDisableSystem.exists()) {
      for (String s : fDisableSystem.list()) {
        if (s.toLowerCase().endsWith(".apk")) {
          EnableappInfo newinfo = new EnableappInfo();
          newinfo.info = getAppInfoFromPackage(DirHelper.ENABLEAPP_DIR_SYSTEM + s);

          if (newinfo.info == null) {
            continue;
          }
          newinfo.type = 0;
          newinfo.enabled = false;
          newinfo.filePath = DirHelper.ENABLEAPP_DIR_SYSTEM + s;
          res.add(newinfo);
        }
      }
    }

    File fDisablePrivate = new File(DirHelper.ENABLEAPP_DIR_PRIVATE);
    if (fDisablePrivate.exists()) {
      for (String s : fDisablePrivate.list()) {
        if (s.toLowerCase().endsWith(".apk")) {
          EnableappInfo newinfo = new EnableappInfo();
          newinfo.info = getAppInfoFromPackage(DirHelper.ENABLEAPP_DIR_PRIVATE + s);

          if (newinfo.info == null) {
            continue;
          }
          newinfo.type = 3;
          newinfo.enabled = false;
          newinfo.filePath = DirHelper.ENABLEAPP_DIR_PRIVATE + s;
          res.add(newinfo);
        }
      }
    }

    File fDisableData = new File(DirHelper.ENABLEAPP_DIR_DATA);
    if (fDisableData.exists()) {
      for (String s : fDisableData.list()) {
        if (s.toLowerCase().endsWith(".apk")) {
          EnableappInfo newinfo = new EnableappInfo();
          newinfo.info = getAppInfoFromPackage(DirHelper.ENABLEAPP_DIR_DATA + s);

          if (newinfo.info == null) {
            continue;
          }
          newinfo.type = 1;
          newinfo.enabled = false;
          newinfo.filePath = DirHelper.ENABLEAPP_DIR_DATA + s;
          res.add(newinfo);
        }
      }
    }

    return res;
  }