/**
  * This method is a bit dangerous and it makes some assumptions. Ideally, if we are connected to
  * an MMF app we would just ask it for the app state and get that state in the {@link
  * com.mapmyfitness.android.mmfremote.RemoteCommandListener#onAppStateEvent(com.mapmyfitness.android.mmfremote.AppState)}
  * callback. However, if we are not connected to an MMF app we can't be 100% sure which MMF app
  * you intend to check for if the {@link com.mapmyfitness.android.mmfremote.AppPackage} is not set
  * in this class. Lastly, if no {@link com.mapmyfitness.android.mmfremote.RemoteCommandListener}
  * is set, you will not receieve a callback. In that case the method will appear to fail silently.
  * These are steps we take:
  *
  * <ol>
  *   <li>If MMF app is connected to SDK: ask it the current state and listen for it in the {@link
  *       com.mapmyfitness.android.mmfremote.RemoteCommandListener#onAppStateEvent(com.mapmyfitness.android.mmfremote.AppState)}
  *       callback. Remember if no callback is set, you will not get any feedback about the state
  *       of the app.
  *   <li>If we have an {@link com.mapmyfitness.android.mmfremote.AppPackage} set, then check it to
  *       see if app is installed. If the app is installed we will send a callback with {@link
  *       com.mapmyfitness.android.mmfremote.AppState#APP_NOT_CONNECTED}. If the app is not
  *       installed we will send a callback with {@link
  *       com.mapmyfitness.android.mmfremote.AppState#APP_NOT_INSTALLED}.
  *   <li>If the {@link com.mapmyfitness.android.mmfremote.AppPackage} is not set, we are not sure
  *       which one of the 10 apps you are requesting. In that case, we will use {@link
  *       #findInstalledApps()} to see if any of our supported apps are installed. If at least one
  *       of them is installed we return {@link
  *       com.mapmyfitness.android.mmfremote.AppState#APP_NOT_CONNECTED}. If none of our supported
  *       are installed, we return {@link
  *       com.mapmyfitness.android.mmfremote.AppState#APP_NOT_INSTALLED}.
  * </ol>
  *
  * A better way to get an app's state is to use {@link
  * #requestAppState(com.mapmyfitness.android.mmfremote.AppPackage)} passing it the {@link
  * com.mapmyfitness.android.mmfremote.AppPackage} you are interested in. That will be more precise
  * by narrowing down the options to one app.
  */
 public void requestAppState() {
   if (isAppConnected()) {
     mRemoteCommunication.getCurrentStateCommand();
   } else if (mAppPackage != null) {
     AppInfo appInfo = getAppInfo(mAppPackage);
     if (appInfo.isInstalled()) {
       if (mRemoteCommunication.getCommandListener() != null) {
         mRemoteCommunication.getCommandListener().onAppStateEvent(AppState.APP_NOT_CONNECTED);
       }
     } else {
       if (mRemoteCommunication.getCommandListener() != null) {
         mRemoteCommunication.getCommandListener().onAppStateEvent(AppState.APP_NOT_INSTALLED);
       }
     }
   } else {
     if (findInstalledApps().size() > 0) {
       if (mRemoteCommunication.getCommandListener() != null) {
         mRemoteCommunication.getCommandListener().onAppStateEvent(AppState.APP_NOT_CONNECTED);
       }
     } else {
       if (mRemoteCommunication.getCommandListener() != null) {
         mRemoteCommunication.getCommandListener().onAppStateEvent(AppState.APP_NOT_INSTALLED);
       }
     }
   }
 }
