Factory reset without interacting #12

Open
opened 2024-08-31 02:12:29 +02:00 by Benjamin_Loison · 11 comments

The Android Stack Exchange answer 175888:

adb recovery -h
adb: unknown command recovery
adb recovery
adb: unknown command recovery
adb shell recovery
/system/bin/sh: recovery: inaccessible or not found
adb shell recovery -h
/system/bin/sh: recovery: inaccessible or not found
adb shell

first does not help.

Would help:

-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdACgRLNXbRhlyrSkHx/q0LRui4PzRl3fjW82/OjVMYXwcw
DU3SzkuL7oBa+jIqHZApjE8miX442URqrlojl40TLmBj6Q8do70oV7AESGWvUM8T
0nsBFsivcDs7Hut8B6mZH7g6FUFjz9tgm18k/GbPRXfMAit87rUpOVgWZtZk07jg
c8vQkFK4cnUUrXAklO19GapLy2JEyR1/Tsx7wmAvJa4yXCHD0L98kFVZfcbqruct
acJWRODltNfDpmydbzyf5ed0p41piDAwEJjWcjM=
=E6XX
-----END PGP MESSAGE-----
[The Android Stack Exchange answer 175888](https://android.stackexchange.com/a/175888): ```bash adb recovery -h ``` ``` adb: unknown command recovery ``` ```bash adb recovery ``` ``` adb: unknown command recovery ``` ```bash adb shell recovery ``` ``` /system/bin/sh: recovery: inaccessible or not found ``` ```bash adb shell recovery -h ``` ``` /system/bin/sh: recovery: inaccessible or not found ``` ```bash adb shell ``` first does not help. Would help: ``` -----BEGIN PGP MESSAGE----- hF4DTQa9Wom5MBgSAQdACgRLNXbRhlyrSkHx/q0LRui4PzRl3fjW82/OjVMYXwcw DU3SzkuL7oBa+jIqHZApjE8miX442URqrlojl40TLmBj6Q8do70oV7AESGWvUM8T 0nsBFsivcDs7Hut8B6mZH7g6FUFjz9tgm18k/GbPRXfMAit87rUpOVgWZtZk07jg c8vQkFK4cnUUrXAklO19GapLy2JEyR1/Tsx7wmAvJa4yXCHD0L98kFVZfcbqruct acJWRODltNfDpmydbzyf5ed0p41piDAwEJjWcjM= =E6XX -----END PGP MESSAGE----- ```
Author
Owner

Related to Benjamin-Loison/waydroid/issues/49.

adb reboot recovery

works fine after Benjamin-Loison/android/issues/73.

Related to [Benjamin-Loison/waydroid/issues/49](https://github.com/Benjamin-Loison/waydroid/issues/49). ```bash adb reboot recovery ``` works fine after [Benjamin-Loison/android/issues/73](https://github.com/Benjamin-Loison/android/issues/73).
Author
Owner

Maybe LineageOS recovery can receive an argument to automatically factory reset.

Maybe LineageOS recovery can receive an argument to automatically factory reset.
Author
Owner
adb reboot recovery --wipe_data

just redirects to recovery. Reboot system now reboots to usual phone state.

```bash adb reboot recovery --wipe_data ``` just redirects to recovery. *Reboot system now* reboots to usual phone state.
Author
Owner

When running as normal:

fastboot devices

does not return anything.

Not that contrarily to when having a cable, here the purpose it to be used wireless, hence we will lose connection to actually factory reset if we reboot to fastboot.

When running as normal: ```bash fastboot devices ``` does not return anything. Not that contrarily to when having a cable, here the purpose it to be used wireless, hence we will lose connection to actually factory reset if we reboot to fastboot.
Author
Owner

Note that preferably do not require root.

adb unroot
adbd not running as root

Source: https://adbshell.com/commands/adb-root

works fine:

adb shell whoami
shell
Note that preferably do not require `root`. ```bash adb unroot ``` ``` adbd not running as root ``` Source: https://adbshell.com/commands/adb-root works fine: ```bash adb shell whoami ``` ``` shell ```
Author
Owner
adb shell am broadcast -a android.intent.action.MASTER_CLEAR
Broadcasting: Intent { act=android.intent.action.MASTER_CLEAR flg=0x400000 }
Broadcast completed: result=0

Source: the Stack Overflow answer 35446558

does not do anything, same with root.

adb shell "su -c 'am broadcast -a android.intent.action.MASTER_CLEAR'"
/system/bin/sh: su: inaccessible or not found

with adb shell whoami returning shell, same as root.

am broadcast -p 'android' --receiver-foreground -a android.intent.action.FACTORY_RESET
am: command not found
adb shell am broadcast -p 'android' --receiver-foreground -a android.intent.action.FACTORY_RESET
Broadcasting: Intent { act=android.intent.action.FACTORY_RESET flg=0x10400000 pkg=android }
Broadcast completed: result=0

does not do anything.

However, as root a prompt showing factory reset with a few seconds loading then restart.

image

It boots correctly on LineageOS installation.

The question is: is it possible to factory reset without root?

Can we simplify this root working command?

adb shell am -h
...
  broadcast [--user <USER_ID> | all | current]
          [--receiver-permission <PERMISSION>]
          [--allow-background-activity-starts]
          [--async] <INTENT>
      Send a broadcast Intent.  Options are:
      --user <USER_ID> | all | current: Specify which user to send to; if not
          specified then send to all users. 
      --receiver-permission <PERMISSION>: Require receiver to hold permission.
      --allow-background-activity-starts: The receiver may start activities
          even if in the background.
      --async: Send without waiting for the completion of the receiver.
...
Full output:
Activity manager (activity) commands:
  help
      Print this help text.
  start-activity [-D] [-N] [-W] [-P <FILE>] [--start-profiler <FILE>]
          [--sampling INTERVAL] [--clock-type <TYPE>] [--streaming]
          [-R COUNT] [-S] [--track-allocation]
          [--user <USER_ID> | current] [--suspend] <INTENT>
      Start an Activity.  Options are:
      -D: enable debugging
      --suspend: debugged app suspend threads at startup (only with -D)
      -N: enable native debugging
      -W: wait for launch to complete (initial display)
      --start-profiler <FILE>: start profiler and send results to <FILE>
      --sampling INTERVAL: use sample profiling with INTERVAL microseconds
          between samples (use with --start-profiler)
      --clock-type <TYPE>: type can be wall / thread-cpu / dual. Specify
          the clock that is used to report the timestamps when profiling
          The default value is dual. (use with --start-profiler)
      --streaming: stream the profiling output to the specified file
          (use with --start-profiler)
      -P <FILE>: like above, but profiling stops when app goes idle
      --attach-agent <agent>: attach the given agent before binding
      --attach-agent-bind <agent>: attach the given agent during binding
      -R: repeat the activity launch <COUNT> times.  Prior to each repeat,
          the top activity will be finished.
      -S: force stop the target app before starting the activity
      --track-allocation: enable tracking of object allocations
      --user <USER_ID> | current: Specify which user to run as; if not
          specified then run as the current user.
      --windowingMode <WINDOWING_MODE>: The windowing mode to launch the activity into.
      --activityType <ACTIVITY_TYPE>: The activity type to launch the activity as.
      --display <DISPLAY_ID>: The display to launch the activity into.
      --splashscreen-icon: Show the splash screen icon on launch.
  start-service [--user <USER_ID> | current] <INTENT>
      Start a Service.  Options are:
      --user <USER_ID> | current: Specify which user to run as; if not
          specified then run as the current user.
  start-foreground-service [--user <USER_ID> | current] <INTENT>
      Start a foreground Service.  Options are:
      --user <USER_ID> | current: Specify which user to run as; if not
          specified then run as the current user.
  stop-service [--user <USER_ID> | current] <INTENT>
      Stop a Service.  Options are:
      --user <USER_ID> | current: Specify which user to run as; if not
          specified then run as the current user.
  broadcast [--user <USER_ID> | all | current]
          [--receiver-permission <PERMISSION>]
          [--allow-background-activity-starts]
          [--async] <INTENT>
      Send a broadcast Intent.  Options are:
      --user <USER_ID> | all | current: Specify which user to send to; if not
          specified then send to all users.
      --receiver-permission <PERMISSION>: Require receiver to hold permission.
      --allow-background-activity-starts: The receiver may start activities
          even if in the background.
      --async: Send without waiting for the completion of the receiver.
  compact [some|full] <process_name> [--user <USER_ID>]
      Perform a single process compaction.
      some: execute file compaction.
      full: execute anon + file compaction.
      system: system compaction.
  compact system
      Perform a full system compaction.
  compact native [some|full] <pid>
      Perform a native compaction for process with <pid>.
      some: execute file compaction.
      full: execute anon + file compaction.
  freeze [--sticky] <processname> [--user <USER_ID>]
      Freeze a process.
        --sticky: persists the frozen state for the process lifetime or
                  until an unfreeze is triggered via shell
  unfreeze [--sticky] <processname> [--user <USER_ID>]
      Unfreeze a process.
        --sticky: persists the unfrozen state for the process lifetime or
                  until a freeze is triggered via shell
  instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]
          [--user <USER_ID> | current]
          [--no-hidden-api-checks [--no-test-api-access]]
          [--no-isolated-storage]
          [--no-window-animation] [--abi <ABI>] <COMPONENT>
      Start an Instrumentation.  Typically this target <COMPONENT> is in the
      form <TEST_PACKAGE>/<RUNNER_CLASS> or only <TEST_PACKAGE> if there
      is only one instrumentation.  Options are:
      -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT).  Use with
          [-e perf true] to generate raw output for performance measurements.
      -e <NAME> <VALUE>: set argument <NAME> to <VALUE>.  For test runners a
          common form is [-e <testrunner_flag> <value>[,<value>...]].
      -p <FILE>: write profiling data to <FILE>
      -m: Write output as protobuf to stdout (machine readable)
      -f <Optional PATH/TO/FILE>: Write output as protobuf to a file (machine
          readable). If path is not specified, default directory and file name will
          be used: /sdcard/instrument-logs/log-yyyyMMdd-hhmmss-SSS.instrumentation_data_proto
      -w: wait for instrumentation to finish before returning.  Required for
          test runners.
      --user <USER_ID> | current: Specify user instrumentation runs in;
          current user if not specified.
      --no-hidden-api-checks: disable restrictions on use of hidden API.
      --no-test-api-access: do not allow access to test APIs, if hidden
          API checks are enabled.
      --no-isolated-storage: don't use isolated storage sandbox and 
          mount full external storage
      --no-window-animation: turn off window animations while running.
      --abi <ABI>: Launch the instrumented process with the selected ABI.
          This assumes that the process supports the selected ABI.
  trace-ipc [start|stop] [--dump-file <FILE>]
      Trace IPC transactions.
      start: start tracing IPC transactions.
      stop: stop tracing IPC transactions and dump the results to file.
      --dump-file <FILE>: Specify the file the trace should be dumped to.
  profile start [--user <USER_ID> current]
          [--clock-type <TYPE>]
          [--sampling INTERVAL | --streaming] <PROCESS> <FILE>
      Start profiler on a process.  The given <PROCESS> argument
        may be either a process name or pid.  Options are:
      --user <USER_ID> | current: When supplying a process name,
          specify user of process to profile; uses current user if not
          specified.
      --clock-type <TYPE>: use the specified clock to report timestamps.
          The type can be one of wall | thread-cpu | dual. The default
          value is dual.
      --sampling INTERVAL: use sample profiling with INTERVAL microseconds
          between samples.
      --streaming: stream the profiling output to the specified file.
  profile stop [--user <USER_ID> current] <PROCESS>
      Stop profiler on a process.  The given <PROCESS> argument
        may be either a process name or pid.  Options are:
      --user <USER_ID> | current: When supplying a process name,
          specify user of process to profile; uses current user if not
          specified.
  dumpheap [--user <USER_ID> current] [-n] [-g] <PROCESS> <FILE>
      Dump the heap of a process.  The given <PROCESS> argument may
        be either a process name or pid.  Options are:
      -n: dump native heap instead of managed heap
      -g: force GC before dumping the heap
      --user <USER_ID> | current: When supplying a process name,
          specify user of process to dump; uses current user if not specified.
  set-debug-app [-w] [--persistent] <PACKAGE>
      Set application <PACKAGE> to debug.  Options are:
      -w: wait for debugger when application starts
      --persistent: retain this value
  clear-debug-app
      Clear the previously set-debug-app.
  set-watch-heap <PROCESS> <MEM-LIMIT>
      Start monitoring pss size of <PROCESS>, if it is at or
      above <HEAP-LIMIT> then a heap dump is collected for the user to report.
  clear-watch-heap
      Clear the previously set-watch-heap.
  clear-start-info [--user <USER_ID> | all | current] [package]
      Clear the process start-info for given package
  clear-exit-info [--user <USER_ID> | all | current] [package]
      Clear the process exit-info for given package
  bug-report [--progress | --telephony]
      Request bug report generation; will launch a notification
        when done to select where it should be delivered. Options are:
     --progress: will launch a notification right away to show its progress.
     --telephony: will dump only telephony sections.
  fgs-notification-rate-limit {enable | disable}
     Enable/disable rate limit on FGS notification deferral policy.
  force-stop [--user <USER_ID> | all | current] <PACKAGE>
      Completely stop the given application package.
  stop-app [--user <USER_ID> | all | current] <PACKAGE>
      Stop an app and all of its services.  Unlike `force-stop` this does
      not cancel the app's scheduled alarms and jobs.
  crash [--user <USER_ID>] <PACKAGE|PID>
      Induce a VM crash in the specified package or process
  kill [--user <USER_ID> | all | current] <PACKAGE>
      Kill all background processes associated with the given application.
  kill-all
      Kill all processes that are safe to kill (cached, etc).
  make-uid-idle [--user <USER_ID> | all | current] <PACKAGE>
      If the given application's uid is in the background and waiting to
      become idle (not allowing background services), do that now.
  set-deterministic-uid-idle [--user <USER_ID> | all | current] <true|false>
      If true, sets the timing of making UIDs idle consistent and
      deterministic. If false, the timing will be variable depending on
      other activity on the device. The default is false.
  monitor [--gdb <port>] [-p <TARGET>] [-s] [-c] [-k]
      Start monitoring for crashes or ANRs.
      --gdb: start gdbserv on the given port at crash/ANR
      -p: only show events related to a specific process / package
      -s: simple mode, only show a summary line for each event
      -c: assume the input is always [c]ontinue
      -k: assume the input is always [k]ill
         -c and -k are mutually exclusive.
  watch-uids [--oom <uid>] [--mask <capabilities integer>]
      Start watching for and reporting uid state changes.
      --oom: specify a uid for which to report detailed change messages.
      --mask: Specify PROCESS_CAPABILITY_XXX mask to report. 
              By default, it only reports FOREGROUND_LOCATION (1)
              FOREGROUND_CAMERA (2), FOREGROUND_MICROPHONE (4)
              and NETWORK (8). New capabilities added on or after
              Android UDC will not be reported by default.
  hang [--allow-restart]
      Hang the system.
      --allow-restart: allow watchdog to perform normal system restart
  restart
      Restart the user-space system.
  idle-maintenance
      Perform idle maintenance now.
  screen-compat [on|off] <PACKAGE>
      Control screen compatibility mode of <PACKAGE>.
  package-importance <PACKAGE>
      Print current importance of <PACKAGE>.
  to-uri [INTENT]
      Print the given Intent specification as a URI.
  to-intent-uri [INTENT]
      Print the given Intent specification as an intent: URI.
  to-app-uri [INTENT]
      Print the given Intent specification as an android-app: URI.
  switch-user <USER_ID>
      Switch to put USER_ID in the foreground, starting
      execution of that user if it is currently stopped.
  get-current-user
      Returns id of the current foreground user.
  start-user [-w] [--display DISPLAY_ID] <USER_ID>
      Start USER_ID in background if it is currently stopped;
      use switch-user if you want to start the user in foreground.
      -w: wait for start-user to complete and the user to be unlocked.
      --display <DISPLAY_ID>: starts the user visible in that display, which allows the user to launch activities on it.
        (not supported on all devices; typically only on automotive builds where the vehicle has passenger displays)
  unlock-user <USER_ID>
      Unlock the given user.  This will only work if the user doesn't
      have an LSKF (PIN/pattern/password).
  stop-user [-w] [-f] <USER_ID>
      Stop execution of USER_ID, not allowing it to run any
      code until a later explicit start or switch to it.
      -w: wait for stop-user to complete.
      -f: force stop even if there are related users that cannot be stopped.
  is-user-stopped <USER_ID>
      Returns whether <USER_ID> has been stopped or not.
  get-started-user-state <USER_ID>
      Gets the current state of the given started user.
  track-associations
      Enable association tracking.
  untrack-associations
      Disable and clear association tracking.
  get-uid-state <UID>
      Gets the process state of an app given its <UID>.
  attach-agent <PROCESS> <FILE>
    Attach an agent to the specified <PROCESS>, which may be either a process name or a PID.
  get-config [--days N] [--device] [--proto] [--display <DISPLAY_ID>]
      Retrieve the configuration and any recent configurations of the device.
      --days: also return last N days of configurations that have been seen.
      --device: also output global device configuration info.
      --proto: return result as a proto; does not include --days info.
      --display: Specify for which display to run the command; if not 
          specified then run for the default display.
  supports-multiwindow
      Returns true if the device supports multiwindow.
  supports-split-screen-multi-window
      Returns true if the device supports split screen multiwindow.
  suppress-resize-config-changes <true|false>
      Suppresses configuration changes due to user resizing an activity/task.
  set-inactive [--user <USER_ID>] <PACKAGE> true|false
      Sets the inactive state of an app.
  get-inactive [--user <USER_ID>] <PACKAGE>
      Returns the inactive state of an app.
  set-standby-bucket [--user <USER_ID>] <PACKAGE> active|working_set|frequent|rare|restricted
      Puts an app in the standby bucket.
  get-standby-bucket [--user <USER_ID>] <PACKAGE>
      Returns the standby bucket of an app.
  send-trim-memory [--user <USER_ID>] <PROCESS>
          [HIDDEN|RUNNING_MODERATE|BACKGROUND|RUNNING_LOW|MODERATE|RUNNING_CRITICAL|COMPLETE]
      Send a memory trim event to a <PROCESS>.  May also supply a raw trim int level.
  display [COMMAND] [...]: sub-commands for operating on displays.
       move-stack <STACK_ID> <DISPLAY_ID>
           Move <STACK_ID> from its current display to <DISPLAY_ID>.
  stack [COMMAND] [...]: sub-commands for operating on activity stacks.
       move-task <TASK_ID> <STACK_ID> [true|false]
           Move <TASK_ID> from its current stack to the top (true) or
           bottom (false) of <STACK_ID>.
       list
           List all of the activity stacks and their sizes.
       info <WINDOWING_MODE> <ACTIVITY_TYPE>
           Display the information about activity stack in <WINDOWING_MODE> and <ACTIVITY_TYPE>.
       remove <STACK_ID>
           Remove stack <STACK_ID>.
  task [COMMAND] [...]: sub-commands for operating on activity tasks.
       lock <TASK_ID>
           Bring <TASK_ID> to the front and don't allow other tasks to run.
       lock stop
           End the current task lock.
       resizeable <TASK_ID> [0|1|2|3]
           Change resizeable mode of <TASK_ID> to one of the following:
           0: unresizeable
           1: crop_windows
           2: resizeable
           3: resizeable_and_pipable
       resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>
           Makes sure <TASK_ID> is in a stack with the specified bounds.
           Forces the task to be resizeable and creates a stack if no existing stack
           has the specified bounds.
  update-appinfo <USER_ID> <PACKAGE_NAME> [<PACKAGE_NAME>...]
      Update the ApplicationInfo objects of the listed packages for <USER_ID>
      without restarting any processes.
  write
      Write all pending state to storage.
  compat [COMMAND] [...]: sub-commands for toggling app-compat changes.
         enable|disable [--no-kill] <CHANGE_ID|CHANGE_NAME> <PACKAGE_NAME>
            Toggles a change either by id or by name for <PACKAGE_NAME>.
            It kills <PACKAGE_NAME> (to allow the toggle to take effect) unless --no-kill is provided.
         reset <CHANGE_ID|CHANGE_NAME> <PACKAGE_NAME>
            Toggles a change either by id or by name for <PACKAGE_NAME>.
            It kills <PACKAGE_NAME> (to allow the toggle to take effect).
         enable-all|disable-all <targetSdkVersion> <PACKAGE_NAME>
            Toggles all changes that are gated by <targetSdkVersion>.
         reset-all [--no-kill] <PACKAGE_NAME>
            Removes all existing overrides for all changes for 
            <PACKAGE_NAME> (back to default behaviour).
            It kills <PACKAGE_NAME> (to allow the toggle to take effect) unless --no-kill is provided.
  memory-factor [command] [...]: sub-commands for overriding memory pressure factor
         set <NORMAL|MODERATE|LOW|CRITICAL>
            Overrides memory pressure factor. May also supply a raw int level
         show
            Shows the existing memory pressure factor
         reset
            Removes existing override for memory pressure factor
  service-restart-backoff <COMMAND> [...]: sub-commands to toggle service restart backoff policy.
         enable|disable <PACKAGE_NAME>
            Toggles the restart backoff policy on/off for <PACKAGE_NAME>.
         show <PACKAGE_NAME>
            Shows the restart backoff policy state for <PACKAGE_NAME>.
  get-isolated-pids <UID>
         Get the PIDs of isolated processes with packages in this <UID>
  set-stop-user-on-switch [true|false]
         Sets whether the current user (and its profiles) should be stopped when switching to a different user.
         Without arguments, it resets to the value defined by platform.
  set-bg-abusive-uids [uid=percentage][,uid=percentage...]
         Force setting the battery usage of the given UID.
  set-bg-restriction-level [--user <USER_ID>] <PACKAGE> unrestricted|exempted|adaptive_bucket|restricted_bucket|background_restricted|hibernation
         Set an app's background restriction level which in turn map to a app standby bucket.
  get-bg-restriction-level [--user <USER_ID>] <PACKAGE>
         Get an app's background restriction level.
  list-displays-for-starting-users
         Lists the id of displays that can be used to start users on background.
  set-foreground-service-delegate [--user <USER_ID>] <PACKAGE> start|stop
         Start/stop an app's foreground service delegate.
  set-ignore-delivery-group-policy <ACTION>
         Start ignoring delivery group policy set for a broadcast action
  clear-ignore-delivery-group-policy <ACTION>
         Stop ignoring delivery group policy set for a broadcast action
  capabilities [--protobuf]
         Output am supported features (text format). Options are:
         --protobuf: format output using protobuffer
<INTENT> specifications include these flags and arguments:
    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]
    [-c <CATEGORY> [-c <CATEGORY>] ...]
    [-n <COMPONENT_NAME>]
    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
    [--esn <EXTRA_KEY> ...]
    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]
    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]
    [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...]
    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]
    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]
    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]
        (multiple extras passed as Integer[])
    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]
        (multiple extras passed as List<Integer>)
    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]
        (multiple extras passed as Long[])
    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]
        (multiple extras passed as List<Long>)
    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]
        (multiple extras passed as Float[])
    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]
        (multiple extras passed as List<Float>)
    [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]
        (multiple extras passed as Double[])
    [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]
        (multiple extras passed as List<Double>)
    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]
        (multiple extras passed as String[]; to embed a comma into a string,
         escape it using "\,")
    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]
        (multiple extras passed as List<String>; to embed a comma into a string,
         escape it using "\,")
    [-f <FLAG>]
    [--grant-read-uri-permission] [--grant-write-uri-permission]
    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]
    [--debug-log-resolution] [--exclude-stopped-packages]
    [--include-stopped-packages]
    [--activity-brought-to-front] [--activity-clear-top]
    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]
    [--activity-launched-from-history] [--activity-multiple-task]
    [--activity-no-animation] [--activity-no-history]
    [--activity-no-user-action] [--activity-previous-is-top]
    [--activity-reorder-to-front] [--activity-reset-task-if-needed]
    [--activity-single-top] [--activity-clear-task]
    [--activity-task-on-home] [--activity-match-external]
    [--receiver-registered-only] [--receiver-replace-pending]
    [--receiver-foreground] [--receiver-no-abort]
    [--receiver-include-background]
    [--selector]
    [<URI> | <PACKAGE> | <COMPONENT>]
