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 1.3.0 to 1.4.0

3

deviceinfo.android.d.ts

@@ -1,2 +0,2 @@

import { Carrier } from './deviceinfo.interface';
import { Carrier, StorageVolume } from './deviceinfo.interface';
export declare function staticDecorator<T>(): (constructor: T) => void;

@@ -24,2 +24,3 @@ export declare class DeviceInfo {

static externalStoragePaths(): string[];
static storageVolumeInfo(): StorageVolume[];
static isTablet(): boolean;

@@ -26,0 +27,0 @@ static is24Hour(): boolean;

@@ -107,3 +107,9 @@ "use strict";

DeviceInfo.userAgent = function () {
return android.webkit.WebSettings.getDefaultUserAgent(application_1.android.context);
try {
return android.webkit.WebSettings.getDefaultUserAgent(application_1.android.context);
}
catch (error) {
console.log(error.message);
}
return "";
};

@@ -187,4 +193,3 @@ DeviceInfo.appName = function () {

method.setAccessible(true);
var invoke = method.invoke(sm, []);
var externalPaths = invoke;
var externalPaths = method.invoke(sm, []);
for (var i = 0; i < externalPaths.length; i++) {

@@ -202,2 +207,50 @@ var path = externalPaths[i];

};
DeviceInfo.storageVolumeInfo = function () {
var storageVolumesCollection = [];
var ctx = application_1.android.context;
var sm = ctx.getSystemService(Context.STORAGE_SERVICE);
try {
var method = StorageManager.class.getMethod("getVolumeList", []);
var storageVolumes = method.invoke(sm, []);
if (storageVolumes == null || storageVolumes.length <= 0) {
return [];
}
for (var i = 0; i < storageVolumes.length; i++) {
try {
var getStateMethod = storageVolumes[i].getClass().getMethod("getState", []);
var mountState = getStateMethod.invoke(storageVolumes[i], []);
if (android.os.Environment.MEDIA_MOUNTED === mountState) {
var sv = {};
var method_1 = storageVolumes[i].getClass().getMethod("getPath", []);
sv.path = method_1.invoke(storageVolumes[i], []);
method_1 = storageVolumes[i].getClass().getMethod("getDescription", [Context.class]);
sv.description = method_1.invoke(storageVolumes[i], [ctx]);
method_1 = storageVolumes[i].getClass().getMethod("isRemovable", []);
sv.isRemovableStorage = method_1.invoke(storageVolumes[i], []).booleanValue();
method_1 = storageVolumes[i].getClass().getMethod("allowMassStorage", []);
sv.isAllowMassStorage = (method_1.invoke(storageVolumes[i], []));
method_1 = storageVolumes[i].getClass().getMethod("isEmulated", []);
sv.isEmulated = method_1.invoke(storageVolumes[i], []).booleanValue();
method_1 = storageVolumes[i].getClass().getMethod("isPrimary", []);
sv.isPrimary = method_1.invoke(storageVolumes[i], []).booleanValue();
var file = new java.io.File(sv.path);
method_1 = StorageManager.class.getMethod("getStorageLowBytes", [java.io.File.class]);
sv.lowBytesLimit = method_1.invoke(sm, [file]).longValue();
method_1 = StorageManager.class.getMethod("getStorageFullBytes", [java.io.File.class]);
sv.fullBytesLimit = method_1.invoke(sm, [file]).longValue();
sv.totalSize = DeviceInfo_1.totalSpace(file);
sv.availableSize = DeviceInfo_1.freeSpace(file);
storageVolumesCollection.push(sv);
}
}
catch (error) {
console.log(error.message);
}
}
}
catch (error) {
console.log(error.message);
}
return storageVolumesCollection;
};
DeviceInfo.isTablet = function () {

@@ -363,4 +416,4 @@ var Configuration = android.content.res.Configuration;

method.setAccessible(true);
var mountStatus = method.invoke(storageManager, [mountPoint]);
return android.os.Environment.MEDIA_MOUNTED === mountStatus;
var mountState = method.invoke(storageManager, [mountPoint]);
return android.os.Environment.MEDIA_MOUNTED === mountState;
}

@@ -367,0 +420,0 @@ catch (error) {

@@ -14,2 +14,14 @@ import { RadioAccessTechnology, WCTGeneration } from "./index.d";

}
export interface StorageVolume {
path: string;
totalSize: number;
availableSize: number;
lowBytesLimit: number;
fullBytesLimit: number;
description: string;
isRemovableStorage: boolean;
isAllowMassStorage: boolean;
isEmulated: boolean;
isPrimary: boolean;
}
export interface DeviceInfoInterface {

@@ -34,2 +46,3 @@ totalMemory(): number;

externalStoragePaths(): string[];
storageVolumeInfo(): StorageVolume[];
isTablet(): boolean;

@@ -36,0 +49,0 @@ is24Hour(): boolean;

@@ -1,2 +0,2 @@

import { Carrier } from './deviceinfo.interface';
import { Carrier, StorageVolume } from './deviceinfo.interface';
export declare function staticDecorator<T>(): (constructor: T) => void;

@@ -26,2 +26,3 @@ export declare class DeviceInfo {

static externalStoragePaths(): string[];
static storageVolumeInfo(): StorageVolume[];
static isTablet(): boolean;

@@ -28,0 +29,0 @@ static is24Hour(): boolean;

@@ -161,2 +161,5 @@ "use strict";

};
DeviceInfo.storageVolumeInfo = function () {
return [];
};
DeviceInfo.isTablet = function () {

@@ -163,0 +166,0 @@ return UIDevice.currentDevice.userInterfaceIdiom === 1;

@@ -1,30 +0,30 @@

import { Carrier } from './deviceinfo.interface';
import { Carrier, StorageVolume } from './deviceinfo.interface';
export const enum RadioAccessTechnology {
UNKNOWN,
CDMA,
CDMAEVDORev0,
CDMAEVDORevA,
CDMAEVDORevB,
EDGE,
EHRPD,
GPRS,
HSPA,
HSDPA,
HSPAP,
HSUPA,
NR,
IDEN,
IWLAN,
UMTS,
LTE,
WCDMA,
UNKNOWN,
CDMA,
CDMAEVDORev0,
CDMAEVDORevA,
CDMAEVDORevB,
EDGE,
EHRPD,
GPRS,
HSPA,
HSDPA,
HSPAP,
HSUPA,
NR,
IDEN,
IWLAN,
UMTS,
LTE,
WCDMA,
}
export const enum WCTGeneration {
_UNKNOWN = "UnKnown",
_2G = "2G",
_3G = "3G",
_4G = "4G",
_5G = "5G"
_UNKNOWN = "UnKnown",
_2G = "2G",
_3G = "3G",
_4G = "4G",
_5G = "5G"
}

@@ -34,24 +34,25 @@

export declare class DeviceInfo {
static totalMemory(): number;
static freeMemory(): number;
static totalStorageSpace(): number;
static freeStorageSpace(): number;
static deviceId(): string;
static deviceName(): string;
static deviceLocale(): string;
static deviceCountry(): string;
static timezone(): string;
static userAgent(): string;
static appName(): string;
static appVersion(): string;
static bundleId(): string;
static bundleNumber(): string;
static systemManufacturer(): string;
static batteryLevel(): number;
static cellularServiceProvider(): Carrier[];
static externalStoragePaths(): string[];
static isTablet(): boolean;
static is24Hour(): boolean;
static isEmulator(): boolean;
static isBatteryCharging(): boolean;
static totalMemory(): number;
static freeMemory(): number;
static totalStorageSpace(): number;
static freeStorageSpace(): number;
static deviceId(): string;
static deviceName(): string;
static deviceLocale(): string;
static deviceCountry(): string;
static timezone(): string;
static userAgent(): string;
static appName(): string;
static appVersion(): string;
static bundleId(): string;
static bundleNumber(): string;
static systemManufacturer(): string;
static batteryLevel(): number;
static cellularServiceProvider(): Carrier[];
static externalStoragePaths(): string[];
static storageVolumeInfo(): StorageVolume[];
static isTablet(): boolean;
static is24Hour(): boolean;
static isEmulator(): boolean;
static isBatteryCharging(): boolean;
}
{
"name": "nativescript-dna-deviceinfo",
"version": "1.3.0",
"version": "1.4.0",
"description": "NativeScript plugin to acquire device information.",

@@ -5,0 +5,0 @@ "main": "deviceinfo",

@@ -23,3 +23,5 @@

- 1.3.0: Added externalStoragePaths API. Fixed crashes and compatibility issues with the Android platform.
- 1.4.0: Added storageVolumeInfo API.
## Installation

@@ -100,4 +102,4 @@

- Notes for Android users:
* Permission BLUETOOTH is needed.
- Note for Android users:
* Permission BLUETOOTH is needed.

@@ -218,11 +220,28 @@ ### - deviceLocale

Returns a list of GSM network providers, carriers, of a device is equipped with.
Returns a list of GSM network providers, *Carrier*, of a device is equipped with.
```javascript
DeviceInfo.cellularServiceProvider();
let carriers = DeviceInfo.cellularServiceProvider();
console.log(carriers);
```
Below is the **Carrier** interface:
```javascript
interface Carrier {
carrierName: string;
displayName: string;
country: string;
mobileCountryCode: string;
isoCountryCode: string;
countryCode: string;
mobileNetworkCode: string;
generation: WCTGeneration; // Wireless Cellular Technology
networkType: RadioAccessTechnology;
}
```
Besides other helpful information returned from the API, it can be used to know whether the device has a fast internet connection or not.
- Notes for Android users:
- Note for Android users:
* If the **targetSdkVersion is 17**, a device with dual sim, the API returns an "active" carrier. Permission ACCESS_COARSE_LOCATION is needed.

@@ -239,3 +258,29 @@ * If the **targetSdkVersion is >= 22**, a device with dual sim, the API returns both the carriers. Permission READ_PHONE_STATE is needed. To know more about the request permissions process, please visit the link [Request App Permissions](https://developer.android.com/training/permissions/requesting).

### - storageVolumeInfo
Returns a list of *StorageVolume*. An empty list means that no mountable volumes found.
```javascript
let storageVolumes = DeviceInfo.storageVolumeInfo();
console.log(storageVolumes);
```
Below is **StorageVolume** interface:
```javascript
interface StorageVolume {
path: string;
totalSize: number;
availableSize: number;
lowBytesLimit: number;
fullBytesLimit: number;
description: string;
isRemovableStorage: boolean;
isAllowMassStorage: boolean;
isEmulated: boolean;
isPrimary: boolean;
}
```
## APIs in Action

@@ -242,0 +287,0 @@

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