Esempio n. 2
0
  void addAllAppsFolder(
      IconCache iconCache,
      ArrayList<AppInfo> allApps,
      ArrayList<ComponentName> onWorkspace,
      Launcher launcher,
      Workspace workspace) {
    if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
      FolderInfo fi = new FolderInfo();

      fi.cellX = getCellXFromOrder(mAllAppsButtonRank);
      fi.cellY = getCellYFromOrder(mAllAppsButtonRank);
      fi.spanX = 1;
      fi.spanY = 1;
      fi.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT;
      fi.screenId = mAllAppsButtonRank;
      fi.itemType = LauncherSettings.Favorites.ITEM_TYPE_FOLDER;
      fi.title = "More Apps";
      LauncherModel.addItemToDatabase(
          launcher, fi, fi.container, fi.screenId, fi.cellX, fi.cellY, false);
      FolderIcon folder =
          FolderIcon.fromXml(R.layout.folder_icon, launcher, getLayout(), fi, iconCache);
      workspace.addInScreen(
          folder, fi.container, fi.screenId, fi.cellX, fi.cellY, fi.spanX, fi.spanY);

      for (AppInfo info : allApps) {
        ComponentName cn = info.intent.getComponent();
        if (!onWorkspace.contains(cn)) {
          Log.d(TAG, "Adding to 'more apps': " + info.intent);
          ShortcutInfo si = info.makeShortcut();
          fi.add(si);
        }
      }
    }
  }
 /**
  * Generate the app list as a String.
  *
  * @return the app list to push to the device.
  */
 private String generateAppList() {
   StringBuilder sb = new StringBuilder();
   for (AppInfo info : mAppInfos.values()) {
     sb.append(info.getAppListEntry());
   }
   return sb.toString();
 }
 /**
  * If a bugreport should be taken after the run.
  *
  * @return true if any of the apps have a {@code null} launch time.
  */
 private boolean shouldTakeBugreport() {
   for (AppInfo appInfo : mAppInfos.values()) {
     if (appInfo.getTime() == null) {
       return true;
     }
   }
   return false;
 }
Esempio n. 5
0
 /** Fill in "application" with the icon and label for "info." */
 public synchronized void getTitleAndIcon(
     AppInfo application, LauncherActivityInfoCompat info, boolean useLowResIcon) {
   UserHandleCompat user = info == null ? application.user : info.getUser();
   CacheEntry entry = cacheLocked(application.componentName, info, user, false, useLowResIcon);
   application.title = Utilities.trim(entry.title);
   application.iconBitmap = getNonNullIcon(entry, user);
   application.contentDescription = entry.contentDescription;
   application.usingLowResIcon = entry.isLowResIcon;
 }
  /** アプリ一覧で、あるアプリがクリックされたときのアクションです。 */
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final AppInfo appInfo = (AppInfo) parent.getItemAtPosition(position);
    BitmapDrawable icon = (BitmapDrawable) appInfo.getIcon();

    final Bitmap bmp = Bitmap.createBitmap(320, 320, Config.ARGB_8888);
    final Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();
    paint.setDither(true);
    canvas.drawBitmap(
        ((BitmapDrawable) icon).getBitmap(),
        null,
        new Rect(0, 0, bmp.getWidth() - 1, bmp.getHeight() - 1),
        paint);
    final int[] pixels = new int[320 * 320];
    bmp.getPixels(pixels, 0, 320, 0, 0, 320, 320);

    // Random Dithering で二値化する
    final Random rand = new Random();
    for (int i = 0; i < pixels.length; i++) {
      final int p = pixels[i];
      // y=0.587*g+0.299*r+0.114b
      final int y =
          Color.green(p) * 587 / 1000 //
              + Color.red(p) * 299 / 1000 //
              + Color.blue(p) * 114 / 1000;

      final int blackOrWhite = (y < rand.nextInt(256)) ? 0 : 255;
      pixels[i] = Color.argb(0xff, blackOrWhite, blackOrWhite, blackOrWhite);
    }

    // 二値化されたデータを印刷用ラスターデータに変換する
    // TODO 二値化の際に変換も一緒に行ったほうが効率的
    final int bmpWidth = bmp.getWidth();
    final int bmpHeight = bmp.getHeight();
    final int black = Color.argb(0xff, 0, 0, 0);
    byte[][] rasterData = new byte[bmpWidth][];
    for (int w = 0; w < rasterData.length; w++) {
      final byte[] line = new byte[4 /*印刷されない領域分*/ + bmp.getHeight() / 8];
      int d = 0;
      for (int h = 0; h < bmpHeight; h++) {
        final int index = h * bmpWidth + w;
        d <<= 1;
        d += (pixels[index] == black ? 1 : 0);
        if (h % 8 == 7) {
          line[4 + h / 8] = (byte) d;
        }
      }
      rasterData[w] = line;
    }

    final Intent intent = new Intent(this, PrintActivity.class);
    intent.putExtra("data", rasterData);
    startActivity(intent);
  }
 /**
  * Parses the output file and populate the {@link AppInfo} objects with the launch times.
  *
  * @param contents The file contents.
  * @throws IOException If an IOException is caused.
  */
 private void parseOutputFile(String contents) throws IOException {
   for (String line : contents.split("\n")) {
     Matcher m = APP_TIME_PATTERN.matcher(line);
     if (m.matches()) {
       AppInfo appInfo = mAppInfos.get(m.group(1).toLowerCase());
       if (appInfo != null) {
         appInfo.setTime(Integer.parseInt(m.group(2)));
       }
     }
   }
 }
