/** * <get usb stroage devices> * * @return usb stroage devices * @see [Class,Class#Method,Class#Member] */ public MountInfoBean getMobileHDDInfo() { List<MountInfoBean> list = getAllMountDevices(); long totleSize = 0; long freeSize = 0; MountInfoBean mBean = null; android.os.StatFs statfs = null; if (null == list) { return null; } for (MountInfoBean bean : list) { // usb stroage. if (bean.getType() == 1) { try { statfs = new android.os.StatFs(bean.getPath()); } catch (Exception e) { e.printStackTrace(); } long[] deviceInfo = getStorageSize(statfs); if (deviceInfo != null && deviceInfo.length > 0) { totleSize = deviceInfo[0]; freeSize = deviceInfo[1]; bean.setTotleSize(totleSize); bean.setFreeSize(freeSize); mBean = bean; break; } } } return mBean; }
/** * <get all external devices> <Functional Details> * * @return external devices collection. * @see [Class,Class#Method,Class#Member] */ private List<MountInfoBean> getAllMountDevices() { List<MountInfoBean> list = new ArrayList<MountInfoBean>(); MountInfoBean bean = null; String path = null; StorageVolume[] storageVolumes = mStorageManager.getVolumeList(); if (null != storageVolumes) { for (int i = 0; i < storageVolumes.length; i++) { bean = new MountInfoBean(); path = storageVolumes[i].getPath(); bean.setPath(path); bean.setType(getPathType(path)); list.add(bean); } } return list; }
/** * <check the external devices status> * * @return 0:success 1:not enough spaces 2:no devices * @see [Class,Class#Method,Class#Member] */ public int checkHDDSpace() { long freeSize; MountInfoBean bean = null; int result = 0; try { bean = getMobileHDDInfo(); if (null != bean) { freeSize = bean.getFreeSize(); LogUtils.printLog(1, 3, TAG, "--->>>check the external device free size is: " + freeSize); if (freeSize < Integer.parseInt(context.getString(R.string.free_space))) { result = 1; } } else { result = 2; } } catch (Exception e) { e.printStackTrace(); } return result; }
public void run() { // parser the entrance of dvb. Uri data = getIntent().getData(); entrance = data.getSchemeSpecificPart(); bootDefaultStatus = getIntent().getIntExtra("service_id", 0); synchronized (LoadDriveService.class) { // load drive and init the CA. nativeDrive = new NativeDrive(SplashActivity.this); nativeDrive.pvwareDRVInit(); nativeDrive.CAInit(); NativeSystemInfo SystemInfo = new NativeSystemInfo(); SystemInfo.SystemInfoInit(SplashActivity.this); } // load player NativePlayer dvbPlayer = NativePlayer.getInstance(); dvbPlayer.DVBPlayerInit(null); dvbPlayer.DVBPlayerSetStopMode(1); // parser the last play program. parserLastProgram(); // process rec logic. synchronized (SplashActivity.class) { PVR_Rec_Status_t recFile = dvbPlayer.new PVR_Rec_Status_t(); dvbPlayer.DVBPlayerPvrRecGetStatus(recFile); int status = recFile.getEnState(); LogUtils.printLog(1, 3, TAG, "-----Rec File return value----->>>" + status); if (status == 2 || status == 3) { recStatus = true; recBundle = parserRecProgram(); } } // delete the time.ts. StorageUtils util = new StorageUtils(SplashActivity.this); MountInfoBean mountInfoBean = util.getMobileHDDInfo(); if (null != mountInfoBean) { // set ts file's name. String tmsFilePath = mountInfoBean.getPath() + "/time.ts"; LogUtils.printLog(1, 3, TAG, "------time file path------->>>" + tmsFilePath); File file = new File(tmsFilePath); if (file.exists()) { dvbPlayer.DVBPlayerPvrRemoveFile(tmsFilePath); } } // get the super and parent-child's password. superPwd = android.provider.Settings.System.getString(getContentResolver(), "password"); if (null == superPwd) { superPwd = Config.SUPER_PASSWORD; } // get programme grade. try { grade = android.provider.Settings.System.getInt(getContentResolver(), "eit_grade"); } catch (SettingNotFoundException e) { // get the eit grade exception, set the default value. grade = 1; e.printStackTrace(); } handler.sendEmptyMessage(Config.CONNECTION_SUCCESS); }