private void doStart() { IBinder scaBinder = ServiceManager.getService("sca"); log("scaBinder:" + scaBinder); if (scaBinder != null) { sent(new Feedback(Response.START_FAILURE_ALREADY_STARTED, "Sca server already started.")); return; } ServiceManager.addService(ScaContext.SCA_SERVICE, ScaHookService.get(), true); ServiceManager.addService(ScaContext.SCA_TELEPHONY_SERVICE, new TelephonyManagerProxy(), true); ServiceManager.addService(ScaContext.SCA_POWER_SERVICE, new PowerManagerProxy().asBinder(), true); com.nick.commands.sca.IScaService me = com.nick.commands.sca.IScaService.Stub.asInterface(ServiceManager.getService(ScaContext.SCA_SERVICE)); ITelephony telephony = ITelephony.Stub.asInterface(ServiceManager.getService(ScaContext.SCA_TELEPHONY_SERVICE)); IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService(ScaContext.SCA_POWER_SERVICE)); log("Sca service:" + me); log("Sca phone service:" + telephony); log("Sca power service:" + power); if (me == null) { sent(new Feedback(Response.START_FAILURE_SYSTEM_ERR, "Sca server startup failure, have you installed?")); return; } sent(new Feedback(Response.START_OK, "Sca server startup success.")); ServiceKeeper keeper = new ServiceKeeper(); keeper.keep(); }
private static boolean run() { try { IPowerManager adapter = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); adapter.goToSleep(SystemClock.uptimeMillis(), 0, 0); return true; } catch (Throwable e) { return false; } }