@capgo/capacitor-device-info 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapgoCapacitorDeviceInfo.podspec +17 -0
- package/LICENSE +373 -0
- package/Package.swift +28 -0
- package/README.md +426 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/app/capgo/deviceinfo/DeviceInfo.java +765 -0
- package/android/src/main/java/app/capgo/deviceinfo/DeviceInfoPlugin.java +195 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +1285 -0
- package/dist/esm/definitions.d.ts +612 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +29 -0
- package/dist/esm/web.js +182 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +196 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +199 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/DeviceInfoPlugin/DeviceInfo.swift +279 -0
- package/ios/Sources/DeviceInfoPlugin/DeviceInfoPlugin.swift +157 -0
- package/ios/Tests/DeviceInfoPluginTests/DeviceInfoTests.swift +22 -0
- package/package.json +95 -0
package/README.md
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
# @capgo/capacitor-device-info
|
|
2
|
+
|
|
3
|
+
<a href="https://capgo.app/"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-device-info" alt="Capgo - Instant updates for Capacitor" /></a>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<h2><a href="https://capgo.app/?ref=plugin_device_info">Get Instant updates for your App with Capgo</a></h2>
|
|
7
|
+
<h2><a href="https://capgo.app/consulting/?ref=plugin_device_info">Missing a feature? We build Capacitor plugins</a></h2>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
Capacitor plugin for reading CPU, memory, GPU, storage, thermal, low-power-mode, and onboard sensor data from iOS, Android, and Web.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Read an instant device snapshot with CPU, memory, GPU, storage, and onboard sensor fields.
|
|
15
|
+
- Stream snapshots on an interval with `deviceInfoUpdate` listeners for charts and dashboards.
|
|
16
|
+
- Stop streams by duration or sample count.
|
|
17
|
+
- Reports available onboard sensors and common readings such as Android battery temperature, ambient temperature, humidity, pressure, light, and proximity when hardware exposes them.
|
|
18
|
+
- Uses native platform APIs: Metal, Mach, and CoreMotion availability on iOS; ActivityManager, StatFs, `/proc`, OpenGL ES, SensorManager, and thermal zones on Android.
|
|
19
|
+
|
|
20
|
+
## Compatibility
|
|
21
|
+
|
|
22
|
+
| Plugin version | Capacitor compatibility | Maintained |
|
|
23
|
+
| -------------- | ----------------------- | ---------- |
|
|
24
|
+
| v8.\*.\* | v8.\*.\* | Yes |
|
|
25
|
+
| v7.\*.\* | v7.\*.\* | On demand |
|
|
26
|
+
| v6.\*.\* | v6.\*.\* | On demand |
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @capgo/capacitor-device-info
|
|
32
|
+
npx cap sync
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { DeviceInfo } from '@capgo/capacitor-device-info';
|
|
39
|
+
|
|
40
|
+
const snapshot = await DeviceInfo.getInfo();
|
|
41
|
+
console.log(snapshot.cpu.cores, snapshot.memory.usedPercent);
|
|
42
|
+
|
|
43
|
+
const handle = await DeviceInfo.addListener('deviceInfoUpdate', (sample) => {
|
|
44
|
+
console.log(sample.sequence, sample.cpu.usagePercent, sample.memory.usedPercent);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
await DeviceInfo.startMonitoring({
|
|
48
|
+
intervalMs: 1000,
|
|
49
|
+
durationMs: 60_000,
|
|
50
|
+
emitImmediately: true,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await DeviceInfo.stopMonitoring();
|
|
54
|
+
await handle.remove();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
CPU usage is calculated from deltas, so the first native sample may omit `cpu.usagePercent`. Periodic monitoring fills it after the second sample when the platform exposes CPU ticks.
|
|
58
|
+
|
|
59
|
+
Sensor data is onboard-only. This plugin does not call weather services or fetch outside temperature/humidity from the network.
|
|
60
|
+
|
|
61
|
+
## Platform Notes
|
|
62
|
+
|
|
63
|
+
- iOS requires no permissions for the metrics exposed here. GPU data comes from Metal, CPU and memory data comes from Mach APIs, and sensor availability comes from CoreMotion checks. iOS public APIs do not expose raw CPU/GPU temperature.
|
|
64
|
+
- Android requires no permissions. GPU data is queried from a short-lived OpenGL ES context and then cached. CPU/GPU temperatures are best-effort thermal-zone reads and may be omitted on restricted devices.
|
|
65
|
+
- Web support is best effort. Browser APIs expose CPU cores, storage quota, JS heap on Chromium, and WebGL GPU strings when allowed.
|
|
66
|
+
|
|
67
|
+
## Example App
|
|
68
|
+
|
|
69
|
+
The `example-app/` folder links to the plugin with `file:..` and includes an interval listener chart.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd example-app
|
|
73
|
+
npm install
|
|
74
|
+
npm run start
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## API
|
|
78
|
+
|
|
79
|
+
<docgen-index>
|
|
80
|
+
|
|
81
|
+
* [`getInfo()`](#getinfo)
|
|
82
|
+
* [`startMonitoring(...)`](#startmonitoring)
|
|
83
|
+
* [`stopMonitoring()`](#stopmonitoring)
|
|
84
|
+
* [`isMonitoring()`](#ismonitoring)
|
|
85
|
+
* [`addListener('deviceInfoUpdate', ...)`](#addlistenerdeviceinfoupdate-)
|
|
86
|
+
* [`removeAllListeners()`](#removealllisteners)
|
|
87
|
+
* [`getPluginVersion()`](#getpluginversion)
|
|
88
|
+
* [Interfaces](#interfaces)
|
|
89
|
+
* [Type Aliases](#type-aliases)
|
|
90
|
+
|
|
91
|
+
</docgen-index>
|
|
92
|
+
|
|
93
|
+
<docgen-api>
|
|
94
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
95
|
+
|
|
96
|
+
Capacitor plugin contract for reading device CPU, memory, GPU, storage, and onboard sensor metrics.
|
|
97
|
+
|
|
98
|
+
### getInfo()
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
getInfo() => Promise<DeviceInfoSnapshot>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Read one CPU, memory, GPU, storage, thermal, and onboard sensor snapshot.
|
|
105
|
+
|
|
106
|
+
**Returns:** <code>Promise<<a href="#deviceinfosnapshot">DeviceInfoSnapshot</a>></code>
|
|
107
|
+
|
|
108
|
+
**Since:** 8.0.0
|
|
109
|
+
|
|
110
|
+
--------------------
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### startMonitoring(...)
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
startMonitoring(options?: MonitoringOptions | undefined) => Promise<StartMonitoringResult>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Start periodic device snapshots.
|
|
120
|
+
|
|
121
|
+
Listen to `deviceInfoUpdate` to receive samples. Calling this while monitoring
|
|
122
|
+
is already active restarts monitoring with the new options.
|
|
123
|
+
|
|
124
|
+
| Param | Type |
|
|
125
|
+
| ------------- | --------------------------------------------------------------- |
|
|
126
|
+
| **`options`** | <code><a href="#monitoringoptions">MonitoringOptions</a></code> |
|
|
127
|
+
|
|
128
|
+
**Returns:** <code>Promise<<a href="#startmonitoringresult">StartMonitoringResult</a>></code>
|
|
129
|
+
|
|
130
|
+
**Since:** 8.0.0
|
|
131
|
+
|
|
132
|
+
--------------------
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### stopMonitoring()
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
stopMonitoring() => Promise<StopMonitoringResult>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Stop periodic device snapshots.
|
|
142
|
+
|
|
143
|
+
**Returns:** <code>Promise<<a href="#stopmonitoringresult">StopMonitoringResult</a>></code>
|
|
144
|
+
|
|
145
|
+
**Since:** 8.0.0
|
|
146
|
+
|
|
147
|
+
--------------------
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### isMonitoring()
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
isMonitoring() => Promise<MonitoringState>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Return current periodic monitoring state.
|
|
157
|
+
|
|
158
|
+
**Returns:** <code>Promise<<a href="#monitoringstate">MonitoringState</a>></code>
|
|
159
|
+
|
|
160
|
+
**Since:** 8.0.0
|
|
161
|
+
|
|
162
|
+
--------------------
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
### addListener('deviceInfoUpdate', ...)
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
addListener(eventName: 'deviceInfoUpdate', listenerFunc: (event: DeviceInfoUpdate) => void) => Promise<PluginListenerHandle>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Listen for periodic device snapshots.
|
|
172
|
+
|
|
173
|
+
| Param | Type | Description |
|
|
174
|
+
| ------------------ | --------------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
175
|
+
| **`eventName`** | <code>'deviceInfoUpdate'</code> | Only the `deviceInfoUpdate` event is supported. |
|
|
176
|
+
| **`listenerFunc`** | <code>(event: <a href="#deviceinfoupdate">DeviceInfoUpdate</a>) => void</code> | Callback invoked with each snapshot. |
|
|
177
|
+
|
|
178
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
179
|
+
|
|
180
|
+
**Since:** 8.0.0
|
|
181
|
+
|
|
182
|
+
--------------------
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
### removeAllListeners()
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
removeAllListeners() => Promise<void>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Remove all listeners that have been registered on the plugin.
|
|
192
|
+
|
|
193
|
+
**Since:** 8.0.0
|
|
194
|
+
|
|
195
|
+
--------------------
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
### getPluginVersion()
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
getPluginVersion() => Promise<PluginVersionResult>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Get the native Capacitor plugin version.
|
|
205
|
+
|
|
206
|
+
**Returns:** <code>Promise<<a href="#pluginversionresult">PluginVersionResult</a>></code>
|
|
207
|
+
|
|
208
|
+
**Since:** 8.0.0
|
|
209
|
+
|
|
210
|
+
--------------------
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
### Interfaces
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
#### DeviceInfoSnapshot
|
|
217
|
+
|
|
218
|
+
Instant device snapshot returned by {@link DeviceInfoPlugin.getInfo}.
|
|
219
|
+
|
|
220
|
+
| Prop | Type | Description | Since |
|
|
221
|
+
| ------------------ | ----------------------------------------------------------------- | --------------------------------------------------- | ----- |
|
|
222
|
+
| **`timestamp`** | <code>number</code> | Snapshot timestamp as Unix epoch milliseconds. | 8.0.0 |
|
|
223
|
+
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | Platform implementation that produced the snapshot. | 8.0.0 |
|
|
224
|
+
| **`cpu`** | <code><a href="#cpuinfo">CpuInfo</a></code> | CPU information and usage. | 8.0.0 |
|
|
225
|
+
| **`memory`** | <code><a href="#memoryinfo">MemoryInfo</a></code> | Memory information and usage. | 8.0.0 |
|
|
226
|
+
| **`storage`** | <code><a href="#storageinfo">StorageInfo</a></code> | Storage information and usage. | 8.0.0 |
|
|
227
|
+
| **`gpu`** | <code><a href="#gpuinfo">GpuInfo</a></code> | GPU information when the platform exposes it. | 8.0.0 |
|
|
228
|
+
| **`thermalState`** | <code><a href="#thermalstate">ThermalState</a></code> | Thermal state when the platform exposes it. | 8.0.0 |
|
|
229
|
+
| **`lowPowerMode`** | <code>boolean</code> | Low-power mode state when the platform exposes it. | 8.0.0 |
|
|
230
|
+
| **`sensors`** | <code><a href="#onboardsensorsinfo">OnboardSensorsInfo</a></code> | Onboard sensor availability and readings. | 8.0.0 |
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
#### CpuInfo
|
|
234
|
+
|
|
235
|
+
CPU snapshot for the current device.
|
|
236
|
+
|
|
237
|
+
All frequency values are reported in hertz. `usagePercent` is `null` when a
|
|
238
|
+
platform needs at least two samples to calculate CPU usage.
|
|
239
|
+
|
|
240
|
+
| Prop | Type | Description | Since |
|
|
241
|
+
| ------------------------ | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
242
|
+
| **`cores`** | <code>number</code> | Total logical CPU cores visible to the app. | 8.0.0 |
|
|
243
|
+
| **`activeCores`** | <code>number</code> | Logical CPU cores currently active, when the platform exposes it. | 8.0.0 |
|
|
244
|
+
| **`architecture`** | <code>string</code> | CPU architecture, for example `arm64` or `x86_64`. | 8.0.0 |
|
|
245
|
+
| **`model`** | <code>string</code> | CPU or SoC model identifier when available. | 8.0.0 |
|
|
246
|
+
| **`usagePercent`** | <code>number \| null</code> | System CPU usage from 0 to 100. | 8.0.0 |
|
|
247
|
+
| **`maxFrequencyHz`** | <code>number</code> | Highest CPU frequency exposed by the platform. | 8.0.0 |
|
|
248
|
+
| **`temperatureCelsius`** | <code>number</code> | CPU temperature in Celsius when the platform exposes an onboard thermal sensor. Android reads this as a best-effort value from device thermal zones. iOS does not expose raw CPU temperature through public APIs. | 8.0.0 |
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
#### MemoryInfo
|
|
252
|
+
|
|
253
|
+
Memory snapshot for the current device and app process.
|
|
254
|
+
|
|
255
|
+
All size values are reported in bytes.
|
|
256
|
+
|
|
257
|
+
| Prop | Type | Description | Since |
|
|
258
|
+
| ------------------- | ------------------------------------------------------------- | ----------------------------------------------------- | ----- |
|
|
259
|
+
| **`totalBytes`** | <code>number</code> | Total physical memory on the device. | 8.0.0 |
|
|
260
|
+
| **`freeBytes`** | <code>number</code> | Memory available to the system. | 8.0.0 |
|
|
261
|
+
| **`usedBytes`** | <code>number</code> | Memory currently used by the system. | 8.0.0 |
|
|
262
|
+
| **`usedPercent`** | <code>number</code> | Memory usage from 0 to 100. | 8.0.0 |
|
|
263
|
+
| **`appUsedBytes`** | <code>number</code> | Memory used by the current app process. | 8.0.0 |
|
|
264
|
+
| **`appLimitBytes`** | <code>number</code> | Heap limit visible to the current app process. | 8.0.0 |
|
|
265
|
+
| **`lowMemory`** | <code>boolean</code> | Whether the OS currently reports low-memory pressure. | 8.0.0 |
|
|
266
|
+
| **`pressure`** | <code>'normal' \| 'warning' \| 'critical' \| 'unknown'</code> | Platform memory pressure label. | 8.0.0 |
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
#### StorageInfo
|
|
270
|
+
|
|
271
|
+
Storage snapshot for the app data volume.
|
|
272
|
+
|
|
273
|
+
All size values are reported in bytes.
|
|
274
|
+
|
|
275
|
+
| Prop | Type | Description | Since |
|
|
276
|
+
| ----------------- | ------------------- | ----------------------------------- | ----- |
|
|
277
|
+
| **`totalBytes`** | <code>number</code> | Total bytes on the app data volume. | 8.0.0 |
|
|
278
|
+
| **`freeBytes`** | <code>number</code> | Free bytes on the app data volume. | 8.0.0 |
|
|
279
|
+
| **`usedBytes`** | <code>number</code> | Used bytes on the app data volume. | 8.0.0 |
|
|
280
|
+
| **`usedPercent`** | <code>number</code> | Storage usage from 0 to 100. | 8.0.0 |
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
#### GpuInfo
|
|
284
|
+
|
|
285
|
+
GPU snapshot for the primary graphics device.
|
|
286
|
+
|
|
287
|
+
| Prop | Type | Description | Since |
|
|
288
|
+
| ------------------------ | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
289
|
+
| **`api`** | <code>'unknown' \| 'metal' \| 'opengl' \| 'webgl'</code> | Graphics API used to query the GPU. | 8.0.0 |
|
|
290
|
+
| **`vendor`** | <code>string</code> | GPU vendor when available. | 8.0.0 |
|
|
291
|
+
| **`renderer`** | <code>string</code> | GPU renderer or model name when available. | 8.0.0 |
|
|
292
|
+
| **`version`** | <code>string</code> | Graphics API version string when available. | 8.0.0 |
|
|
293
|
+
| **`maxTextureSize`** | <code>number</code> | Maximum texture size reported by the graphics API. | 8.0.0 |
|
|
294
|
+
| **`temperatureCelsius`** | <code>number</code> | GPU temperature in Celsius when the platform exposes an onboard thermal sensor. Android reads this as a best-effort value from device thermal zones. iOS does not expose raw GPU temperature through public APIs. | 8.0.0 |
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
#### OnboardSensorsInfo
|
|
298
|
+
|
|
299
|
+
Onboard sensors snapshot.
|
|
300
|
+
|
|
301
|
+
This only reports hardware sensors exposed by the device or operating system.
|
|
302
|
+
It does not fetch weather data or any external temperature/humidity source.
|
|
303
|
+
|
|
304
|
+
| Prop | Type | Description | Since |
|
|
305
|
+
| ------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------- | ----- |
|
|
306
|
+
| **`availableSensors`** | <code>OnboardSensorDescriptor[]</code> | Sensors available to the app. | 8.0.0 |
|
|
307
|
+
| **`readings`** | <code>OnboardSensorReading[]</code> | Instant sensor readings captured for common environmental sensors. | 8.0.0 |
|
|
308
|
+
| **`batteryTemperatureCelsius`** | <code>number</code> | Battery temperature in Celsius when available. | 8.0.0 |
|
|
309
|
+
| **`ambientTemperatureCelsius`** | <code>number</code> | Ambient air temperature from an onboard sensor in Celsius when available. | 8.0.0 |
|
|
310
|
+
| **`relativeHumidityPercent`** | <code>number</code> | Relative humidity from an onboard sensor as a percentage when available. | 8.0.0 |
|
|
311
|
+
| **`pressureHpa`** | <code>number</code> | Atmospheric pressure from an onboard barometer in hectopascals when available. | 8.0.0 |
|
|
312
|
+
| **`illuminanceLux`** | <code>number</code> | Ambient light from an onboard light sensor in lux when available. | 8.0.0 |
|
|
313
|
+
| **`proximityDistanceCm`** | <code>number</code> | Proximity distance from an onboard proximity sensor in centimeters when available. | 8.0.0 |
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
#### OnboardSensorDescriptor
|
|
317
|
+
|
|
318
|
+
Description of an onboard hardware sensor exposed by the platform.
|
|
319
|
+
|
|
320
|
+
| Prop | Type | Description | Since |
|
|
321
|
+
| -------------------------- | -------------------- | ------------------------------------------------------------------------------------------- | ----- |
|
|
322
|
+
| **`type`** | <code>string</code> | Stable sensor type label, for example `pressure`, `ambientTemperature`, or `accelerometer`. | 8.0.0 |
|
|
323
|
+
| **`name`** | <code>string</code> | Platform sensor name when available. | 8.0.0 |
|
|
324
|
+
| **`vendor`** | <code>string</code> | Sensor vendor when available. | 8.0.0 |
|
|
325
|
+
| **`platformType`** | <code>number</code> | Android sensor type id when available. | 8.0.0 |
|
|
326
|
+
| **`maximumRange`** | <code>number</code> | Maximum sensor range when available. | 8.0.0 |
|
|
327
|
+
| **`resolution`** | <code>number</code> | Sensor resolution when available. | 8.0.0 |
|
|
328
|
+
| **`powerMilliamp`** | <code>number</code> | Sensor power draw in milliamps when available. | 8.0.0 |
|
|
329
|
+
| **`minDelayMicroseconds`** | <code>number</code> | Minimum sensor delay in microseconds when available. | 8.0.0 |
|
|
330
|
+
| **`wakeUp`** | <code>boolean</code> | Whether this is a wake-up sensor when available. | 8.0.0 |
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
#### OnboardSensorReading
|
|
334
|
+
|
|
335
|
+
Instant onboard sensor reading.
|
|
336
|
+
|
|
337
|
+
| Prop | Type | Description | Since |
|
|
338
|
+
| --------------- | ------------------- | ----------------------------------------------------------------------------- | ----- |
|
|
339
|
+
| **`type`** | <code>string</code> | Stable sensor type label. | 8.0.0 |
|
|
340
|
+
| **`unit`** | <code>string</code> | Human-readable unit, for example `celsius`, `percent`, `hPa`, `lux`, or `cm`. | 8.0.0 |
|
|
341
|
+
| **`value`** | <code>number</code> | Sensor value. | 8.0.0 |
|
|
342
|
+
| **`name`** | <code>string</code> | Platform sensor name when available. | 8.0.0 |
|
|
343
|
+
| **`timestamp`** | <code>number</code> | Reading timestamp as Unix epoch milliseconds. | 8.0.0 |
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
#### StartMonitoringResult
|
|
347
|
+
|
|
348
|
+
Result returned when monitoring starts.
|
|
349
|
+
|
|
350
|
+
| Prop | Type | Description | Since |
|
|
351
|
+
| ---------------- | -------------------- | ------------------------------------------------------ | ----- |
|
|
352
|
+
| **`monitoring`** | <code>boolean</code> | Whether monitoring is active. | 8.0.0 |
|
|
353
|
+
| **`intervalMs`** | <code>number</code> | Effective interval in milliseconds. | 8.0.0 |
|
|
354
|
+
| **`startedAt`** | <code>number</code> | Monitoring start timestamp as Unix epoch milliseconds. | 8.0.0 |
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
#### MonitoringOptions
|
|
358
|
+
|
|
359
|
+
Options used to start periodic device snapshots.
|
|
360
|
+
|
|
361
|
+
| Prop | Type | Description | Since |
|
|
362
|
+
| --------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
363
|
+
| **`intervalMs`** | <code>number</code> | Time between samples in milliseconds. Values below 250ms are clamped to 250ms to avoid excessive native work. Defaults to 1000ms. | 8.0.0 |
|
|
364
|
+
| **`durationMs`** | <code>number</code> | Stop automatically after this duration in milliseconds. | 8.0.0 |
|
|
365
|
+
| **`sampleCount`** | <code>number</code> | Stop automatically after this number of emitted samples. | 8.0.0 |
|
|
366
|
+
| **`emitImmediately`** | <code>boolean</code> | Emit one sample immediately when monitoring starts. Defaults to `true`. | 8.0.0 |
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
#### StopMonitoringResult
|
|
370
|
+
|
|
371
|
+
Result returned by {@link DeviceInfoPlugin.stopMonitoring}.
|
|
372
|
+
|
|
373
|
+
| Prop | Type | Description | Since |
|
|
374
|
+
| ---------------- | -------------------- | --------------------------------------------------------- | ----- |
|
|
375
|
+
| **`monitoring`** | <code>boolean</code> | Whether monitoring remains active after the stop request. | 8.0.0 |
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
#### MonitoringState
|
|
379
|
+
|
|
380
|
+
Current monitoring state.
|
|
381
|
+
|
|
382
|
+
| Prop | Type | Description | Since |
|
|
383
|
+
| -------------------- | -------------------- | ------------------------------------------------------------- | ----- |
|
|
384
|
+
| **`monitoring`** | <code>boolean</code> | Whether monitoring is active. | 8.0.0 |
|
|
385
|
+
| **`intervalMs`** | <code>number</code> | Effective interval in milliseconds when monitoring is active. | 8.0.0 |
|
|
386
|
+
| **`startedAt`** | <code>number</code> | Monitoring start timestamp as Unix epoch milliseconds. | 8.0.0 |
|
|
387
|
+
| **`samplesEmitted`** | <code>number</code> | Number of samples emitted by the active monitoring session. | 8.0.0 |
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
#### PluginListenerHandle
|
|
391
|
+
|
|
392
|
+
| Prop | Type |
|
|
393
|
+
| ------------ | ----------------------------------------- |
|
|
394
|
+
| **`remove`** | <code>() => Promise<void></code> |
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
#### DeviceInfoUpdate
|
|
398
|
+
|
|
399
|
+
Periodic event payload emitted while monitoring is active.
|
|
400
|
+
|
|
401
|
+
| Prop | Type | Description | Since |
|
|
402
|
+
| --------------- | ------------------- | ------------------------------------------------------------ | ----- |
|
|
403
|
+
| **`sequence`** | <code>number</code> | One-based sample sequence for the active monitoring session. | 8.0.0 |
|
|
404
|
+
| **`startedAt`** | <code>number</code> | Monitoring start timestamp as Unix epoch milliseconds. | 8.0.0 |
|
|
405
|
+
| **`elapsedMs`** | <code>number</code> | Elapsed milliseconds since monitoring started. | 8.0.0 |
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
#### PluginVersionResult
|
|
409
|
+
|
|
410
|
+
Plugin version payload.
|
|
411
|
+
|
|
412
|
+
| Prop | Type | Description | Since |
|
|
413
|
+
| ------------- | ------------------- | ----------------------------------------------------------- | ----- |
|
|
414
|
+
| **`version`** | <code>string</code> | Version identifier returned by the platform implementation. | 8.0.0 |
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
### Type Aliases
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
#### ThermalState
|
|
421
|
+
|
|
422
|
+
Thermal state reported by the platform.
|
|
423
|
+
|
|
424
|
+
<code>'nominal' | 'fair' | 'serious' | 'critical' | 'unknown'</code>
|
|
425
|
+
|
|
426
|
+
</docgen-api>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace = "app.capgo.deviceinfo"
|
|
22
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lint {
|
|
37
|
+
abortOnError = false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
annotationProcessor project(':capacitor-android')
|
|
55
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
|
+
testImplementation "junit:junit:$junitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
59
|
+
}
|