Esempio n. 8
0
  /**
   * Process an "appinfo" element.
   *
   * @param element The "appinfo" element.
   */
  protected void processAppInfo(Element element) {

    // get the annotation object
    SchemaObject current = getCurrentObject();
    if (current instanceof Annotation) {
      Annotation annotation = (Annotation) current;
      AppInfo appinfo = new AppInfo();
      appinfo.setElements(element.getChildren());
      annotation.setAppInfo(appinfo);
    }
  }
Esempio n. 9
0
 /** Updates {@param application} only if a valid entry is found. */
 public synchronized void updateTitleAndIcon(AppInfo application) {
   CacheEntry entry =
       cacheLocked(
           application.componentName, null, application.user, false, application.usingLowResIcon);
   if (entry.icon != null && !isDefaultIcon(entry.icon, application.user)) {
     application.title = Utilities.trim(entry.title);
     application.iconBitmap = entry.icon;
     application.contentDescription = entry.contentDescription;
     application.usingLowResIcon = entry.isLowResIcon;
   }
 }
 /**
  * Sets up the {@link AppInfo} map based on the app-name args.
  *
  * <p>Generates from {@link appNames}, a collection of Strings formated as either an app name or
  * as an app name, key pair with a comma separator. The key for the map will be the lowercase name
  * with spaces removed.
  */
 private void setupAppInfos() {
   for (String app : mAppNames) {
     Matcher m = APP_NAME_PATTERN.matcher(app);
     AppInfo info;
     if (m.matches()) {
       info = new AppInfo(m.group(1), m.group(2));
     } else {
       info = new AppInfo(app);
     }
     mAppInfos.put(info.getOutputKey(), info);
   }
 }
    /**
     * アプリ1つ分を表現する {@link View} を返します。
     *
     * @param position アイテムのインデックス。 0 ベース。
     * @param convertView これまで使用されていた {@link View} オブジェクト。 {@code null} の可能性あり。 可能なかぎり再利用すること。
     * @param parent 対象とする {@link View} の親。
     * @return {@link View} オブジェクト。
     */
    public View getView(int position, View convertView, ViewGroup parent) {
      final View v =
          (convertView == null) ? inflater_.inflate(R.layout.grid_row, null) : convertView;
      final GridRowData rowData =
          (v.getTag() == null) ? createRowData(v) : (GridRowData) v.getTag();

      final AppInfo info = getItem(position);
      rowData.getTextView().setText(info.getLabel());
      rowData.getImageView().setImageDrawable(info.getIcon());

      v.setTag(rowData);
      return v;
    }
Esempio n. 12
0
    public void handle(Intent intent, Handler handler, Runnable startMonitoring) {

      AppInfo appInfo =
          new AppInfo(
              intent.getStringExtra("AppName"), intent.getStringExtra("PackageName"), mConfig);

      if (appInfo.isDifferent(mPreviousAppInfo)) {
        handler.removeCallbacks(startMonitoring);
        handler.postDelayed(startMonitoring, MONITORING_JUDGE_TIME);
        handleAppStop();
        handleChangedAppStartTime();
        handleChangedAppInfo(appInfo);
        mPreviousAppInfo = appInfo;
      }
    }
Esempio n. 13
0
  public static File createBuildXML(
      String justepHome, String antLibDir, String nativeDir, AppInfo appInfo, String session)
      throws IOException, IllegalAccessException {
    File buildTmplFile = new File(antLibDir + "/build.xml");
    BufferedReader br =
        new BufferedReader(new InputStreamReader(new FileInputStream(buildTmplFile)));
    StringBuffer sb = new StringBuffer();
    String str = null;
    while ((str = br.readLine()) != null) sb.append(str + "\r\n");
    String content = sb.toString();
    // 文件中的占位标识为@value@,和ant的文本替换一致
    content = content.replace("@justepHome@", justepHome);
    content = content.replace("@antLibDir@", antLibDir);
    content = content.replace("@nativeDir@", nativeDir);
    content = content.replace("@session@", session);
    Class<? extends AppInfo> cls = appInfo.getClass();
    Field[] flds = cls.getFields();
    Object v;
    if (flds != null) {
      for (int i = 0; i < flds.length; i++) {
        v = flds[i].get(appInfo);
        content = content.replace("@" + flds[i].getName() + "@", v != null ? v.toString() : "");
      }
    }

    File buildFile = File.createTempFile("x5app-build", ".xml");
    buildFile.deleteOnExit();
    FileOutputStream buildFileStream = new FileOutputStream(buildFile);
    buildFileStream.write(content.getBytes("UTF-8"));
    br.close();
    buildFileStream.close();

    return buildFile;
  }
    /** Initializes a PendingInstallShortcutInfo to represent a launcher target. */
    public PendingInstallShortcutInfo(LauncherActivityInfoCompat info, Context context) {
      this.data = null;
      mContext = context;
      activityInfo = info;
      user = info.getUser();

      launchIntent = AppInfo.makeLaunchIntent(context, info, user);
      label = info.getLabel().toString();
    }
