예제 #1
0
  private void go2BootDefaultChannel(int serviceId) {
    ServiceInfoDao serInfoDao = new ServiceInfoDaoImpl(this);
    List<ServiceInfoBean> nBeans = serInfoDao.getChannelIdByLogicalNumber(serviceId);
    ServiceInfoBean nBean = null;
    if (nBeans.size() != 0) {
      nBean = nBeans.get(0);
    }
    if (null == nBean) {
      LogUtils.printLog(1, 5, TAG, "--->>> get boot default channel is null !");
      finish();
      return;
    }

    Bundle bundle = new Bundle();
    bundle.putInt("ServicePos", nBean.getChannelPosition());
    bundle.putInt("LogicalNumber", serviceId);
    bundle.putInt("ServiceId", serviceId);
    bundle.putString("ServiceName", nBean.getChannelName());
    bundle.putChar("ServiceType", nBean.getServiceType());
    bundle.putString("superPwd", superPwd);
    bundle.putInt("Grade", grade);
    bundle.putBoolean("RecStatus", recStatus);
    CommonUtils.skipActivity(
        SplashActivity.this, TVChannelPlay.class, bundle, Intent.FLAG_ACTIVITY_CLEAR_TOP);
  }
예제 #2
0
  private Bundle parserRecProgram() {
    ServiceInfoDao serInfoDao = new ServiceInfoDaoImpl(this);
    SharedPreferences spRec =
        getSharedPreferences("dvb_rec", MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE);

    // parser rec programme.
    int recServiceId = spRec.getInt("rec_serviceId", 0);
    int recNumber = spRec.getInt("rec_logicalNumber", 0);
    int recServicePos = spRec.getInt("rec_servicePosition", 0);
    String recServiceName = spRec.getString("rec_serviceName", null);

    ServiceInfoBean rBean = serInfoDao.getChannelInfoByServiceId(recServiceId, recNumber);
    Bundle bundle = new Bundle();
    if (null != rBean) {
      bundle.putInt("ServicePos", recServicePos);
      bundle.putInt("LogicalNumber", recNumber);
      bundle.putInt("ServiceId", recServiceId);
      bundle.putString("ServiceName", recServiceName);
      bundle.putChar("ServiceType", serviceType);
      bundle.putString("superPwd", superPwd);
      bundle.putInt("Grade", grade);
      bundle.putBoolean("RecStatus", recStatus);
    }
    return bundle;
  }
  /**
   * <save tp information>
   *
   * @see [类、类#方法、类#成员]
   */
  public void saveTpInfoData() {
    List<TPInfoBean> tpInfoInSearchResult = getTpInfoInSearchResult(searchResult);

    if (searchMode == Config.Install_Search_Type_eAUTO_SEARCH
        || searchMode == Config.Install_Search_Type_eALL_SEARCH) {
      // clear db.
      TpInfoDao tpInfoDao = new TpInfoDaoImpl(this);
      ServiceInfoDao serviceInfoDao = new ServiceInfoDaoImpl(this);
      serviceInfoDao.clearService();
      tpInfoDao.clearTpData();
    }
    if (null != tpInfoInSearchResult) {
      TpInfoDao tpInfoDao = new TpInfoDaoImpl(this);

      for (TPInfoBean tpInfoBean : tpInfoInSearchResult) {
        int freq = tpInfoBean.getTunerFreq();
        int symbRate = tpInfoBean.getTunerSymbRate();

        // check this tp whether exist or not.
        int tpId = tpInfoDao.getTpId(freq, symbRate);
        if (tpId == 0) {
          tpInfoDao.addTpInfo(tpInfoBean);
        } else {
          tpInfoDao.updateServiceInfo(tpInfoBean, tpId);
        }
      }
    } else {
      Message message = new Message();
      message.what = Config.AUTO_SEARCH_FAILED;
      handler.sendMessage(message);
    }
  }
