expo-device 5.2.0 → 5.3.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 +15 -0
- package/README.md +2 -2
- package/android/build.gradle +3 -3
- package/android/src/main/java/expo/modules/device/DeviceModule.kt +43 -8
- package/build/Device.d.ts +13 -0
- package/build/Device.d.ts.map +1 -1
- package/build/Device.js +13 -0
- package/build/Device.js.map +1 -1
- package/build/ExpoDevice.web.d.ts +1 -0
- package/build/ExpoDevice.web.d.ts.map +1 -1
- package/build/ExpoDevice.web.js +20 -14
- package/build/ExpoDevice.web.js.map +1 -1
- package/ios/DeviceModule.swift +27 -10
- package/package.json +2 -2
- package/src/Device.ts +14 -0
- package/src/ExpoDevice.web.ts +21 -14
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,21 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 5.3.0 — 2023-05-08
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Added `deviceType` constant. ([#21633](https://github.com/expo/expo/pull/21633) by [@robertherber](https://github.com/robertherber))
|
|
18
|
+
- On iOS added support for deviceType detection of Desktop on MacOS, checking for Catalyst and iPad app running on Mac. ([#21636](https://github.com/expo/expo/pull/21636) by [@robertherber](https://github.com/robertherber))
|
|
19
|
+
|
|
20
|
+
### 🐛 Bug fixes
|
|
21
|
+
|
|
22
|
+
- Fixed Device.getDeviceTypeAsync() returning TABLET on some devices. ([#21325](https://github.com/expo/expo/pull/21325) by [@behenate](https://github.com/behenate))
|
|
23
|
+
|
|
24
|
+
## 5.2.1 — 2023-02-09
|
|
25
|
+
|
|
26
|
+
_This version does not introduce any user-facing changes._
|
|
27
|
+
|
|
13
28
|
## 5.2.0 — 2023-02-03
|
|
14
29
|
|
|
15
30
|
### 💡 Others
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Provides specific information about the device running the application.
|
|
|
9
9
|
|
|
10
10
|
# Installation in managed Expo projects
|
|
11
11
|
|
|
12
|
-
For [managed](https://docs.expo.dev/
|
|
12
|
+
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/device/).
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ For bare React Native projects, you must ensure that you have [installed and con
|
|
|
18
18
|
### Add the package to your npm dependencies
|
|
19
19
|
|
|
20
20
|
```
|
|
21
|
-
expo install expo-device
|
|
21
|
+
npx expo install expo-device
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
# Contributing
|
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 = '5.
|
|
6
|
+
version = '5.3.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -22,7 +22,7 @@ buildscript {
|
|
|
22
22
|
if (ext.has("kotlinVersion")) {
|
|
23
23
|
ext.kotlinVersion()
|
|
24
24
|
} else {
|
|
25
|
-
ext.safeExtGet("kotlinVersion", "1.
|
|
25
|
+
ext.safeExtGet("kotlinVersion", "1.8.10")
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
76
76
|
versionCode 12
|
|
77
|
-
versionName '5.
|
|
77
|
+
versionName '5.3.0'
|
|
78
78
|
}
|
|
79
79
|
lintOptions {
|
|
80
80
|
abortOnError false
|
|
@@ -18,8 +18,6 @@ import java.io.File
|
|
|
18
18
|
import kotlin.math.pow
|
|
19
19
|
import kotlin.math.sqrt
|
|
20
20
|
|
|
21
|
-
private const val NAME = "ExpoDevice"
|
|
22
|
-
|
|
23
21
|
class DeviceModule : Module() {
|
|
24
22
|
// Keep this enum in sync with JavaScript
|
|
25
23
|
enum class DeviceType(val JSValue: Int) {
|
|
@@ -50,6 +48,9 @@ class DeviceModule : Module() {
|
|
|
50
48
|
(context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).getMemoryInfo(memoryInfo)
|
|
51
49
|
memoryInfo.totalMem
|
|
52
50
|
},
|
|
51
|
+
"deviceType" to run {
|
|
52
|
+
getDeviceType(context).JSValue
|
|
53
|
+
},
|
|
53
54
|
"supportedCpuArchitectures" to Build.SUPPORTED_ABIS?.takeIf { it.isNotEmpty() },
|
|
54
55
|
"osName" to systemName,
|
|
55
56
|
"osVersion" to Build.VERSION.RELEASE,
|
|
@@ -130,8 +131,6 @@ class DeviceModule : Module() {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
companion object {
|
|
133
|
-
private val TAG = DeviceModule::class.java.simpleName
|
|
134
|
-
|
|
135
134
|
private val isRunningOnEmulator: Boolean
|
|
136
135
|
get() = EmulatorUtilities.isRunningOnEmulator()
|
|
137
136
|
|
|
@@ -146,18 +145,54 @@ class DeviceModule : Module() {
|
|
|
146
145
|
return DeviceType.TV
|
|
147
146
|
}
|
|
148
147
|
|
|
148
|
+
val deviceTypeFromResourceConfiguration = getDeviceTypeFromResourceConfiguration(context)
|
|
149
|
+
return if (deviceTypeFromResourceConfiguration != DeviceType.UNKNOWN) {
|
|
150
|
+
deviceTypeFromResourceConfiguration
|
|
151
|
+
} else {
|
|
152
|
+
getDeviceTypeFromPhysicalSize(context)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Device type based on the smallest screen width quantifier
|
|
157
|
+
// https://developer.android.com/guide/topics/resources/providing-resources#SmallestScreenWidthQualifier
|
|
158
|
+
private fun getDeviceTypeFromResourceConfiguration(context: Context): DeviceType {
|
|
159
|
+
val smallestScreenWidthDp = context.resources.configuration.smallestScreenWidthDp
|
|
160
|
+
|
|
161
|
+
return if (smallestScreenWidthDp == Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
|
|
162
|
+
DeviceType.UNKNOWN
|
|
163
|
+
} else if (smallestScreenWidthDp >= 600) {
|
|
164
|
+
DeviceType.TABLET
|
|
165
|
+
} else {
|
|
166
|
+
DeviceType.PHONE
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private fun getDeviceTypeFromPhysicalSize(context: Context): DeviceType {
|
|
149
171
|
// Find the current window manager, if none is found we can't measure the device physical size.
|
|
150
172
|
val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager?
|
|
151
173
|
?: return DeviceType.UNKNOWN
|
|
152
174
|
|
|
153
175
|
// Get display metrics to see if we can differentiate phones and tablets.
|
|
154
|
-
val
|
|
155
|
-
|
|
176
|
+
val widthInches: Double
|
|
177
|
+
val heightInches: Double
|
|
178
|
+
|
|
179
|
+
// windowManager.defaultDisplay was marked as deprecated in API level 30 (Android R) and above
|
|
180
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
181
|
+
val windowBounds = windowManager.currentWindowMetrics.bounds
|
|
182
|
+
val densityDpi = context.resources.configuration.densityDpi
|
|
183
|
+
widthInches = windowBounds.width() / densityDpi.toDouble()
|
|
184
|
+
heightInches = windowBounds.height() / densityDpi.toDouble()
|
|
185
|
+
} else {
|
|
186
|
+
val metrics = DisplayMetrics()
|
|
187
|
+
@Suppress("DEPRECATION")
|
|
188
|
+
windowManager.defaultDisplay.getRealMetrics(metrics)
|
|
189
|
+
widthInches = metrics.widthPixels / metrics.xdpi.toDouble()
|
|
190
|
+
heightInches = metrics.heightPixels / metrics.ydpi.toDouble()
|
|
191
|
+
}
|
|
156
192
|
|
|
157
193
|
// Calculate physical size.
|
|
158
|
-
val widthInches = metrics.widthPixels / metrics.xdpi.toDouble()
|
|
159
|
-
val heightInches = metrics.heightPixels / metrics.ydpi.toDouble()
|
|
160
194
|
val diagonalSizeInches = sqrt(widthInches.pow(2.0) + heightInches.pow(2.0))
|
|
195
|
+
|
|
161
196
|
return if (diagonalSizeInches in 3.0..6.9) {
|
|
162
197
|
// Devices in a sane range for phones are considered to be phones.
|
|
163
198
|
DeviceType.PHONE
|
package/build/Device.d.ts
CHANGED
|
@@ -70,6 +70,19 @@ export declare const designName: string | null;
|
|
|
70
70
|
* @platform android
|
|
71
71
|
*/
|
|
72
72
|
export declare const productName: string | null;
|
|
73
|
+
/**
|
|
74
|
+
* The type of the device as a [`DeviceType`](#devicetype) enum value.
|
|
75
|
+
*
|
|
76
|
+
* 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.
|
|
77
|
+
* 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`.
|
|
78
|
+
* Otherwise, the method returns `DeviceType.UNKNOWN`.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```js
|
|
82
|
+
* Device.deviceType; // UNKNOWN, PHONE, TABLET, TV, DESKTOP
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare const deviceType: DeviceType | null;
|
|
73
86
|
/**
|
|
74
87
|
* The [device year class](https://github.com/facebook/device-year-class) of this device. On web, this value is always `null`.
|
|
75
88
|
*/
|
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,MAAM,gBAAgB,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAiD,CAAC;AAEzE;;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,CAAC,OAAO,CAAC,CAKlE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAKlE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK/E"}
|
package/build/Device.js
CHANGED
|
@@ -72,6 +72,19 @@ export const designName = ExpoDevice ? ExpoDevice.designName || null : null;
|
|
|
72
72
|
* @platform android
|
|
73
73
|
*/
|
|
74
74
|
export const productName = ExpoDevice ? ExpoDevice.productName || null : null;
|
|
75
|
+
/**
|
|
76
|
+
* The type of the device as a [`DeviceType`](#devicetype) enum value.
|
|
77
|
+
*
|
|
78
|
+
* 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.
|
|
79
|
+
* 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`.
|
|
80
|
+
* Otherwise, the method returns `DeviceType.UNKNOWN`.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```js
|
|
84
|
+
* Device.deviceType; // UNKNOWN, PHONE, TABLET, TV, DESKTOP
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export const deviceType = ExpoDevice ? ExpoDevice.deviceType : null;
|
|
75
88
|
/**
|
|
76
89
|
* The [device year class](https://github.com/facebook/device-year-class) of this device. On web, this value is always `null`.
|
|
77
90
|
*/
|
package/build/Device.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.js","sourceRoot":"","sources":["../src/Device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EA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,CAAC,UAAU,CAAC,wBAAwB,EAAE;QACxC,OAAO,EAAE,CAAC;KACX;IACD,OAAO,MAAM,UAAU,CAAC,wBAAwB,EAAE,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAe;IAC3D,IAAI,CAAC,UAAU,CAAC,uBAAuB,EAAE;QACvC,OAAO,KAAK,CAAC;KACd;IACD,OAAO,MAAM,UAAU,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { DeviceType } from './Device.types';\nimport ExpoDevice from './ExpoDevice';\n\nexport { DeviceType };\n\n/**\n * `true` if the app is running on a real device and `false` if running in a simulator or emulator.\n * On web, this is always set to `true`.\n */\nexport const isDevice: boolean = ExpoDevice ? ExpoDevice.isDevice : true;\n\n/**\n * The device brand. The consumer-visible brand of the product/hardware. On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.brand; // Android: \"google\", \"xiaomi\"; iOS: \"Apple\"; web: null\n * ```\n * @platform android\n * @platform ios\n */\nexport const brand: string | null = ExpoDevice ? ExpoDevice.brand : null;\n\n/**\n * The actual device manufacturer of the product or hardware. This value of this field may be `null` if it cannot be determined.\n *\n * To view difference between `brand` and `manufacturer` on Android see [official documentation](https://developer.android.com/reference/android/os/Build).\n *\n * @example\n * ```js\n * Device.manufacturer; // Android: \"Google\", \"xiaomi\"; iOS: \"Apple\"; web: \"Google\", null\n * ```\n */\nexport const manufacturer: string | null = ExpoDevice ? ExpoDevice.manufacturer : null;\n\n/**\n * The internal model ID of the device. This is useful for programmatically identifying the type of device and is not a human-friendly string.\n * On web and Android, this value is always `null`.\n *\n * @example\n * ```js\n * Device.modelId; // iOS: \"iPhone7,2\"; Android: null; web: null\n * ```\n * @platform ios\n */\nexport const modelId = ExpoDevice ? ExpoDevice.modelId || null : null;\n\n/**\n * 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.\n * This value of this field may be `null` if it cannot be determined.\n *\n * @example\n * ```js\n * Device.modelName; // Android: \"Pixel 2\"; iOS: \"iPhone XS Max\"; web: \"iPhone\", null\n * ```\n */\nexport const modelName: string | null = ExpoDevice ? ExpoDevice.modelName : null;\n\n/**\n * The specific configuration or name of the industrial design. It represents the device's name when it was designed during manufacturing into mass production.\n * 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`.\n *\n * @example\n * ```js\n * Device.designName; // Android: \"kminilte\"; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const designName: string | null = ExpoDevice ? ExpoDevice.designName || null : null;\n\n/**\n * The device's overall product name chosen by the device implementer containing the development name or code name of the device.\n * Corresponds to [`Build.PRODUCT`](https://developer.android.com/reference/android/os/Build#PRODUCT). On web and iOS, this value is always `null`.\n *\n * @example\n * ```js\n * Device.productName; // Android: \"kminiltexx\"; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const productName: string | null = ExpoDevice ? ExpoDevice.productName || null : null;\n\n/**\n * The [device year class](https://github.com/facebook/device-year-class) of this device. On web, this value is always `null`.\n */\nexport const deviceYearClass: number | null = ExpoDevice ? ExpoDevice.deviceYearClass : null;\n\n/**\n * The device's total memory, in bytes. This is the total memory accessible to the kernel, but not necessarily to a single app.\n * 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…\n * On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.totalMemory; // 17179869184\n * ```\n */\nexport const totalMemory: number | null = ExpoDevice ? ExpoDevice.totalMemory : null;\n\n/**\n * A list of supported processor architecture versions. The device expects the binaries it runs to be compiled for one of these architectures.\n * This value is `null` if the supported architectures could not be determined, particularly on web.\n *\n * @example\n * ```js\n * Device.supportedCpuArchitectures; // ['arm64 v8', 'Intel x86-64h Haswell', 'arm64-v8a', 'armeabi-v7a\", 'armeabi']\n * ```\n */\nexport const supportedCpuArchitectures: string[] | null = ExpoDevice\n ? ExpoDevice.supportedCpuArchitectures\n : null;\n\n/**\n * The name of the OS running on the device.\n *\n * @example\n * ```js\n * Device.osName; // Android: \"Android\"; iOS: \"iOS\" or \"iPadOS\"; web: \"iOS\", \"Android\", \"Windows\"\n * ```\n */\nexport const osName: string | null = ExpoDevice ? ExpoDevice.osName : null;\n\n/**\n * The human-readable OS version string. Note that the version string may not always contain three numbers separated by dots.\n *\n * @example\n * ```js\n * Device.osVersion; // Android: \"4.0.3\"; iOS: \"12.3.1\"; web: \"11.0\", \"8.1.0\"\n * ```\n */\nexport const osVersion: string | null = ExpoDevice ? ExpoDevice.osVersion : null;\n\n/**\n * 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`)\n * and currently is a string as described [here](https://source.android.com/setup/start/build-numbers). On iOS, this corresponds to `kern.osversion`\n * and is the detailed OS version sometimes displayed next to the more human-readable version. On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osBuildId; // Android: \"PSR1.180720.075\"; iOS: \"16F203\"; web: null\n * ```\n */\nexport const osBuildId: string | null = ExpoDevice ? ExpoDevice.osBuildId : null;\n\n/**\n * The internal build ID of the OS running on the device. On Android, this corresponds to `Build.ID`.\n * On iOS, this is the same value as [`Device.osBuildId`](#deviceosbuildid). On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osInternalBuildId; // Android: \"MMB29K\"; iOS: \"16F203\"; web: null,\n * ```\n */\nexport const osInternalBuildId: string | null = ExpoDevice ? ExpoDevice.osInternalBuildId : null;\n\n/**\n * A string that uniquely identifies the build of the currently running system OS. On Android, it follows this template:\n * - `$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/\\$(TAGS)`\n * On web and iOS, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osBuildFingerprint;\n * // Android: \"google/sdk_gphone_x86/generic_x86:9/PSR1.180720.075/5124027:user/release-keys\";\n * // iOS: null; web: null\n * ```\n * @platform android\n */\nexport const osBuildFingerprint: string | null = ExpoDevice\n ? ExpoDevice.osBuildFingerprint || null\n : null;\n\n/**\n * The Android SDK version of the software currently running on this hardware device. This value never changes while a device is booted,\n * 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)\n * to see all possible version codes and corresponding versions. On iOS and web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.platformApiLevel; // Android: 19; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const platformApiLevel: number | null = ExpoDevice\n ? ExpoDevice.platformApiLevel || null\n : null;\n\n/**\n * 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`.\n *\n * > 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)\n * > to learn how to add one and check out [Apple documentation](https://developer.apple.com/documentation/uikit/uidevice/1620015-name#discussion)\n * > for more details on this change.\n *\n * @example\n * ```js\n * Device.deviceName; // \"Vivian's iPhone XS\"\n * ```\n */\nexport const deviceName: string | null = ExpoDevice ? ExpoDevice.deviceName : null;\n\n/**\n * Checks the type of the device as a [`DeviceType`](#devicetype) enum value.\n *\n * 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.\n * 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`.\n * Otherwise, the method returns `DeviceType.UNKNOWN`.\n *\n * @return Returns a promise that resolves to a [`DeviceType`](#devicetype) enum value.\n * @example\n * ```js\n * await Device.getDeviceTypeAsync();\n * // DeviceType.PHONE\n * ```\n */\nexport async function getDeviceTypeAsync(): Promise<DeviceType> {\n if (!ExpoDevice.getDeviceTypeAsync) {\n throw new UnavailabilityError('expo-device', 'getDeviceTypeAsync');\n }\n return await ExpoDevice.getDeviceTypeAsync();\n}\n\n/**\n * Gets the uptime since the last reboot of the device, in milliseconds. Android devices do not count time spent in deep sleep.\n * @return Returns a promise that resolves to a `number` that represents the milliseconds since last reboot.\n * @example\n * ```js\n * await Device.getUptimeAsync();\n * // 4371054\n * ```\n * @platform android\n * @platform ios\n */\nexport async function getUptimeAsync(): Promise<number> {\n if (!ExpoDevice.getUptimeAsync) {\n throw new UnavailabilityError('expo-device', 'getUptimeAsync');\n }\n return await ExpoDevice.getUptimeAsync();\n}\n\n/**\n * 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.\n * @return Returns a promise that resolves to the maximum available memory that the Java VM will use, in bytes.\n * @example\n * ```js\n * await Device.getMaxMemoryAsync();\n * // 402653184\n * ```\n * @platform android\n */\nexport async function getMaxMemoryAsync(): Promise<number> {\n if (!ExpoDevice.getMaxMemoryAsync) {\n throw new UnavailabilityError('expo-device', 'getMaxMemoryAsync');\n }\n let maxMemory = await ExpoDevice.getMaxMemoryAsync();\n if (maxMemory === -1) {\n maxMemory = Number.MAX_SAFE_INTEGER;\n }\n return maxMemory;\n}\n\n/**\n * > **warning** This method is experimental and is not completely reliable. See description below.\n *\n * Checks whether the device has been rooted (Android) or jailbroken (iOS). This is not completely reliable because there exist solutions to bypass root-detection\n * on both [iOS](https://www.theiphonewiki.com/wiki/XCon) and [Android](https://tweakerlinks.com/how-to-bypass-apps-root-detection-in-android-device/).\n * Further, many root-detection checks can be bypassed via reverse engineering.\n * - 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.\n * - 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.\n * - On web, this always resolves to `false` even if the device is rooted.\n * @return Returns a promise that resolves to a `boolean` that specifies whether this device is rooted.\n * @example\n * ```js\n * await Device.isRootedExperimentalAsync();\n * // true or false\n * ```\n */\nexport async function isRootedExperimentalAsync(): Promise<boolean> {\n if (!ExpoDevice.isRootedExperimentalAsync) {\n throw new UnavailabilityError('expo-device', 'isRootedExperimentalAsync');\n }\n return await ExpoDevice.isRootedExperimentalAsync();\n}\n\n/**\n * **Using this method requires you to [add the `REQUEST_INSTALL_PACKAGES` permission](/config/app#permissions).**\n * 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)\n * mechanism rather than through the OS's default app store, like Google Play.\n * @return Returns a promise that resolves to a `boolean` that represents whether the calling package is allowed to request package installation.\n * @example\n * ```js\n * await Device.isSideLoadingEnabledAsync();\n * // true or false\n * ```\n * @platform android\n */\nexport async function isSideLoadingEnabledAsync(): Promise<boolean> {\n if (!ExpoDevice.isSideLoadingEnabledAsync) {\n throw new UnavailabilityError('expo-device', 'isSideLoadingEnabledAsync');\n }\n return await ExpoDevice.isSideLoadingEnabledAsync();\n}\n\n/**\n * Gets a list of features that are available on the system. The feature names are platform-specific.\n * See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures()>)\n * to learn more about this implementation.\n * @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.\n * On iOS and web, the promise always resolves to an empty array.\n * @example\n * ```js\n * await Device.getPlatformFeaturesAsync();\n * // [\n * // 'android.software.adoptable_storage',\n * // 'android.software.backup',\n * // 'android.hardware.sensor.accelerometer',\n * // 'android.hardware.touchscreen',\n * // ]\n * ```\n * @platform android\n */\nexport async function getPlatformFeaturesAsync(): Promise<string[]> {\n if (!ExpoDevice.getPlatformFeaturesAsync) {\n return [];\n }\n return await ExpoDevice.getPlatformFeaturesAsync();\n}\n\n/**\n * Tells if the device has a specific system feature.\n * @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()`.\n * See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)>) to view acceptable feature strings.\n * @return Returns a promise that resolves to a boolean value indicating whether the device has the specified system feature.\n * On iOS and web, the promise always resolves to `false`.\n * @example\n * ```js\n * await Device.hasPlatformFeatureAsync('amazon.hardware.fire_tv');\n * // true or false\n * ```\n * @platform android\n */\nexport async function hasPlatformFeatureAsync(feature: string): Promise<boolean> {\n if (!ExpoDevice.hasPlatformFeatureAsync) {\n return false;\n }\n return await ExpoDevice.hasPlatformFeatureAsync(feature);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Device.js","sourceRoot":"","sources":["../src/Device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAY,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,KAAK,GAAkB,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAEvF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,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C,CAAC;KACnE;IACD,IAAI,SAAS,GAAG,MAAM,UAAU,CAAC,iBAAiB,EAAE,CAAC;IACrD,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;QACpB,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;KACrC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,UAAU,CAAC,yBAAyB,EAAE;QACzC,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC;KAC3E;IACD,OAAO,MAAM,UAAU,CAAC,yBAAyB,EAAE,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,UAAU,CAAC,yBAAyB,EAAE;QACzC,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC;KAC3E;IACD,OAAO,MAAM,UAAU,CAAC,yBAAyB,EAAE,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC5C,IAAI,CAAC,UAAU,CAAC,wBAAwB,EAAE;QACxC,OAAO,EAAE,CAAC;KACX;IACD,OAAO,MAAM,UAAU,CAAC,wBAAwB,EAAE,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAe;IAC3D,IAAI,CAAC,UAAU,CAAC,uBAAuB,EAAE;QACvC,OAAO,KAAK,CAAC;KACd;IACD,OAAO,MAAM,UAAU,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { DeviceType } from './Device.types';\nimport ExpoDevice from './ExpoDevice';\n\nexport { DeviceType };\n\n/**\n * `true` if the app is running on a real device and `false` if running in a simulator or emulator.\n * On web, this is always set to `true`.\n */\nexport const isDevice: boolean = ExpoDevice ? ExpoDevice.isDevice : true;\n\n/**\n * The device brand. The consumer-visible brand of the product/hardware. On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.brand; // Android: \"google\", \"xiaomi\"; iOS: \"Apple\"; web: null\n * ```\n * @platform android\n * @platform ios\n */\nexport const brand: string | null = ExpoDevice ? ExpoDevice.brand : null;\n\n/**\n * The actual device manufacturer of the product or hardware. This value of this field may be `null` if it cannot be determined.\n *\n * To view difference between `brand` and `manufacturer` on Android see [official documentation](https://developer.android.com/reference/android/os/Build).\n *\n * @example\n * ```js\n * Device.manufacturer; // Android: \"Google\", \"xiaomi\"; iOS: \"Apple\"; web: \"Google\", null\n * ```\n */\nexport const manufacturer: string | null = ExpoDevice ? ExpoDevice.manufacturer : null;\n\n/**\n * The internal model ID of the device. This is useful for programmatically identifying the type of device and is not a human-friendly string.\n * On web and Android, this value is always `null`.\n *\n * @example\n * ```js\n * Device.modelId; // iOS: \"iPhone7,2\"; Android: null; web: null\n * ```\n * @platform ios\n */\nexport const modelId = ExpoDevice ? ExpoDevice.modelId || null : null;\n\n/**\n * 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.\n * This value of this field may be `null` if it cannot be determined.\n *\n * @example\n * ```js\n * Device.modelName; // Android: \"Pixel 2\"; iOS: \"iPhone XS Max\"; web: \"iPhone\", null\n * ```\n */\nexport const modelName: string | null = ExpoDevice ? ExpoDevice.modelName : null;\n\n/**\n * The specific configuration or name of the industrial design. It represents the device's name when it was designed during manufacturing into mass production.\n * 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`.\n *\n * @example\n * ```js\n * Device.designName; // Android: \"kminilte\"; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const designName: string | null = ExpoDevice ? ExpoDevice.designName || null : null;\n\n/**\n * The device's overall product name chosen by the device implementer containing the development name or code name of the device.\n * Corresponds to [`Build.PRODUCT`](https://developer.android.com/reference/android/os/Build#PRODUCT). On web and iOS, this value is always `null`.\n *\n * @example\n * ```js\n * Device.productName; // Android: \"kminiltexx\"; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const productName: string | null = ExpoDevice ? ExpoDevice.productName || null : null;\n\n/**\n * The type of the device as a [`DeviceType`](#devicetype) enum value.\n *\n * 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.\n * 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`.\n * Otherwise, the method returns `DeviceType.UNKNOWN`.\n *\n * @example\n * ```js\n * Device.deviceType; // UNKNOWN, PHONE, TABLET, TV, DESKTOP\n * ```\n */\nexport const deviceType: DeviceType | null = ExpoDevice ? ExpoDevice.deviceType : null;\n\n/**\n * The [device year class](https://github.com/facebook/device-year-class) of this device. On web, this value is always `null`.\n */\nexport const deviceYearClass: number | null = ExpoDevice ? ExpoDevice.deviceYearClass : null;\n\n/**\n * The device's total memory, in bytes. This is the total memory accessible to the kernel, but not necessarily to a single app.\n * 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…\n * On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.totalMemory; // 17179869184\n * ```\n */\nexport const totalMemory: number | null = ExpoDevice ? ExpoDevice.totalMemory : null;\n\n/**\n * A list of supported processor architecture versions. The device expects the binaries it runs to be compiled for one of these architectures.\n * This value is `null` if the supported architectures could not be determined, particularly on web.\n *\n * @example\n * ```js\n * Device.supportedCpuArchitectures; // ['arm64 v8', 'Intel x86-64h Haswell', 'arm64-v8a', 'armeabi-v7a\", 'armeabi']\n * ```\n */\nexport const supportedCpuArchitectures: string[] | null = ExpoDevice\n ? ExpoDevice.supportedCpuArchitectures\n : null;\n\n/**\n * The name of the OS running on the device.\n *\n * @example\n * ```js\n * Device.osName; // Android: \"Android\"; iOS: \"iOS\" or \"iPadOS\"; web: \"iOS\", \"Android\", \"Windows\"\n * ```\n */\nexport const osName: string | null = ExpoDevice ? ExpoDevice.osName : null;\n\n/**\n * The human-readable OS version string. Note that the version string may not always contain three numbers separated by dots.\n *\n * @example\n * ```js\n * Device.osVersion; // Android: \"4.0.3\"; iOS: \"12.3.1\"; web: \"11.0\", \"8.1.0\"\n * ```\n */\nexport const osVersion: string | null = ExpoDevice ? ExpoDevice.osVersion : null;\n\n/**\n * 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`)\n * and currently is a string as described [here](https://source.android.com/setup/start/build-numbers). On iOS, this corresponds to `kern.osversion`\n * and is the detailed OS version sometimes displayed next to the more human-readable version. On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osBuildId; // Android: \"PSR1.180720.075\"; iOS: \"16F203\"; web: null\n * ```\n */\nexport const osBuildId: string | null = ExpoDevice ? ExpoDevice.osBuildId : null;\n\n/**\n * The internal build ID of the OS running on the device. On Android, this corresponds to `Build.ID`.\n * On iOS, this is the same value as [`Device.osBuildId`](#deviceosbuildid). On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osInternalBuildId; // Android: \"MMB29K\"; iOS: \"16F203\"; web: null,\n * ```\n */\nexport const osInternalBuildId: string | null = ExpoDevice ? ExpoDevice.osInternalBuildId : null;\n\n/**\n * A string that uniquely identifies the build of the currently running system OS. On Android, it follows this template:\n * - `$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/\\$(TAGS)`\n * On web and iOS, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osBuildFingerprint;\n * // Android: \"google/sdk_gphone_x86/generic_x86:9/PSR1.180720.075/5124027:user/release-keys\";\n * // iOS: null; web: null\n * ```\n * @platform android\n */\nexport const osBuildFingerprint: string | null = ExpoDevice\n ? ExpoDevice.osBuildFingerprint || null\n : null;\n\n/**\n * The Android SDK version of the software currently running on this hardware device. This value never changes while a device is booted,\n * 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)\n * to see all possible version codes and corresponding versions. On iOS and web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.platformApiLevel; // Android: 19; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const platformApiLevel: number | null = ExpoDevice\n ? ExpoDevice.platformApiLevel || null\n : null;\n\n/**\n * 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`.\n *\n * > 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)\n * > to learn how to add one and check out [Apple documentation](https://developer.apple.com/documentation/uikit/uidevice/1620015-name#discussion)\n * > for more details on this change.\n *\n * @example\n * ```js\n * Device.deviceName; // \"Vivian's iPhone XS\"\n * ```\n */\nexport const deviceName: string | null = ExpoDevice ? ExpoDevice.deviceName : null;\n\n/**\n * Checks the type of the device as a [`DeviceType`](#devicetype) enum value.\n *\n * 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.\n * 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`.\n * Otherwise, the method returns `DeviceType.UNKNOWN`.\n *\n * @return Returns a promise that resolves to a [`DeviceType`](#devicetype) enum value.\n * @example\n * ```js\n * await Device.getDeviceTypeAsync();\n * // DeviceType.PHONE\n * ```\n */\nexport async function getDeviceTypeAsync(): Promise<DeviceType> {\n if (!ExpoDevice.getDeviceTypeAsync) {\n throw new UnavailabilityError('expo-device', 'getDeviceTypeAsync');\n }\n return await ExpoDevice.getDeviceTypeAsync();\n}\n\n/**\n * Gets the uptime since the last reboot of the device, in milliseconds. Android devices do not count time spent in deep sleep.\n * @return Returns a promise that resolves to a `number` that represents the milliseconds since last reboot.\n * @example\n * ```js\n * await Device.getUptimeAsync();\n * // 4371054\n * ```\n * @platform android\n * @platform ios\n */\nexport async function getUptimeAsync(): Promise<number> {\n if (!ExpoDevice.getUptimeAsync) {\n throw new UnavailabilityError('expo-device', 'getUptimeAsync');\n }\n return await ExpoDevice.getUptimeAsync();\n}\n\n/**\n * 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.\n * @return Returns a promise that resolves to the maximum available memory that the Java VM will use, in bytes.\n * @example\n * ```js\n * await Device.getMaxMemoryAsync();\n * // 402653184\n * ```\n * @platform android\n */\nexport async function getMaxMemoryAsync(): Promise<number> {\n if (!ExpoDevice.getMaxMemoryAsync) {\n throw new UnavailabilityError('expo-device', 'getMaxMemoryAsync');\n }\n let maxMemory = await ExpoDevice.getMaxMemoryAsync();\n if (maxMemory === -1) {\n maxMemory = Number.MAX_SAFE_INTEGER;\n }\n return maxMemory;\n}\n\n/**\n * > **warning** This method is experimental and is not completely reliable. See description below.\n *\n * Checks whether the device has been rooted (Android) or jailbroken (iOS). This is not completely reliable because there exist solutions to bypass root-detection\n * on both [iOS](https://www.theiphonewiki.com/wiki/XCon) and [Android](https://tweakerlinks.com/how-to-bypass-apps-root-detection-in-android-device/).\n * Further, many root-detection checks can be bypassed via reverse engineering.\n * - 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.\n * - 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.\n * - On web, this always resolves to `false` even if the device is rooted.\n * @return Returns a promise that resolves to a `boolean` that specifies whether this device is rooted.\n * @example\n * ```js\n * await Device.isRootedExperimentalAsync();\n * // true or false\n * ```\n */\nexport async function isRootedExperimentalAsync(): Promise<boolean> {\n if (!ExpoDevice.isRootedExperimentalAsync) {\n throw new UnavailabilityError('expo-device', 'isRootedExperimentalAsync');\n }\n return await ExpoDevice.isRootedExperimentalAsync();\n}\n\n/**\n * **Using this method requires you to [add the `REQUEST_INSTALL_PACKAGES` permission](/config/app#permissions).**\n * 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)\n * mechanism rather than through the OS's default app store, like Google Play.\n * @return Returns a promise that resolves to a `boolean` that represents whether the calling package is allowed to request package installation.\n * @example\n * ```js\n * await Device.isSideLoadingEnabledAsync();\n * // true or false\n * ```\n * @platform android\n */\nexport async function isSideLoadingEnabledAsync(): Promise<boolean> {\n if (!ExpoDevice.isSideLoadingEnabledAsync) {\n throw new UnavailabilityError('expo-device', 'isSideLoadingEnabledAsync');\n }\n return await ExpoDevice.isSideLoadingEnabledAsync();\n}\n\n/**\n * Gets a list of features that are available on the system. The feature names are platform-specific.\n * See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures()>)\n * to learn more about this implementation.\n * @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.\n * On iOS and web, the promise always resolves to an empty array.\n * @example\n * ```js\n * await Device.getPlatformFeaturesAsync();\n * // [\n * // 'android.software.adoptable_storage',\n * // 'android.software.backup',\n * // 'android.hardware.sensor.accelerometer',\n * // 'android.hardware.touchscreen',\n * // ]\n * ```\n * @platform android\n */\nexport async function getPlatformFeaturesAsync(): Promise<string[]> {\n if (!ExpoDevice.getPlatformFeaturesAsync) {\n return [];\n }\n return await ExpoDevice.getPlatformFeaturesAsync();\n}\n\n/**\n * Tells if the device has a specific system feature.\n * @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()`.\n * See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)>) to view acceptable feature strings.\n * @return Returns a promise that resolves to a boolean value indicating whether the device has the specified system feature.\n * On iOS and web, the promise always resolves to `false`.\n * @example\n * ```js\n * await Device.hasPlatformFeatureAsync('amazon.hardware.fire_tv');\n * // true or false\n * ```\n * @platform android\n */\nexport async function hasPlatformFeatureAsync(feature: string): Promise<boolean> {\n if (!ExpoDevice.hasPlatformFeatureAsync) {\n return false;\n }\n return await ExpoDevice.hasPlatformFeatureAsync(feature);\n}\n"]}
|
|
@@ -5,6 +5,7 @@ declare const _default: {
|
|
|
5
5
|
readonly manufacturer: null;
|
|
6
6
|
readonly modelName: string | null;
|
|
7
7
|
readonly deviceYearClass: null;
|
|
8
|
+
readonly deviceType: DeviceType;
|
|
8
9
|
readonly totalMemory: number | null;
|
|
9
10
|
readonly supportedCpuArchitectures: string[] | null;
|
|
10
11
|
readonly osName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoDevice.web.d.ts","sourceRoot":"","sources":["../src/ExpoDevice.web.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC
|
|
1
|
+
{"version":3,"file":"ExpoDevice.web.d.ts","sourceRoot":"","sources":["../src/ExpoDevice.web.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;;;;;;;;;;;;;;;0BA2Ed,QAAQ,UAAU,CAAC;iCAGZ,QAAQ,OAAO,CAAC;;AA/CrD,wBAkDE"}
|
package/build/ExpoDevice.web.js
CHANGED
|
@@ -9,6 +9,22 @@ if (Platform.isDOMAvailable) {
|
|
|
9
9
|
function convertGiBtoBytes(gib) {
|
|
10
10
|
return Math.round(gib * 1024 ** 3);
|
|
11
11
|
}
|
|
12
|
+
function getDeviceType() {
|
|
13
|
+
switch (result?.device?.type) {
|
|
14
|
+
case 'mobile':
|
|
15
|
+
return DeviceType.PHONE;
|
|
16
|
+
case 'tablet':
|
|
17
|
+
return DeviceType.TABLET;
|
|
18
|
+
case 'smarttv':
|
|
19
|
+
return DeviceType.TV;
|
|
20
|
+
case 'console':
|
|
21
|
+
case 'embedded':
|
|
22
|
+
case 'wearable':
|
|
23
|
+
return DeviceType.UNKNOWN;
|
|
24
|
+
default:
|
|
25
|
+
return DeviceType.DESKTOP;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
12
28
|
export default {
|
|
13
29
|
get isDevice() {
|
|
14
30
|
return true;
|
|
@@ -25,6 +41,9 @@ export default {
|
|
|
25
41
|
get deviceYearClass() {
|
|
26
42
|
return null;
|
|
27
43
|
},
|
|
44
|
+
get deviceType() {
|
|
45
|
+
return getDeviceType();
|
|
46
|
+
},
|
|
28
47
|
get totalMemory() {
|
|
29
48
|
if (Platform.isDOMAvailable && 'deviceMemory' in navigator) {
|
|
30
49
|
const { deviceMemory } = navigator;
|
|
@@ -51,20 +70,7 @@ export default {
|
|
|
51
70
|
return null;
|
|
52
71
|
},
|
|
53
72
|
async getDeviceTypeAsync() {
|
|
54
|
-
|
|
55
|
-
case 'mobile':
|
|
56
|
-
return DeviceType.PHONE;
|
|
57
|
-
case 'tablet':
|
|
58
|
-
return DeviceType.TABLET;
|
|
59
|
-
case 'smarttv':
|
|
60
|
-
return DeviceType.TV;
|
|
61
|
-
case 'console':
|
|
62
|
-
case 'embedded':
|
|
63
|
-
case 'wearable':
|
|
64
|
-
return DeviceType.UNKNOWN;
|
|
65
|
-
default:
|
|
66
|
-
return DeviceType.DESKTOP;
|
|
67
|
-
}
|
|
73
|
+
return getDeviceType();
|
|
68
74
|
},
|
|
69
75
|
async isRootedExperimentalAsync() {
|
|
70
76
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoDevice.web.js","sourceRoot":"","sources":["../src/ExpoDevice.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,QAAQ,MAAM,cAAc,CAAC;AAEpC,OAAO,E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AC;IACD,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,kBAAkB;QACtB,OAAO,aAAa,EAAE,CAAC;IACzB,CAAC;IACD,KAAK,CAAC,yBAAyB;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\nimport UAParser from 'ua-parser-js';\n\nimport { DeviceType } from './Device.types';\n\ntype NavigatorWithDeviceMemory = Navigator & { deviceMemory: number };\n\nlet result: any = null;\nif (Platform.isDOMAvailable) {\n const parser = new UAParser(window.navigator.userAgent);\n result = parser.getResult();\n}\n\nfunction convertGiBtoBytes(gib: number): number {\n return Math.round(gib * 1024 ** 3);\n}\n\nfunction getDeviceType(): DeviceType {\n switch (result?.device?.type) {\n case 'mobile':\n return DeviceType.PHONE;\n case 'tablet':\n return DeviceType.TABLET;\n case 'smarttv':\n return DeviceType.TV;\n case 'console':\n case 'embedded':\n case 'wearable':\n return DeviceType.UNKNOWN;\n default:\n return DeviceType.DESKTOP;\n }\n}\n\nexport default {\n get isDevice(): boolean {\n return true;\n },\n get brand(): null {\n return null;\n },\n get manufacturer(): null {\n return (result && result.device.vendor) || null;\n },\n get modelName(): string | null {\n return (result && result.device.model) || null;\n },\n get deviceYearClass(): null {\n return null;\n },\n get deviceType(): DeviceType {\n return getDeviceType();\n },\n get totalMemory(): number | null {\n if (Platform.isDOMAvailable && 'deviceMemory' in navigator) {\n const { deviceMemory } = navigator as NavigatorWithDeviceMemory;\n return convertGiBtoBytes(deviceMemory);\n }\n return null;\n },\n get supportedCpuArchitectures(): string[] | null {\n return result && result.cpu.architecture ? [result.cpu.architecture] : null;\n },\n get osName(): string {\n return (result && result.os.name) || '';\n },\n get osVersion(): string {\n return (result && result.os.version) || '';\n },\n get osBuildId(): null {\n return null;\n },\n get osInternalBuildId(): null {\n return null;\n },\n get deviceName(): null {\n return null;\n },\n async getDeviceTypeAsync(): Promise<DeviceType> {\n return getDeviceType();\n },\n async isRootedExperimentalAsync(): Promise<boolean> {\n return false;\n },\n};\n"]}
|
package/ios/DeviceModule.swift
CHANGED
|
@@ -19,20 +19,12 @@ public class DeviceModule: Module {
|
|
|
19
19
|
"osBuildId": osBuildId(),
|
|
20
20
|
"osInternalBuildId": osBuildId(),
|
|
21
21
|
"deviceName": UIDevice.current.name,
|
|
22
|
+
"deviceType": getDeviceType(),
|
|
22
23
|
"supportedCpuArchitectures": cpuArchitectures()
|
|
23
24
|
])
|
|
24
25
|
|
|
25
26
|
AsyncFunction("getDeviceTypeAsync") { () -> Int in
|
|
26
|
-
|
|
27
|
-
case UIUserInterfaceIdiom.phone:
|
|
28
|
-
return DeviceType.phone.rawValue
|
|
29
|
-
case UIUserInterfaceIdiom.pad:
|
|
30
|
-
return DeviceType.tablet.rawValue
|
|
31
|
-
case UIUserInterfaceIdiom.tv:
|
|
32
|
-
return DeviceType.tv.rawValue
|
|
33
|
-
default:
|
|
34
|
-
return DeviceType.unknown.rawValue
|
|
35
|
-
}
|
|
27
|
+
return getDeviceType()
|
|
36
28
|
}
|
|
37
29
|
|
|
38
30
|
AsyncFunction("getUptimeAsync") { () -> Double in
|
|
@@ -47,6 +39,31 @@ public class DeviceModule: Module {
|
|
|
47
39
|
}
|
|
48
40
|
}
|
|
49
41
|
|
|
42
|
+
func getDeviceType() -> Int {
|
|
43
|
+
// if it's a macOS Catalyst app
|
|
44
|
+
if ProcessInfo.processInfo.isMacCatalystApp {
|
|
45
|
+
return DeviceType.desktop.rawValue
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// if it's built for iPad running on a Mac
|
|
49
|
+
if #available(iOS 14.0, *) {
|
|
50
|
+
if ProcessInfo.processInfo.isiOSAppOnMac {
|
|
51
|
+
return DeviceType.desktop.rawValue
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
switch UIDevice.current.userInterfaceIdiom {
|
|
56
|
+
case UIUserInterfaceIdiom.phone:
|
|
57
|
+
return DeviceType.phone.rawValue
|
|
58
|
+
case UIUserInterfaceIdiom.pad:
|
|
59
|
+
return DeviceType.tablet.rawValue
|
|
60
|
+
case UIUserInterfaceIdiom.tv:
|
|
61
|
+
return DeviceType.tv.rawValue
|
|
62
|
+
default:
|
|
63
|
+
return DeviceType.unknown.rawValue
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
50
67
|
func isDevice() -> Bool {
|
|
51
68
|
#if targetEnvironment(simulator)
|
|
52
69
|
return false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-device",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "A universal module that gets physical information about the device running the application",
|
|
5
5
|
"main": "build/Device.js",
|
|
6
6
|
"types": "build/Device.d.ts",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"expo": "*"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
|
|
45
45
|
}
|
package/src/Device.ts
CHANGED
|
@@ -82,6 +82,20 @@ export const designName: string | null = ExpoDevice ? ExpoDevice.designName || n
|
|
|
82
82
|
*/
|
|
83
83
|
export const productName: string | null = ExpoDevice ? ExpoDevice.productName || null : null;
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* The type of the device as a [`DeviceType`](#devicetype) enum value.
|
|
87
|
+
*
|
|
88
|
+
* 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.
|
|
89
|
+
* 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`.
|
|
90
|
+
* Otherwise, the method returns `DeviceType.UNKNOWN`.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```js
|
|
94
|
+
* Device.deviceType; // UNKNOWN, PHONE, TABLET, TV, DESKTOP
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export const deviceType: DeviceType | null = ExpoDevice ? ExpoDevice.deviceType : null;
|
|
98
|
+
|
|
85
99
|
/**
|
|
86
100
|
* The [device year class](https://github.com/facebook/device-year-class) of this device. On web, this value is always `null`.
|
|
87
101
|
*/
|
package/src/ExpoDevice.web.ts
CHANGED
|
@@ -15,6 +15,23 @@ function convertGiBtoBytes(gib: number): number {
|
|
|
15
15
|
return Math.round(gib * 1024 ** 3);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
function getDeviceType(): DeviceType {
|
|
19
|
+
switch (result?.device?.type) {
|
|
20
|
+
case 'mobile':
|
|
21
|
+
return DeviceType.PHONE;
|
|
22
|
+
case 'tablet':
|
|
23
|
+
return DeviceType.TABLET;
|
|
24
|
+
case 'smarttv':
|
|
25
|
+
return DeviceType.TV;
|
|
26
|
+
case 'console':
|
|
27
|
+
case 'embedded':
|
|
28
|
+
case 'wearable':
|
|
29
|
+
return DeviceType.UNKNOWN;
|
|
30
|
+
default:
|
|
31
|
+
return DeviceType.DESKTOP;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
18
35
|
export default {
|
|
19
36
|
get isDevice(): boolean {
|
|
20
37
|
return true;
|
|
@@ -31,6 +48,9 @@ export default {
|
|
|
31
48
|
get deviceYearClass(): null {
|
|
32
49
|
return null;
|
|
33
50
|
},
|
|
51
|
+
get deviceType(): DeviceType {
|
|
52
|
+
return getDeviceType();
|
|
53
|
+
},
|
|
34
54
|
get totalMemory(): number | null {
|
|
35
55
|
if (Platform.isDOMAvailable && 'deviceMemory' in navigator) {
|
|
36
56
|
const { deviceMemory } = navigator as NavigatorWithDeviceMemory;
|
|
@@ -57,20 +77,7 @@ export default {
|
|
|
57
77
|
return null;
|
|
58
78
|
},
|
|
59
79
|
async getDeviceTypeAsync(): Promise<DeviceType> {
|
|
60
|
-
|
|
61
|
-
case 'mobile':
|
|
62
|
-
return DeviceType.PHONE;
|
|
63
|
-
case 'tablet':
|
|
64
|
-
return DeviceType.TABLET;
|
|
65
|
-
case 'smarttv':
|
|
66
|
-
return DeviceType.TV;
|
|
67
|
-
case 'console':
|
|
68
|
-
case 'embedded':
|
|
69
|
-
case 'wearable':
|
|
70
|
-
return DeviceType.UNKNOWN;
|
|
71
|
-
default:
|
|
72
|
-
return DeviceType.DESKTOP;
|
|
73
|
-
}
|
|
80
|
+
return getDeviceType();
|
|
74
81
|
},
|
|
75
82
|
async isRootedExperimentalAsync(): Promise<boolean> {
|
|
76
83
|
return false;
|