Esempio n. 15
0
 /*获取正在运行的应用*/
 private List<AppInfo> getRunningProcess() {
   PackagesInfo pi = new PackagesInfo(this);
   ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
   // 获取正在运行的应用
   List<ActivityManager.RunningAppProcessInfo> run = activityManager.getRunningAppProcesses();
   List<AppInfo> list = new ArrayList<AppInfo>();
   for (ActivityManager.RunningAppProcessInfo ra : run) {
     if (ra.processName.equals("system") || ra.processName.equals("com.Android.phone")) {
       continue;
     }
     AppInfo appInfo = pi.getInfo(ra.processName);
     if (appInfo != null) {
       appInfo.setVersionCode(ra.lastTrimLevel);
       list.add(appInfo);
     }
   }
   return list;
 }
Esempio n. 16
0
  public static AppInfo queryApp(ContentResolver cr) {
    AppInfo info = new AppInfo();

    Cursor c = cr.query(CrsyncConstants.URI_APP, null, null, null, null);

    if (c != null && c.moveToFirst()) {
      int hashColumn = c.getColumnIndex(CrsyncConstants.COLUMN_APP_HASH);
      int percentColumn = c.getColumnIndex(CrsyncConstants.COLUMN_APP_PERCENT);

      info.mHash = c.getString(hashColumn);
      info.mPercent = c.getInt(percentColumn);
    } else {
      logger.severe("####AppInfo query URI fail");
    }
    if (c != null) {
      c.close();
    }
    return info;
  }
  /**
   * Report the metrics and attach it to the listener.
   *
   * <p>If any of the app times are {@code null}, that app is assumed to not have launched and will
   * be marked as failed.
   *
   * @param listener the {@link ITestInvocationListener}
   */
  private void reportMetrics(ITestInvocationListener listener) {
    listener.testRunStarted(TEST_KEY, 0);
    Map<String, String> metrics = new HashMap<String, String>();

    for (AppInfo appInfo : mAppInfos.values()) {
      TestIdentifier testId =
          new TestIdentifier(getClass().getCanonicalName(), appInfo.getPostKey());
      listener.testStarted(testId);
      if (appInfo.getTime() != null) {
        metrics.put(appInfo.getPostKey(), Integer.toString(appInfo.getTime()));
      } else {
        listener.testFailed(TestFailure.FAILURE, testId, "No app launch time");
      }
      Map<String, String> empty = Collections.emptyMap();
      listener.testEnded(testId, empty);
    }
    CLog.d("About to report app launch metrics: %s", metrics);
    listener.testRunEnded(0, metrics);
  }
Esempio n. 18
0
  /**
   * Creates a new AppInfoUnmarshaller
   *
   * @param atts the AttributeList
   */
  public AppInfoUnmarshaller(AttributeList atts) throws SAXException {
    super();

    _appInfo = new AppInfo();

    // -- handle attributes
    String attValue = null;

    _appInfo.setSource(atts.getValue(SchemaNames.BASE_ATTR));
  } // -- AppInfoUnmarshaller
Esempio n. 19
0
 private void handleChangedAppInfo(AppInfo appInfo) {
   mCurrentAppInfo = appInfo;
   if (mConfig.isExpExpired() && mCurrentAppInfo.isHomeApp()) {
     Log.d("trans", "----------------expired at home---------------");
     if (!mConfig.isCompletePostsurvey()) {
       mContext.startActivity(
           new Intent(mContext, TranslucentActivity.class)
               .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY));
     }
   }
 }
