The actions are triggered by sending an intent to the service. From there, the commands are executed with system-level permissions. Depending on the commands you want to run you’ll have to add permissions to your app’s manifest file.
See below for possible commands you can use.
// Power down the device. Requires com.handheldgroup.shutdown.SHUTDOWN permission public void shutdown() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.SHUTDOWN"); intent.setPackage("com.handheldgroup.shutdown"); startService(intent); } // Reboot the device. Requires com.handheldgroup.shutdown.SHUTDOWN permission public void reboot() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.SHUTDOWN"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("reboot", true); startService(intent); } // Turn off screen / lock the device. Requires com.handheldgroup.shutdown.SHUTDOWN permission public void lockScreen() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.SLEEP"); intent.setPackage("com.handheldgroup.shutdown"); startService(intent); } // Install apk file. Requires com.handheldgroup.shutdown.INSTALL permission public void installApp() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.INSTALL"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("path", (new File(Environment.getExternalStorageDirectory(), "your-app.apk")).getAbsolutePath()); startService(intent); } // Enables or disables a app by its package. Requires com.handheldgroup.shutdown.ACTIVATE permission public void deactivateApp() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.ACTIVATE"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("package", "com.android.calculator2"); intent.putExtra("enable", false); startService(intent); } // Enables or disables usb debugging. Requires com.handheldgroup.shutdown.USB permission public void disableUsbdebug() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.USB"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("activate", false); startService(intent); } // Sets the screen rotation // value can be -1 for automatic rotation, 0 for 0┬░, 1 for 90┬░, 2 for 180┬░ or 3 for 270┬░ public void setScreenRotation() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.SCREEN_ROTATION"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("rotation", value); startService(intent); } // Sets the screen timeout // value can be -1 for never, 0 for 15 sec, 1 for 30 sec, 2 for 1 min, 3 for 2 min, 4 for 10 min or 5 for 30 min public void setScreenTimeout() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.SCREEN_TIMEOUT"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("timeout", value); startService(intent); } // Sets the screen brightness // value can be any percentage between 0-100 or -1 for automatic brightness public void setScreenBrightness() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.SCREEN_BRIGHTNESS"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("brightness", value); startService(intent); } // Enabled or disables NFC // value can true or false public void setNfcEnabled() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.NFC"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("enable", value); startService(intent); } // Enabled or disables Airplane mode // value can true or false public void setAirplaneEnabled() { Intent intent = new Intent(); intent.setAction("com.handheldgroup.shutdown.AIRPLANE_MODE"); intent.setPackage("com.handheldgroup.shutdown"); intent.putExtra("enable", value); startService(intent); }
Release notes
See the release notes for this article here.