title: Android Management API's Delegation Scopes do not seem to be acquired by Companion app
body: <p>Following the <a href="https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#DelegatedScope" rel="nofollow noreferrer">Android Management API reference</a>, we've configured our Android Companion app to be able to : enable system apps, hide and unhide packages.</p>
  
  <p>We've added the following information in our policy configuration:</p>
  
  <pre><code>{
    '
    '
    '
    "applications": [
      {
        "packageName": "com.domain.app",
        "installType": "REQUIRED_FOR_SETUP",
        "defaultPermissionPolicy": "GRANT",
        "delegatedScopes": [
          "ENABLE_SYSTEM_APP",
          "PACKAGE_ACCESS"
        ]
      }
    ],
    '
    '
    '
  }
  </code></pre>
  
  <p>Then, in our Android Companion app, we've added the following lines of code in compliance with Google documentation <a href="https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#enableSystemApp(android.content.ComponentName,%20java.lang.String)" rel="nofollow noreferrer">here</a> and <a href="https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#setApplicationHidden(android.content.ComponentName,%20java.lang.String,%20boolean)" rel="nofollow noreferrer">here</a> :</p>
  
  <pre><code>DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
  ComponentName admin = new ComponentName(mContext, DeviceAdminReceiver.class);
  
  // Iterate through system application package names list
  for (String packageName : systemAppsList) {
    if (packageName != null &amp;&amp; !packageName.equals("")) {
      try {
        // Re-enable a system app that was disabled by default when the user was initialized
        dpm.enableSystemApp(admin, packageName);
  
        // Unhide a package (it could be any app : system, managed, etc...)
        dpm.setApplicationHidden(admin, packageName, false);
      } catch (SecurityException e) {
        e.printStackTrace();
        Log.e(TAG, e.getMessage());
      }
    }
  }
  </code></pre>
  
  <p>We expect the Android launcher to show the enabled system apps, but Android catches a <code>SecurityException</code> and prints the following error log :</p>
  
  <blockquote>
    <p>No active admin ComponentInfo{com.domain.app/android.app.admin.DeviceAdminReceiver}</p>
  </blockquote>
  
  <p>Do you have any idea about what could be wrong ?</p>