Skip to content

ztc1997/anycall

Repository files navigation

anycall

This project can run as root to call system service IPC from normal apps.

You can find the native part here

Use

This module simple demonstrates how to call the PowerManager.goToSleep(long uptimeMillis) to turn the screen off.

  1. Import Available on jcenter
compile 'com.ztc1997.anycall:library:x.y.z'
  1. Initializes an Anycall instance
Anycall anycall = new Anycall(this);
anycall.startShell(new Anycall.StartShellListener() {
    @Override
    public void onFinish(boolean success) {
        output.append("Start shell success = " + success + "\n");
    }
});
  1. Calling the IPC method
anycall.callMethod("android.os.IPowerManager", POWER_SERVICE, "goToSleep",
       SystemClock.uptimeMillis(), new Anycall.CallMethodResultListener() {
           @Override
           public boolean onResult(int resultCode, Parcel reply) {
               output.append("Go to sleep resultCode = " + resultCode + "\n");
               Log.d(TAG, "resultCode = " + resultCode);
               try {
                   reply.readException();
               } catch (Exception e) {
                   e.printStackTrace();
               }
               return true;
           }
       });
  1. Recycle resources
anycall.stopShell();

known bugs

  1. Because there is no time to compile the binaries, temporarily can only use in Android 6.0-7.1.

About

Call system service IPC from normal apps (ROOT)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages