UNPKG

appium-adb

Version:

Android Debug Bridge interface

311 lines 13.2 kB
import type { ADB } from '../adb'; import type { SetPropOpts } from './types'; /** * Get the particular property of the device under test. * * @param property - The name of the property. This name should * be known to _adb shell getprop_ tool. * * @returns The value of the given property. */ export declare function getDeviceProperty(this: ADB, property: string): Promise<string>; /** * Set the particular property of the device under test. * * @param prop - The name of the property. This name should * be known to _adb shell setprop_ tool. * @param val - The new property value. * @param opts * * @throws If _setprop_ utility fails to change property value. */ export declare function setDeviceProperty(this: ADB, prop: string, val: string, opts?: SetPropOpts): Promise<void>; /** * @returns Current system language on the device under test. */ export declare function getDeviceSysLanguage(this: ADB): Promise<string>; /** * @returns Current country name on the device under test. */ export declare function getDeviceSysCountry(this: ADB): Promise<string>; /** * @returns Current system locale name on the device under test. */ export declare function getDeviceSysLocale(this: ADB): Promise<string>; /** * @returns Current product language name on the device under test. */ export declare function getDeviceProductLanguage(this: ADB): Promise<string>; /** * @returns Current product country name on the device under test. */ export declare function getDeviceProductCountry(this: ADB): Promise<string>; /** * @returns Current product locale name on the device under test. */ export declare function getDeviceProductLocale(this: ADB): Promise<string>; /** * @returns The model name of the device under test. */ export declare function getModel(this: ADB): Promise<string>; /** * @returns The manufacturer name of the device under test. */ export declare function getManufacturer(this: ADB): Promise<string>; /** * Get the current screen size. * * @returns Device screen size as string in format 'WxH' or * _null_ if it cannot be determined. */ export declare function getScreenSize(this: ADB): Promise<string | null>; /** * Get the current screen density in dpi * * @returns Device screen density as a number or _null_ if it * cannot be determined */ export declare function getScreenDensity(this: ADB): Promise<number | null>; /** * Setup HTTP proxy in device global settings. * Read https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r21/core/java/android/provider/Settings.java for each property * * @param proxyHost - The host name of the proxy. * @param proxyPort - The port number to be set. */ export declare function setHttpProxy(this: ADB, proxyHost: string, proxyPort: string | number): Promise<void>; /** * Delete HTTP proxy in device global settings. * Rebooting the test device is necessary to apply the change. */ export declare function deleteHttpProxy(this: ADB): Promise<void>; /** * Set device property. * [android.provider.Settings]{@link https://developer.android.com/reference/android/provider/Settings.html} * * @param namespace - one of {system, secure, global}, case-insensitive. * @param setting - property name. * @param value - property value. * @returns command output. */ export declare function setSetting(this: ADB, namespace: string, setting: string, value: string | number): Promise<string>; /** * Get device property. * [android.provider.Settings]{@link https://developer.android.com/reference/android/provider/Settings.html} * * @param namespace - one of {system, secure, global}, case-insensitive. * @param setting - property name. * @returns property value. */ export declare function getSetting(this: ADB, namespace: string, setting: string): Promise<string>; /** * Get tz database time zone formatted timezone * * @returns TZ database Time Zones format * @throws If any exception is reported by adb shell. */ export declare function getTimeZone(this: ADB): Promise<string>; /** * Retrieve the platform version of the device under test. * * @returns The platform version as a string, for example '5.0' for * Android Lollipop. */ export declare function getPlatformVersion(this: ADB): Promise<string>; /** * Retrieve the list of location providers for the device under test. * * @returns The list of available location providers or an empty list. */ export declare function getLocationProviders(this: ADB): Promise<string[]>; /** * Toggle the state of GPS location provider. * * @param enabled - Whether to enable (true) or disable (false) the GPS provider. */ export declare function toggleGPSLocationProvider(this: ADB, enabled: boolean): Promise<void>; /** * Set hidden api policy to manage access to non-SDK APIs. * https://developer.android.com/preview/restrictions-non-sdk-interfaces * * @param value - The API enforcement policy. * For Android P * 0: Disable non-SDK API usage detection. This will also disable logging, and also break the strict mode API, * detectNonSdkApiUsage(). Not recommended. * 1: "Just warn" - permit access to all non-SDK APIs, but keep warnings in the log. * The strict mode API will keep working. * 2: Disallow usage of dark grey and black listed APIs. * 3: Disallow usage of blacklisted APIs, but allow usage of dark grey listed APIs. * * For Android Q * https://developer.android.com/preview/non-sdk-q#enable-non-sdk-access * 0: Disable all detection of non-SDK interfaces. Using this setting disables all log messages for non-SDK interface usage * and prevents you from testing your app using the StrictMode API. This setting is not recommended. * 1: Enable access to all non-SDK interfaces, but print log messages with warnings for any non-SDK interface usage. * Using this setting also allows you to test your app using the StrictMode API. * 2: Disallow usage of non-SDK interfaces that belong to either the black list * or to a restricted greylist for your target API level. * * @param ignoreError - Whether to ignore an exception in 'adb shell settings put global' command * @throws If there was an error and ignoreError was true while executing 'adb shell settings put global' * command on the device under test. */ export declare function setHiddenApiPolicy(this: ADB, value: number | string, ignoreError?: boolean): Promise<void>; /** * Reset access to non-SDK APIs to its default setting. * https://developer.android.com/preview/restrictions-non-sdk-interfaces * * @param ignoreError - Whether to ignore an exception in 'adb shell settings delete global' command * @throws If there was an error and ignoreError was true while executing 'adb shell settings delete global' * command on the device under test. */ export declare function setDefaultHiddenApiPolicy(this: ADB, ignoreError?: boolean): Promise<void>; /** * Get the language name of the device under test. * * @returns The name of device language. */ export declare function getDeviceLanguage(this: ADB): Promise<string>; /** * Get the country name of the device under test. * * @summary Could only be used for Android API < 23 * @returns The name of device country. */ export declare function getDeviceCountry(this: ADB): Promise<string>; /** * Get the locale name of the device under test. * * @summary Could only be used for Android API >= 23 * @returns The name of device locale. */ export declare function getDeviceLocale(this: ADB): Promise<string>; /** * Make sure current device locale is expected or not. * * @privateRemarks FIXME: language or country is required * @param language - Language. The language field is case insensitive, but Locale always canonicalizes to lower case. * @param country - Country. The language field is case insensitive, but Locale always canonicalizes to lower case. * @param script - Script. The script field is case insensitive but Locale always canonicalizes to title case. * * @returns If current locale is language and country as arguments, return true. */ export declare function ensureCurrentLocale(this: ADB, language?: string, country?: string, script?: string): Promise<boolean>; /** * Change the state of WiFi on the device under test. * Only works for real devices since API 30 * * @param on - True to enable and false to disable it. * @param isEmulator - Set it to true if the device under test * is an emulator rather than a real device. */ export declare function setWifiState(this: ADB, on: boolean, isEmulator?: boolean): Promise<void>; /** * Change the state of Data transfer on the device under test. * Only works for real devices since API 30 * * @param on - True to enable and false to disable it. * @param isEmulator - Set it to true if the device under test * is an emulator rather than a real device. */ export declare function setDataState(this: ADB, on: boolean, isEmulator?: boolean): Promise<void>; /** * Retrieves the list of packages from Doze whitelist on Android 8+ * * @returns The list of whitelisted packages. An example output: * system,com.android.shell,2000 * system,com.google.android.cellbroadcastreceiver,10143 * user,io.appium.settings,10157 */ export declare function getDeviceIdleWhitelist(this: ADB): Promise<string[]>; /** * Adds an existing package(s) into the Doze whitelist on Android 8+ * * @param packages One or more packages to add. If the package * already exists in the whitelist then it is only going to be added once. * If the package with the given name is not installed/not known then an error * will be thrown. * @returns `true` if the command to add package(s) has been executed */ export declare function addToDeviceIdleWhitelist(this: ADB, ...packages: string[]): Promise<boolean>; /** * Check the state of Airplane mode on the device under test. * * @returns True if Airplane mode is enabled. */ export declare function isAirplaneModeOn(this: ADB): Promise<boolean>; /** * Change the state of Airplane mode in Settings on the device under test. * * @param on - True to enable the Airplane mode in Settings and false to disable it. */ export declare function setAirplaneMode(this: ADB, on: boolean): Promise<void>; /** * Change the state of the bluetooth service on the device under test. * * @param on - True to enable bluetooth service and false to disable it. */ export declare function setBluetoothOn(this: ADB, on: boolean): Promise<void>; /** * Change the state of the NFC service on the device under test. * * @param on - True to enable NFC service and false to disable it. * @throws If there was an error while changing the service state */ export declare function setNfcOn(this: ADB, on: boolean): Promise<void>; /** * Broadcast the state of Airplane mode on the device under test. * This method should be called after {@link #setAirplaneMode}, otherwise * the mode change is not going to be applied for the device. * ! This API requires root since Android API 24. Since API 30 * there is a dedicated adb command to change airplane mode state, which * does not require to call this one afterwards. * * @param on - True to broadcast enable and false to broadcast disable. */ export declare function broadcastAirplaneMode(this: ADB, on: boolean): Promise<void>; /** * Check the state of WiFi on the device under test. * * @returns True if WiFi is enabled. */ export declare function isWifiOn(this: ADB): Promise<boolean>; /** * Check the state of Data transfer on the device under test. * * @returns True if Data transfer is enabled. */ export declare function isDataOn(this: ADB): Promise<boolean>; /** * Check the state of animation on the device under test below: * - animator_duration_scale * - transition_animation_scale * - window_animation_scale * * @returns True if at least one of animation scale settings * is not equal to '0.0'. */ export declare function isAnimationOn(this: ADB): Promise<boolean>; /** * Set animation scale with the given value via adb shell settings command. * - animator_duration_scale * - transition_animation_scale * - window_animation_scale * API level 24 and newer OS versions may change the animation, at least emulators are so. * API level 28+ real devices checked this worked, but we haven't checked older ones * with real devices. * * @param value Animation scale value (int or float) to set. * The minimum value of zero disables animations. * By increasing the value, animations become slower. * '1' is the system default animation scale. * @throws If the adb setting command raises an exception. */ export declare function setAnimationScale(this: ADB, value: number): Promise<void>; /** * Retrieve current screen orientation of the device under test. * * @returns The current orientation encoded as an integer number. */ export declare function getScreenOrientation(this: ADB): Promise<number | null>; //# sourceMappingURL=device-settings.d.ts.map