Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
react-native-device-info
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
放牛的园子
react-native-device-info
Commits
40e1b51c
Commit
40e1b51c
authored
Sep 21, 2017
by
Gant Laborde
Committed by
GitHub
Sep 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #225 from douglasjunior/patch-2
Added version check and permission to work with Android API >= 16.
parents
c362de2b
dd9d1957
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
RNDeviceModule.java
...c/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
+10
-3
No files found.
android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
View file @
40e1b51c
package
com
.
learnium
.
RNDeviceInfo
;
import
android.Manifest
;
import
android.app.KeyguardManager
;
import
android.bluetooth.BluetoothAdapter
;
import
android.content.Context
;
...
...
@@ -85,7 +86,6 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
public
@Nullable
Map
<
String
,
Object
>
getConstants
()
{
HashMap
<
String
,
Object
>
constants
=
new
HashMap
<
String
,
Object
>();
TelephonyManager
telMgr
=
(
TelephonyManager
)
this
.
reactContext
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
PackageManager
packageManager
=
this
.
reactContext
.
getPackageManager
();
String
packageName
=
this
.
reactContext
.
getPackageName
();
...
...
@@ -126,11 +126,18 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants
.
put
(
"uniqueId"
,
Secure
.
getString
(
this
.
reactContext
.
getContentResolver
(),
Secure
.
ANDROID_ID
));
constants
.
put
(
"systemManufacturer"
,
Build
.
MANUFACTURER
);
constants
.
put
(
"bundleId"
,
packageName
);
constants
.
put
(
"userAgent"
,
WebSettings
.
getDefaultUserAgent
(
this
.
reactContext
));
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
constants
.
put
(
"userAgent"
,
WebSettings
.
getDefaultUserAgent
(
this
.
reactContext
));
}
constants
.
put
(
"timezone"
,
TimeZone
.
getDefault
().
getID
());
constants
.
put
(
"isEmulator"
,
this
.
isEmulator
());
constants
.
put
(
"isTablet"
,
this
.
isTablet
());
constants
.
put
(
"phoneNumber"
,
telMgr
.
getLine1Number
());
if
(
getCurrentActivity
().
checkCallingOrSelfPermission
(
Manifest
.
permission
.
READ_PHONE_STATE
)
==
PackageManager
.
PERMISSION_GRANTED
||
getCurrentActivity
().
checkCallingOrSelfPermission
(
Manifest
.
permission
.
READ_SMS
)
==
PackageManager
.
PERMISSION_GRANTED
||
getCurrentActivity
().
checkCallingOrSelfPermission
(
"android.permission.READ_PHONE_NUMBERS"
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
TelephonyManager
telMgr
=
(
TelephonyManager
)
this
.
reactContext
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
constants
.
put
(
"phoneNumber"
,
telMgr
.
getLine1Number
());
}
return
constants
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment