mikehardy / react-native-update-apk

Update apk from non-play store servers, and update ios from app store in React Native.
MIT License
195 stars 57 forks source link

Bypassing authorization #79

Open ScreamZ opened 1 year ago

ScreamZ commented 1 year ago

Hi @mikehardy (you're everywhere ! RN Firebase, here, ;))

Thank you for this awesome library that is doing well. I'm currently working on improving the doc a bit and adding typescript support.

I'm using this library for a kiosk station far away from the company headquarters and while I'm using Expo with code push updates, I would like someday to be able to update the native code. Everything works well, despite I would like to bypass the modal asking for installing the APK ("Would you kike to update this application? Your data won't be lost). As the tablet is black-boxed, there is no interaction on it from the user, you need to use a screwdriver and wire USB peripherals to gain access to the interface, which is something I would like to avoid.

I have no access to the Play Store, do you have any idea how to proceed?

Thanks

ScreamZ commented 1 year ago

Have something like that, maybe we could add it to this library, will do some tests

    public static void rootInstallApk(File file) {
        PrintWriter printWriter;
        Process process = null;
        try {
            process = Runtime.getRuntime().exec("su");
            printWriter = new PrintWriter(process.getOutputStream());
//            printWriter.println("pm install -r " + file.toString()+"; reboot");
            String packageName = Global.application.getPackageName();
            printWriter.println("pm install -r " + file.toString()+"; am start -n "+packageName+"/com.app.FullscreenActivity");
            printWriter.flush();
            printWriter.close();
            process.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (process != null){
                process.destroy();
            }
        }
    }