termux / termux/termux-api

Read Android settings

Open
#794 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.3k
Forks
920
PR merge metrics
No merged PRs in 30d

Description

Feature description

I'd like to read Android settings from within Termux. For instance, to determine user-assigned device name, one of these adb shell commands is likely to work (revise_device_name is where my OnePlus phone keeps the user-specified device name):

adb shell settings get global revise_device_name
adb shell settings get secure bluetooth_name
adb shell settings get global device_name

Termux:API doesn't seem to have any way to invoke android.provider.Settings.Global.getString. Calling settings from the Termux CLI fails with "failure calling service settings". Wrapping stdin/out (or using cmd settings, hat tip) causes another error about missing permission android.permission.INTERACT_ACROSS_USERS, even if --user <uid> is supplied (also raised in termux/termux-app#3718 and termux/termux-app#4543)

Am I missing an obvious way to do this? It'll be nice if Termux-API provides an interface for reading settings to get around the broken OS-provided CLI tools.

Reference implementation

import android.provider.Settings;

String userDeviceName = Settings.Global.getString(getContentResolver(), "revise_device_name");
if(userDeviceName == null)
    userDeviceName = Settings.Secure.getString(getContentResolver(), "bluetooth_name");
if(userDeviceName == null)
    userDeviceName = Settings.Global.getString(getContentResolver(), Settings.Global.DEVICE_NAME);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing Termux:API command interfaces and the Android Settings.Global.getString and Settings.Secure.getString entry points described in the reference implementation. Check how the adb shell settings and cmd settings attempts fail, then define the API behavior around the three device-name keys and null fallback; done means settings can be read through Termux:API without the broken CLI path.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
api, cli, mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.