@capacitor/device 1.0.4 → 1.1.1
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/CHANGELOG.md +41 -0
- package/README.md +15 -13
- package/android/src/main/java/com/capacitorjs/plugins/device/Device.java +10 -0
- package/android/src/main/java/com/capacitorjs/plugins/device/DevicePlugin.java +2 -0
- package/dist/docs.json +34 -2
- package/dist/esm/definitions.d.ts +23 -2
- package/ios/Plugin/Device.swift +16 -0
- package/ios/Plugin/DevicePlugin.swift +4 -1
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.1.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/device@1.1.0...@capacitor/device@1.1.1) (2021-12-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **device:** isVirtual is false on M1 simulators ([#726](https://github.com/ionic-team/capacitor-plugins/issues/726)) ([5377586](https://github.com/ionic-team/capacitor-plugins/commit/53775863df624531e8ffa4b18852b408e1bd2cbd))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.1.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/device@1.0.6...@capacitor/device@1.1.0) (2021-11-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **device:** Add realDiskTotal and realDiskFree properties ([#694](https://github.com/ionic-team/capacitor-plugins/issues/694)) ([3f67643](https://github.com/ionic-team/capacitor-plugins/commit/3f67643edf4cfd90a84d4606c4c6349b72531b92))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [1.0.6](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/device@1.0.5...@capacitor/device@1.0.6) (2021-11-03)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @capacitor/device
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [1.0.5](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/device@1.0.4...@capacitor/device@1.0.5) (2021-10-14)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
6
47
|
## [1.0.4](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/device@1.0.3...@capacitor/device@1.0.4) (2021-10-13)
|
|
7
48
|
|
|
8
49
|
|
package/README.md
CHANGED
|
@@ -115,19 +115,21 @@ Get the device's current language locale code.
|
|
|
115
115
|
|
|
116
116
|
#### DeviceInfo
|
|
117
117
|
|
|
118
|
-
| Prop | Type | Description
|
|
119
|
-
| --------------------- | ----------------------------------------------------------- |
|
|
120
|
-
| **`name`** | <code>string</code> | The name of the device. For example, "John's iPhone". This is only supported on iOS and Android 7.1 or above.
|
|
121
|
-
| **`model`** | <code>string</code> | The device model. For example, "iPhone".
|
|
122
|
-
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | The device platform (lowercase).
|
|
123
|
-
| **`operatingSystem`** | <code><a href="#operatingsystem">OperatingSystem</a></code> | The operating system of the device.
|
|
124
|
-
| **`osVersion`** | <code>string</code> | The version of the device OS.
|
|
125
|
-
| **`manufacturer`** | <code>string</code> | The manufacturer of the device.
|
|
126
|
-
| **`isVirtual`** | <code>boolean</code> | Whether the app is running in a simulator/emulator.
|
|
127
|
-
| **`memUsed`** | <code>number</code> | Approximate memory used by the current app, in bytes. Divide by 1048576 to get the number of MBs used.
|
|
128
|
-
| **`diskFree`** | <code>number</code> | How much free disk space is available on the the normal data storage
|
|
129
|
-
| **`diskTotal`** | <code>number</code> | The total size of the normal data storage path for the OS, in bytes.
|
|
130
|
-
| **`
|
|
118
|
+
| Prop | Type | Description | Since |
|
|
119
|
+
| --------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
120
|
+
| **`name`** | <code>string</code> | The name of the device. For example, "John's iPhone". This is only supported on iOS and Android 7.1 or above. | 1.0.0 |
|
|
121
|
+
| **`model`** | <code>string</code> | The device model. For example, "iPhone". | 1.0.0 |
|
|
122
|
+
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | The device platform (lowercase). | 1.0.0 |
|
|
123
|
+
| **`operatingSystem`** | <code><a href="#operatingsystem">OperatingSystem</a></code> | The operating system of the device. | 1.0.0 |
|
|
124
|
+
| **`osVersion`** | <code>string</code> | The version of the device OS. | 1.0.0 |
|
|
125
|
+
| **`manufacturer`** | <code>string</code> | The manufacturer of the device. | 1.0.0 |
|
|
126
|
+
| **`isVirtual`** | <code>boolean</code> | Whether the app is running in a simulator/emulator. | 1.0.0 |
|
|
127
|
+
| **`memUsed`** | <code>number</code> | Approximate memory used by the current app, in bytes. Divide by 1048576 to get the number of MBs used. | 1.0.0 |
|
|
128
|
+
| **`diskFree`** | <code>number</code> | How much free disk space is available on the the normal data storage path for the os, in bytes. On Android it returns the free disk space on the "system" partition holding the core Android OS. On iOS this value is not accurate. | 1.0.0 |
|
|
129
|
+
| **`diskTotal`** | <code>number</code> | The total size of the normal data storage path for the OS, in bytes. On Android it returns the disk space on the "system" partition holding the core Android OS. | 1.0.0 |
|
|
130
|
+
| **`realDiskFree`** | <code>number</code> | How much free disk space is available on the the normal data storage, in bytes. | 1.1.0 |
|
|
131
|
+
| **`realDiskTotal`** | <code>number</code> | The total size of the normal data storage path, in bytes. | 1.1.0 |
|
|
132
|
+
| **`webViewVersion`** | <code>string</code> | The web view browser version | 1.0.0 |
|
|
131
133
|
|
|
132
134
|
|
|
133
135
|
#### BatteryInfo
|
|
@@ -36,6 +36,16 @@ public class Device {
|
|
|
36
36
|
return statFs.getBlockCountLong() * statFs.getBlockSizeLong();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
public long getRealDiskFree() {
|
|
40
|
+
StatFs statFs = new StatFs(Environment.getDataDirectory().getAbsolutePath());
|
|
41
|
+
return statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public long getRealDiskTotal() {
|
|
45
|
+
StatFs statFs = new StatFs(Environment.getDataDirectory().getAbsolutePath());
|
|
46
|
+
return statFs.getBlockCountLong() * statFs.getBlockSizeLong();
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
public String getPlatform() {
|
|
40
50
|
return "android";
|
|
41
51
|
}
|
|
@@ -33,6 +33,8 @@ public class DevicePlugin extends Plugin {
|
|
|
33
33
|
r.put("memUsed", implementation.getMemUsed());
|
|
34
34
|
r.put("diskFree", implementation.getDiskFree());
|
|
35
35
|
r.put("diskTotal", implementation.getDiskTotal());
|
|
36
|
+
r.put("realDiskFree", implementation.getRealDiskFree());
|
|
37
|
+
r.put("realDiskTotal", implementation.getRealDiskTotal());
|
|
36
38
|
r.put("model", android.os.Build.MODEL);
|
|
37
39
|
r.put("operatingSystem", "android");
|
|
38
40
|
r.put("osVersion", android.os.Build.VERSION.RELEASE);
|
package/dist/docs.json
CHANGED
|
@@ -206,24 +206,56 @@
|
|
|
206
206
|
{
|
|
207
207
|
"name": "diskFree",
|
|
208
208
|
"tags": [
|
|
209
|
+
{
|
|
210
|
+
"text": "Use `realDiskFree`.",
|
|
211
|
+
"name": "deprecated"
|
|
212
|
+
},
|
|
209
213
|
{
|
|
210
214
|
"text": "1.0.0",
|
|
211
215
|
"name": "since"
|
|
212
216
|
}
|
|
213
217
|
],
|
|
214
|
-
"docs": "How much free disk space is available on the the normal data storage
|
|
218
|
+
"docs": "How much free disk space is available on the the normal data storage\npath for the os, in bytes.\n\nOn Android it returns the free disk space on the \"system\"\npartition holding the core Android OS.\nOn iOS this value is not accurate.",
|
|
215
219
|
"complexTypes": [],
|
|
216
220
|
"type": "number | undefined"
|
|
217
221
|
},
|
|
218
222
|
{
|
|
219
223
|
"name": "diskTotal",
|
|
220
224
|
"tags": [
|
|
225
|
+
{
|
|
226
|
+
"text": "Use `realDiskTotal`.",
|
|
227
|
+
"name": "deprecated"
|
|
228
|
+
},
|
|
221
229
|
{
|
|
222
230
|
"text": "1.0.0",
|
|
223
231
|
"name": "since"
|
|
224
232
|
}
|
|
225
233
|
],
|
|
226
|
-
"docs": "The total size of the normal data storage path for the OS, in bytes.",
|
|
234
|
+
"docs": "The total size of the normal data storage path for the OS, in bytes.\n\nOn Android it returns the disk space on the \"system\"\npartition holding the core Android OS.",
|
|
235
|
+
"complexTypes": [],
|
|
236
|
+
"type": "number | undefined"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"name": "realDiskFree",
|
|
240
|
+
"tags": [
|
|
241
|
+
{
|
|
242
|
+
"text": "1.1.0",
|
|
243
|
+
"name": "since"
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
"docs": "How much free disk space is available on the the normal data storage, in bytes.",
|
|
247
|
+
"complexTypes": [],
|
|
248
|
+
"type": "number | undefined"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"name": "realDiskTotal",
|
|
252
|
+
"tags": [
|
|
253
|
+
{
|
|
254
|
+
"text": "1.1.0",
|
|
255
|
+
"name": "since"
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
"docs": "The total size of the normal data storage path, in bytes.",
|
|
227
259
|
"complexTypes": [],
|
|
228
260
|
"type": "number | undefined"
|
|
229
261
|
},
|
|
@@ -63,18 +63,39 @@ export interface DeviceInfo {
|
|
|
63
63
|
*/
|
|
64
64
|
memUsed?: number;
|
|
65
65
|
/**
|
|
66
|
-
* How much free disk space is available on the the normal data storage
|
|
67
|
-
* path for the os, in bytes
|
|
66
|
+
* How much free disk space is available on the the normal data storage
|
|
67
|
+
* path for the os, in bytes.
|
|
68
68
|
*
|
|
69
|
+
* On Android it returns the free disk space on the "system"
|
|
70
|
+
* partition holding the core Android OS.
|
|
71
|
+
* On iOS this value is not accurate.
|
|
72
|
+
*
|
|
73
|
+
* @deprecated Use `realDiskFree`.
|
|
69
74
|
* @since 1.0.0
|
|
70
75
|
*/
|
|
71
76
|
diskFree?: number;
|
|
72
77
|
/**
|
|
73
78
|
* The total size of the normal data storage path for the OS, in bytes.
|
|
74
79
|
*
|
|
80
|
+
* On Android it returns the disk space on the "system"
|
|
81
|
+
* partition holding the core Android OS.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated Use `realDiskTotal`.
|
|
75
84
|
* @since 1.0.0
|
|
76
85
|
*/
|
|
77
86
|
diskTotal?: number;
|
|
87
|
+
/**
|
|
88
|
+
* How much free disk space is available on the the normal data storage, in bytes.
|
|
89
|
+
*
|
|
90
|
+
* @since 1.1.0
|
|
91
|
+
*/
|
|
92
|
+
realDiskFree?: number;
|
|
93
|
+
/**
|
|
94
|
+
* The total size of the normal data storage path, in bytes.
|
|
95
|
+
*
|
|
96
|
+
* @since 1.1.0
|
|
97
|
+
*/
|
|
98
|
+
realDiskTotal?: number;
|
|
78
99
|
/**
|
|
79
100
|
* The web view browser version
|
|
80
101
|
*
|
package/ios/Plugin/Device.swift
CHANGED
|
@@ -33,6 +33,22 @@ import Foundation
|
|
|
33
33
|
return nil
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Get real free disk space
|
|
38
|
+
*/
|
|
39
|
+
public func getRealFreeDiskSize() -> Int64? {
|
|
40
|
+
do {
|
|
41
|
+
let values = try URL(fileURLWithPath: NSHomeDirectory() as String).resourceValues(forKeys: [URLResourceKey.volumeAvailableCapacityForImportantUsageKey])
|
|
42
|
+
if let available = values.volumeAvailableCapacityForImportantUsage {
|
|
43
|
+
return available
|
|
44
|
+
} else {
|
|
45
|
+
return nil
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
return nil
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
36
52
|
/**
|
|
37
53
|
* Get total disk size
|
|
38
54
|
*/
|
|
@@ -16,18 +16,21 @@ public class DevicePlugin: CAPPlugin {
|
|
|
16
16
|
}
|
|
17
17
|
@objc func getInfo(_ call: CAPPluginCall) {
|
|
18
18
|
var isSimulator = false
|
|
19
|
-
#if
|
|
19
|
+
#if targetEnvironment(simulator)
|
|
20
20
|
isSimulator = true
|
|
21
21
|
#endif
|
|
22
22
|
|
|
23
23
|
let memUsed = implementation.getMemoryUsage()
|
|
24
24
|
let diskFree = implementation.getFreeDiskSize() ?? 0
|
|
25
|
+
let realDiskFree = implementation.getRealFreeDiskSize() ?? 0
|
|
25
26
|
let diskTotal = implementation.getTotalDiskSize() ?? 0
|
|
26
27
|
|
|
27
28
|
call.resolve([
|
|
28
29
|
"memUsed": memUsed,
|
|
29
30
|
"diskFree": diskFree,
|
|
30
31
|
"diskTotal": diskTotal,
|
|
32
|
+
"realDiskFree": realDiskFree,
|
|
33
|
+
"realDiskTotal": diskTotal,
|
|
31
34
|
"name": UIDevice.current.name,
|
|
32
35
|
"model": UIDevice.current.model,
|
|
33
36
|
"operatingSystem": "ios",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/device",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "The Device API exposes internal information about the device, such as the model and operating system version, along with user information such as unique ids.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
35
35
|
"verify:web": "npm run build && npm test",
|
|
36
36
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
37
|
-
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint --
|
|
37
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
38
38
|
"eslint": "eslint . --ext ts",
|
|
39
39
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
40
40
|
"swiftlint": "node-swiftlint",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"clean": "rimraf ./dist",
|
|
44
44
|
"watch": "tsc --watch",
|
|
45
45
|
"prepublishOnly": "npm run build",
|
|
46
|
-
"postpublish": "npm run publish:cocoapod",
|
|
47
46
|
"publish:cocoapod": "pod trunk push ./CapacitorDevice.podspec --allow-warnings"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
@@ -84,5 +83,5 @@
|
|
|
84
83
|
"publishConfig": {
|
|
85
84
|
"access": "public"
|
|
86
85
|
},
|
|
87
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "d378c00d51b1c9fb978772906448fa0ec9cb81d0"
|
|
88
87
|
}
|