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); }
public List<ServiceInfoBean> getServiceInfoInSearchResult( NativeInstallation.Install_Search_Result_t searchResult) { ServiceInfoBean serviceInfoBean = null; TPInfoBean tpInfoBean = null; List<ServiceInfoBean> serviceInfoBeans = new ArrayList<ServiceInfoBean>(); Install_Serv_t[] servList = searchResult.ptServList; if (servList.length != 0) { for (int i = 0; i < servList.length; i++) { serviceInfoBean = new ServiceInfoBean(); String servName = servList[i].sServName; if (null == servName || "".equals(servName)) { servName = "SDT:" + servList[i].u16ServId; } Install_Tp_t tpDesc = servList[i].ptTpDesc; DVBCore_Cab_Desc_t tunerDesc = tpDesc.uTunerDesc; char tunerId = tunerDesc.getU8TunerId(); int freq = tunerDesc.getU32Freq(); int symbRate = tunerDesc.getU32SymbRate(); int mod = tunerDesc.geteMod(); int fec_Inner = tunerDesc.geteFEC_Inner(); int fec_Outer = tunerDesc.geteFEC_Outer(); serviceInfoBean.setTunerType(tpDesc.eSignalSource); serviceInfoBean.setServiceId(servList[i].u16ServId); serviceInfoBean.setServiceType(servList[i].u8ServType); serviceInfoBean.setPmtPid(servList[i].u16PMTPid); serviceInfoBean.setCaMode(servList[i].u8FreeCA_Mode); serviceInfoBean.setChannelName(servName); serviceInfoBean.setLogicalNumber(servList[i].u16LogicalNum); serviceInfoBean.setAudioPid(servList[i].u16AudioPid); serviceInfoBean.setAudioType((int) servList[i].u8AudioFmt); serviceInfoBean.setVideoPid(servList[i].u16VideoPid); serviceInfoBean.setVideoType((int) servList[i].u8VideoFmt); // serviceInfoBean.setEcmId(ecmId); // serviceInfoBean.setEmmId(emmId); tpInfoBean = new TPInfoBean(); tpInfoBean.setTunerType(tpDesc.eSignalSource); tpInfoBean.setTunerId(tunerId); tpInfoBean.setNetId(tpDesc.u16NetId); tpInfoBean.setOriginalNetId(tpDesc.u16ON_Id); tpInfoBean.setTranStreamId(tpDesc.u16TS_Id); tpInfoBean.setTunerFreq(freq); tpInfoBean.setTunerSymbRate(symbRate); tpInfoBean.setTunerEmod(mod); tpInfoBean.setEfecInner(fec_Inner); tpInfoBean.setEfecOuter(fec_Outer); tpInfoBean.setPatVersion(tpDesc.u8Pat_Ver); serviceInfoBean.setTpInfoBean(tpInfoBean); serviceInfoBeans.add(serviceInfoBean); } } return serviceInfoBeans; }
/** * <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; }