Delegated-Scopes-Manager

在单设备上共享设备管理员权限

Stars
116

Delegated-Scopes-Manager

Android root App App

DevicePolicyManager.DELEGATION

DELEGATION_APP_RESTRICTIONS

DELEGATION_BLOCK_UNINSTALL

DELEGATION_CERT_INSTALL

DELEGATION_ENABLE_SYSTEM_APP

......

dsm-delegation-install-uninstall-app App API >= 23)

dsm-delegation-set-app-ops AppOps API >= 28)

App

implementation 'com.github.heruoxin.Delegated-Scopes-Manager:manager:master-SNAPSHOT'
  1. DeviceAdminReceiver#onEnabled CenterApp.getInstance(context).refreshState();

  2. App

startActivity(new Intent(CenterApp.ACTION_APP_LIST).setPackage(context.getPackageName()));

App

implementation 'com.github.heruoxin.Delegated-Scopes-Manager:client:master-SNAPSHOT'
  1. manifests
        <receiver
            android:name="yourAdminReceiver"
            android:permission="android.permission.BIND_DEVICE_ADMIN">
            <intent-filter>
                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
                <!-- -->
                <action android:name="android.app.develop.action.DEVICE_DELEGATION" />
            </intent-filter>

            <meta-data
                android:name="android.app.develop.delegation"
                android:resource="@xml/app_delegation" />
        </receiver>

app_delegation.xml

<?xml version="1.0" encoding="utf-8"?>
<device-delegation>
    <uses-policies>
        <!--  DevicePolicyManager.DELEGATION_APP_RESTRICTIONS  -->
        <delegation-app-restrictions />
        <!-- SDK  dsm-  -->
        <dsm-delegation-set-app-ops />
    </uses-policies>
</device-delegation>
  1. App
DSMClient.getOwnerSDKVersion(context) >= DSMClient.SDK_VERSION //  SDK

String packageName = DSMClient.getOwnerPackageName(context); // 
List<String> scopes = DSMClient.getDelegatedScopes(context); // 

// 
DSMClient.requestScopes(activity, DevicePolicyManager.DELEGATION_ENABLE_SYSTEM_APP, "dsm-delegation-install-uninstall-app", ...);
     
//  `Activity#onActivityResult`  `RESULT_OK` `RESULT_CANCEL`
  1. DevicePolicyManager DSMClient#installApp``DSMClient#setAppOpsMode

App

IceBoxApp Ops

License

WTFPL

License

  1. Lincense
Related Projects