电视TV开发之App升级权限不够无法安装,应用权限给了还是无法安装

244 阅读1分钟

App更新失败需要权限;应用权限给了还是无法安装,执行安装依然还是没有权限,需要给775权限,才能继续执行安装;

/***检查安装权限**/
if(isInstallPermissions(path)){
    ApkUtil.installApp(context, path);
}else {
    Log.e(Tag,"安装授权失败:");
}						

 * @param path 路径地址
 * @return
 */
public Boolean isInstallPermissions(String path){
    try {
        String cmd = "chmod 755 " +path;
        Process process =Runtime.getRuntime().exec(cmd);
        try {
            int exitValue = process.waitFor();
            if (0 == exitValue) {
                ApkUtil.installApp(context, path);
                return true;
            }else {
                Toast.makeText(context,"error code is:"+exitValue,Toast.LENGTH_LONG).show();
                return false;
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
            Toast.makeText(context,"error:"+e,Toast.LENGTH_LONG).show();
            return false;
        }
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(context,"error:"+e,Toast.LENGTH_LONG).show();
        return false;
    }
}