Example usage for android.app.admin DevicePolicyManager setProfileOwner

List of usage examples for android.app.admin DevicePolicyManager setProfileOwner

Introduction

In this page you can find the example usage for android.app.admin DevicePolicyManager setProfileOwner.

Prototype

public boolean setProfileOwner(@NonNull ComponentName admin, @Deprecated String ownerName, int userHandle)
        throws IllegalArgumentException 

Source Link

Usage

From source file:com.android.managedprovisioning.ProfileOwnerProvisioningService.java

private void setMdmAsManagedProfileOwner() throws ProvisioningException {
    ProvisionLogger.logd("Setting package " + mParams.deviceAdminComponentName + " as managed profile owner.");

    DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (!dpm.setProfileOwner(mParams.deviceAdminComponentName,
            mParams.deviceAdminComponentName.getPackageName(), mManagedProfileOrUserInfo.id)) {
        ProvisionLogger.logw("Could not set profile owner.");
        throw raiseError("Could not set profile owner.");
    }/*  ww w.  j av  a2 s. co m*/
}