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
46a14456
Unverified
Commit
46a14456
authored
Oct 05, 2021
by
PieterAelse
Committed by
GitHub
Oct 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for the 3 new Bluetooth permissions of Android 12. (#671)
Co-authored-by: Pieter Otten <pieter.otten@signify.com>
parent
be4ae86c
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
101 additions
and
21 deletions
+101
-21
permission_handler/CHANGELOG.md
+7
-0
permission_handler/android/build.gradle
+4
-4
permission_handler/android/gradle.properties
+1
-0
permission_handler/android/gradle/wrapper/gradle-wrapper.properties
+5
-0
permission_handler/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java
+8
-1
permission_handler/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java
+24
-0
permission_handler/example/android/app/build.gradle
+3
-4
permission_handler/example/android/app/src/debug/AndroidManifest.xml
+1
-1
permission_handler/example/android/app/src/main/AndroidManifest.xml
+8
-2
permission_handler/example/android/build.gradle
+1
-1
permission_handler/example/android/gradle.properties
+0
-1
permission_handler/example/android/gradle/wrapper/gradle-wrapper.properties
+1
-1
permission_handler/example/lib/main.dart
+6
-2
permission_handler/ios/Classes/PermissionHandlerEnums.h
+3
-0
permission_handler/pubspec.yaml
+3
-2
permission_handler_platform_interface/CHANGELOG.md
+4
-0
permission_handler_platform_interface/lib/src/permissions.dart
+20
-0
permission_handler_platform_interface/pubspec.yaml
+1
-1
permission_handler_platform_interface/test/src/permissions_test.dart
+1
-1
No files found.
permission_handler/CHANGELOG.md
View file @
46a14456
## 8.2.0
*
Added support for the new Android 12 Bluetooth permissions: BLUETOOTH_SCAN, BLUETOOTH_ADVERTISE and BLUETOOTH_CONNECT.
*
Updated Android compile and target SDK to 31 (Android 12 (S)).
*
Updated Gradle and dependencies of Android project.
*
Updated applicationID of example app
## 8.1.6
*
Android: Fixed a
`NullPointerException`
when changing permissions in the Location Settings intent.
...
...
permission_handler/android/build.gradle
View file @
46a14456
...
...
@@ -10,7 +10,7 @@ buildscript {
}
dependencies
{
classpath
'com.android.tools.build:gradle:
3.5.0
'
classpath
'com.android.tools.build:gradle:
4.0.2
'
}
}
...
...
@@ -28,7 +28,7 @@ project.getTasks().withType(JavaCompile){
apply
plugin:
'com.android.library'
android
{
compileSdkVersion
3
0
compileSdkVersion
3
1
defaultConfig
{
minSdkVersion
16
...
...
@@ -44,8 +44,8 @@ android {
}
dependencies
{
implementation
'androidx.annotation:annotation:1.
1
.0'
implementation
'androidx.core:core:1.
1
.0'
implementation
'androidx.annotation:annotation:1.
2
.0'
implementation
'androidx.core:core:1.
6
.0'
}
repositories
{
...
...
permission_handler/android/gradle.properties
View file @
46a14456
org.gradle.jvmargs
=
-Xmx1536M
android.useAndroidX
=
true
permission_handler/android/gradle/wrapper/gradle-wrapper.properties
0 → 100644
View file @
46a14456
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-6.8-bin.zip
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
permission_handler/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java
View file @
46a14456
...
...
@@ -43,6 +43,10 @@ final class PermissionConstants {
static
final
int
PERMISSION_GROUP_APP_TRACK_TRANSPARENCY
=
25
;
static
final
int
PERMISSION_GROUP_CRITICAL_ALERTS
=
26
;
static
final
int
PERMISSION_GROUP_ACCESS_NOTIFICATION_POLICY
=
27
;
static
final
int
PERMISSION_GROUP_BLUETOOTH_SCAN
=
28
;
static
final
int
PERMISSION_GROUP_BLUETOOTH_ADVERTISE
=
29
;
static
final
int
PERMISSION_GROUP_BLUETOOTH_CONNECT
=
30
;
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
...
...
@@ -70,7 +74,10 @@ final class PermissionConstants {
PERMISSION_GROUP_MANAGE_EXTERNAL_STORAGE
,
PERMISSION_GROUP_SYSTEM_ALERT_WINDOW
,
PERMISSION_GROUP_REQUEST_INSTALL_PACKAGES
,
PERMISSION_GROUP_ACCESS_NOTIFICATION_POLICY
PERMISSION_GROUP_ACCESS_NOTIFICATION_POLICY
,
PERMISSION_GROUP_BLUETOOTH_SCAN
,
PERMISSION_GROUP_BLUETOOTH_ADVERTISE
,
PERMISSION_GROUP_BLUETOOTH_CONNECT
})
@interface
PermissionGroup
{
}
...
...
permission_handler/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java
View file @
46a14456
...
...
@@ -69,6 +69,12 @@ public class PermissionUtils {
return
PermissionConstants
.
PERMISSION_GROUP_REQUEST_INSTALL_PACKAGES
;
case
Manifest
.
permission
.
ACCESS_NOTIFICATION_POLICY
:
return
PermissionConstants
.
PERMISSION_GROUP_ACCESS_NOTIFICATION_POLICY
;
case
Manifest
.
permission
.
BLUETOOTH_SCAN
:
return
PermissionConstants
.
PERMISSION_GROUP_BLUETOOTH_SCAN
;
case
Manifest
.
permission
.
BLUETOOTH_ADVERTISE
:
return
PermissionConstants
.
PERMISSION_GROUP_BLUETOOTH_ADVERTISE
;
case
Manifest
.
permission
.
BLUETOOTH_CONNECT
:
return
PermissionConstants
.
PERMISSION_GROUP_BLUETOOTH_CONNECT
;
default
:
return
PermissionConstants
.
PERMISSION_GROUP_UNKNOWN
;
}
...
...
@@ -247,6 +253,24 @@ public class PermissionUtils {
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
&&
hasPermissionInManifest
(
context
,
permissionNames
,
Manifest
.
permission
.
ACCESS_NOTIFICATION_POLICY
))
permissionNames
.
add
(
Manifest
.
permission
.
ACCESS_NOTIFICATION_POLICY
);
break
;
case
PermissionConstants
.
PERMISSION_GROUP_BLUETOOTH_SCAN
:
// The BLUETOOTH_SCAN permission is introduced in Android S, meaning we should
// not handle permissions on pre Android S devices.
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
&&
hasPermissionInManifest
(
context
,
permissionNames
,
Manifest
.
permission
.
BLUETOOTH_SCAN
))
permissionNames
.
add
(
Manifest
.
permission
.
BLUETOOTH_SCAN
);
break
;
case
PermissionConstants
.
PERMISSION_GROUP_BLUETOOTH_ADVERTISE
:
// The BLUETOOTH_ADVERTISE permission is introduced in Android S, meaning we should
// not handle permissions on pre Android S devices.
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
&&
hasPermissionInManifest
(
context
,
permissionNames
,
Manifest
.
permission
.
BLUETOOTH_ADVERTISE
))
permissionNames
.
add
(
Manifest
.
permission
.
BLUETOOTH_ADVERTISE
);
break
;
case
PermissionConstants
.
PERMISSION_GROUP_BLUETOOTH_CONNECT
:
// The BLUETOOTH_CONNECT permission is introduced in Android S, meaning we should
// not handle permissions on pre Android S devices.
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
S
&&
hasPermissionInManifest
(
context
,
permissionNames
,
Manifest
.
permission
.
BLUETOOTH_CONNECT
))
permissionNames
.
add
(
Manifest
.
permission
.
BLUETOOTH_CONNECT
);
break
;
case
PermissionConstants
.
PERMISSION_GROUP_NOTIFICATION
:
case
PermissionConstants
.
PERMISSION_GROUP_MEDIA_LIBRARY
:
case
PermissionConstants
.
PERMISSION_GROUP_PHOTOS
:
...
...
permission_handler/example/android/app/build.gradle
View file @
46a14456
...
...
@@ -25,17 +25,16 @@ apply plugin: 'com.android.application'
apply
from:
"$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android
{
compileSdkVersion
3
0
compileSdkVersion
3
1
lintOptions
{
disable
'InvalidPackage'
}
defaultConfig
{
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId
"com.example.permissionhandlerexample"
applicationId
"com.baseflow.permissionhandler.example"
minSdkVersion
16
targetSdkVersion
29
targetSdkVersion
31
versionCode
flutterVersionCode
.
toInteger
()
versionName
flutterVersionName
}
...
...
permission_handler/example/android/app/src/debug/AndroidManifest.xml
View file @
46a14456
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.
example.permissionhandler
example"
>
package=
"com.
baseflow.permissionhandler.
example"
>
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
...
...
permission_handler/example/android/app/src/main/AndroidManifest.xml
View file @
46a14456
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.
example.permissionhandler
example"
>
package=
"com.
baseflow.permissionhandler.
example"
>
<!--
Internet permissions do not affect the `permission_handler` plugin, but are required if your app needs access to
...
...
@@ -62,6 +62,9 @@
<!-- Permissions options for the `bluetooth` group -->
<uses-permission
android:name=
"android.permission.BLUETOOTH"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH_SCAN"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH_ADVERTISE"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH_CONNECT"
/>
<!-- Permissions options for the `manage external storage` group -->
<uses-permission
android:name=
"android.permission.MANAGE_EXTERNAL_STORAGE"
/>
...
...
@@ -80,17 +83,20 @@
android:icon=
"@mipmap/ic_launcher"
android:label=
"permission_handler_example"
tools:ignore=
"AllowBackup,GoogleAppIndexingWarning"
>
<activity
android:name=
"io.flutter.embedding.android.FlutterActivity"
android:launchMode=
"singleTop"
android:theme=
"@android:style/Theme.Black.NoTitleBar"
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated=
"true"
android:windowSoftInputMode=
"adjustResize"
>
android:windowSoftInputMode=
"adjustResize"
android:exported=
"true"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<meta-data
android:name=
"flutterEmbedding"
android:value=
"2"
/>
...
...
permission_handler/example/android/build.gradle
View file @
46a14456
...
...
@@ -5,7 +5,7 @@ buildscript {
}
dependencies
{
classpath
'com.android.tools.build:gradle:
3.5.0
'
classpath
'com.android.tools.build:gradle:
4.0.2
'
}
}
...
...
permission_handler/example/android/gradle.properties
View file @
46a14456
org.gradle.jvmargs
=
-Xmx1536M
android.enableJetifier
=
true
android.useAndroidX
=
true
android.enableR8
=
true
permission_handler/example/android/gradle/wrapper/gradle-wrapper.properties
View file @
46a14456
...
...
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
5.6.2
-all.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
6.1.1
-all.zip
permission_handler/example/lib/main.dart
View file @
46a14456
import
'package:flutter/material.dart'
;
import
'dart:io'
;
import
'package:baseflow_plugin_template/baseflow_plugin_template.dart'
;
import
'package:flutter/material.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
void
main
(
)
{
...
...
@@ -46,7 +47,10 @@ class _PermissionHandlerWidgetState extends State<PermissionHandlerWidget> {
permission
!=
Permission
.
manageExternalStorage
&&
permission
!=
Permission
.
systemAlertWindow
&&
permission
!=
Permission
.
requestInstallPackages
&&
permission
!=
Permission
.
accessNotificationPolicy
;
permission
!=
Permission
.
accessNotificationPolicy
&&
permission
!=
Permission
.
bluetoothScan
&&
permission
!=
Permission
.
bluetoothAdvertise
&&
permission
!=
Permission
.
bluetoothConnect
;
}
else
{
return
permission
!=
Permission
.
unknown
&&
permission
!=
Permission
.
mediaLibrary
&&
...
...
permission_handler/ios/Classes/PermissionHandlerEnums.h
View file @
46a14456
...
...
@@ -139,6 +139,9 @@ typedef NS_ENUM(int, PermissionGroup) {
PermissionGroupAppTrackingTransparency
,
PermissionGroupCriticalAlerts
,
PermissionGroupAccessNotificationPolicy
,
PermissionGroupBluetoothScan
,
PermissionGroupBluetoothAdvertise
,
PermissionGroupBluetoothConnect
,
};
typedef
NS_ENUM
(
int
,
PermissionStatus
)
{
...
...
permission_handler/pubspec.yaml
View file @
46a14456
name
:
permission_handler
description
:
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
version
:
8.
1.6
version
:
8.
2.0
homepage
:
https://github.com/baseflowit/flutter-permission-handler
flutter
:
...
...
@@ -16,7 +16,8 @@ dependencies:
flutter
:
sdk
:
flutter
meta
:
^1.3.0
permission_handler_platform_interface
:
^3.6.1
permission_handler_platform_interface
:
path
:
../permission_handler_platform_interface
# FIXME: Publish new version and use it here
dev_dependencies
:
flutter_test
:
...
...
permission_handler_platform_interface/CHANGELOG.md
View file @
46a14456
## 3.7.0
*
Added support for the new Android 12 Bluetooth permissions: BLUETOOTH_SCAN, BLUETOOTH_ADVERTISE and BLUETOOTH_CONNECT.
## 3.6.2
*
Updated the MethodChannelMock due to breaking changes in the platform channel test interface.
...
...
permission_handler_platform_interface/lib/src/permissions.dart
View file @
46a14456
...
...
@@ -162,6 +162,20 @@ class Permission {
///iOS: Nothing
static
const
accessNotificationPolicy
=
Permission
.
_
(
27
);
///Android: Allows the user to look for Bluetooth devices
///(e.g. BLE peripherals).
///iOS: Nothing
static
const
bluetoothScan
=
Permission
.
_
(
28
);
///Android: Allows the user to make this device discoverable to other
///Bluetooth devices.
///iOS: Nothing
static
const
bluetoothAdvertise
=
Permission
.
_
(
29
);
///Android: Allows the user to connect with already paired Bluetooth devices.
///iOS: Nothing
static
const
bluetoothConnect
=
Permission
.
_
(
30
);
/// Returns a list of all possible [PermissionGroup] values.
static
const
List
<
Permission
>
values
=
<
Permission
>[
calendar
,
...
...
@@ -192,6 +206,9 @@ class Permission {
appTrackingTransparency
,
criticalAlerts
,
accessNotificationPolicy
,
bluetoothScan
,
bluetoothAdvertise
,
bluetoothConnect
,
];
static
const
List
<
String
>
_names
=
<
String
>[
...
...
@@ -223,6 +240,9 @@ class Permission {
'appTrackingTransparency'
,
'criticalAlerts'
,
'accessNotificationPolicy'
,
'bluetoothScan'
,
'bluetoothAdvertise'
,
'bluetoothConnect'
,
];
@override
...
...
permission_handler_platform_interface/pubspec.yaml
View file @
46a14456
...
...
@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin.
homepage
:
https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version
:
3.
6.2
version
:
3.
7.0
dependencies
:
flutter
:
...
...
permission_handler_platform_interface/test/src/permissions_test.dart
View file @
46a14456
...
...
@@ -6,7 +6,7 @@ void main() {
()
{
const
values
=
Permission
.
values
;
expect
(
values
.
length
,
28
);
expect
(
values
.
length
,
31
);
});
test
(
'check if byValue returns corresponding PermissionGroup value'
,
()
{
...
...
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