Esempio n. 1
0
  @Override
  public void onRecvData(ipcMessage result) {

    // check
    if (ipcStop == true) return;

    if (stopUpdate == true || result == null) {
      ipcAction newCommand[] = {ipcAction.CONNECTION, ipcAction.PROCESS};
      ipcService.addRequest(newCommand, settings.getInterval(), this);
      return;
    }

    // clean up
    while (!data.isEmpty()) data.remove(0);
    data.clear();

    map.clear();

    // convert data
    // TODO: reuse old objects
    for (int index = 0; index < result.getDataCount(); index++) {

      try {
        ipcData rawData = result.getData(index);

        // prepare mapping table
        if (rawData.getAction() == ipcAction.PROCESS) {
          for (int count = 0; count < rawData.getPayloadCount(); count++) {
            processInfo psInfo = processInfo.parseFrom(rawData.getPayload(count));
            if (!infoHelper.checkPackageInformation(psInfo.getName())) {
              infoHelper.doCacheInfo(psInfo.getUid(), psInfo.getOwner(), psInfo.getName());
            }
            map.put(psInfo.getUid(), infoHelper.getPackageName(psInfo.getName()));
          }
        }

        if (rawData.getAction() != ipcAction.CONNECTION) continue;

        // process processInfo
        for (int count = 0; count < rawData.getPayloadCount(); count++) {
          connectionInfo cnInfo = connectionInfo.parseFrom(rawData.getPayload(count));
          data.add(cnInfo);
        }

      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    ((ConnectionListAdapter) getListAdapter()).refresh();

    // send command again
    ipcAction newCommand[] = {ipcAction.CONNECTION, ipcAction.PROCESS};
    ipcService.addRequest(newCommand, settings.getInterval(), this);
  }
Esempio n. 2
0
  public static ProcessUtil getInstance(Context context, boolean detail) {

    if (singletone == null) {
      singletone = new ProcessUtil();

      singletone.packageMgr = context.getPackageManager();
      singletone.resourceMgr = context.getResources();
      singletone.activityMgr = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

      DisplayMetrics metrics = new DisplayMetrics();
      WindowManager wmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
      wmanager.getDefaultDisplay().getMetrics(metrics);

      switch (metrics.densityDpi) {
        case DisplayMetrics.DENSITY_LOW:
          singletone.iconSize = 12;
          break;
        case DisplayMetrics.DENSITY_MEDIUM:
          singletone.iconSize = 48;
          break;
        case DisplayMetrics.DENSITY_HIGH:
          singletone.iconSize = 60;
          break;
        case DisplayMetrics.DENSITY_XHIGH:
          singletone.iconSize = 100;
          break;
      }

      singletone.useDetail = detail;
      if (singletone.useDetail == true)
        singletone.commonIcon =
            resizeImage(
                singletone.resourceMgr.getDrawable(R.drawable.ic_process_system),
                singletone.iconSize);

      singletone.start();
    }

    return singletone;
  }
Esempio n. 3
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    infoHelper = ProcessUtil.getInstance(getSherlockActivity().getApplicationContext(), true);
    setListAdapter(new ConnectionListAdapter(getSherlockActivity().getApplicationContext()));
  }