I am trying to provision a Meta Quest headset with a custom MDM (SecureGuard) by setting it as the Device Owner via ADB.
The Goal: Run the command: adb shell dpm set-device-owner com.secureguard.mdm/.SecureGuardDeviceAdminReceiver
The Problem: The command fails with java.lang.IllegalStateException: Not allowed to set the device owner because there are already some accounts on the device.
The Paradox:
To set a Device Owner, I must remove all accounts (Meta/Oculus/Horizon).
To have ADB access to run the command, Developer Mode must be enabled.
On Meta Quest, Developer Mode requires a Meta account to be logged in.
What I have tried:
pm clear or pm disable-user on com.oculus.horizon → Failed (SecurityException: Protected Package).
Trying to open native Android Settings via am start to remove accounts manually → Failed (Permission Denial).
Using Activity Launcher to access Settings$AccountsActivity → The specific activities crash or refuse to open.
My Question: Is there a known workaround or a “race condition” script that allows removing the primary Meta account while keeping the ADB session alive long enough to set the Device Owner? Or is there a specific intent/activity I can launch to remove accounts without killing the ADB session immediately?
If I understood correctly, you wrote that I would try the command adb shell pm disable-user --user 0 com.oculus.horizon or adb shell pm disable-user --user 0
Both of them don’t work
C:\\Users\\user\\Downloads\\platform-tools-latest-windows\\platform-tools>adb shell am start -n com.android.settings/com.android.settings.Settings$AccountDashboardActivity
Starting: Intent { cmp=com.android.settings/.Settings }
Exception occurred while executing ‘start’:
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.android.settings/.Settings } from null (pid=30610, uid=2000) not exported from uid 1000
at com.android.server.wm.ActivityTaskSupervisor.checkStartAnyActivityPermission(ActivityTaskSupervisor.java:1197)
at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1113)
at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:768)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1295)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1246)
at com.android.server.am.ActivityManagerService.startActivityAsUserWithFeature(ActivityManagerService.java:3321)
at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:728)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:235)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:40)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10160)
at android.os.Binder.shellCommand(Binder.java:1093)
at android.os.Binder.onTransact(Binder.java:913)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5436)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2793)
at android.os.Binder.execTransactInternal(Binder.java:1369)
at android.os.Binder.execTransact(Binder.java:1300)
C:\\Users\\user\\Downloads\\platform-tools-latest-windows\\platform-tools>adb shell am start -n “com.android.settings/com.android.settings.Settings$AccountDashboardActivity”
Starting: Intent { cmp=com.android.settings/.Settings }
Exception occurred while executing ‘start’:
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.android.settings/.Settings } from null (pid=30777, uid=2000) not exported from uid 1000
at com.android.server.wm.ActivityTaskSupervisor.checkStartAnyActivityPermission(ActivityTaskSupervisor.java:1197)
at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1113)
at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:768)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1295)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1246)
at com.android.server.am.ActivityManagerService.startActivityAsUserWithFeature(ActivityManagerService.java:3321)
at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:728)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:235)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:40)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10160)
at android.os.Binder.shellCommand(Binder.java:1093)
at android.os.Binder.onTransact(Binder.java:913)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5436)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2793)
at android.os.Binder.execTransactInternal(Binder.java:1369)
at android.os.Binder.execTransact(Binder.java:1300)
Is there a way to maybe flash the firmware?
Then configure it
If it goes into download mode is it possible to flash?
How can I try to flash without taking a risk on the device