SD卡自动升级即把升级包拷到SD卡后,一点button自动完成所有升级的工作,
不用再手动去点选升级包,主要涉及到三个步骤:
1.检测升级包是否存在
2.将升级包所在的路径保存到cache中,重启进入recovery模式
3.取出升级包路径,根据升级包路径找到升级包,完成升级工作.
1.检测升级包是否存在
先确认SD卡是否存在:
public boolean checkSDExist(){
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
return true;
}
return false;
}
再判断升级包是否存在
String sdcardPath = null;
String defaultPath = null;
StorageManager storageManager = StorageManager.from(this);
final StorageVolume[] volumes = storageManager.getVolumeList();
for(StorageVolume volume : volumes){
if(volume.isRemovable()){
sdcardPath = volume.getPath();
}else{
defaultPath = volume.getPath();
}
}
File file &