Repository navigation
(commands) add well-known commands for setting and disk operations #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,8 @@ message DeviceCommandArgumentDefinition { | |
| INT64 = 5; | ||
| // Data.bool_data. | ||
| BOOL = 6; | ||
| // Any data type; | ||
| ANY = 99; | ||
| } | ||
|
|
||
| // The name used as the key in the command invocation's arguments map. | ||
|
|
@@ -202,6 +204,355 @@ enum WellKnownCommandType { | |
| } | ||
| ] | ||
| }]; | ||
| // Remove a value from app settings, using `UserDefaults` on Apple platforms or `SharedPreferences` | ||
| // on Android. | ||
| // | ||
| // Specify a key to remove a corresponding value from settings. On Android, the `file_name` argument | ||
| // is required and equivalent to `Context.getSharedPreferences(file_name)`. | ||
| USER_SETTINGS_REMOVE = 4 [(well_known_command_options) = { | ||
| key: "user_settings_remove" | ||
| description: "Removes a value from UserDefaults (Apple platforms) or SharedPreferences (Android)" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 50 | ||
| }, | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| argument_definitions: [ | ||
| { | ||
| name: "key" | ||
| type: STRING | ||
| description: "Settings key to remove" | ||
| }, | ||
| { | ||
| name: "file_name" | ||
| type: STRING | ||
| description: "Desired shared preferences file, equivalent to `Context.getSharedPreferences(file_name)`" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| name: "suite_name" | ||
| type: STRING | ||
| description: "Name of the app group or suite to use, equivalent to `UserDefaults(suiteName: suite_name)`" | ||
| optional: true | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| }]; | ||
| // Set a value in app settings, using `UserDefaults` on Apple platforms or `SharedPreferences` on | ||
| // Android. | ||
| // | ||
| // Specify a key and value to set. On Android, the `file_name` argument is required and equivalent | ||
| // to `Context.getSharedPreferences(file_name)`. | ||
| USER_SETTINGS_SET = 5 [(well_known_command_options) = { | ||
| key: "user_settings_set" | ||
| description: "Updates a value in UserDefaults (Apple platforms) or SharedPreferences (Android)" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 49 | ||
| }, | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 49 | ||
| } | ||
| ] | ||
| } | ||
| argument_definitions: [ | ||
| { | ||
| name: "key" | ||
| type: STRING | ||
| description: "Settings key to update" | ||
| }, | ||
| { | ||
| name: "value" | ||
| type: ANY | ||
| description: "New settings value" | ||
| }, | ||
| { | ||
| name: "file_name" | ||
| type: STRING | ||
| description: "Desired shared preferences file, equivalent to `Context.getSharedPreferences(file_name)`" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| name: "suite_name" | ||
| type: STRING | ||
| description: "Name of the app group or suite to use, equivalent to `UserDefaults(suiteName: suite_name)`" | ||
| optional: true | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| }]; | ||
| // Get a value from app settings, using `UserDefaults` on Apple platforms or `SharedPreferences` on | ||
| // Android. | ||
| // | ||
| // Specify a key to fetch. On Android, the `file_name` argument is required and equivalent to | ||
| // `Context.getSharedPreferences(file_name)`. | ||
| USER_SETTINGS_GET = 6 [(well_known_command_options) = { | ||
| key: "user_settings_get" | ||
| description: "Reads a value from UserDefaults (Apple platforms) or SharedPreferences (Android)" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 50 | ||
| }, | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| argument_definitions: [ | ||
| { | ||
| name: "key" | ||
| type: STRING | ||
| description: "Settings key to read" | ||
| }, | ||
| { | ||
| name: "file_name" | ||
| type: STRING | ||
| description: "Desired shared preferences file, equivalent to `Context.getSharedPreferences(file_name)`" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 49 | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| name: "suite_name" | ||
| type: STRING | ||
| description: "Name of the app group or suite to use, equivalent to `UserDefaults(suiteName: suite_name)`" | ||
| optional: true | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| }]; | ||
| // Remove all values from app settings, using `UserDefaults` on Apple platforms or | ||
| // `SharedPreferences` on Android. | ||
| // | ||
| // On Android, the `file_name` argument is required and equivalent to | ||
| // `Context.getSharedPreferences(file_name)`. | ||
| USER_SETTINGS_CLEAR = 7 [(well_known_command_options) = { | ||
| key: "user_settings_clear" | ||
| description: "Removes all values from UserDefaults (Apple platforms) or SharedPreferences (Android)" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 49 | ||
| }, | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 49 | ||
| } | ||
| ] | ||
| } | ||
| argument_definitions: [ | ||
| { | ||
| name: "file_name" | ||
| type: STRING | ||
| description: "Desired shared preferences file, equivalent to `Context.getSharedPreferences(file_name)`" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 49 | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| name: "suite_name" | ||
| type: STRING | ||
| description: "Name of the app group or suite to use, equivalent to `UserDefaults(suiteName: suite_name)`" | ||
| optional: true | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| }]; | ||
| // List files within the cache directory | ||
| // | ||
| // Lists the file names with the cache directory or a directory within the cache if the path | ||
| // argument is specified | ||
| FILE_LIST = 8 [(well_known_command_options) = { | ||
| key: "file_list" | ||
|
Comment on lines
+447
to
+448
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The file commands are named broadly to support later adding an optional argument to handle other file areas |
||
| description: "List file names relative to the cache directory" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 50 | ||
| }, | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| argument_definitions: [ | ||
| { | ||
| name: "path" | ||
| type: STRING | ||
| description: "Directory path relative to the area or unspecified for the entire area" | ||
| optional: true | ||
| } | ||
| ] | ||
| }]; | ||
| // Read the size of a file or directory | ||
| // | ||
| // Returns the size of the cache directory or a directory within the cache if the path | ||
| // argument is specified | ||
| FILE_SIZE = 9 [(well_known_command_options) = { | ||
| key: "file_size" | ||
| description: "Get the size of a file or directory within the cache" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 50 | ||
| }, | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| argument_definitions: [ | ||
| { | ||
| name: "path" | ||
| type: STRING | ||
| description: "Directory path relative to the area or unspecified for the entire area" | ||
| optional: true | ||
| } | ||
| ] | ||
| }]; | ||
| // Delete the contents of the cache directory | ||
| FILE_CLEAR = 10 [(well_known_command_options) = { | ||
| key: "file_clear" | ||
| description: "Delete the contents of the cache" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 49 | ||
| }, | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 49 | ||
| } | ||
| ] | ||
| } | ||
| }]; | ||
| // Delete a file or directory within the cache directory | ||
| // | ||
| // Directories are only removed if the recursive argument is set | ||
| FILE_DELETE = 11 [(well_known_command_options) = { | ||
| key: "file_delete" | ||
| description: "Delete a file or directory within the cache" | ||
| availability: { | ||
| supported_platforms: [ | ||
| { | ||
| platform: ANDROID | ||
| min_os_version: "8.0" | ||
| min_config_version: 50 | ||
| }, | ||
| { | ||
| platform: APPLE | ||
| min_os_version: "15.0" | ||
| min_config_version: 50 | ||
| } | ||
| ] | ||
| } | ||
| argument_definitions: [ | ||
| { | ||
| name: "path" | ||
| type: STRING | ||
| description: "Directory path relative to the area" | ||
| }, | ||
| { | ||
| name: "recursive" | ||
| type: BOOL | ||
| description: "Set true to remove a directory and all contents" | ||
| optional: true | ||
| } | ||
| ] | ||
| }]; | ||
| // Captures a snapshot of the application's memory. | ||
| // | ||
| // On Apple platforms the attachment is a `bitdrift_public.protobuf.memory.v1.MemoryDump` with MIME | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this and the other
NSUserDefaults/UserDefaultscommands: wouldnt be also good to have this parameter (or a separate one with a more specific name) for thesuiteName(more info)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda wondered something similar, though the semantics are weird, especially for mac apps, where you can use it to access other apps' settings