Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-dna-deviceinfo

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-dna-deviceinfo - npm Package Compare versions

Comparing version 3.6.1 to 3.7.0

4

deviceinfo.android.d.ts

@@ -32,2 +32,4 @@ import { Address, Carrier, DisplayMetrics, StorageVolume } from './deviceinfo.interface';

static setAudioVolumeLevel(audioVol: number): void;
static screenBrightnessLevel(): number;
static setScreenBrightnessLevel(level: number): void;
static isBluetoothHeadsetConnected(): boolean;

@@ -58,2 +60,4 @@ static isMicAvailable(): boolean;

private static bluetoothAdapter;
private static checkSystemWritePermission;
private static openAndroidPermissionsMenu;
}

@@ -337,2 +337,29 @@ var DeviceInfo_1;

}
static screenBrightnessLevel() {
const ctx = application.android.context;
const cResolver = ctx.getContentResolver();
try {
const System = android.provider.Settings.System;
System.putInt(cResolver, System.SCREEN_BRIGHTNESS_MODE, System.SCREEN_BRIGHTNESS_MODE_MANUAL);
const brightness = System.getInt(cResolver, System.SCREEN_BRIGHTNESS);
return brightness / 255.0;
}
catch (error) {
console.log(error.message);
}
return -1;
}
static setScreenBrightnessLevel(level) {
if (!DeviceInfo_1.checkSystemWritePermission()) {
DeviceInfo_1.openAndroidPermissionsMenu();
}
if (!DeviceInfo_1.checkSystemWritePermission()) {
console.error("Missing System Write Settings Permmissions");
}
const brightness = Math.round(level * 255);
const ctx = application.android.context;
const cResolver = ctx.getContentResolver();
const System = android.provider.Settings.System;
System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness);
}
static isBluetoothHeadsetConnected() {

@@ -624,2 +651,25 @@ const BluetoothProfile = android.bluetooth.BluetoothProfile;

}
static checkSystemWritePermission() {
const System = android.provider.Settings.System;
const Build = android.os.Build;
if (Build.VERSION.SDK_INT >= 23) {
const ctx = application.android.context;
if (System.canWrite(ctx)) {
return true;
}
}
else {
}
return false;
}
static openAndroidPermissionsMenu() {
const ctx = application.android.context;
const Settings = android.provider.Settings;
const Build = android.os.Build;
if (Build.VERSION.SDK_INT >= 23) {
const intent = new android.content.Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(android.net.Uri.parse("package:" + ctx.getPackageName()));
ctx.startActivity(intent);
}
}
};

