Related to [Benjamin-Loison/android/issues/](https://github.com/Benjamin-Loison/android/issues){[139](https://github.com/Benjamin-Loison/android/issues/139),[140](https://github.com/Benjamin-Loison/android/issues/140)}.
+124
Benjamin_Loison
changed title from Set *Restrict USB* > *Deny USB connections* with `adb` to Set *Restrict USB* > *Deny USB connections*/*Allow USB connections when unlocked* with `adb`2024-12-31 00:39:46 +01:00
Related to [Benjamin_Loison/Voice_assistant/issues/18#issuecomment-4414577](https://codeberg.org/Benjamin_Loison/Voice_assistant/issues/18#issuecomment-4414577).
for section in global system secure
doecho$section
adb shell settings list $section| grep -iE 'restr|usb'done
Output:
global
default_restrict_background_data=0
restricted_networking_mode=1
uids_allowed_on_restricted_networks=
usb_mass_storage_enabled=1
system
volume_music_usb_headset=3
volume_voice_usb_headset=15
secure
usb_audio_automatic_routing_disabled=0
<details>
<summary>Bash script:</summary>
```bash
for section in global system secure
do
echo $section
adb shell settings list $section | grep -iE 'restr|usb'
done
```
</details>
<details>
<summary>Output:</summary>
```
global
default_restrict_background_data=0
restricted_networking_mode=1
uids_allowed_on_restricted_networks=
usb_mass_storage_enabled=1
system
volume_music_usb_headset=3
volume_voice_usb_headset=15
secure
usb_audio_automatic_routing_disabled=0
```
</details>
Could just proceed automatically graphically, see [Benjamin_Loison/Voice_assistant/issues/46](https://codeberg.org/Benjamin_Loison/Voice_assistant/issues/46).
does not change, as mentioned in #issuecomment-3944. Especially as there are 3 states.
https://chat.mistral.ai/chat/9ab408ba-dd8b-4454-aacf-db4d00ada110
```bash
adb shell settings list global
```
does not change, as mentioned in [#issuecomment-3944](#issuecomment-3944). Especially as there are 3 states.
Settings provider (settings) commands:
help
Print this help text.
get [--user <USER_ID> | current] [--deviceId <DEVICE_ID> | 0] [--lineage] NAMESPACE KEY
Retrieve the current value of KEY.
put [--user <USER_ID> | current] [--deviceId <DEVICE_ID> | 0] [--lineage] NAMESPACE KEY VALUE [TAG] [default] [overrideableByRestore]
Change the contents of KEY to VALUE.
TAG to associate with the setting (cannot be default or overrideableByRestore).
{default} to set as the default, case-insensitive only for global/secure namespace
{overrideableByRestore} to let the value be overridden by BackupManager on restore operations
delete [--user <USER_ID> | current] [--deviceId <DEVICE_ID> | 0] [--lineage] NAMESPACE KEY
Delete the entry for KEY.
reset [--user <USER_ID> | current] [--deviceId <DEVICE_ID> | 0] [--lineage] NAMESPACE {PACKAGE_NAME | RESET_MODE}
Reset the global/secure table for a package with mode.
RESET_MODE is one of {untrusted_defaults, untrusted_clear, trusted_defaults}, case-insensitive
list [--user <USER_ID> | current] [--lineage] NAMESPACE
Print all defined keys.
NAMESPACE is one of {system, secure, global}, case-insensitive
adb shell settings delete secure usb_restrict
Deleted 1 rows
```bash
adb shell settings
```
<details>
<summary>Output:</summary>
```
Settings provider (settings) commands:
help
Print this help text.
get [--user <USER_ID> | current] [--deviceId <DEVICE_ID> | 0] [--lineage] NAMESPACE KEY
Retrieve the current value of KEY.
put [--user <USER_ID> | current] [--deviceId <DEVICE_ID> | 0] [--lineage] NAMESPACE KEY VALUE [TAG] [default] [overrideableByRestore]
Change the contents of KEY to VALUE.
TAG to associate with the setting (cannot be default or overrideableByRestore).
{default} to set as the default, case-insensitive only for global/secure namespace
{overrideableByRestore} to let the value be overridden by BackupManager on restore operations
delete [--user <USER_ID> | current] [--deviceId <DEVICE_ID> | 0] [--lineage] NAMESPACE KEY
Delete the entry for KEY.
reset [--user <USER_ID> | current] [--deviceId <DEVICE_ID> | 0] [--lineage] NAMESPACE {PACKAGE_NAME | RESET_MODE}
Reset the global/secure table for a package with mode.
RESET_MODE is one of {untrusted_defaults, untrusted_clear, trusted_defaults}, case-insensitive
list [--user <USER_ID> | current] [--lineage] NAMESPACE
Print all defined keys.
NAMESPACE is one of {system, secure, global}, case-insensitive
```
</details>
```bash
adb shell settings delete secure usb_restrict
```
```
Deleted 1 rows
```
I verified that both globalusb_restricted_mode and secureusb_restrict0 and 1 do not disconnect me with adb shell whoami contrarily to manually setting to Deny USB connections.
I verified that both `global` `usb_restricted_mode` and `secure` `usb_restrict` `0` and `1` do not disconnect me with `adb shell whoami` contrarily to manually setting to *Deny USB connections*.
adb shell 'settings put --lineage global trust_restrict_usb 2 && settings put global adb_enabled 0'
and
adb shell 'settings put global adb_enabled 0 && settings put --lineage global trust_restrict_usb 2'
achieve executing the second command while:
adb shell 'whoami && whoami'
Output:
shell
shell
works as wanted.
None of:
```bash
adb shell 'settings put --lineage global trust_restrict_usb 2 && settings put global adb_enabled 0'
```
and
```bash
adb shell 'settings put global adb_enabled 0 && settings put --lineage global trust_restrict_usb 2'
```
achieve executing the second command while:
```bash
adb shell 'whoami && whoami'
```
<details>
<summary>Output:</summary>
```
shell
shell
```
</details>
works as wanted.
for category in global secure system
do
adb shell settings list $categorydone| grep root
does not return anything as root.
Disabling graphically does not seem trivial notably due to temporary:
adb shell whoami
adb: no devices/emulators found
after disabling graphically.
DuckDuckGo search *ADB disable Rooted debugging*.
[Alex4SSB/ADB-Explorer/issues/181](https://github.com/Alex4SSB/ADB-Explorer/issues/181)
```bash
adb shell setprop service.adb.root 0
```
does not return anything and does not block `adb shell whoami` `root`.
Google search *ADB disable Rooted debugging*.
https://chat.mistral.ai/chat/c31140fc-ec5f-4430-8c77-f0674e4a9115
`disable-verity` and `setenforce` is not explained and looks suspicious to me.
https://chatgpt.com/share/699790fb-49a8-8002-9113-d3b855fbb0e1
```bash
adb shell stop adbd
adb shell whoami
```
```
adb: no devices/emulators found
```
```bash
adb shell start adbd
```
```
adb: no devices/emulators found
```
```bash
adb unroot
```
```
restarting adbd as non root
```
does not help.
<details>
<summary>Bash script:</summary>
```bash
for category in global secure system
do
adb shell settings list $category
done | grep root
```
</details>
does not return anything as `root`.
Disabling graphically does not seem trivial notably due to temporary:
```bash
adb shell whoami
```
```
adb: no devices/emulators found
```
after disabling graphically.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Related to Benjamin-Loison/android/issues/{139,140}.
+124
Set *Restrict USB* > *Deny USB connections* with `adb`to Set *Restrict USB* > *Deny USB connections*/*Allow USB connections when unlocked* with `adb`DuckDuckGo and Google search
"adb" "Restrict USB"first page of results does not seem to help.Related to Benjamin_Loison/Voice_assistant/issues/18#issuecomment-4414577.
Bash script:
Output:
No matter Restrict USB I face
usb_mass_storage_enabled=1.Output:
Output:
does not help experimentally.
adb rootdoes not help, see #39#issuecomment-3991.Could just proceed automatically graphically, see Benjamin_Loison/Voice_assistant/issues/46.
Related to Benjamin_Loison/Backup_Android_apps/issues/40.
Related to Benjamin-Loison/android/issues/28#issuecomment-3902625664.
https://chat.mistral.ai/chat/9ab408ba-dd8b-4454-aacf-db4d00ada110
does not change, as mentioned in #issuecomment-3944. Especially as there are 3 states.
Same for:
Output:
I verified that both
globalusb_restricted_modeandsecureusb_restrict0and1do not disconnect me withadb shell whoamicontrarily to manually setting to Deny USB connections.https://chat.mistral.ai/chat/159c960e-e7e1-4d67-a4ea-f7eba642e291
does not help.
https://chatgpt.com/share/6994f885-148c-8002-b3b1-c042967a9823
solved my issue, parentheses are needed.
Otherwise I would have used:
DuckDuckGo search Bash execute string.
The Stack Overflow answer 2005201 helps.
~/.bashrcexcerpt:always worked fine from my multiple tests.
None of:
and
achieve executing the second command while:
Output:
works as wanted.
DuckDuckGo search ADB disable Rooted debugging.
Alex4SSB/ADB-Explorer/issues/181
does not return anything and does not block
adb shell whoamiroot.Google search ADB disable Rooted debugging.
https://chat.mistral.ai/chat/c31140fc-ec5f-4430-8c77-f0674e4a9115
disable-verityandsetenforceis not explained and looks suspicious to me.https://chatgpt.com/share/699790fb-49a8-8002-9113-d3b855fbb0e1
does not help.
Bash script:
does not return anything as
root.Disabling graphically does not seem trivial notably due to temporary:
after disabling graphically.
Related to Benjamin_Loison/Voice_assistant/issues/106.