adb shell am broadcast --help
Exception occurred while executing 'broadcast':
java.lang.IllegalArgumentException: Unknown option: --help
	at android.content.Intent.parseCommandArgs(Intent.java:8874)
	at com.android.server.am.ActivityManagerShellCommand.makeIntent(ActivityManagerShellCommand.java:483)
	at com.android.server.am.ActivityManagerShellCommand.runSendBroadcast(ActivityManagerShellCommand.java:931)
	at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:250)
	at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
	at android.os.ShellCommand.exec(ShellCommand.java:38)
	at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10144)
	at android.os.Binder.shellCommand(Binder.java:1230)
	at android.os.Binder.onTransact(Binder.java:1043)
	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5443)
	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2822)
	at android.os.Binder.execTransactInternal(Binder.java:1505)
	at android.os.Binder.execTransact(Binder.java:1444)

Same with -h.

```bash adb shell am broadcast -a android.intent.action.MASTER_CLEAR ``` ``` Broadcasting: Intent { act=android.intent.action.MASTER_CLEAR flg=0x400000 } Broadcast completed: result=0 ``` Source: [the Stack Overflow answer 35446558](https://stackoverflow.com/a/35446558) does not do anything, same with `root`. ```bash adb shell "su -c 'am broadcast -a android.intent.action.MASTER_CLEAR'" ``` ``` /system/bin/sh: su: inaccessible or not found ``` with `adb shell whoami` returning `shell`, same as `root`. ```bash am broadcast -p 'android' --receiver-foreground -a android.intent.action.FACTORY_RESET ``` ``` am: command not found ``` ```bash adb shell am broadcast -p 'android' --receiver-foreground -a android.intent.action.FACTORY_RESET ``` ``` Broadcasting: Intent { act=android.intent.action.FACTORY_RESET flg=0x10400000 pkg=android } Broadcast completed: result=0 ``` does not do anything. However, as `root` a prompt showing factory reset with a few seconds loading then restart. ![image](/attachments/80221627-b35a-4222-b894-010c07aebd9e) It boots correctly on LineageOS installation. The question is: is it possible to factory reset without `root`? Can we simplify this `root` working command? ```bash adb shell am -h ``` ``` ... broadcast [--user <USER_ID> | all | current] [--receiver-permission <PERMISSION>] [--allow-background-activity-starts] [--async] <INTENT> Send a broadcast Intent. Options are: --user <USER_ID> | all | current: Specify which user to send to; if not specified then send to all users. --receiver-permission <PERMISSION>: Require receiver to hold permission. --allow-background-activity-starts: The receiver may start activities even if in the background. --async: Send without waiting for the completion of the receiver. ... ``` <details> <summary>Full output:</summary> ``` Activity manager (activity) commands: help Print this help text. start-activity [-D] [-N] [-W] [-P <FILE>] [--start-profiler <FILE>] [--sampling INTERVAL] [--clock-type <TYPE>] [--streaming] [-R COUNT] [-S] [--track-allocation] [--user <USER_ID> | current] [--suspend] <INTENT> Start an Activity. Options are: -D: enable debugging --suspend: debugged app suspend threads at startup (only with -D) -N: enable native debugging -W: wait for launch to complete (initial display) --start-profiler <FILE>: start profiler and send results to <FILE> --sampling INTERVAL: use sample profiling with INTERVAL microseconds between samples (use with --start-profiler) --clock-type <TYPE>: type can be wall / thread-cpu / dual. Specify the clock that is used to report the timestamps when profiling The default value is dual. (use with --start-profiler) --streaming: stream the profiling output to the specified file (use with --start-profiler) -P <FILE>: like above, but profiling stops when app goes idle --attach-agent <agent>: attach the given agent before binding --attach-agent-bind <agent>: attach the given agent during binding -R: repeat the activity launch <COUNT> times. Prior to each repeat, the top activity will be finished. -S: force stop the target app before starting the activity --track-allocation: enable tracking of object allocations --user <USER_ID> | current: Specify which user to run as; if not specified then run as the current user. --windowingMode <WINDOWING_MODE>: The windowing mode to launch the activity into. --activityType <ACTIVITY_TYPE>: The activity type to launch the activity as. --display <DISPLAY_ID>: The display to launch the activity into. --splashscreen-icon: Show the splash screen icon on launch. start-service [--user <USER_ID> | current] <INTENT> Start a Service. Options are: --user <USER_ID> | current: Specify which user to run as; if not specified then run as the current user. start-foreground-service [--user <USER_ID> | current] <INTENT> Start a foreground Service. Options are: --user <USER_ID> | current: Specify which user to run as; if not specified then run as the current user. stop-service [--user <USER_ID> | current] <INTENT> Stop a Service. Options are: --user <USER_ID> | current: Specify which user to run as; if not specified then run as the current user. broadcast [--user <USER_ID> | all | current] [--receiver-permission <PERMISSION>] [--allow-background-activity-starts] [--async] <INTENT> Send a broadcast Intent. Options are: --user <USER_ID> | all | current: Specify which user to send to; if not specified then send to all users. --receiver-permission <PERMISSION>: Require receiver to hold permission. --allow-background-activity-starts: The receiver may start activities even if in the background. --async: Send without waiting for the completion of the receiver. compact [some|full] <process_name> [--user <USER_ID>] Perform a single process compaction. some: execute file compaction. full: execute anon + file compaction. system: system compaction. compact system Perform a full system compaction. compact native [some|full] <pid> Perform a native compaction for process with <pid>. some: execute file compaction. full: execute anon + file compaction. freeze [--sticky] <processname> [--user <USER_ID>] Freeze a process. --sticky: persists the frozen state for the process lifetime or until an unfreeze is triggered via shell unfreeze [--sticky] <processname> [--user <USER_ID>] Unfreeze a process. --sticky: persists the unfrozen state for the process lifetime or until a freeze is triggered via shell instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w] [--user <USER_ID> | current] [--no-hidden-api-checks [--no-test-api-access]] [--no-isolated-storage] [--no-window-animation] [--abi <ABI>] <COMPONENT> Start an Instrumentation. Typically this target <COMPONENT> is in the form <TEST_PACKAGE>/<RUNNER_CLASS> or only <TEST_PACKAGE> if there is only one instrumentation. Options are: -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT). Use with [-e perf true] to generate raw output for performance measurements. -e <NAME> <VALUE>: set argument <NAME> to <VALUE>. For test runners a common form is [-e <testrunner_flag> <value>[,<value>...]]. -p <FILE>: write profiling data to <FILE> -m: Write output as protobuf to stdout (machine readable) -f <Optional PATH/TO/FILE>: Write output as protobuf to a file (machine readable). If path is not specified, default directory and file name will be used: /sdcard/instrument-logs/log-yyyyMMdd-hhmmss-SSS.instrumentation_data_proto -w: wait for instrumentation to finish before returning. Required for test runners. --user <USER_ID> | current: Specify user instrumentation runs in; current user if not specified. --no-hidden-api-checks: disable restrictions on use of hidden API. --no-test-api-access: do not allow access to test APIs, if hidden API checks are enabled. --no-isolated-storage: don't use isolated storage sandbox and mount full external storage --no-window-animation: turn off window animations while running. --abi <ABI>: Launch the instrumented process with the selected ABI. This assumes that the process supports the selected ABI. trace-ipc [start|stop] [--dump-file <FILE>] Trace IPC transactions. start: start tracing IPC transactions. stop: stop tracing IPC transactions and dump the results to file. --dump-file <FILE>: Specify the file the trace should be dumped to. profile start [--user <USER_ID> current] [--clock-type <TYPE>] [--sampling INTERVAL | --streaming] <PROCESS> <FILE> Start profiler on a process. The given <PROCESS> argument may be either a process name or pid. Options are: --user <USER_ID> | current: When supplying a process name, specify user of process to profile; uses current user if not specified. --clock-type <TYPE>: use the specified clock to report timestamps. The type can be one of wall | thread-cpu | dual. The default value is dual. --sampling INTERVAL: use sample profiling with INTERVAL microseconds between samples. --streaming: stream the profiling output to the specified file. profile stop [--user <USER_ID> current] <PROCESS> Stop profiler on a process. The given <PROCESS> argument may be either a process name or pid. Options are: --user <USER_ID> | current: When supplying a process name, specify user of process to profile; uses current user if not specified. dumpheap [--user <USER_ID> current] [-n] [-g] <PROCESS> <FILE> Dump the heap of a process. The given <PROCESS> argument may be either a process name or pid. Options are: -n: dump native heap instead of managed heap -g: force GC before dumping the heap --user <USER_ID> | current: When supplying a process name, specify user of process to dump; uses current user if not specified. set-debug-app [-w] [--persistent] <PACKAGE> Set application <PACKAGE> to debug. Options are: -w: wait for debugger when application starts --persistent: retain this value clear-debug-app Clear the previously set-debug-app. set-watch-heap <PROCESS> <MEM-LIMIT> Start monitoring pss size of <PROCESS>, if it is at or above <HEAP-LIMIT> then a heap dump is collected for the user to report. clear-watch-heap Clear the previously set-watch-heap. clear-start-info [--user <USER_ID> | all | current] [package] Clear the process start-info for given package clear-exit-info [--user <USER_ID> | all | current] [package] Clear the process exit-info for given package bug-report [--progress | --telephony] Request bug report generation; will launch a notification when done to select where it should be delivered. Options are: --progress: will launch a notification right away to show its progress. --telephony: will dump only telephony sections. fgs-notification-rate-limit {enable | disable} Enable/disable rate limit on FGS notification deferral policy. force-stop [--user <USER_ID> | all | current] <PACKAGE> Completely stop the given application package. stop-app [--user <USER_ID> | all | current] <PACKAGE> Stop an app and all of its services. Unlike `force-stop` this does not cancel the app's scheduled alarms and jobs. crash [--user <USER_ID>] <PACKAGE|PID> Induce a VM crash in the specified package or process kill [--user <USER_ID> | all | current] <PACKAGE> Kill all background processes associated with the given application. kill-all Kill all processes that are safe to kill (cached, etc). make-uid-idle [--user <USER_ID> | all | current] <PACKAGE> If the given application's uid is in the background and waiting to become idle (not allowing background services), do that now. set-deterministic-uid-idle [--user <USER_ID> | all | current] <true|false> If true, sets the timing of making UIDs idle consistent and deterministic. If false, the timing will be variable depending on other activity on the device. The default is false. monitor [--gdb <port>] [-p <TARGET>] [-s] [-c] [-k] Start monitoring for crashes or ANRs. --gdb: start gdbserv on the given port at crash/ANR -p: only show events related to a specific process / package -s: simple mode, only show a summary line for each event -c: assume the input is always [c]ontinue -k: assume the input is always [k]ill -c and -k are mutually exclusive. watch-uids [--oom <uid>] [--mask <capabilities integer>] Start watching for and reporting uid state changes. --oom: specify a uid for which to report detailed change messages. --mask: Specify PROCESS_CAPABILITY_XXX mask to report. By default, it only reports FOREGROUND_LOCATION (1) FOREGROUND_CAMERA (2), FOREGROUND_MICROPHONE (4) and NETWORK (8). New capabilities added on or after Android UDC will not be reported by default. hang [--allow-restart] Hang the system. --allow-restart: allow watchdog to perform normal system restart restart Restart the user-space system. idle-maintenance Perform idle maintenance now. screen-compat [on|off] <PACKAGE> Control screen compatibility mode of <PACKAGE>. package-importance <PACKAGE> Print current importance of <PACKAGE>. to-uri [INTENT] Print the given Intent specification as a URI. to-intent-uri [INTENT] Print the given Intent specification as an intent: URI. to-app-uri [INTENT] Print the given Intent specification as an android-app: URI. switch-user <USER_ID> Switch to put USER_ID in the foreground, starting execution of that user if it is currently stopped. get-current-user Returns id of the current foreground user. start-user [-w] [--display DISPLAY_ID] <USER_ID> Start USER_ID in background if it is currently stopped; use switch-user if you want to start the user in foreground. -w: wait for start-user to complete and the user to be unlocked. --display <DISPLAY_ID>: starts the user visible in that display, which allows the user to launch activities on it. (not supported on all devices; typically only on automotive builds where the vehicle has passenger displays) unlock-user <USER_ID> Unlock the given user. This will only work if the user doesn't have an LSKF (PIN/pattern/password). stop-user [-w] [-f] <USER_ID> Stop execution of USER_ID, not allowing it to run any code until a later explicit start or switch to it. -w: wait for stop-user to complete. -f: force stop even if there are related users that cannot be stopped. is-user-stopped <USER_ID> Returns whether <USER_ID> has been stopped or not. get-started-user-state <USER_ID> Gets the current state of the given started user. track-associations Enable association tracking. untrack-associations Disable and clear association tracking. get-uid-state <UID> Gets the process state of an app given its <UID>. attach-agent <PROCESS> <FILE> Attach an agent to the specified <PROCESS>, which may be either a process name or a PID. get-config [--days N] [--device] [--proto] [--display <DISPLAY_ID>] Retrieve the configuration and any recent configurations of the device. --days: also return last N days of configurations that have been seen. --device: also output global device configuration info. --proto: return result as a proto; does not include --days info. --display: Specify for which display to run the command; if not specified then run for the default display. supports-multiwindow Returns true if the device supports multiwindow. supports-split-screen-multi-window Returns true if the device supports split screen multiwindow. suppress-resize-config-changes <true|false> Suppresses configuration changes due to user resizing an activity/task. set-inactive [--user <USER_ID>] <PACKAGE> true|false Sets the inactive state of an app. get-inactive [--user <USER_ID>] <PACKAGE> Returns the inactive state of an app. set-standby-bucket [--user <USER_ID>] <PACKAGE> active|working_set|frequent|rare|restricted Puts an app in the standby bucket. get-standby-bucket [--user <USER_ID>] <PACKAGE> Returns the standby bucket of an app. send-trim-memory [--user <USER_ID>] <PROCESS> [HIDDEN|RUNNING_MODERATE|BACKGROUND|RUNNING_LOW|MODERATE|RUNNING_CRITICAL|COMPLETE] Send a memory trim event to a <PROCESS>. May also supply a raw trim int level. display [COMMAND] [...]: sub-commands for operating on displays. move-stack <STACK_ID> <DISPLAY_ID> Move <STACK_ID> from its current display to <DISPLAY_ID>. stack [COMMAND] [...]: sub-commands for operating on activity stacks. move-task <TASK_ID> <STACK_ID> [true|false] Move <TASK_ID> from its current stack to the top (true) or bottom (false) of <STACK_ID>. list List all of the activity stacks and their sizes. info <WINDOWING_MODE> <ACTIVITY_TYPE> Display the information about activity stack in <WINDOWING_MODE> and <ACTIVITY_TYPE>. remove <STACK_ID> Remove stack <STACK_ID>. task [COMMAND] [...]: sub-commands for operating on activity tasks. lock <TASK_ID> Bring <TASK_ID> to the front and don't allow other tasks to run. lock stop End the current task lock. resizeable <TASK_ID> [0|1|2|3] Change resizeable mode of <TASK_ID> to one of the following: 0: unresizeable 1: crop_windows 2: resizeable 3: resizeable_and_pipable resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM> Makes sure <TASK_ID> is in a stack with the specified bounds. Forces the task to be resizeable and creates a stack if no existing stack has the specified bounds. update-appinfo <USER_ID> <PACKAGE_NAME> [<PACKAGE_NAME>...] Update the ApplicationInfo objects of the listed packages for <USER_ID> without restarting any processes. write Write all pending state to storage. compat [COMMAND] [...]: sub-commands for toggling app-compat changes. enable|disable [--no-kill] <CHANGE_ID|CHANGE_NAME> <PACKAGE_NAME> Toggles a change either by id or by name for <PACKAGE_NAME>. It kills <PACKAGE_NAME> (to allow the toggle to take effect) unless --no-kill is provided. reset <CHANGE_ID|CHANGE_NAME> <PACKAGE_NAME> Toggles a change either by id or by name for <PACKAGE_NAME>. It kills <PACKAGE_NAME> (to allow the toggle to take effect). enable-all|disable-all <targetSdkVersion> <PACKAGE_NAME> Toggles all changes that are gated by <targetSdkVersion>. reset-all [--no-kill] <PACKAGE_NAME> Removes all existing overrides for all changes for <PACKAGE_NAME> (back to default behaviour). It kills <PACKAGE_NAME> (to allow the toggle to take effect) unless --no-kill is provided. memory-factor [command] [...]: sub-commands for overriding memory pressure factor set <NORMAL|MODERATE|LOW|CRITICAL> Overrides memory pressure factor. May also supply a raw int level show Shows the existing memory pressure factor reset Removes existing override for memory pressure factor service-restart-backoff <COMMAND> [...]: sub-commands to toggle service restart backoff policy. enable|disable <PACKAGE_NAME> Toggles the restart backoff policy on/off for <PACKAGE_NAME>. show <PACKAGE_NAME> Shows the restart backoff policy state for <PACKAGE_NAME>. get-isolated-pids <UID> Get the PIDs of isolated processes with packages in this <UID> set-stop-user-on-switch [true|false] Sets whether the current user (and its profiles) should be stopped when switching to a different user. Without arguments, it resets to the value defined by platform. set-bg-abusive-uids [uid=percentage][,uid=percentage...] Force setting the battery usage of the given UID. set-bg-restriction-level [--user <USER_ID>] <PACKAGE> unrestricted|exempted|adaptive_bucket|restricted_bucket|background_restricted|hibernation Set an app's background restriction level which in turn map to a app standby bucket. get-bg-restriction-level [--user <USER_ID>] <PACKAGE> Get an app's background restriction level. list-displays-for-starting-users Lists the id of displays that can be used to start users on background. set-foreground-service-delegate [--user <USER_ID>] <PACKAGE> start|stop Start/stop an app's foreground service delegate. set-ignore-delivery-group-policy <ACTION> Start ignoring delivery group policy set for a broadcast action clear-ignore-delivery-group-policy <ACTION> Stop ignoring delivery group policy set for a broadcast action capabilities [--protobuf] Output am supported features (text format). Options are: --protobuf: format output using protobuffer <INTENT> specifications include these flags and arguments: [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>] [-c <CATEGORY> [-c <CATEGORY>] ...] [-n <COMPONENT_NAME>] [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...] [--esn <EXTRA_KEY> ...] [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...] [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...] [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...] [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...] [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...] [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...] [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>] [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]] (multiple extras passed as Integer[]) [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]] (multiple extras passed as List<Integer>) [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]] (multiple extras passed as Long[]) [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]] (multiple extras passed as List<Long>) [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]] (multiple extras passed as Float[]) [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]] (multiple extras passed as List<Float>) [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]] (multiple extras passed as Double[]) [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]] (multiple extras passed as List<Double>) [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]] (multiple extras passed as String[]; to embed a comma into a string, escape it using "\,") [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]] (multiple extras passed as List<String>; to embed a comma into a string, escape it using "\,") [-f <FLAG>] [--grant-read-uri-permission] [--grant-write-uri-permission] [--grant-persistable-uri-permission] [--grant-prefix-uri-permission] [--debug-log-resolution] [--exclude-stopped-packages] [--include-stopped-packages] [--activity-brought-to-front] [--activity-clear-top] [--activity-clear-when-task-reset] [--activity-exclude-from-recents] [--activity-launched-from-history] [--activity-multiple-task] [--activity-no-animation] [--activity-no-history] [--activity-no-user-action] [--activity-previous-is-top] [--activity-reorder-to-front] [--activity-reset-task-if-needed] [--activity-single-top] [--activity-clear-task] [--activity-task-on-home] [--activity-match-external] [--receiver-registered-only] [--receiver-replace-pending] [--receiver-foreground] [--receiver-no-abort] [--receiver-include-background] [--selector] [<URI> | <PACKAGE> | <COMPONENT>] ``` </details> ```bash adb shell am broadcast --help ``` ``` Exception occurred while executing 'broadcast': java.lang.IllegalArgumentException: Unknown option: --help at android.content.Intent.parseCommandArgs(Intent.java:8874) at com.android.server.am.ActivityManagerShellCommand.makeIntent(ActivityManagerShellCommand.java:483) at com.android.server.am.ActivityManagerShellCommand.runSendBroadcast(ActivityManagerShellCommand.java:931) at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:250) at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97) at android.os.ShellCommand.exec(ShellCommand.java:38) at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10144) at android.os.Binder.shellCommand(Binder.java:1230) at android.os.Binder.onTransact(Binder.java:1043) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5443) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2822) at android.os.Binder.execTransactInternal(Binder.java:1505) at android.os.Binder.execTransact(Binder.java:1444) ``` Same with `-h`.
251 KiB
Author
Owner

At least be able to shutdown the phone with adb can avoid physically dumping plaintext memory.

adb shell reboot -p
Done

Source: the Android Stack Exchange answer 47994

works fine on my Fairphone 4 LineageOS.

At least be able to shutdown the phone with adb can avoid physically dumping plaintext memory. ```bash adb shell reboot -p ``` ``` Done ``` Source: [the Android Stack Exchange answer 47994](https://android.stackexchange.com/a/47994) works fine on my Fairphone 4 LineageOS.
Author
Owner
adb shell wipe data
/system/bin/sh: wipe: inaccessible or not found

Source: the Stack Overflow comment 32226315

```bash adb shell wipe data ``` ``` /system/bin/sh: wipe: inaccessible or not found ``` Source: [the Stack Overflow comment 32226315](https://stackoverflow.com/questions/14685721/how-can-i-do-factory-reset-using-adb-in-android#comment32226315_14685786)
Author
Owner

Investigating DuckDuckGo and Google results for adb factory reset without root:

Investigating DuckDuckGo and Google results for *adb factory reset without root*:
Author
Owner
adb shell am broadcast -p android -a android.intent.action.FACTORY_RESET
Broadcasting: Intent { act=android.intent.action.FACTORY_RESET flg=0x400000 pkg=android }
Broadcast completed: result=0

and

adb shell am broadcast -p android -a android.intent.action.FACTORY_RESET -e "android.intent.extra.REASON" "MasterClearConfirm" --ez "android.intent.extra.WIPE_EXTERNAL_STORAGE" true --ez "com.android.internal.intent.extra.WIPE_ESIMS" true --receiver-foreground
Broadcasting: Intent { act=android.intent.action.FACTORY_RESET flg=0x10400000 pkg=android (has extras) }
Broadcast completed: result=0

Source: https://xdaforums.com/t/adb-command-to-factory-reset-device.4315169/post-86668111

do not work too.

```bash adb shell am broadcast -p android -a android.intent.action.FACTORY_RESET ``` ``` Broadcasting: Intent { act=android.intent.action.FACTORY_RESET flg=0x400000 pkg=android } Broadcast completed: result=0 ``` and ```bash adb shell am broadcast -p android -a android.intent.action.FACTORY_RESET -e "android.intent.extra.REASON" "MasterClearConfirm" --ez "android.intent.extra.WIPE_EXTERNAL_STORAGE" true --ez "com.android.internal.intent.extra.WIPE_ESIMS" true --receiver-foreground Broadcasting: Intent { act=android.intent.action.FACTORY_RESET flg=0x10400000 pkg=android (has extras) } Broadcast completed: result=0 ``` Source: https://xdaforums.com/t/adb-command-to-factory-reset-device.4315169/post-86668111 do not work too.
Author
Owner
adb shell am broadcast -a android.intent.action.MASTER_CLEAR -n android/com.android.server.MasterClearReceiver
Broadcasting: Intent { act=android.intent.action.MASTER_CLEAR flg=0x400000 cmp=android/com.android.server.MasterClearReceiver }
Broadcast completed: result=0

Source: https://xdaforums.com/t/help-enable-or-do-a-factory-reset-using-adb.4675265/post-89546631

adb shell am broadcast -a android.intent.action.FACTORY_RESET -n android/com.android.server.MasterClearReceiver
Broadcasting: Intent { act=android.intent.action.FACTORY_RESET flg=0x400000 cmp=android/com.android.server.MasterClearReceiver }
Broadcast completed: result=0

does not work too.

Maybe can investigate with adb logcat if some clues are given to make it work without root, as investigated in https://blog.deanwild.co.uk/android-factory-reset-via-adb-intent.

```bash adb shell am broadcast -a android.intent.action.MASTER_CLEAR -n android/com.android.server.MasterClearReceiver ``` ``` Broadcasting: Intent { act=android.intent.action.MASTER_CLEAR flg=0x400000 cmp=android/com.android.server.MasterClearReceiver } Broadcast completed: result=0 ``` Source: https://xdaforums.com/t/help-enable-or-do-a-factory-reset-using-adb.4675265/post-89546631 ```bash adb shell am broadcast -a android.intent.action.FACTORY_RESET -n android/com.android.server.MasterClearReceiver ``` ``` Broadcasting: Intent { act=android.intent.action.FACTORY_RESET flg=0x400000 cmp=android/com.android.server.MasterClearReceiver } Broadcast completed: result=0 ``` does not work too. Maybe can investigate with `adb logcat` if some clues are given to make it work without `root`, as investigated in https://blog.deanwild.co.uk/android-factory-reset-via-adb-intent.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Benjamin_Loison/adb#12
No description provided.