Search code examples
androidandroid-sourceota

java.io.FileNotFoundException: /cache/recovery/uncrypt_file: open failed: EACCES (Permission denied)


It confused me with this Error:

java.io.FileNotFoundException: /cache/recovery/uncrypt_file: open failed: EACCES (Permission denied)

when I used this methodRecoverySystem.installPackage(),and my ota path was in sdcard.My android version is 6.0.1,and the source code ofRecoverySystem.installPackage()as follows:

public static void installPackage(Context context, File packageFile)
    throws IOException {
    String filename = packageFile.getCanonicalPath();

    FileWrite uncryptFile=new FileWriter(UNCRYPT_FILE);
    try{
        uncryptFile.write(filename+"\n");
    }finally{
        uncryptFile.close();
    }

    Log.w(TAG, "!!! REBOOTING TO INSTALL " + filename + " !!!");

    if(filename.startWith("/data/")){
       filename="@/cache/recovery/block.map";
    }  
    final String filenameArg = "--update_package=" + filename;
    final String localeArg = "--locale=" + Locale.getDefault().toString();
    bootCommand(context, filenameArg, localeArg);
}

Solution

  • It is not working since your default app is installed in the folder /system/app folder. You should move it to /system/priv-app.