@@ -626,0 +676,0 @@ DeviceInfo = DeviceInfo_1 = __decorate([

@@ -94,2 +94,4 @@ export declare const enum RadioAccessTechnology {

setAudioVolumeLevel(audioVol: number): void;
screenBrightnessLevel(): number;
setScreenBrightnessLevel(level: number): void;
isBluetoothHeadsetConnected(): boolean;

@@ -96,0 +98,0 @@ isMicAvailable(): boolean;

@@ -34,2 +34,4 @@ import { Address, Carrier, DisplayMetrics, StorageVolume } from './deviceinfo.interface';

static setAudioVolumeLevel(audioVol: number): void;
static screenBrightnessLevel(): number;
static setScreenBrightnessLevel(level: number): void;
static isBluetoothHeadsetConnected(): boolean;

@@ -36,0 +38,0 @@ static isMicAvailable(): boolean;

@@ -253,2 +253,8 @@ var DeviceInfo_1;

}
static screenBrightnessLevel() {
return UIScreen.mainScreen.brightness;
}
static setScreenBrightnessLevel(level) {
UIScreen.mainScreen.brightness = level;
}
static isBluetoothHeadsetConnected() {

@@ -510,2 +516,14 @@ const availableInputs = AVAudioSession.sharedInstance().currentRoute;

"iPad11,4": "iPad Air (3rd generation)",
"iPad11,6": "iPad 8th Gen (WiFi)",
"iPad11,7": "iPad 8th Gen (WiFi+Cellular)",
"iPad13,1": "iPad air 4th Gen (WiFi)",
"iPad13,2": "iPad air 4th Gen (WiFi+Cellular)",
"iPad13,4": "iPad Pro 11 inch 3rd Gen",
"iPad13,5": "iPad Pro 11 inch 3rd Gen",
"iPad13,6": "iPad Pro 11 inch 3rd Gen",
"iPad13,7": "iPad Pro 11 inch 3rd Gen",
"iPad13,8": "iPad Pro 12.9 inch 5th Gen",
"iPad13,9": "iPad Pro 12.9 inch 5th Gen",
"iPad13,10": "iPad Pro 12.9 inch 5th Gen",
"iPad13,11": "iPad Pro 12.9 inch 5th Gen",
"AppleTV2,1": "Apple TV",

@@ -512,0 +530,0 @@ "AppleTV3,1": "Apple TV",

4

index.d.ts

@@ -33,3 +33,5 @@ import { Carrier, StorageVolume, DisplayMetrics, RadioAccessTechnology, WCTGeneration } from './deviceinfo.interface';

static audioVolumeLevel(): number;
static setAudioVolumeLevel(audioVol: number);
static setAudioVolumeLevel(level: number);
static screenBrightnessLevel(): number;
static setScreenBrightnessLevel(level: number);
static isBluetoothHeadsetConnected(): boolean;

@@ -36,0 +38,0 @@ static isMicAvailable(): boolean;

{
"name": "nativescript-dna-deviceinfo",
"version": "3.6.1",
"version": "3.7.0",
"description": "NativeScript plugin to acquire device information.",

@@ -9,4 +9,4 @@ "main": "deviceinfo",

"platforms": {
"android": "7.0.0",
"ios": "7.0.0"
"android": "8.0.0",
"ios": "8.0.0"
}

@@ -96,16 +96,16 @@ },

"devDependencies": {
"@nativescript/android": "~7.0.1",
"@nativescript/ios": "~7.2.0",
"@nativescript/core": "~7.3.0",
"@nativescript/types": "~7.2.0",
"@nativescript/android": "~8.0.0",
"@nativescript/ios": "~8.0.0",
"@nativescript/core": "~8.0.3",
"@nativescript/types": "~8.0.1",
"@nativescript/webpack": "~3.0.0",
"prompt": "^1.1.0",
"rimraf": "^3.0.2",
"semver": "^7.3.4",
"semver": "^7.3.5",
"ts-node": "^9.1.1",
"ts-patch": "^1.3.2",
"tslint": "^5.20.1",
"typescript": "~4.1.5"
"ts-patch": "^1.3.3",
"tslint": "^6.1.3",
"typescript": "~4.2.4"
},
"bootstrapper": "nativescript-plugin-seed"
}

@@ -76,2 +76,4 @@

| [setAudioVolumeLevel](#setAudioVolumeLevel) | void | + | + |
| [screenBrightnessLevel](#screenBrightnessLevel) | number | + | + |
| [setScreenBrightnessLevel](#setScreenBrightnessLevel) | void | + | + |
| [isBluetoothHeadsetConnected](#isBluetoothHeadsetConnected) | boolean | + | + |

@@ -383,3 +385,3 @@ | [isMicAvailable](#isMicAvailable) | boolean | + | + |

Returns the audio volume level as a scalar from 0 to 100.
Returns the audio volume level as a scalar value from 0 to 100.

@@ -392,3 +394,3 @@ ```javascript

Sets the audio volume level. The level should be a scalar value between 0 and 100.
Sets the audio volume level. The level should be a scalar value from 0 and 100.

@@ -399,2 +401,23 @@ ```javascript

### screenBrightnessLevel
Returns the screen brightness level as a scalar value from 0 to 10.
```javascript
DeviceInfo.screenBrightnessLevel();
```
- Notes for Android users:
* Make sure that the permissions *android.permission.WRITE_SETTINGS* is in place in AndroidManifest.xml and in code too
### setScreenBrightnessLevel
Sets the screen brightness level. The level should be a scalar value from 0 and 10.
```javascript
DeviceInfo.setScreenBrightnessLevel(0.8);
```
- Notes for Android users:
* Make sure that the permissions *android.permission.WRITE_SETTINGS* is in place in AndroidManifest.xml and in code too
### isBluetoothHeadsetConnected

@@ -550,2 +573,3 @@

## Changelogs:
- 3.7.0: Bumped up various packages version. Added APIs to set and get screen brightness level. Updated Apple mobile device types with iPad Pro 11 inch and 12.9 inch.
- 3.6.1: Switch to webpack 3.0.0 version due to some security warnings.

@@ -552,0 +576,0 @@ - 3.6.0: Introducing basic audio management APIs for Android and iOS. For Andriod, memory-related APIs are updated to use non-depreciated system APIs.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc