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
33bc60d1
Unverified
Commit
33bc60d1
authored
Jun 03, 2019
by
Sebastian Roth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document & improve the battery optimization code on Android
parent
9a53ea98
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
+4
-3
No files found.
android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
View file @
33bc60d1
...
@@ -271,10 +271,12 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
...
@@ -271,10 +271,12 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
final
boolean
targetsMOrHigher
=
context
.
getApplicationInfo
().
targetSdkVersion
>=
VERSION_CODES
.
M
;
final
boolean
targetsMOrHigher
=
context
.
getApplicationInfo
().
targetSdkVersion
>=
VERSION_CODES
.
M
;
for
(
String
name
:
names
)
{
for
(
String
name
:
names
)
{
// Only handle them if the client app actually targets a API level greater than M.
if
(
targetsMOrHigher
)
{
if
(
targetsMOrHigher
)
{
if
(
permission
==
PERMISSION_GROUP_IGNORE_BATTERY_OPTIMIZATIONS
)
{
if
(
permission
==
PERMISSION_GROUP_IGNORE_BATTERY_OPTIMIZATIONS
)
{
String
packageName
=
context
.
getPackageName
();
String
packageName
=
context
.
getPackageName
();
PowerManager
pm
=
(
PowerManager
)
context
.
getSystemService
(
Context
.
POWER_SERVICE
);
PowerManager
pm
=
(
PowerManager
)
context
.
getSystemService
(
Context
.
POWER_SERVICE
);
// PowerManager.isIgnoringBatteryOptimizations has been included in Android M first.
if
(
VERSION
.
SDK_INT
>=
VERSION_CODES
.
M
)
{
if
(
VERSION
.
SDK_INT
>=
VERSION_CODES
.
M
)
{
if
(
pm
.
isIgnoringBatteryOptimizations
(
packageName
))
{
if
(
pm
.
isIgnoringBatteryOptimizations
(
packageName
))
{
return
PERMISSION_STATUS_GRANTED
;
return
PERMISSION_STATUS_GRANTED
;
...
@@ -622,9 +624,8 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
...
@@ -622,9 +624,8 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
break
;
break
;
case
PERMISSION_GROUP_IGNORE_BATTERY_OPTIMIZATIONS:
case
PERMISSION_GROUP_IGNORE_BATTERY_OPTIMIZATIONS:
if
(
hasPermissionInManifest
(
Manifest
.
permission
.
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
))
if
(
VERSION
.
SDK_INT
>=
VERSION_CODES
.
M
&&
hasPermissionInManifest
(
Manifest
.
permission
.
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
))
if
(
VERSION
.
SDK_INT
>=
VERSION_CODES
.
M
)
permissionNames
.
add
(
Manifest
.
permission
.
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
);
permissionNames
.
add
(
Manifest
.
permission
.
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
);
break
;
break
;
case
PERMISSION_GROUP_MEDIA_LIBRARY:
case
PERMISSION_GROUP_MEDIA_LIBRARY:
...
...
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