0 votes
by (260 points)

Is there a way to run the update (download and install process) of PUI firmware from Unity C# or Android Java code? We have some devices we want to update remotely.

1 Answer

0 votes
by (2.8k points)
selected by
 
Best answer

You can install package using the following code

public static void rebootAndUpdate(Context context, String filePath) {
    File updateFile = new File(filePath);
    if (!updateFile.exists()) {
        return;
    }
    try {
        Class<?> sysClass = Class.forName("android.os.RecoverySystem");
        Method method = sysClass.getMethod("installPackage",
                new Class[]{Context.class, File.class, boolean.class});
        method.invoke(null, context, updateFile, false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
...