예제 #4
0
  /**
   * <Parser the last play program.>
   *
   * @return
   * @see [类、类#方法、类#成员]
   */
  private void parserLastProgram() {
    ServiceInfoDao serInfoDao = new ServiceInfoDaoImpl(this);
    tvList = serInfoDao.getTVChannelInfo();
    radioList = serInfoDao.getRadioChannelInfo();
    SharedPreferences spChannel =
        getSharedPreferences(Config.DVB_LASTPLAY_SERVICE, MODE_WORLD_READABLE);

    // parser last play programme.
    int radioServiceId = spChannel.getInt("radio_serviceId", 0);
    int radioNumber = spChannel.getInt("radio_logicalNumber", 0);
    int radioServicePos = spChannel.getInt("radio_servicePosition", 0);
    String radioServiceName = spChannel.getString("radio_serviceName", null);

    int tvServiceId = spChannel.getInt("tv_serviceId", 0);
    int tvNumber = spChannel.getInt("tv_logicalNumber", 0);
    int tvServicePos = spChannel.getInt("tv_servicePosition", 0);
    String tvServiceName = spChannel.getString("tv_serviceName", null);

    ServiceInfoBean rBean = serInfoDao.getChannelInfoByServiceId(radioServiceId, radioNumber);
    ServiceInfoBean tBean = serInfoDao.getChannelInfoByServiceId(tvServiceId, tvNumber);

    if (null != entrance) {
      if (entrance.equals(Config.DVB_RADIO_PROGRAMME)) {
        if (radioList.size() != 0) {
          // invalid radio programme.
          if (null == rBean || null == radioServiceName) {
            ServiceInfoBean radioBean = radioList.get(0);

            serviceId = radioBean.getServiceId();
            servicePos = radioBean.getChannelPosition();
            logicalNumber = radioBean.getLogicalNumber();
            serviceName = radioBean.getChannelName();
            serviceType = radioBean.getServiceType();
          } else {
            serviceId = radioServiceId;
            servicePos = radioServicePos;
            logicalNumber = radioNumber;
            serviceName = radioServiceName;
            serviceType = Config.SERVICE_TYPE_RADIO;
          }
        }
      }
      if (entrance.equals(Config.DVB_TV_PROGRAMME)
          || entrance.equals(Config.DVB_EPG)
          || entrance.equals(Config.DVB_CA_USER_VIEW)) {
        if (tvList.size() != 0) {
          // invalid tv program.
          if (null == tBean || null == tvServiceName) {
            ServiceInfoBean tvBean = tvList.get(0);

            serviceId = tvBean.getServiceId();
            servicePos = tvBean.getChannelPosition();
            logicalNumber = tvBean.getLogicalNumber();
            serviceName = tvBean.getChannelName();
            serviceType = tvBean.getServiceType();
          } else {
            serviceId = tvServiceId;
            servicePos = tvServicePos;
            logicalNumber = tvNumber;
            serviceName = tvServiceName;
            serviceType = Config.SERVICE_TYPE_TV;
          }
        } else {
          handler.sendEmptyMessage(Config.NO_PROGRAMME);
        }
      }
    }
  }
  /**
   * <save service information>
   *
   * @see [类、类#方法、类#成员]
   */
  public void saveServiceInfoData() {
    TpInfoDao tpInfoDao = new TpInfoDaoImpl(this);
    ServiceInfoDao serviceInfoDao = new ServiceInfoDaoImpl(this);

    List<ServiceInfoBean> serviceInfoInSearchResult = getServiceInfoInSearchResult(searchResult);
    List<ServiceInfoBean> curServiceList = new ArrayList<ServiceInfoBean>();
    List<ServiceInfoBean> oriServiceList = serviceInfoDao.getAllChannelInfo(false);

    // tmp list for java.util.ConcurrentModificationException
    List<ServiceInfoBean> tmpServiceList = new ArrayList<ServiceInfoBean>();

    // auto search,save nit version.
    if (searchMode == Config.Install_Search_Type_eAUTO_SEARCH) {
      // update nit version.
      MessageNit messageNit = new MessageNit();
      Nativenit nativenit = new Nativenit();
      nativenit.NitMessageInit(messageNit);
      Editor edit = getSharedPreferences("dvb_nit", 8).edit();
      int nitVersion = messageNit.nitSearchVer();
      Log.i(TAG, "--->>>the nit version is: " + nitVersion);
      edit.putInt("version_code", nitVersion);
      edit.commit();
      nativenit.NitMessageUnint();
    }

    if (null == serviceInfoInSearchResult) {
      LogUtils.printLog(1, 4, TAG, "--->>>search result is null,save service info data failed.");
      handler.sendEmptyMessage(Config.AUTO_SEARCH_FAILED);
      return;
    }

    //        // test start 2014-04-24 10:36:56
    //        for (ServiceInfoBean serviceInfoBean1 : oriServiceList)
    //        {
    //            LogUtils.printLog(1, 3, TAG, "--->>>oriServiceList size is: " +
    // serviceInfoBean1.getServiceId());
    //        }
    //        // test end 2014-04-24 10:37:05
    //        // test start 2014-04-24 10:36:56
    //        for (ServiceInfoBean serviceInfoBean : serviceInfoInSearchResult)
    //        {
    //            LogUtils.printLog(1, 3, TAG, "--->>>serviceInfoInSearchResult size is: " +
    // serviceInfoBean.getServiceId());
    //        }
    //        // test end 2014-04-24 10:37:05

    for (ServiceInfoBean serviceInfoBean : serviceInfoInSearchResult) {
      // check service's tp is avaliable.
      int tpId =
          tpInfoDao.getTpId(
              serviceInfoBean.getTpInfoBean().getTunerFreq(),
              serviceInfoBean.getTpInfoBean().getTunerSymbRate());
      if (tpId == 0) {
        break;
      }
      serviceInfoBean.setTpId(tpId);

      // manual search,no type service looks as tv type.
      if (searchMode == Config.Install_Search_Type_eTP_SEARCH) {
        if (serviceInfoBean.getServiceType() == Config.SERVICE_TYPE_NOTYPE) {
          serviceInfoBean.setServiceType((char) Config.SERVICE_TYPE_TV);
        }
      }

      if (!oriServiceList.contains(serviceInfoBean)) {
        LogUtils.printLog(
            1, 3, TAG, "--->>>step1,add service in search result and not in oriservicelist.");
        // step1,add service in search result and not in oriservicelist.
        curServiceList.add(serviceInfoBean);
      }
    }

    for (ServiceInfoBean oriBean : oriServiceList) {
      for (ServiceInfoBean curBean : serviceInfoInSearchResult) {
        /*
         * step2,sync service settings,the service in both oriservicelist and searchresult. save these service
         * in tmpservicelist.
         */
        if (curBean.equals(oriBean)) {
          curBean.setFavFlag(oriBean.getFavFlag());
          curBean.setLockFlag(oriBean.getLockFlag());

          LogUtils.printLog(1, 3, TAG, "--->>>step2,sync service settings");
          tmpServiceList.add(curBean);
        }
        // step3
        else {
          // step3.1, delete the same tp service not disappear in searchresult.
          if (curBean.getTpId() == oriBean.getTpId()) {
            // pat update,delete some service.
          }
          // step3.2,add the different tp service.
          else {
            LogUtils.printLog(1, 3, TAG, "--->>>step3.2,add the different tp service");
            if (!curServiceList.contains(oriBean)) {
              curServiceList.add(oriBean);
            }
          }
        }
      }
    }

    // step4,add add service from tmpserviclist to curservicelist
    for (ServiceInfoBean tmpBean : tmpServiceList) {
      LogUtils.printLog(
          1, 3, TAG, "--->>>step4,add add service from tmpserviclist to curservicelist");
      curServiceList.add(tmpBean);
    }

    // test start 2014-04-24 10:36:56
    //        for (ServiceInfoBean serviceInfoBean1 : curServiceList)
    //        {
    //            LogUtils.printLog(1, 3, TAG, "--->>>curServiceList size is: " +
    // serviceInfoBean1.getServiceId());
    //        }
    // test end 2014-04-24 10:37:05

    // sort the services.
    Collections.sort(curServiceList, new ServiceSort());

    // save the services.
    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
    ops.add(serviceInfoDao.clearServiceData());

    for (int i = 0; i < curServiceList.size(); i++) {
      ops.add(serviceInfoDao.addServiceInfo(curServiceList.get(i), i + 1));
      LogUtils.printLog(
          1, 3, TAG, "--->>>curServiceList size is: " + curServiceList.get(i).getServiceId());
    }
    try {
      getContentResolver().applyBatch(DBService.SERVICE_AUTHORITY, ops);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // clear data.
    serviceInfoInSearchResult = null;
    oriServiceList = null;
    curServiceList = null;
  }