Esempio n. 20
0
  void addAppsToAllAppsFolder(ArrayList<AppInfo> apps) {
    if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
      View v =
          mContent.getChildAt(
              getCellXFromOrder(mAllAppsButtonRank), getCellYFromOrder(mAllAppsButtonRank));
      FolderIcon fi = null;

      if (v instanceof FolderIcon) {
        fi = (FolderIcon) v;
      } else {
        return;
      }

      FolderInfo info = fi.getFolderInfo();
      for (AppInfo a : apps) {
        ShortcutInfo si = a.makeShortcut();
        info.add(si);
      }
    }
  }
Esempio n. 21
0
  private List<AppInfo> loadApps(ProgressDialog dialog) {
    PackageManager packageManager = getPackageManager();
    List<ApplicationInfo> packages =
        packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
    List<AppInfo> apps = new ArrayList<AppInfo>();

    dialog.setMax(packages.size());
    int i = 1;

    for (ApplicationInfo app : packages) {
      AppInfo appInfo = new AppInfo();
      appInfo.title = (String) app.loadLabel(packageManager);
      appInfo.summary = app.packageName;
      appInfo.icon = app.loadIcon(packageManager);
      appInfo.enabled = mSettingsHelper.isListed(app.packageName);
      apps.add(appInfo);
      dialog.setProgress(i++);
    }

    Collections.sort(
        apps,
        new Comparator<AppInfo>() {
          @Override
          public int compare(AppInfo appInfo1, AppInfo appInfo2) {
            boolean app1 = mSettingsHelper.isListed(appInfo1.summary);
            boolean app2 = mSettingsHelper.isListed(appInfo2.summary);

            if (app1 && app2 || !app1 && !app2) {
              return appInfo1.title.compareToIgnoreCase(appInfo2.title);
            } else if (app1) {
              return -1;
            } else if (app2) {
              return 1;
            }

            return 0;
          }
        });

    return apps;
  }
  @Override
  public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
    mCursor.moveToPosition(position);
    String packagename = mCursor.getString(mCursor.getColumnIndex(AppData.App.PKG_NAME));
    ApplicationInfo applicationInfo = null;
    AppInfo appInfo = null;
    try {
      applicationInfo = pm.getApplicationInfo(packagename, 0);
      appInfo = new AppInfo(getActivity(), applicationInfo);
      appInfo.setPackageName(packagename);
      appInfo.setAppIcon(applicationInfo.loadIcon(pm));
      appInfo.loadLabel();
      appInfo.loadVersion();

      showMenuDialog(appInfo, arg1);
    } catch (NameNotFoundException e) {
      Log.e(TAG, e.toString());
      e.printStackTrace();
    }
    return true;
  }
  public void showMenuDialog(final AppInfo appInfo, final View view) {
    new AlertDialog.Builder(mContext)
        .setIcon(appInfo.getAppIcon())
        .setTitle(appInfo.getLabel())
        .setItems(
            R.array.zy_game_menu,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                  case 0:
                    // send
                    FileTransferUtil fileSendUtil = new FileTransferUtil(getActivity());
                    fileSendUtil.sendFile(
                        appInfo.getInstallPath(),
                        new TransportCallback() {

                          @Override
                          public void onTransportSuccess() {
                            ViewHolder viewHolder = (ViewHolder) view.getTag();
                            showTransportAnimation(viewHolder.iconView);
                          }

                          @Override
                          public void onTransportFail() {}
                        });
                    break;
                  case 1:
                    // app info
                    mAppManager.showInfoDialog(appInfo);
                    break;

                  default:
                    break;
                }
              }
            })
        .create()
        .show();
  }
Esempio n. 24
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    int selected = neither;
    // TODO Auto-generated method stub
    LinearLayout ll = null;

    if (convertView != null) {
      ll = (LinearLayout) convertView;
    } else {
      ll = (LinearLayout) LayoutInflater.from(context).inflate(resID, parent, false);
    }

    AppInfo appInfo = getItem(position);

    if (context.currentSelectedGridView == ll) {
      selected = currentSelected;
    } else if (context.lastSelectedGridView == ll) {
      selected = lastSelected;
    }

    appInfo.SetMeOnTextView(ll, selected);

    return ll;
  }
 public ShortcutInfo getShortcutInfo() {
   if (activityInfo != null) {
     final ShortcutInfo info = new ShortcutInfo();
     info.user = user;
     info.title = label;
     info.contentDescription = label;
     info.customIcon = false;
     info.intent = launchIntent;
     info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
     info.flags = AppInfo.initFlags(activityInfo);
     info.firstInstallTime = activityInfo.getFirstInstallTime();
     return info;
   } else {
     return LauncherAppState.getInstance().getModel().infoFromShortcutIntent(mContext, data);
   }
 }
