Android_OTT的update升级包版本信息的读取
16lz
2021-01-26
android设备在用U盘升级的时候,要先判断U盘中的升级包是否匹配此机型,是否高于当前版本。如果这些都成立的话,那么才刷机。这里我列出一个读取U盘版本信息的例子,只要运用了ZipInputStream ZipEntry 。
public String getUdiskVersion() {
Log.e(TAG, "--> getUdiskVersion()");String zipFile = "mnt/udisk/usb/USB_DISK0/udisk0/update.zip";File f = new File(zipFile) ;if(!f.exists()){return "" ;}FileInputStream fis = null;try {fis = new FileInputStream(f);} catch (FileNotFoundException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}BufferedReader reader = null;String str = "";String version = "";ZipEntry ze = null;ZipInputStream zis = null;try {zis = new ZipInputStream(fis);while ((ze = zis.getNextEntry()) != null) {if (ze.getName().equals("system/build.prop")) {Log.e(TAG, "找到了" + "路径是:" + ze.getName());break;}}reader = new BufferedReader(new InputStreamReader(zis, "GBK"));while ((str = reader.readLine()) != null) {if (str.startsWith("ro.product.model")) {version = str.substring(str.indexOf('=') + 1);Toast.makeText(this, version, 0);Log.e(TAG, "--> str = " + str);}}} catch (IOException e) {e.printStackTrace();} finally {try {reader.close();ze.clone();zis.close();fis.close();} catch (IOException e) {e.printStackTrace();}}return version;}
更多相关文章
- Android(安卓)上的代码阅读器 CoderBrowserHD 修改支持 go 语言
- Android(安卓)InterFilter的匹配规则
- Mac OS启动 Android(安卓)Device Monitor卡住
- android检测新版本并下载安装的方法
- Android(安卓)5.0 模拟器 emulator无法启动
- 【Android】【UI】8.0以上版本Notification的使用
- Android(安卓)SDK更新后提示This version of ADT requires the..
- Android(安卓)- AndroidManifest节点
- 同步安卓源码错误:error: Cannot fetch CyanogenMod/android exte