Skip to content

Commit

Permalink
feat(android): getInfo response to include sdkVersion (#157)
Browse files Browse the repository at this point in the history
* feat(android): getInfo response to include sdkVersion
* feat(android): sdk version appears on device object
* doc(android): add device.sdkVersion info
* doc(android): remove word installed

Co-authored-by: Norman Breau <[email protected]>
  • Loading branch information
erisu and breautek authored Apr 1, 2022
1 parent 45a1316 commit d217d6a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function onDeviceReady() {
- device.manufacturer
- device.isVirtual
- device.serial
- device.sdkVersion (Android only)

## device.cordova

Expand Down Expand Up @@ -251,6 +252,10 @@ whether the device is running on a simulator.
var isSim = device.isVirtual;
```

## device.sdkVersion (Android only)

Will return the Android device's SDK version.

### Supported Platforms

- Android
Expand Down
5 changes: 2 additions & 3 deletions src/android/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
r.put("manufacturer", this.getManufacturer());
r.put("isVirtual", this.isVirtual());
r.put("serial", this.getSerialNumber());
r.put("sdkVersion", this.getSDKVersion());
callbackContext.success(r);
}
else {
Expand Down Expand Up @@ -144,9 +145,7 @@ public String getOSVersion() {
}

public String getSDKVersion() {
@SuppressWarnings("deprecation")
String sdkversion = android.os.Build.VERSION.SDK;
return sdkversion;
return String.valueOf(android.os.Build.VERSION.SDK_INT);
}

public String getTimeZoneID() {
Expand Down
6 changes: 6 additions & 0 deletions www/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ function Device () {
me.isVirtual = info.isVirtual;
me.manufacturer = info.manufacturer || 'unknown';
me.serial = info.serial || 'unknown';

// SDK Version is Android specific. If defined, it will be appended.
if (info.sdkVersion !== undefined) {
me.sdkVersion = info.sdkVersion;
}

channel.onCordovaInfoReady.fire();
},
function (e) {
Expand Down

0 comments on commit d217d6a

Please sign in to comment.