Esempio n. 26
0
  public List<AppInfo> getInstalledApps() {

    List<PackageInfo> packageInfos = pm.getInstalledPackages(PackageManager.MATCH_DEFAULT_ONLY);
    ArrayList<AppInfo> appList = new ArrayList<AppInfo>();
    List<PackageInfo> packages = pm.getInstalledPackages(0);

    for (PackageInfo info : packages) {
      AppInfo appinfo = new AppInfo();

      appinfo.setPackname(info.packageName);
      appinfo.setVersion(info.versionName);
      appinfo.setAppname(info.applicationInfo.loadLabel(pm).toString());
      appinfo.setAppicon(info.applicationInfo.loadIcon(pm));
      appinfo.setUserpp(filterApp(info.applicationInfo));
      appList.add(appinfo);

      appinfo = null;
    }

    //        ArrayList<AppInfo> appList = new ArrayList<AppInfo>();
    //        List<ApplicationInfo> applicationInfo = pm.getInstalledApplications(0);
    //
    //        for (ApplicationInfo info : applicationInfo) {
    //            AppInfo appinfo = new AppInfo();
    //
    //            Drawable app_icon = info.loadIcon(pm);
    //            appinfo.setAppicon(app_icon);
    //            String app_name = info.loadLabel(pm).toString();
    //            appinfo.setAppname(app_name);
    //            String packageName = info.packageName;
    //            appinfo.setPackname(packageName);
    //            try {
    //                //获取应用的版本号
    //                PackageInfo packageInfo = pm.getPackageInfo(packageName, 0);
    //                String app_version = packageInfo.versionName;
    //                appinfo.setVersion(app_version);
    //            } catch (PackageManager.NameNotFoundException e) {
    //                e.printStackTrace();
    //            }
    //            appList.add(appinfo);

    //            Log.i("duanlang", "applicationInfos = " + applicationInfo);

    //        }

    return appList;
  }
Esempio n. 27
0
 /*获取已经安装了的应用*/
 private List<AppInfo> getInstalledPackages() {
   ArrayList<AppInfo> appList = new ArrayList<AppInfo>(); // 用来存储获取的应用信息数据
   List<PackageInfo> packages = getPackageManager().getInstalledPackages(0);
   for (int i = 0; i < packages.size(); i++) {
     PackageInfo packageInfo = packages.get(i);
     AppInfo tmpInfo = new AppInfo();
     tmpInfo.appName = packageInfo.applicationInfo.loadLabel(getPackageManager()).toString();
     tmpInfo.packageName = packageInfo.packageName;
     tmpInfo.versionName = packageInfo.versionName;
     tmpInfo.versionCode = packageInfo.versionCode;
     tmpInfo.appIcon = packageInfo.applicationInfo.loadIcon(getPackageManager());
     if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
       // 非系统应用
       //                appList.add(tmpInfo);
     } else {
       // 系统应用
     }
     appList.add(tmpInfo);
   }
   return appList;
 }
  /**
   * Get a list of all MMF apps installed. This will return an empty {@link java.util.ArrayList<
   * com.mapmyfitness.android.mmfremote.AppInfo >} object. Then you would know non of our supported
   * apps are installed in the phone.
   *
   * @return array of type {@link com.mapmyfitness.android.mmfremote.AppInfo} with info on apps
   *     installed
   */
  public ArrayList<AppInfo> findInstalledApps() {
    AppInfo appInfo;
    ArrayList<AppInfo> appInfoList = new ArrayList<AppInfo>();

    // try each of the 10 apps
    appInfo = getAppInfo(AppPackage.MAPMYFITNESS);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYFITNESSPLUS);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYRUN);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYRUNPLUS);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYRIDE);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYRIDEPLUS);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYHIKE);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYHIKEPLUS);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYWALK);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    appInfo = getAppInfo(AppPackage.MAPMYWALKPLUS);
    if (appInfo.isInstalled()) {
      appInfoList.add(appInfo);
    }

    return appInfoList;
  }
Esempio n. 29
0
 /**
  * Called to signal an end of unmarshalling. This method should be overridden to perform any
  * necessary clean up by an unmarshaller
  */
 public void finish() {
   if (sb != null) {
     _appInfo.setContent(sb.toString());
     sb = null;
   }
 } // -- finish
 @Override
 public int compare(AppInfo object1, AppInfo object2) {
   return sCollator.compare(object1.getLabel(), object2.getLabel());
 }