Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7fb74af authored by Ameya Thakur's avatar Ameya Thakur
Browse files

services: Add hook to run device specific shutdown code.

Add hook to call OEM specific shutdown synchronously. OEMs
need to add ShutdownOem class and define deviceRebootOrShutdown
function in that.

ShutdownThread class would call this OEM defined function
just before shutting down the device.

Change-Id: I620495bfc99c6b0855a98ac54c6ede96e20ff1b8
parent e11c83c0
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.internal.telephony.msim.ITelephonyMSim;

import android.util.Log;
import android.view.WindowManager;
import java.lang.reflect.Method;

public final class ShutdownThread extends Thread {
    // constants
@@ -544,8 +545,35 @@ public final class ShutdownThread extends Thread {
            }
        }

        // Oem specific shutdown
        deviceRebootOrShutdown(reboot, reason);

        // Shutdown power
        Log.i(TAG, "Performing low-level shutdown...");
        PowerManagerService.lowLevelShutdown();
    }

    private static void deviceRebootOrShutdown(boolean reboot, String reason) {

        Class<?> cl;
        String deviceShutdownClassName = "com.qti.server.power.ShutdownOem";

        try{
            cl = Class.forName(deviceShutdownClassName);
            Method m;
            try {
                m = cl.getMethod("rebootOrShutdown", new Class[]{boolean.class, String.class});
                m.invoke(cl.newInstance(), reboot, reason);

            } catch (NoSuchMethodException ex) {
                //Method not found.
            } catch (Exception ex) {
                //Unknown exception
            }
        }catch(ClassNotFoundException e){
        //Classnotfound!
        }catch(Exception e){
        //Unknown exception
        }
     }
}