mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-06 03:50:18 +02:00
refactor(bin): extract settings wrapper
This commit is contained in:
parent
0d0fd8d759
commit
67738d206e
3 changed files with 35 additions and 28 deletions
32
libraries/android-bin/src/settings.ts
Normal file
32
libraries/android-bin/src/settings.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { AdbCommandBase } from "@yume-chan/adb";
|
||||
|
||||
export type SettingsNamespace = 'system' | 'secure' | 'global';
|
||||
|
||||
// frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/SettingsService.java
|
||||
export class Settings extends AdbCommandBase {
|
||||
// TODO: `--user <user>` argument
|
||||
// TODO: `reset` command
|
||||
|
||||
public base(command: string, namespace: SettingsNamespace, ...args: string[]) {
|
||||
return this.adb.childProcess.spawnAndWaitLegacy(['settings', command, namespace, ...args]);
|
||||
}
|
||||
|
||||
public get(namespace: SettingsNamespace, key: string) {
|
||||
return this.base('get', namespace, key);
|
||||
}
|
||||
|
||||
public delete(namespace: SettingsNamespace, key: string) {
|
||||
return this.base('delete', namespace, key);
|
||||
}
|
||||
|
||||
public put(namespace: SettingsNamespace, key: string, value: string, tag?: string, makeDefault?: boolean) {
|
||||
return this.base(
|
||||
'put',
|
||||
namespace,
|
||||
key,
|
||||
value,
|
||||
...(tag ? [tag] : []),
|
||||
...(makeDefault ? ['default'] : []),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue