Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 0083a3e

Browse files
Merge pull request #578 from telerik/vladimirov/improve-device-documentation
Improve device documentation
2 parents 4533e2a + 5e43675 commit 0083a3e

File tree

3 files changed

+142
-32
lines changed

3 files changed

+142
-32
lines changed

README.md

+86-31
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Usage
117117
In order to use mobile-cli-lib, just add a reference to it in your package.json:
118118
```JSON
119119
dependencies: {
120-
"mobile-cli-lib": "0.0.4"
120+
"mobile-cli-lib": "0.4.0"
121121
}
122122
```
123123

@@ -144,51 +144,103 @@ You can change the filename in `index.js`.
144144
Public API
145145
==
146146

147-
This section contains information about each public method. All methods return Promise.
147+
This section contains information about each public method.
148148

149-
### Module deviceEmitter
150-
> Stability 2 - Stable
151-
152-
`deviceEmitter` module is used to emit different events related to devices attached to the system.
153-
You can use `deviceEmitter` to add handles for the following events:
154-
155-
* `deviceFound` - Raised when a new device is attached to the system. The callback function will receive one argument - deviceInfoData. It contains the following information:
149+
Device related public API, exposes `IDeviceInfo` data, that contains the following information:
156150
```TypeScript
151+
/**
152+
* Describes available information for a device.
153+
*/
157154
interface IDeviceInfo {
155+
/**
156+
* Unique identifier of the device.
157+
*/
158158
identifier: string;
159+
160+
/**
161+
* The name of the device.
162+
* For Android this is the value of device's 'ro.product.name' property.
163+
* For iOS this is the value of device's 'DeviceName' property.
164+
*/
159165
displayName: string;
166+
167+
/**
168+
* Device model.
169+
* For Android this is the value of device's 'ro.product.model' property.
170+
* For iOS this is the value of device's 'ProductType' property.
171+
*/
160172
model: string;
173+
174+
/**
175+
* Version of the OS.
176+
* For Android this is the value of device's 'ro.build.version.release' property.
177+
* For iOS this is the value of device's 'ProductVersion' property.
178+
*/
161179
version: string;
180+
181+
/**
182+
* Vendor of the device.
183+
* For Android this is the value of device's 'ro.product.brand' property.
184+
* For iOS the value is always "Apple".
185+
*/
162186
vendor: string;
187+
188+
/**
189+
* Device's platform.
190+
* Can be Android or iOS.
191+
*/
163192
platform: string;
193+
194+
/**
195+
* Status of device describing if you can work with this device or there's communication error.
196+
* Can be Connected or Unreachable.
197+
*/
198+
status: string;
199+
200+
/**
201+
* Additional information for errors that prevents working with this device.
202+
* It will be null when status is Connected.
203+
*/
204+
errorHelp: string;
205+
206+
/**
207+
* Defines if the device is tablet or not.
208+
* For Android the value will be true when device's 'ro.build.characteristics' property contains "tablet" word or when the 'ro.build.version.release' is 3.x
209+
* For iOS the value will be true when device's 'ProductType' property contains "ipad" word.
210+
*/
211+
isTablet: boolean;
212+
213+
/**
214+
* Optional property describing the color of the device.
215+
* Available for iOS only - the value of device's 'DeviceColor' property.
216+
*/
217+
color?: string;
164218
}
165219
```
220+
221+
### Module deviceEmitter
222+
> Stability 2 - Stable
223+
224+
`deviceEmitter` module is used to emit different events related to devices attached to the system.
225+
You can use `deviceEmitter` to add handles for the following events:
226+
227+
* `deviceFound` - Raised when a new device is attached to the system. The callback function will receive one argument - deviceInfoData.
166228
Sample usage:
167229
```JavaScript
168230
require("mobile-cli-lib").deviceEmitter.on("deviceFound", function(deviceInfoData) {
169231
console.log("Found device with identifier: " + deviceInfoData.identifier);
170232
});
171233
```
172234

173-
* `deviceLost` - Raised when a device is detached from the system. The callback function will receive one argument - deviceInfoData. It contains the following information:
174-
```TypeScript
175-
interface IDeviceInfo {
176-
identifier: string;
177-
displayName: string;
178-
model: string;
179-
version: string;
180-
vendor: string;
181-
platform: string;
182-
}
183-
```
235+
* `deviceLost` - Raised when a device is detached from the system. The callback function will receive one argument - deviceInfoData.
184236
Sample usage:
185237
```JavaScript
186238
require("mobile-cli-lib").deviceEmitter.on("deviceLost", function(deviceInfoData) {
187239
console.log("Detached device with identifier: " + deviceInfoData.identifier);
188240
});
189241
```
190242

191-
* `deviceLogData` - Raised when attached device sends reports any information. This is the output of `adb logcat` for Android devices. For iOS this si the `iOS SysLog`.
243+
* `deviceLogData` - Raised when attached device sends reports any information. This is the output of `adb logcat` for Android devices. For iOS this is the `iOS SysLog`.
192244
The event is raised for any device that reports data. The callback function has two arguments - `deviceIdentifier` and `reportedData`. <br/><br/>
193245
Sample usage:
194246
```JavaScript
@@ -203,16 +255,6 @@ require("mobile-cli-lib").deviceEmitter.on("deviceLogData", function(identifier
203255
This modules allows interaction with devices. You can get a list of the attached devices or deploy on specific devices.
204256

205257
* `getDevices()` - This function returns array of all connected devices. For each of them the following information is provided:
206-
```TypeScript
207-
interface IDeviceInfo {
208-
identifier: string;
209-
displayName: string;
210-
model: string;
211-
version: string;
212-
vendor: string;
213-
platform: string;
214-
}
215-
```
216258
Sample usage:
217259
```JavaScript
218260
var devices = require("mobile-cli-lib").devicesService.getDevices();
@@ -240,6 +282,19 @@ Promise.all(require("mobile-cli-lib")
240282
});
241283
```
242284

285+
* `setLogLevel(logLevel: string, deviceIdentifier?: string)` - Sets the logging level for device(s) to `INFO` or `FULL`.
286+
The method has two parameters, only the first one is mandatory. When only `logLevel` is passed, it's value is used for all currently connected devices and all devices that will be connected in the future.
287+
By default the logging level is set to `INFO`. For example when there are two devices attached and this method is called in the following way:
288+
```JavaScript
289+
require("mobile-cli-lib").devicesService.setLogLevel("FULL");
290+
```
291+
Everything that the devices report will be raised in `deviceEmitter.deviceLogData` event. When a new device is attached, all of the information that it reports will also be send.
292+
When the `deviceIdentifier` is passed, the value of the log level will be used only for this device. For example when all devices report all of their logs (`FULL`) level, you may call:
293+
```JavaScript
294+
require("mobile-cli-lib").devicesService.setLogLevel("INFO", "129604ab96a4d0053023b4bf5b288cf34a9ed5fa");
295+
```
296+
This will set the logging level to `INFO` only for device with identifier `129604ab96a4d0053023b4bf5b288cf34a9ed5fa`.
297+
243298
### Module fs
244299
> Stability: 0 - Only for testing purposes. Will be removed.
245300

definitions/mobile.d.ts

+56
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,72 @@ declare module Mobile {
66
skipRefresh?: boolean;
77
}
88

9+
/**
10+
* Describes available information for a device.
11+
*/
912
interface IDeviceInfo {
13+
/**
14+
* Unique identifier of the device.
15+
*/
1016
identifier: string;
17+
18+
/**
19+
* The name of the device.
20+
* For Android this is the value of device's 'ro.product.name' property.
21+
* For iOS this is the value of device's 'DeviceName' property.
22+
*/
1123
displayName: string;
24+
25+
/**
26+
* Device model.
27+
* For Android this is the value of device's 'ro.product.model' property.
28+
* For iOS this is the value of device's 'ProductType' property.
29+
*/
1230
model: string;
31+
32+
/**
33+
* Version of the OS.
34+
* For Android this is the value of device's 'ro.build.version.release' property.
35+
* For iOS this is the value of device's 'ProductVersion' property.
36+
*/
1337
version: string;
38+
39+
/**
40+
* Vendor of the device.
41+
* For Android this is the value of device's 'ro.product.brand' property.
42+
* For iOS the value is always "Apple".
43+
*/
1444
vendor: string;
45+
46+
/**
47+
* Device's platform.
48+
* Can be Android or iOS.
49+
*/
1550
platform: string;
51+
52+
/**
53+
* Status of device describing if you can work with this device or there's communication error.
54+
* Can be Connected or Unauthorized.
55+
*/
1656
status: string;
57+
58+
/**
59+
* Additional information for errors that prevents working with this device.
60+
* It will be null when status is Connected.
61+
*/
1762
errorHelp: string;
63+
64+
/**
65+
* Defines if the device is tablet or not.
66+
* For Android the value will be true when device's 'ro.build.characteristics' property contains "tablet" word or when the 'ro.build.version.release' is 3.x
67+
* For iOS the value will be true when device's 'ProductType' property contains "ipad" word.
68+
*/
1869
isTablet: boolean;
70+
71+
/**
72+
* Optional property describing the color of the device.
73+
* Available for iOS only - the value of device's 'DeviceColor' property.
74+
*/
1975
color?: string;
2076
}
2177

test/unit-tests/appbuilder/device-log-provider.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Yok } from "../../../yok";
55
import * as assert from "assert";
66
import { DeviceLogProvider } from "../../../appbuilder/device-log-provider";
77

8-
// $logFilter
98
function createTestInjector(loggingLevel: string, emptyFilteredData?: boolean) {
109
let testInjector = new Yok();
1110
testInjector.register("logFilter", {

0 commit comments

Comments
 (0)