expo-device 4.3.0 → 5.1.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/CHANGELOG.md +21 -0
- package/README.md +1 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/device/DeviceModule.kt +86 -106
- package/build/Device.d.ts +250 -0
- package/build/Device.d.ts.map +1 -1
- package/build/Device.js +250 -0
- package/build/Device.js.map +1 -1
- package/build/Device.types.d.ts +18 -0
- package/build/Device.types.d.ts.map +1 -1
- package/build/Device.types.js +18 -0
- package/build/Device.types.js.map +1 -1
- package/build/ExpoDevice.d.ts +1 -1
- package/build/ExpoDevice.d.ts.map +1 -1
- package/build/ExpoDevice.js +2 -2
- package/build/ExpoDevice.js.map +1 -1
- package/expo-module.config.json +10 -0
- package/ios/DeviceModule.swift +95 -0
- package/ios/{EXDevice.podspec → ExpoDevice.podspec} +11 -4
- package/ios/UIDevice.swift +261 -0
- package/package.json +3 -3
- package/src/Device.ts +266 -0
- package/src/Device.types.ts +18 -0
- package/src/ExpoDevice.ts +2 -2
- package/android/src/main/java/expo/modules/device/DevicePackage.kt +0 -11
- package/ios/EXDevice/EXDevice.h +0 -21
- package/ios/EXDevice/EXDevice.m +0 -374
- package/unimodule.json +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,27 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 5.1.0 — 2022-12-30
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Migrated Android codebase to use the new Expo modules API. ([#20118](https://github.com/expo/expo/pull/20118) by [@alanhughes](https://github.com/alanjhughes))
|
|
18
|
+
- Native module on iOS is now written in Swift using the Sweet API. ([#19526](https://github.com/expo/expo/pull/19526) by [@fobos531](https://github.com/fobos531))
|
|
19
|
+
|
|
20
|
+
## 5.0.0 — 2022-10-25
|
|
21
|
+
|
|
22
|
+
### 🛠 Breaking changes
|
|
23
|
+
|
|
24
|
+
- Bumped iOS deployment target to 13.0 and deprecated support for iOS 12. ([#18873](https://github.com/expo/expo/pull/18873) by [@tsapeta](https://github.com/tsapeta))
|
|
25
|
+
|
|
26
|
+
### 🐛 Bug fixes
|
|
27
|
+
|
|
28
|
+
- Fixed `<bluetooth_name> is only readable to apps with targetSdkVersion lower than or equal to: 31` error when the `targetSdkVersion` is set to 33. ([#19666](https://github.com/expo/expo/pull/19666) by [@kudo](https://github.com/kudo), [@kudo](https://github.com/kudo))
|
|
29
|
+
|
|
30
|
+
### 💡 Others
|
|
31
|
+
|
|
32
|
+
- Refactored inline emulator checks to use enhanced checking in `EmulatorUtilities.isRunningOnEmulator() `. ([#16177](https://github.com/expo/expo/pull/16177)) by [@kbrandwijk](https://github.com/kbrandwijk), [@keith-kurak](https://github.com/keith-kurak))
|
|
33
|
+
|
|
13
34
|
## 4.3.0 — 2022-07-07
|
|
14
35
|
|
|
15
36
|
_This version does not introduce any user-facing changes._
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Provides specific information about the device running the application.
|
|
|
4
4
|
|
|
5
5
|
# API documentation
|
|
6
6
|
|
|
7
|
-
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/device.
|
|
7
|
+
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/device.mdx)
|
|
8
8
|
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/device/)
|
|
9
9
|
|
|
10
10
|
# Installation in managed Expo projects
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '
|
|
6
|
+
version = '5.1.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
76
76
|
versionCode 12
|
|
77
|
-
versionName '
|
|
77
|
+
versionName '5.1.0'
|
|
78
78
|
}
|
|
79
79
|
lintOptions {
|
|
80
80
|
abortOnError false
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
package expo.modules.device
|
|
2
2
|
|
|
3
|
-
import expo.modules.core.ExportedModule
|
|
4
|
-
import expo.modules.core.Promise
|
|
5
|
-
import expo.modules.core.interfaces.ExpoMethod
|
|
6
|
-
|
|
7
|
-
import com.facebook.device.yearclass.YearClass
|
|
8
|
-
|
|
9
3
|
import android.app.ActivityManager
|
|
10
4
|
import android.app.UiModeManager
|
|
11
5
|
import android.content.Context
|
|
@@ -13,16 +7,20 @@ import android.content.res.Configuration
|
|
|
13
7
|
import android.os.Build
|
|
14
8
|
import android.os.SystemClock
|
|
15
9
|
import android.provider.Settings
|
|
16
|
-
import android.view.WindowManager
|
|
17
10
|
import android.util.DisplayMetrics
|
|
18
|
-
|
|
11
|
+
import android.view.WindowManager
|
|
12
|
+
import com.facebook.device.yearclass.YearClass
|
|
13
|
+
import expo.modules.core.utilities.EmulatorUtilities
|
|
14
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
15
|
+
import expo.modules.kotlin.modules.Module
|
|
16
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
19
17
|
import java.io.File
|
|
20
18
|
import kotlin.math.pow
|
|
21
19
|
import kotlin.math.sqrt
|
|
22
20
|
|
|
23
21
|
private const val NAME = "ExpoDevice"
|
|
24
22
|
|
|
25
|
-
class DeviceModule
|
|
23
|
+
class DeviceModule : Module() {
|
|
26
24
|
// Keep this enum in sync with JavaScript
|
|
27
25
|
enum class DeviceType(val JSValue: Int) {
|
|
28
26
|
UNKNOWN(0),
|
|
@@ -32,73 +30,57 @@ class DeviceModule(private val mContext: Context) : ExportedModule(mContext) {
|
|
|
32
30
|
TV(4);
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
private val deviceYearClass: Int
|
|
69
|
-
get() = YearClass.get(mContext)
|
|
70
|
-
|
|
71
|
-
private val systemName: String
|
|
72
|
-
get() {
|
|
73
|
-
return if (Build.VERSION.SDK_INT < 23) {
|
|
74
|
-
"Android"
|
|
75
|
-
} else {
|
|
76
|
-
Build.VERSION.BASE_OS.takeIf { it.isNotEmpty() } ?: "Android"
|
|
77
|
-
}
|
|
33
|
+
private val context: Context
|
|
34
|
+
get() = appContext.reactContext ?: throw Exceptions.ReactContextLost()
|
|
35
|
+
|
|
36
|
+
override fun definition() = ModuleDefinition {
|
|
37
|
+
Name("ExpoDevice")
|
|
38
|
+
|
|
39
|
+
Constants {
|
|
40
|
+
return@Constants mapOf(
|
|
41
|
+
"isDevice" to !isRunningOnEmulator,
|
|
42
|
+
"brand" to Build.BRAND,
|
|
43
|
+
"manufacturer" to Build.MANUFACTURER,
|
|
44
|
+
"modelName" to Build.MODEL,
|
|
45
|
+
"designName" to Build.DEVICE,
|
|
46
|
+
"productName" to Build.DEVICE,
|
|
47
|
+
"deviceYearClass" to deviceYearClass,
|
|
48
|
+
"totalMemory" to run {
|
|
49
|
+
val memoryInfo = ActivityManager.MemoryInfo()
|
|
50
|
+
(context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).getMemoryInfo(memoryInfo)
|
|
51
|
+
memoryInfo.totalMem
|
|
52
|
+
},
|
|
53
|
+
"supportedCpuArchitectures" to Build.SUPPORTED_ABIS?.takeIf { it.isNotEmpty() },
|
|
54
|
+
"osName" to systemName,
|
|
55
|
+
"osVersion" to Build.VERSION.RELEASE,
|
|
56
|
+
"osBuildId" to Build.DISPLAY,
|
|
57
|
+
"osInternalBuildId" to Build.ID,
|
|
58
|
+
"osBuildFingerprint" to Build.FINGERPRINT,
|
|
59
|
+
"platformApiLevel" to Build.VERSION.SDK_INT,
|
|
60
|
+
"deviceName" to if (Build.VERSION.SDK_INT <= 31)
|
|
61
|
+
Settings.Secure.getString(context.contentResolver, "bluetooth_name")
|
|
62
|
+
else
|
|
63
|
+
Settings.Global.getString(context.contentResolver, Settings.Global.DEVICE_NAME)
|
|
64
|
+
)
|
|
78
65
|
}
|
|
79
66
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
67
|
+
AsyncFunction("getDeviceTypeAsync") {
|
|
68
|
+
return@AsyncFunction getDeviceType(context).JSValue
|
|
69
|
+
}
|
|
84
70
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
71
|
+
AsyncFunction("getUptimeAsync") {
|
|
72
|
+
return@AsyncFunction SystemClock.uptimeMillis().toDouble()
|
|
73
|
+
}
|
|
89
74
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
75
|
+
AsyncFunction("getMaxMemoryAsync") {
|
|
76
|
+
val maxMemory = Runtime.getRuntime().maxMemory()
|
|
77
|
+
return@AsyncFunction if (maxMemory != Long.MAX_VALUE) maxMemory.toDouble() else -1
|
|
78
|
+
}
|
|
95
79
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
val isDevice = !isRunningOnGenymotion && !isRunningOnStockEmulator
|
|
80
|
+
AsyncFunction("isRootedExperimentalAsync") {
|
|
81
|
+
val isRooted: Boolean
|
|
82
|
+
val isDevice = !isRunningOnEmulator
|
|
100
83
|
|
|
101
|
-
try {
|
|
102
84
|
val buildTags = Build.TAGS
|
|
103
85
|
isRooted = if (isDevice && buildTags != null && buildTags.contains("test-keys")) {
|
|
104
86
|
true
|
|
@@ -109,52 +91,49 @@ class DeviceModule(private val mContext: Context) : ExportedModule(mContext) {
|
|
|
109
91
|
isDevice && File("/system/xbin/su").exists()
|
|
110
92
|
}
|
|
111
93
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"ERR_DEVICE_ROOT_DETECTION",
|
|
115
|
-
"Could not access the file system to determine if the device is rooted.",
|
|
116
|
-
se
|
|
117
|
-
)
|
|
118
|
-
return
|
|
94
|
+
|
|
95
|
+
return@AsyncFunction isRooted
|
|
119
96
|
}
|
|
120
97
|
|
|
121
|
-
|
|
122
|
-
|
|
98
|
+
AsyncFunction("isSideLoadingEnabledAsync") {
|
|
99
|
+
return@AsyncFunction if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
100
|
+
Settings.Global.getInt(
|
|
101
|
+
context.applicationContext.contentResolver,
|
|
102
|
+
Settings.Global.INSTALL_NON_MARKET_APPS,
|
|
103
|
+
0
|
|
104
|
+
) == 1
|
|
105
|
+
} else {
|
|
106
|
+
context.applicationContext.packageManager.canRequestPackageInstalls()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
123
109
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
Settings.Global.getInt(
|
|
128
|
-
mContext.applicationContext.contentResolver,
|
|
129
|
-
Settings.Global.INSTALL_NON_MARKET_APPS,
|
|
130
|
-
0
|
|
131
|
-
) == 1
|
|
132
|
-
} else {
|
|
133
|
-
mContext.applicationContext.packageManager.canRequestPackageInstalls()
|
|
110
|
+
AsyncFunction("getPlatformFeaturesAsync") {
|
|
111
|
+
val allFeatures = context.applicationContext.packageManager.systemAvailableFeatures
|
|
112
|
+
return@AsyncFunction allFeatures.filterNotNull().map { it.name }
|
|
134
113
|
}
|
|
135
114
|
|
|
136
|
-
|
|
115
|
+
AsyncFunction("hasPlatformFeatureAsync") { feature: String ->
|
|
116
|
+
return@AsyncFunction context.applicationContext.packageManager.hasSystemFeature(feature)
|
|
117
|
+
}
|
|
137
118
|
}
|
|
138
119
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
val allFeatures = mContext.applicationContext.packageManager.systemAvailableFeatures
|
|
142
|
-
val featureList = allFeatures.filterNotNull().map { it.name }
|
|
143
|
-
promise.resolve(featureList)
|
|
144
|
-
}
|
|
120
|
+
private val deviceYearClass: Int
|
|
121
|
+
get() = YearClass.get(context)
|
|
145
122
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
123
|
+
private val systemName: String
|
|
124
|
+
get() {
|
|
125
|
+
return if (Build.VERSION.SDK_INT < 23) {
|
|
126
|
+
"Android"
|
|
127
|
+
} else {
|
|
128
|
+
Build.VERSION.BASE_OS.takeIf { it.isNotEmpty() } ?: "Android"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
150
131
|
|
|
151
132
|
companion object {
|
|
152
133
|
private val TAG = DeviceModule::class.java.simpleName
|
|
153
134
|
|
|
154
|
-
private val
|
|
155
|
-
get() =
|
|
156
|
-
private val isRunningOnStockEmulator: Boolean
|
|
157
|
-
get() = Build.FINGERPRINT.contains("generic")
|
|
135
|
+
private val isRunningOnEmulator: Boolean
|
|
136
|
+
get() = EmulatorUtilities.isRunningOnEmulator()
|
|
158
137
|
|
|
159
138
|
private fun getDeviceType(context: Context): DeviceType {
|
|
160
139
|
// Detect TVs via UI mode (Android TVs) or system features (Fire TV).
|
|
@@ -168,7 +147,8 @@ class DeviceModule(private val mContext: Context) : ExportedModule(mContext) {
|
|
|
168
147
|
}
|
|
169
148
|
|
|
170
149
|
// Find the current window manager, if none is found we can't measure the device physical size.
|
|
171
|
-
val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager?
|
|
150
|
+
val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager?
|
|
151
|
+
?: return DeviceType.UNKNOWN
|
|
172
152
|
|
|
173
153
|
// Get display metrics to see if we can differentiate phones and tablets.
|
|
174
154
|
val metrics = DisplayMetrics()
|
|
@@ -178,7 +158,7 @@ class DeviceModule(private val mContext: Context) : ExportedModule(mContext) {
|
|
|
178
158
|
val widthInches = metrics.widthPixels / metrics.xdpi.toDouble()
|
|
179
159
|
val heightInches = metrics.heightPixels / metrics.ydpi.toDouble()
|
|
180
160
|
val diagonalSizeInches = sqrt(widthInches.pow(2.0) + heightInches.pow(2.0))
|
|
181
|
-
return if (diagonalSizeInches
|
|
161
|
+
return if (diagonalSizeInches in 3.0..6.9) {
|
|
182
162
|
// Devices in a sane range for phones are considered to be phones.
|
|
183
163
|
DeviceType.PHONE
|
|
184
164
|
} else if (diagonalSizeInches > 6.9 && diagonalSizeInches <= 18.0) {
|
package/build/Device.d.ts
CHANGED
|
@@ -1,27 +1,277 @@
|
|
|
1
1
|
import { DeviceType } from './Device.types';
|
|
2
2
|
export { DeviceType };
|
|
3
|
+
/**
|
|
4
|
+
* `true` if the app is running on a real device and `false` if running in a simulator or emulator.
|
|
5
|
+
* On web, this is always set to `true`.
|
|
6
|
+
*/
|
|
3
7
|
export declare const isDevice: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The device brand. The consumer-visible brand of the product/hardware. On web, this value is always `null`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* Device.brand; // Android: "google", "xiaomi"; iOS: "Apple"; web: null
|
|
14
|
+
* ```
|
|
15
|
+
* @platform android
|
|
16
|
+
* @platform ios
|
|
17
|
+
*/
|
|
4
18
|
export declare const brand: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* The actual device manufacturer of the product or hardware. This value of this field may be `null` if it cannot be determined.
|
|
21
|
+
*
|
|
22
|
+
* To view difference between `brand` and `manufacturer` on Android see [official documentation](https://developer.android.com/reference/android/os/Build).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```js
|
|
26
|
+
* Device.manufacturer; // Android: "Google", "xiaomi"; iOS: "Apple"; web: "Google", null
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
5
29
|
export declare const manufacturer: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* The internal model ID of the device. This is useful for programmatically identifying the type of device and is not a human-friendly string.
|
|
32
|
+
* On web and Android, this value is always `null`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```js
|
|
36
|
+
* Device.modelId; // iOS: "iPhone7,2"; Android: null; web: null
|
|
37
|
+
* ```
|
|
38
|
+
* @platform ios
|
|
39
|
+
*/
|
|
6
40
|
export declare const modelId: any;
|
|
41
|
+
/**
|
|
42
|
+
* The human-friendly name of the device model. This is the name that people would typically use to refer to the device rather than a programmatic model identifier.
|
|
43
|
+
* This value of this field may be `null` if it cannot be determined.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```js
|
|
47
|
+
* Device.modelName; // Android: "Pixel 2"; iOS: "iPhone XS Max"; web: "iPhone", null
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
7
50
|
export declare const modelName: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* The specific configuration or name of the industrial design. It represents the device's name when it was designed during manufacturing into mass production.
|
|
53
|
+
* On Android, it corresponds to [`Build.DEVICE`](https://developer.android.com/reference/android/os/Build#DEVICE). On web and iOS, this value is always `null`.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```js
|
|
57
|
+
* Device.designName; // Android: "kminilte"; iOS: null; web: null
|
|
58
|
+
* ```
|
|
59
|
+
* @platform android
|
|
60
|
+
*/
|
|
8
61
|
export declare const designName: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* The device's overall product name chosen by the device implementer containing the development name or code name of the device.
|
|
64
|
+
* Corresponds to [`Build.PRODUCT`](https://developer.android.com/reference/android/os/Build#PRODUCT). On web and iOS, this value is always `null`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```js
|
|
68
|
+
* Device.productName; // Android: "kminiltexx"; iOS: null; web: null
|
|
69
|
+
* ```
|
|
70
|
+
* @platform android
|
|
71
|
+
*/
|
|
9
72
|
export declare const productName: string | null;
|
|
73
|
+
/**
|
|
74
|
+
* The [device year class](https://github.com/facebook/device-year-class) of this device. On web, this value is always `null`.
|
|
75
|
+
*/
|
|
10
76
|
export declare const deviceYearClass: number | null;
|
|
77
|
+
/**
|
|
78
|
+
* The device's total memory, in bytes. This is the total memory accessible to the kernel, but not necessarily to a single app.
|
|
79
|
+
* This is basically the amount of RAM the device has, not including below-kernel fixed allocations like DMA buffers, RAM for the baseband CPU, etc…
|
|
80
|
+
* On web, this value is always `null`.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```js
|
|
84
|
+
* Device.totalMemory; // 17179869184
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
11
87
|
export declare const totalMemory: number | null;
|
|
88
|
+
/**
|
|
89
|
+
* A list of supported processor architecture versions. The device expects the binaries it runs to be compiled for one of these architectures.
|
|
90
|
+
* This value is `null` if the supported architectures could not be determined, particularly on web.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```js
|
|
94
|
+
* Device.supportedCpuArchitectures; // ['arm64 v8', 'Intel x86-64h Haswell', 'arm64-v8a', 'armeabi-v7a", 'armeabi']
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
12
97
|
export declare const supportedCpuArchitectures: string[] | null;
|
|
98
|
+
/**
|
|
99
|
+
* The name of the OS running on the device.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```js
|
|
103
|
+
* Device.osName; // Android: "Android"; iOS: "iOS" or "iPadOS"; web: "iOS", "Android", "Windows"
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
13
106
|
export declare const osName: string | null;
|
|
107
|
+
/**
|
|
108
|
+
* The human-readable OS version string. Note that the version string may not always contain three numbers separated by dots.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```js
|
|
112
|
+
* Device.osVersion; // Android: "4.0.3"; iOS: "12.3.1"; web: "11.0", "8.1.0"
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
14
115
|
export declare const osVersion: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* The build ID of the OS that more precisely identifies the version of the OS. On Android, this corresponds to `Build.DISPLAY` (not `Build.ID`)
|
|
118
|
+
* and currently is a string as described [here](https://source.android.com/setup/start/build-numbers). On iOS, this corresponds to `kern.osversion`
|
|
119
|
+
* and is the detailed OS version sometimes displayed next to the more human-readable version. On web, this value is always `null`.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```js
|
|
123
|
+
* Device.osBuildId; // Android: "PSR1.180720.075"; iOS: "16F203"; web: null
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
15
126
|
export declare const osBuildId: string | null;
|
|
127
|
+
/**
|
|
128
|
+
* The internal build ID of the OS running on the device. On Android, this corresponds to `Build.ID`.
|
|
129
|
+
* On iOS, this is the same value as [`Device.osBuildId`](#deviceosbuildid). On web, this value is always `null`.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```js
|
|
133
|
+
* Device.osInternalBuildId; // Android: "MMB29K"; iOS: "16F203"; web: null,
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
16
136
|
export declare const osInternalBuildId: string | null;
|
|
137
|
+
/**
|
|
138
|
+
* A string that uniquely identifies the build of the currently running system OS. On Android, it follows this template:
|
|
139
|
+
* - `$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/\$(TAGS)`
|
|
140
|
+
* On web and iOS, this value is always `null`.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```js
|
|
144
|
+
* Device.osBuildFingerprint;
|
|
145
|
+
* // Android: "google/sdk_gphone_x86/generic_x86:9/PSR1.180720.075/5124027:user/release-keys";
|
|
146
|
+
* // iOS: null; web: null
|
|
147
|
+
* ```
|
|
148
|
+
* @platform android
|
|
149
|
+
*/
|
|
17
150
|
export declare const osBuildFingerprint: string | null;
|
|
151
|
+
/**
|
|
152
|
+
* The Android SDK version of the software currently running on this hardware device. This value never changes while a device is booted,
|
|
153
|
+
* but it may increase when the hardware manufacturer provides an OS update. See [here](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html)
|
|
154
|
+
* to see all possible version codes and corresponding versions. On iOS and web, this value is always `null`.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```js
|
|
158
|
+
* Device.platformApiLevel; // Android: 19; iOS: null; web: null
|
|
159
|
+
* ```
|
|
160
|
+
* @platform android
|
|
161
|
+
*/
|
|
18
162
|
export declare const platformApiLevel: number | null;
|
|
163
|
+
/**
|
|
164
|
+
* The human-readable name of the device, which may be set by the device's user. If the device name is unavailable, particularly on web, this value is `null`.
|
|
165
|
+
*
|
|
166
|
+
* > On iOS 16 and newer, this value will be set to generic "iPhone" until you add the correct entitlement, see [iOS Capabilities page](/build-reference/ios-capabilities)
|
|
167
|
+
* > to learn how to add one and check out [Apple documentation](https://developer.apple.com/documentation/uikit/uidevice/1620015-name#discussion)
|
|
168
|
+
* > for more details on this change.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```js
|
|
172
|
+
* Device.deviceName; // "Vivian's iPhone XS"
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
19
175
|
export declare const deviceName: string | null;
|
|
176
|
+
/**
|
|
177
|
+
* Checks the type of the device as a [`DeviceType`](#devicetype) enum value.
|
|
178
|
+
*
|
|
179
|
+
* On Android, for devices other than TVs, the device type is determined by the screen resolution (screen diagonal size), so the result may not be completely accurate.
|
|
180
|
+
* If the screen diagonal length is between 3" and 6.9", the method returns `DeviceType.PHONE`. For lengths between 7" and 18", the method returns `DeviceType.TABLET`.
|
|
181
|
+
* Otherwise, the method returns `DeviceType.UNKNOWN`.
|
|
182
|
+
*
|
|
183
|
+
* @return Returns a promise that resolves to a [`DeviceType`](#devicetype) enum value.
|
|
184
|
+
* @example
|
|
185
|
+
* ```js
|
|
186
|
+
* await Device.getDeviceTypeAsync();
|
|
187
|
+
* // DeviceType.PHONE
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
20
190
|
export declare function getDeviceTypeAsync(): Promise<DeviceType>;
|
|
191
|
+
/**
|
|
192
|
+
* Gets the uptime since the last reboot of the device, in milliseconds. Android devices do not count time spent in deep sleep.
|
|
193
|
+
* @return Returns a promise that resolves to a `number` that represents the milliseconds since last reboot.
|
|
194
|
+
* @example
|
|
195
|
+
* ```js
|
|
196
|
+
* await Device.getUptimeAsync();
|
|
197
|
+
* // 4371054
|
|
198
|
+
* ```
|
|
199
|
+
* @platform android
|
|
200
|
+
* @platform ios
|
|
201
|
+
*/
|
|
21
202
|
export declare function getUptimeAsync(): Promise<number>;
|
|
203
|
+
/**
|
|
204
|
+
* Returns the maximum amount of memory that the Java VM will attempt to use. If there is no inherent limit then `Number.MAX_SAFE_INTEGER` is returned.
|
|
205
|
+
* @return Returns a promise that resolves to the maximum available memory that the Java VM will use, in bytes.
|
|
206
|
+
* @example
|
|
207
|
+
* ```js
|
|
208
|
+
* await Device.getMaxMemoryAsync();
|
|
209
|
+
* // 402653184
|
|
210
|
+
* ```
|
|
211
|
+
* @platform android
|
|
212
|
+
*/
|
|
22
213
|
export declare function getMaxMemoryAsync(): Promise<number>;
|
|
214
|
+
/**
|
|
215
|
+
* > **warning** This method is experimental and is not completely reliable. See description below.
|
|
216
|
+
*
|
|
217
|
+
* Checks whether the device has been rooted (Android) or jailbroken (iOS). This is not completely reliable because there exist solutions to bypass root-detection
|
|
218
|
+
* on both [iOS](https://www.theiphonewiki.com/wiki/XCon) and [Android](https://tweakerlinks.com/how-to-bypass-apps-root-detection-in-android-device/).
|
|
219
|
+
* Further, many root-detection checks can be bypassed via reverse engineering.
|
|
220
|
+
* - On Android, it's implemented in a way to find all possible files paths that contain the `"su"` executable but some devices that are not rooted may also have this executable. Therefore, there's no guarantee that this method will always return correctly.
|
|
221
|
+
* - On iOS, [these jailbreak checks](https://www.theiphonewiki.com/wiki/Bypassing_Jailbreak_Detection) are used to detect if a device is rooted/jailbroken. However, since there are closed-sourced solutions such as [xCon](https://www.theiphonewiki.com/wiki/XCon) that aim to hook every known method and function responsible for informing an application of a jailbroken device, this method may not reliably detect devices that have xCon or similar packages installed.
|
|
222
|
+
* - On web, this always resolves to `false` even if the device is rooted.
|
|
223
|
+
* @return Returns a promise that resolves to a `boolean` that specifies whether this device is rooted.
|
|
224
|
+
* @example
|
|
225
|
+
* ```js
|
|
226
|
+
* await Device.isRootedExperimentalAsync();
|
|
227
|
+
* // true or false
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
23
230
|
export declare function isRootedExperimentalAsync(): Promise<boolean>;
|
|
231
|
+
/**
|
|
232
|
+
* **Using this method requires you to [add the `REQUEST_INSTALL_PACKAGES` permission](/config/app#permissions).**
|
|
233
|
+
* Returns whether applications can be installed for this user via the system's [Intent#ACTION_INSTALL_PACKAGE](https://developer.android.com/reference/android/content/Intent.html#ACTION_INSTALL_PACKAGE)
|
|
234
|
+
* mechanism rather than through the OS's default app store, like Google Play.
|
|
235
|
+
* @return Returns a promise that resolves to a `boolean` that represents whether the calling package is allowed to request package installation.
|
|
236
|
+
* @example
|
|
237
|
+
* ```js
|
|
238
|
+
* await Device.isSideLoadingEnabledAsync();
|
|
239
|
+
* // true or false
|
|
240
|
+
* ```
|
|
241
|
+
* @platform android
|
|
242
|
+
*/
|
|
24
243
|
export declare function isSideLoadingEnabledAsync(): Promise<boolean>;
|
|
244
|
+
/**
|
|
245
|
+
* Gets a list of features that are available on the system. The feature names are platform-specific.
|
|
246
|
+
* See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures()>)
|
|
247
|
+
* to learn more about this implementation.
|
|
248
|
+
* @return Returns a promise that resolves to an array of strings, each of which is a platform-specific name of a feature available on the current device.
|
|
249
|
+
* On iOS and web, the promise always resolves to an empty array.
|
|
250
|
+
* @example
|
|
251
|
+
* ```js
|
|
252
|
+
* await Device.getPlatformFeaturesAsync();
|
|
253
|
+
* // [
|
|
254
|
+
* // 'android.software.adoptable_storage',
|
|
255
|
+
* // 'android.software.backup',
|
|
256
|
+
* // 'android.hardware.sensor.accelerometer',
|
|
257
|
+
* // 'android.hardware.touchscreen',
|
|
258
|
+
* // ]
|
|
259
|
+
* ```
|
|
260
|
+
* @platform android
|
|
261
|
+
*/
|
|
25
262
|
export declare function getPlatformFeaturesAsync(): Promise<string[]>;
|
|
263
|
+
/**
|
|
264
|
+
* Tells if the device has a specific system feature.
|
|
265
|
+
* @param feature The platform-specific name of the feature to check for on the device. You can get all available system features with `Device.getSystemFeatureAsync()`.
|
|
266
|
+
* See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)>) to view acceptable feature strings.
|
|
267
|
+
* @return Returns a promise that resolves to a boolean value indicating whether the device has the specified system feature.
|
|
268
|
+
* On iOS and web, the promise always resolves to `false`.
|
|
269
|
+
* @example
|
|
270
|
+
* ```js
|
|
271
|
+
* await Device.hasPlatformFeatureAsync('amazon.hardware.fire_tv');
|
|
272
|
+
* // true or false
|
|
273
|
+
* ```
|
|
274
|
+
* @platform android
|
|
275
|
+
*/
|
|
26
276
|
export declare function hasPlatformFeatureAsync(feature: string): Promise<boolean>;
|
|
27
277
|
//# sourceMappingURL=Device.d.ts.map
|
package/build/Device.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../src/Device.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,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