System customization

Dynamic Permissions

1.Shutdown/restart

Function:void setShundownOrReboot()

Remarks:

 1private void setShundownOrReboot(String appName , Boolean isReboot){
 2    try {
 3        Class<?> c = Class.forName("android.app.ActivityManager");
 4        Method method = c.getMethod("setShutdownOrRebootforApp",String.class,boolean.class);
 5        method.invoke(am,appName,isReboot);
 6        Log.d("iminSF","setShundownOrReboot : " + appName);
 7    } catch (Exception e) {
 8        e.printStackTrace();
 9    }
10}

parameter:

appName –> the package name of the app

isReboot –> ture indicates restart, false indicates shutdown

2.App installs in background

Function:void setSilenceInstall()

Remarks:

 1 private void setSilenceInstall(String apkName , String apkFilePath){
 2    try {
 3        Class<?> c = Class.forName("android.app.ActivityManager");
 4        Method method = c.getMethod("setSilenceInstallforApp",String.class,String.class);
 5        method.invoke(am,apkName,apkFilePath);
 6        Log.d("iminSF","setSilenceInstall : " + apkName);
 7    } catch (Exception e) {
 8        e.printStackTrace();
 9    }
10}

parameter:

apkName –> the package name of the app

apkFilePath –> Path to install the APK package silently, for example, String apkFilePath = “/sdcard/test.apk”;