Skip to content

Commit 06687e4

Browse files
committed
refactor(device): remove unneeded code
1 parent f6c8ac2 commit 06687e4

3 files changed

Lines changed: 20 additions & 40 deletions

File tree

device/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,26 +124,26 @@ Get the device's current language locale tag.
124124

125125
#### DeviceId
126126

127-
| Prop | Type | Description | Since |
128-
| ---------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
129-
| **`identifier`** | <code>string</code> | The identifier of the device as available to the app. This identifier may change on modern mobile platforms that only allow per-app install ids. On iOS, the identifier is a UUID that uniquely identifies a device to the app’s vendor ([read more](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)). on Android 8+, __the identifier is a 64-bit number (expressed as a hexadecimal string)__, unique to each combination of app-signing key, user, and device ([read more](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID)). On web, a random identifier is generated and stored on localStorage for subsequent calls. If localStorage is not available a new random identifier will be generated on every call. | 1.0.0 |
127+
| Prop | Type | Description | Since |
128+
| ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
129+
| **`identifier`** | <code>string</code> | The identifier of the device as available to the app. This identifier may change on modern mobile platforms that only allow per-app install ids. On iOS, the identifier is a UUID that uniquely identifies a device to the app’s vendor ([read more](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)). on Android, __the identifier is a 64-bit number (expressed as a hexadecimal string)__, unique to each combination of app-signing key, user, and device ([read more](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID)). On web, a random identifier is generated and stored on localStorage for subsequent calls. If localStorage is not available a new random identifier will be generated on every call. | 1.0.0 |
130130

131131

132132
#### DeviceInfo
133133

134-
| Prop | Type | Description | Since |
135-
| ----------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
136-
| **`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. On iOS 16+ this will return a generic device name without the appropriate [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_device-information_user-assigned-device-name). | 1.0.0 |
137-
| **`model`** | <code>string</code> | The device model. For example, "iPhone13,4". | 1.0.0 |
138-
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | The device platform (lowercase). | 1.0.0 |
139-
| **`operatingSystem`** | <code><a href="#operatingsystem">OperatingSystem</a></code> | The operating system of the device. | 1.0.0 |
140-
| **`osVersion`** | <code>string</code> | The version of the device OS. | 1.0.0 |
141-
| **`iOSVersion`** | <code>number</code> | The iOS version number. Only available on iOS. Multi-part version numbers are crushed down into an integer padded to two-digits, ex: `"16.3.1"` -&gt; `160301` | 5.0.0 |
142-
| **`androidSDKVersion`** | <code>number</code> | The Android SDK version number. Only available on Android. | 5.0.0 |
143-
| **`manufacturer`** | <code>string</code> | The manufacturer of the device. | 1.0.0 |
144-
| **`isVirtual`** | <code>boolean</code> | Whether the app is running in a simulator/emulator. | 1.0.0 |
145-
| **`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 |
146-
| **`webViewVersion`** | <code>string</code> | The web view browser version | 1.0.0 |
134+
| Prop | Type | Description | Since |
135+
| ----------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
136+
| **`name`** | <code>string</code> | The name of the device. For example, "John's iPhone". This is only supported on iOS and Android. On iOS 16+ this will return a generic device name without the appropriate [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_device-information_user-assigned-device-name). | 1.0.0 |
137+
| **`model`** | <code>string</code> | The device model. For example, "iPhone13,4". | 1.0.0 |
138+
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | The device platform (lowercase). | 1.0.0 |
139+
| **`operatingSystem`** | <code><a href="#operatingsystem">OperatingSystem</a></code> | The operating system of the device. | 1.0.0 |
140+
| **`osVersion`** | <code>string</code> | The version of the device OS. | 1.0.0 |
141+
| **`iOSVersion`** | <code>number</code> | The iOS version number. Only available on iOS. Multi-part version numbers are crushed down into an integer padded to two-digits, ex: `"16.3.1"` -&gt; `160301` | 5.0.0 |
142+
| **`androidSDKVersion`** | <code>number</code> | The Android SDK version number. Only available on Android. | 5.0.0 |
143+
| **`manufacturer`** | <code>string</code> | The manufacturer of the device. | 1.0.0 |
144+
| **`isVirtual`** | <code>boolean</code> | Whether the app is running in a simulator/emulator. | 1.0.0 |
145+
| **`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 |
146+
| **`webViewVersion`** | <code>string</code> | The web view browser version | 1.0.0 |
147147

148148

149149
#### BatteryInfo

device/android/src/main/java/com/capacitorjs/plugins/device/Device.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import android.content.Intent;
55
import android.content.IntentFilter;
66
import android.content.pm.PackageInfo;
7-
import android.content.pm.PackageManager;
87
import android.os.BatteryManager;
98
import android.os.Build;
109
import android.provider.Settings;
@@ -63,33 +62,14 @@ public boolean isVirtual() {
6362
}
6463

6564
public String getName() {
66-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
67-
return Settings.Global.getString(this.context.getContentResolver(), Settings.Global.DEVICE_NAME);
68-
}
69-
70-
return null;
65+
return Settings.Global.getString(this.context.getContentResolver(), Settings.Global.DEVICE_NAME);
7166
}
7267

7368
public String getWebViewVersion() {
74-
PackageInfo info = null;
75-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
76-
info = WebView.getCurrentWebViewPackage();
77-
} else {
78-
try {
79-
info = getWebViewVersionSubAndroid26();
80-
} catch (PackageManager.NameNotFoundException e) {
81-
e.printStackTrace();
82-
}
83-
}
69+
PackageInfo info = WebView.getCurrentWebViewPackage();;
8470
if (info != null) {
8571
return info.versionName;
8672
}
87-
8873
return Build.VERSION.RELEASE;
8974
}
90-
91-
private PackageInfo getWebViewVersionSubAndroid26() throws PackageManager.NameNotFoundException {
92-
PackageManager pm = this.context.getPackageManager();
93-
return pm.getPackageInfo("com.android.chrome", 0);
94-
}
9575
}

device/src/definitions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface DeviceId {
77
*
88
* On iOS, the identifier is a UUID that uniquely identifies a device to the app’s vendor ([read more](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)).
99
*
10-
* on Android 8+, __the identifier is a 64-bit number (expressed as a hexadecimal string)__, unique to each combination of app-signing key, user, and device ([read more](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID)).
10+
* on Android, __the identifier is a 64-bit number (expressed as a hexadecimal string)__, unique to each combination of app-signing key, user, and device ([read more](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID)).
1111
*
1212
* On web, a random identifier is generated and stored on localStorage for subsequent calls.
1313
* If localStorage is not available a new random identifier will be generated on every call.
@@ -21,7 +21,7 @@ export interface DeviceInfo {
2121
/**
2222
* The name of the device. For example, "John's iPhone".
2323
*
24-
* This is only supported on iOS and Android 7.1 or above.
24+
* This is only supported on iOS and Android.
2525
*
2626
* On iOS 16+ this will return a generic device name without the appropriate [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_device-information_user-assigned-device-name).
2727
*

0 commit comments

Comments
 (0)