title: How to use reflection to change backup service?
body: <p>I posted a <a href="https://stackoverflow.com/q/30343205/1720332">question</a> about a new behavior of Android 5.1 that disables the Backup Service when setting up a device-owner on a device here...</p>
  
  <p>A possible solution could be (I guess) to use reflection to fix the issue: I could find some reflection examples using a particular method in a hidden class, but this case looks more complicated, with a constructor that uses another hidden class (ServiceManager) etc. and I dunno how to do this...</p>
  
  <p>The code that is annoying me is located in DevicePolicyManagerService.java (can be found <a href="https://android.googlesource.com/platform/frameworks/base/+/master/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java" rel="nofollow noreferrer">here</a>) on lines 3739 to 3749:</p>
  
  <pre><code>long ident = Binder.clearCallingIdentity();
  try {
      IBackupManager ibm = IBackupManager.Stub.asInterface(
          ServiceManager.getService(Context.BACKUP_SERVICE));
      ibm.setBackupServiceActive(UserHandle.USER_OWNER, false);
  } catch (RemoteException e) {
      throw new IllegalStateException("Failed deactivating backup service.", e);
  } finally {
      Binder.restoreCallingIdentity(ident);
  }
  </code></pre>
  
  <p>And my goal would be to re-enable the Backup Service, ideally this would call something like:</p>
  
  <pre><code>ibm.setBackupServiceActive(UserHandle.USER_OWNER, false);
  </code></pre>
  
  <p>Could you help me to do this ?</p>