Example #1
0
  public void switchOutputMode() {
    if (TurnkeyUiMainActivity.isResume) {
      MtkLog.i(TAG, "tk ui is running, can't change output mode.");
      return;
    }

    GetCurrentTask ctask = GetCurrentTask.getInstance(mContext);

    if (ctask.isCurActivtyMeidaMainActivity()) {
      toastNofunction();
      return;
    }

    if (!ctask.isCurTaskTKUI() && null != mtv) {
      try {
        int currentOutputMode = mtv.getCurrentOutputMode();
        if (ITVCommon.OUTPUT_MODE_NORMAL == currentOutputMode) {
          pipOn = false;
        }
      } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      //			 if (isCurrentModePIP()) {
      //			 DestroyApp.getTVDialogView(mContext.getApplicationContext())
      //			 .hide();
      //			 // changeModeToNormal();
      //			 TVOutputCommon common = TVOutputCommon.getInstance(mContext);
      //			 common.stop("sub");
      //			 } else {
      //			 changeModeToPip();
      //			 DestroyApp.getTVDialogView(mContext.getApplicationContext())
      //			 .show(mContext);
      //			 }
      if (pipOn) {
        DestroyApp.getTVDialogView(mContext.getApplicationContext()).hide();
        // changeModeToNormal();
        TVOutputCommon common = TVOutputCommon.getInstance(mContext);
        mTvContent.setScreenPosition("sub", 0, 0, 0, 0);
        // common.stop("sub");
        common.stopEx("sub", true);
        pipOn = false;
      } else {
        changeModeToPip();
        DestroyApp.getTVDialogView(mContext.getApplicationContext()).show(mContext);
        //				DestroyApp.getTVDialogView(mContext.getApplicationContext())
        //						.startCheckPosition();
        pipOn = true;
      }
    }
  }
Example #2
0
  public void swap3rdappTvapp() {
    ActivityManager mActivityManager =
        (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningTaskInfo> runningTaskList = mActivityManager.getRunningTasks(8);
    List<RunningTaskInfo> newRunningTaskList = mActivityManager.getMtkRunningTasks();

    if (runningTaskList.size() > newRunningTaskList.size()) {
      int i = 0, j = 0;
      while (i < runningTaskList.size() && j < newRunningTaskList.size()) {
        RunningTaskInfo child = runningTaskList.get(i);
        RunningTaskInfo newChild = newRunningTaskList.get(i);
        if (child.id != newChild.id) {
          runningTaskList.remove(i);
        } else {
          i++;
          j++;
        }
      }
      while (i < runningTaskList.size()) {
        runningTaskList.remove(i);
      }
    }

    if (runningTaskList != null && runningTaskList.size() > 1) {
      RunningTaskInfo currenTaskInfo = runningTaskList.get(0);
      ComponentName currentActivity = runningTaskList.get(0).topActivity;

      GetCurrentTask ct = GetCurrentTask.getInstance(mContext);

      if ("com.mediatek.ui.TurnkeyUiMainActivity".equals(currentActivity.getClassName())) {
        Intent mIntent = new Intent(START_ACTION);
        mContext.sendBroadcast(mIntent);
        if (mBreComponentName) {
          pauseMainOutput();

          try {
            ActivityManagerNative.getDefault().moveTaskToFront(mLastTastId, 0, null);
          } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }

          myHandler.removeMessages(MessageType.MESSAGE_FOR_CHECK_SWAP);
          MtkLog.d(TAG, "come in send MessageType.MESSAGE_FOR_CHECK_SWAP");
          myHandler.sendEmptyMessageDelayed(MessageType.MESSAGE_FOR_CHECK_SWAP, 700);
        }
      } else {
        if (ct.isCurActivtyMeidaMainActivity()) {
          toastNofunction();
          return;
        }

        if (!ct.isCurTaskTKUI()) {
          mBreComponentName = true;
          mLastTastId = currenTaskInfo.id;

          changeModeToNormal();

          try {
            for (int i = 0; i < runningTaskList.size(); i++) {
              if ("com.mediatek.ui.TurnkeyUiMainActivity"
                  .equals(runningTaskList.get(i).baseActivity.getClassName())) {
                ActivityManagerNative.getDefault()
                    .moveTaskToFront(runningTaskList.get(i).id, 0, null);
                break;
              }
            }
          } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    }
  }