Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
4c4de275
Unverified
Commit
4c4de275
authored
Feb 16, 2019
by
Razvan Cristian Lung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix lint warning and add Android Pie specific implementation for getting
the locations service status
parent
33de6dd7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
+17
-7
lib/src/permission_enums.dart
+3
-3
No files found.
android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
View file @
4c4de275
...
@@ -7,11 +7,14 @@ import android.content.Context;
...
@@ -7,11 +7,14 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.location.LocationManager
;
import
android.os.Build
;
import
android.os.Build
;
import
android.provider.Settings
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.Log
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -54,6 +57,7 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
...
@@ -54,6 +57,7 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
this
.
mRegistrar
=
mRegistrar
;
this
.
mRegistrar
=
mRegistrar
;
}
}
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
@IntDef
({
PERMISSION_GROUP_CALENDAR
,
PERMISSION_GROUP_CALENDAR
,
PERMISSION_GROUP_CAMERA
,
PERMISSION_GROUP_CAMERA
,
...
@@ -82,6 +86,7 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
...
@@ -82,6 +86,7 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
private
static
final
int
PERMISSION_STATUS_RESTRICTED
=
3
;
private
static
final
int
PERMISSION_STATUS_RESTRICTED
=
3
;
private
static
final
int
PERMISSION_STATUS_UNKNOWN
=
4
;
private
static
final
int
PERMISSION_STATUS_UNKNOWN
=
4
;
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
@IntDef
({
PERMISSION_STATUS_DENIED
,
PERMISSION_STATUS_DENIED
,
PERMISSION_STATUS_DISABLED
,
PERMISSION_STATUS_DISABLED
,
...
@@ -99,6 +104,7 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
...
@@ -99,6 +104,7 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
private
static
final
int
SERVICE_STATUS_NOT_APPLICABLE
=
2
;
private
static
final
int
SERVICE_STATUS_NOT_APPLICABLE
=
2
;
private
static
final
int
SERVICE_STATUS_UNKNOWN
=
3
;
private
static
final
int
SERVICE_STATUS_UNKNOWN
=
3
;
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
@IntDef
({
SERVICE_STATUS_DISABLED
,
SERVICE_STATUS_DISABLED
,
SERVICE_STATUS_ENABLED
,
SERVICE_STATUS_ENABLED
,
...
@@ -199,8 +205,7 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
...
@@ -199,8 +205,7 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
}
}
mResult
=
result
;
mResult
=
result
;
//noinspection unchecked
final
List
<
Integer
>
permissions
=
call
.
arguments
();
final
List
<
Integer
>
permissions
=
(
List
<
Integer
>)
call
.
arguments
;
requestPermissions
(
permissions
);
requestPermissions
(
permissions
);
break
;
break
;
case
"shouldShowRequestPermissionRationale"
:
{
case
"shouldShowRequestPermissionRationale"
:
{
...
@@ -571,23 +576,28 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
...
@@ -571,23 +576,28 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
return
false
;
return
false
;
}
}
@SuppressWarnings
(
"deprecation"
)
private
boolean
isLocationServiceEnabled
(
Context
context
)
{
private
boolean
isLocationServiceEnabled
(
Context
context
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
P
)
{
final
LocationManager
locationManager
=
context
.
getSystemService
(
LocationManager
.
class
);
if
(
locationManager
==
null
)
{
return
false
;
}
return
locationManager
.
isLocationEnabled
();
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
final
int
locationMode
;
final
int
locationMode
;
final
String
locationProviders
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
try
{
try
{
locationMode
=
Settings
.
Secure
.
getInt
(
context
.
getContentResolver
(),
Settings
.
Secure
.
LOCATION_MODE
);
locationMode
=
Settings
.
Secure
.
getInt
(
context
.
getContentResolver
(),
Settings
.
Secure
.
LOCATION_MODE
);
}
catch
(
Settings
.
SettingNotFoundException
e
)
{
}
catch
(
Settings
.
SettingNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
false
;
return
false
;
}
}
return
locationMode
!=
Settings
.
Secure
.
LOCATION_MODE_OFF
;
return
locationMode
!=
Settings
.
Secure
.
LOCATION_MODE_OFF
;
}
else
{
}
else
{
locationProviders
=
Settings
.
Secure
.
getString
(
context
.
getContentResolver
(),
Settings
.
Secure
.
LOCATION_PROVIDERS_ALLOWED
);
final
String
locationProviders
=
Settings
.
Secure
.
getString
(
context
.
getContentResolver
(),
Settings
.
Secure
.
LOCATION_PROVIDERS_ALLOWED
);
return
!
TextUtils
.
isEmpty
(
locationProviders
);
return
!
TextUtils
.
isEmpty
(
locationProviders
);
}
}
}
}
...
...
lib/src/permission_enums.dart
View file @
4c4de275
...
@@ -49,7 +49,7 @@ class ServiceStatus {
...
@@ -49,7 +49,7 @@ class ServiceStatus {
static
const
ServiceStatus
disabled
=
ServiceStatus
.
_
(
0
);
static
const
ServiceStatus
disabled
=
ServiceStatus
.
_
(
0
);
/// The service for the supplied permission group is enabled.
/// The service for the supplied permission group is enabled.
static
const
ServiceStatus
enable
=
ServiceStatus
.
_
(
1
);
static
const
ServiceStatus
enable
d
=
ServiceStatus
.
_
(
1
);
/// There is no service for the supplied permission group.
/// There is no service for the supplied permission group.
static
const
ServiceStatus
notApplicable
=
ServiceStatus
.
_
(
2
);
static
const
ServiceStatus
notApplicable
=
ServiceStatus
.
_
(
2
);
...
@@ -59,14 +59,14 @@ class ServiceStatus {
...
@@ -59,14 +59,14 @@ class ServiceStatus {
static
const
List
<
ServiceStatus
>
values
=
<
ServiceStatus
>[
static
const
List
<
ServiceStatus
>
values
=
<
ServiceStatus
>[
disabled
,
disabled
,
enable
,
enable
d
,
notApplicable
,
notApplicable
,
unknown
,
unknown
,
];
];
static
const
List
<
String
>
_names
=
<
String
>[
static
const
List
<
String
>
_names
=
<
String
>[
'disabled'
,
'disabled'
,
'enable'
,
'enable
d
'
,
'notApplicable'
,
'notApplicable'
,
'unknown'
,
'unknown'
,
];
];
...
...
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