• Stars
    star
    121
  • Rank 293,924 (Top 6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

App for dealing with Android settings

Settings

NPM version Downloads

Release

Toggle settings in Android device or emulator.

A small and simple Android application that deals with the system settings. Then the application shuts down.

Requirements

You may also consider using Android Studio to debug the code easily.

Building

$ ./gradlew clean assembleDebug

You can also run gradlew installDebug to build and immediately deploy the app to a connected Android device or emulator.

Installing

You can install the apk through the Android Debug Bridge.

To install:

$ cd app/build/outputs/apk
$ adb install settings_apk-debug.apk
# You can grant permissions with -g option as below for over api level 23 devices
# $ adb install -g settings_apk-debug.apk

To uninstall:

$ adb uninstall io.appium.settings

Using the JavaScript wrapper

This module exports the SettingsApp class, which allows you to automate the below interactions with JavaScript. The wrapper expects you to also have the appium-adb module listed in your dependencies. The actual version of the appium-adb module must satisfy the same semver requirement this module has in its devDependencies. Here is the usage example:

import ADB from 'appium-adb'
import { SettingsApp } from 'io.appium.settings';

async function main() {
  // It is expected 'io.appium.settings' is already installed on the device
  // and the neccessary permissions are granted to it.
  // Check https://github.com/appium/appium-android-driver/blob/master/lib/helpers/android.ts
  // if you are looking on how to automate this process.
  const app = new SettingsApp({
    adb: await ADB.createADB()
  });
  const recorder = app.makeMediaProjectionRecorder();
  const filename = 'video.mp4';
  const didStart = await recorder.start({filename});
  if (didStart) {
    log.info(`A new media projection recording '${filename}' has been successfully started`);
  } else {
    log.info('A new media projection recording was unable to start. Is it already running?');
  }
}

main();

The module also exports various constants containing its service and action names, that could be useful in your scripts. Check constants.js for more details.

Changing of system settings

Once installed on a device, you can change the wifi, data, animation and locale settings through the following commands:

To turn on wifi:

$ adb shell am broadcast -a io.appium.settings.wifi --es setstatus enable

To turn off wifi:

$ adb shell am broadcast -a io.appium.settings.wifi --es setstatus disable

To turn on data:

$ adb shell am broadcast -a io.appium.settings.data_connection --es setstatus enable

To turn off data:

$ adb shell am broadcast -a io.appium.settings.data_connection --es setstatus disable

To turn on bluetooth:

$ adb shell am broadcast -a io.appium.settings.bluetooth --es setstatus enable

To turn off bluetooth:

$ adb shell am broadcast -a io.appium.settings.bluetooth --es setstatus disable

To unpair known bluetooth devices:

$ adb shell am broadcast -a io.appium.settings.unpair_bluetooth

To turn on animation:

$ adb shell am broadcast -a io.appium.settings.animation --es setstatus enable

To turn off animation:

$ adb shell am broadcast -a io.appium.settings.animation --es setstatus disable

Set particular locale:

# If not granted already, grant locale change permission https://developer.android.com/reference/android/Manifest.permission#CHANGE_CONFIGURATION
$ adb shell pm grant io.appium.settings android.permission.CHANGE_CONFIGURATION
$ adb shell am broadcast -a io.appium.settings.locale -n io.appium.settings/.receivers.LocaleSettingReceiver --es lang ja --es country JP
$ adb shell getprop persist.sys.locale # ja-JP
$ adb shell am broadcast -a io.appium.settings.locale -n io.appium.settings/.receivers.LocaleSettingReceiver --es lang zh --es country CN --es script Hans
$ adb shell getprop persist.sys.locale # zh-Hans-CN for API level 21+
# When 'skip_locale_check' parameter is set appium settings application doesn't check that locale you are trying to set is a valid locale string, by default it validates the locale and throws error when invalid
$ adb shell am broadcast -a io.appium.settings.locale -n io.appium.settings/.receivers.LocaleSettingReceiver --es lang xx --es country US --es skip_locale_check 1

You can set the Locale format, especially this feature support Locale(String language, String country) so far.

-n io.appium.settings/.receivers.LocaleSettingReceiver is not necessary in some devices.

Retrieval of system settings

You can retrieve the current geo location by executing:

$ adb shell am broadcast -a io.appium.settings.location -n io.appium.settings/.receivers.LocationInfoReceiver --ez forceUpdate false

The first value in the returned data string is the current latitude, the second is the longitude and the last one is the altitude. An empty string is returned if the data cannot be retrieved (more details on the failure cause can be found in the logcat output).

Since version 3.6.0 it is also possible to provide forceUpdate boolean argument. If it is set to true then GPS cache refresh request is going to be send asynchronously every time when the current location is requested. By default the cached location value is returned instead.

Note

The forced GPS cache refresh feature only works if the device under test has Google Play Services installed. In case the vanilla LocationManager is used the device API level must be at version 30 (Android R) or higher. If none of the conditions above is satisfied then enabling of the forceUpdate option would have no effect.

Setting Mock Locations

Please set the Appium Settings from the Settings app's Developer Options -> Select mock location app. Or adb shell appops set io.appium.settings android:mock_location allow let you do the same via adb command. adb shell appops set io.appium.settings android:mock_location deny is to turn it off.

Start sending scheduled updates (every 2s) for mock location with the specified values by executing: (API versions 26+):

$ adb shell am start-foreground-service --user 0 -n io.appium.settings/.LocationService --es longitude {longitude-value} --es latitude {latitude-value} [--es altitude {altitude-value}]

(Older versions):

$ adb shell am startservice --user 0 -n io.appium.settings/.LocationService --es longitude {longitude-value} --es latitude {latitude-value} [--es altitude {altitude-value}]

Running the command again stops sending the previously specified location and starts sending updates for the new mock location.

Additionally the service allows to provide the following optional parameters to the mocked location:

  • speed: the speed, in meters/second over ground. A float value greater than zero is acceptable.
  • bearing: the bearing, in degrees. Bearing is the horizontal direction of travel of this device, and is not related to the device orientation. The input will be wrapped into the range (0.0, 360.0]

Stop sending new mocklocations and clean up everything (remove the mock location providers) by executing:

$ adb shell am stopservice io.appium.settings/.LocationService

IME actions generation

You can simulate IME actions generation with this application. First, it is necessary to enable and activate the corresponding service:

adb shell ime enable io.appium.settings/.AppiumIME
adb shell ime set io.appium.settings/.AppiumIME

After the service is active simply focus any edit field, which contains an IME handler, and send /action_name_or_integer_code/ text into this field: adb shell input text '/action_name_or_integer_code/' (enclosing slashes are required). The following action names are supported (case-insensitive): normal, unspecified, none, go, search, send, next, done, previous. If the given action name is unknown then it is going to be printed into the text field as is without executing any action.

Unicode IME

This input method allows to enter unicode values into text fields using adb shell input text terminal command. The idea is to encode the given unicode string into UTF-7 and then let the corresponding IME to decode and transform the actual input. This helper is also useful for automating applications running under Android API19 and older where sendText method of UiObject did not support Unicode properly. The actual implementation is based on the Uiautomator Unicode Input Helper by TOYAMA Sumio.

Use the following commands to enable the Unicode IME:

adb shell ime enable io.appium.settings/.UnicodeIME
adb shell ime set io.appium.settings/.UnicodeIME

Clipboard

This action allows to retrieve the text content of the current clipboard as base64-encoded string. An empty string is returned if the clipboard cannot be retrieved or the clipboard is empty. Remember, that since Android Q the clipboard content can only be retrieved if the requester application is set as the default IME in the system:

adb shell ime enable io.appium.settings/.AppiumIME
adb shell ime set io.appium.settings/.AppiumIME
adb shell am broadcast -a io.appium.settings.clipboard.get
adb shell ime set com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME

Notifications

Since version 2.16.0 Appium Settings supports retrieval of system notifications. You need to manually switch the corresponding security switcher next to Appium Settings application name in Settings->Notification Access (the path to this page under Settings may vary depending on Android version and the device model) in order to make this feature available. The next step would be to send the following broadcast command:

$ adb shell am broadcast -a io.appium.settings.notifications

The notifications listener service is running in the background and collects all the active and newly created notifications into the internal buffer with maximum size of 100. The collected data (e.g. the properties and texts of each notification) is returned as JSON-formatted string. An error description string is returned instead if the notifications list cannot be retrieved. The example of the resulting data:

{
  "statusBarNotifications": [
    {
      "isGroup":false,
      "packageName":"io.appium.settings",
      "isClearable":false,
      "isOngoing":true,
      "id":1,
      "tag":null,
      "notification":{
        "title":null,
        "bigTitle":"Appium Settings",
        "text":null,
        "bigText":"Keep this service running, so Appium for Android can properly interact with several system APIs",
        "tickerText":null,
        "subText":null,
        "infoText":null,
        "template":"android.app.Notification$BigTextStyle"
      },
      "userHandle":0,
      "groupKey":"0|io.appium.settings|1|null|10133",
      "overrideGroupKey":null,
      "postTime":1576853518850,
      "key":"0|io.appium.settings|1|null|10133",
      "isRemoved":false
    }
  ]
}

See https://developer.android.com/reference/android/service/notification/StatusBarNotification and https://developer.android.com/reference/android/app/Notification.html for more information on available notification properties and their values.

SMS

Since version 3.1 Appium Settings supports retrieval of SMS messages. Make sure the corresponding permission has been granted to the app in order to make this feature available. The next step would be to send the following broadcast command:

$ adb shell am broadcast -a io.appium.settings.sms.read --es max 10

In this example the SMS reader broadcast receiver would retrieve the properties of 10 recent incoming SMS messages. By default the limit is set to 100. The collected data (e.g. the properties and texts of each SMS) is returned as JSON-formatted string. An error description string is returned instead if the SMS list cannot be retrieved. The example of the resulting data:

{
  "items":[
    {
      "id":"2",
      "address":"+123456789",
      "person":null,
      "date":"1581936422203",
      "read":"0",
      "status":"-1",
      "type":"1",
      "subject":null,
      "body":"\"text message2\"",
      "serviceCenter":null
    },
    {
      "id":"1",
      "address":"+123456789",
      "person":null,
      "date":"1581936382740",
      "read":"0",
      "status":"-1",
      "type":"1",
      "subject":null,
      "body":"\"text message\"",
      "serviceCenter":null
    }
  ],
  "total":2
}

Media Scanning

Since version 3.5 Appium Settings supports broadcast messages handling that performs media scanning in response to io.appium.settings.scan_media intent. This was done due to android.intent.action.MEDIA_SCANNER_SCAN_FILE deprecation since Android API version 30. To scan the given file or folder for media data simply run:

$ adb shell am broadcast -a io.appium.settings.scan_media --es path /sdcard/media

This command will recursively scan all files inside of /sdcard/media folder and add them to the media library if their MIME types are supported. If the file/folder in path does not exist/is not readable or is not provided then an error will be returned and the corresponding log message would be written into logs.

Internal Audio & Video Recording

Required steps to activate recording:

adb shell pm grant io.appium.settings android.permission.RECORD_AUDIO
adb shell appops set io.appium.settings PROJECT_MEDIA allow

Start Recording:

adb shell am start -n "io.appium.settings/io.appium.settings.Settings" -a io.appium.settings.recording.ACTION_START --es filename abc.mp4 --es priority high --es max_duration_sec 900 --es resolution 1920x1080

Arguments (see above start command as an example for giving arguments)

  • filename (Mandatory) - You can type recording video file name as you want, but recording currently supports only "mp4" format so your filename must end with ".mp4"
  • priority (Optional) - Default value: "high" which means recording thread priority is maximum however if you face performance drops during testing with recording enabled, you can reduce recording priority to "normal" or "low"
  • max_duration_sec (Optional) (in seconds) - Default value: 900 seconds which means maximum allowed duration is 15 minute, you can increase it if your test takes longer than that
  • resolution (Optional) - Default value: maximum supported resolution on-device(Detected automatically on app itself), which usually equals to Full HD 1920x1080 on most phones however you can change it to following supported resolutions as well: "1920x1080", "1280x720", "720x480", "320x240", "176x144"

Stop Recording:

adb shell am start -n "io.appium.settings/io.appium.settings.Settings" -a io.appium.settings.recording.ACTION_STOP

Obtain Recording Output File:

adb pull /storage/emulated/0/Android/data/io.appium.settings/files/abc.mp4 abc.mp4

Notes:

  • You have to specify the receiver class if the app has never been executed before:
$ adb shell am broadcast -a io.appium.settings.wifi -n io.appium.settings/.receivers.WiFiConnectionSettingReceiver --es setstatus disable
  • To change animation setting, the app should be granted SET_ANIMATION_SCALE permission:
$ adb shell pm grant io.appium.settings android.permission.SET_ANIMATION_SCALE
  • To change locale setting, the app should be granted CHANGE_CONFIGURATION permission:
$ adb shell pm grant io.appium.settings android.permission.CHANGE_CONFIGURATION
  • To get location, the app should be granted ACCESS_FINE_LOCATION permission at least:
$ adb shell pm grant io.appium.settings android.permission.ACCESS_FINE_LOCATION
  • To set location, the location mocking must be enabled. On Android 5 this requires enabling option Allow mock locations in Developer Settings. In later versions following command can be used:
$ adb shell appops set io.appium.settings android:mock_location allow
  • On Android 6.0+ you must enable the corresponding permissions for the app first. This can be done in application settings, Permissions entry.

  • Switching mobile data on/off requires the phone to be rooted on Android 5.0+ ('su' binary is expected to be available on internal phone file system). Read this StackOverflow thread for more details.

Voila!

Caveats

There are certain system services which cannot be accessed through an application. Two ones central here are airplane_mode and gps.

License

Apache License 2.0

More Repositories

1

appium

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
JavaScript
18,666
star
2

appium-desktop

Appium Server in Desktop GUIs for Mac, Windows, and Linux
JavaScript
4,709
star
3

python-client

Python language bindings for Appium
Python
1,669
star
4

java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Java
1,203
star
5

appium-inspector

A GUI inspector for mobile apps and more, powered by a (separately installed) Appium server
JavaScript
1,125
star
6

appium-xcuitest-driver

Appium iOS driver, backed by Apple XCTest
JavaScript
736
star
7

appium-docker-android

Appium Server setup to automate android testing on real devices
Shell
585
star
8

appium-uiautomator2-driver

Appium driver for Android UIAutomator2
JavaScript
558
star
9

appium-flutter-driver

Appium Flutter Driver is a test automation tool for Flutter apps on multiple platforms/OSes. Appium Flutter Driver is part of the Appium mobile test automation tool maintained by community
TypeScript
451
star
10

dotnet-client

Extension to the official Selenium dotnet webdriver
C#
381
star
11

appium-uiautomator2-server

Appium UiAutomator/UiObject2-based server for Android UI automation. This module is used by appium-uiautomator2-driver component
Java
326
star
12

appium-adb

Wrapper around adb used by appium + helper libs
JavaScript
273
star
13

appium-android-driver

Common methods collection used by Android drivers
JavaScript
249
star
14

android-apidemos

A fork of Google's Android ApiDemos application, used for testing Appium
Java
235
star
15

ruby_lib

πŸ’Ž Ruby library for Appium
Ruby
216
star
16

appium-for-mac

[deprecated] Application for automating a mac app with JSON wire protocol
Objective-C
193
star
17

appium-espresso-driver

Espresso integration for Appium
Kotlin
189
star
18

appium-doctor

[Deprecated] Please use https://github.com/appium/appium/tree/master/packages/doctor
JavaScript
128
star
19

appium-ios-device

Tools for interacting with iOS devices
JavaScript
126
star
20

appium-mac2-driver

Next-gen Appium macOS driver, backed by Apple XCTest
Objective-C
124
star
21

appium-ios-simulator

Module for interacting with iOS simulators
JavaScript
97
star
22

appium-base-driver

Base class for an Appium driver
JavaScript
82
star
23

appium-idb

idb integration for Appium
JavaScript
75
star
24

ios-uicatalog

Apple UICatalog App
Objective-C
73
star
25

appium-chromedriver

Node.js wrapper around Chromedriver
JavaScript
66
star
26

mitmproxy-java

A bridge between Python's mitmproxy and Java programs. Built on top of mitmproxy-node
Java
64
star
27

node-simctl

Node wrapper around Apple's simctl binary
JavaScript
63
star
28

ruby_console

🎁 Appium Ruby Console
Ruby
45
star
29

appium-remote-debugger

Module for dealing with Remote Debugger protocol
JavaScript
44
star
30

appium_capybara

Gem enabling appium support in capybara
Ruby
40
star
31

appium-mac-driver

[deprecated] Mac application driver for Appium
JavaScript
36
star
32

ios-test-app

iOS app for testing
Objective-C
35
star
33

ruby_lib_core

Core library for the Ruby client
Ruby
34
star
34

selenium-swift

selenium bindings for the swift programming language
Swift
33
star
35

node-teen_process

A slightly more grown-up version of Node's child_process
JavaScript
27
star
36

node-adb-client

A direct-to-device ADB client implementation in Node
JavaScript
27
star
37

appium-safari-driver

Safari browser support for Appium
JavaScript
24
star
38

appium.io

[deprecated] The public front-end for Appium
CSS
21
star
39

appium-support

Support libs used across appium packages.
JavaScript
17
star
40

appium-chromium-driver

An Appium driver for the Chrome browser
JavaScript
17
star
41

appium-xcode

Xcode related utilities. Get version number and path to executable.
JavaScript
16
star
42

appium-geckodriver

Support for Geckodriver (Firefox driver) within Appium
JavaScript
15
star
43

sample-apps

Sample app manager, for testing
JavaScript
14
star
44

VodQAReactNative

Sample react native app demoing components and gestures
JavaScript
10
star
45

screenshooter

Screenshot application for Android
Java
10
star
46

appium-fake-driver

A fake Appium driver used for testing and demonstration
JavaScript
8
star
47

droiddriver_examples

Java
6
star
48

DynamicApp

Titanium app generating random code + command injector.
JavaScript
6
star
49

appium-gulp-plugins

Custom plugins used across appium modules
JavaScript
5
star
50

dump2json

Converts UIAutomator XML dump to JSON for Appium.
Java
5
star
51

io.appium.gappium.sampleapp

Appium Sample App for Cordova Test Automation (Gappium)
JavaScript
5
star
52

appium-test-support

A collection of test utility lib used across Appium packages
JavaScript
4
star
53

appium-build-store

Temporary store for Appium builds, for sub-package CI systems
4
star
54

gps-demo-app

Android GPS demo from http://www.impressive-artworx.de/tutorials/android/gps_tutorial_1.zip
Java
4
star
55

appium-event-parser

Node CLI script to help parse event timing output from Appium scripts
JavaScript
4
star
56

appium-gui-libs

Code shared between various Appium GUI projects (Appium Desktop Server, Appium Inspector)
JavaScript
4
star
57

perl-client

Perl
3
star
58

workshop

To be used when people do Appium workshops
JavaScript
3
star
59

clean_apk

APK used to clean up between tests for Appium.
Java
3
star
60

eslint-config-appium

Shared configuration for ESLint
JavaScript
3
star
61

python-client-sphinx

Docs repo for Appium Python Client
3
star
62

worms

Issue tracker for Apple bugs affecting Appium
2
star
63

appium-ios

iOS-specific packages for Appium
JavaScript
2
star
64

ios-webview-app

Webview app for testing appium
Objective-C
2
star
65

blog

A GH powered Appium blog
1
star
66

dmg-template

dmg template for building appium-dot-app
Objective-C
1
star
67

appium.github.com

Appium.io
JavaScript
1
star
68

ios

Appium mono repo containing iOS specific packages.
1
star
69

appium_thor

Appium Thor helpers for appium's gems
Ruby
1
star
70

appiumlogs

Logs from the #appium IRC channel on freenode.net
Shell
1
star
71

packweb

Tools for maintaining projects with large numbers of packages
JavaScript
1
star
72

appium-package-master

A set of tools to create and manage appium packages.
JavaScript
1
star
73

jobs

Appium job board
1
star
74

test_runner

Ruby test runner for Appium
Ruby
1
star
75

appium-benchmarks

A suite of exercises designed to evaluate the performance of an Appium server or service
TypeScript
1
star