mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 00:13:01 +08:00
android 13+ request notification permission when start service (#7941)
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
3be4bfc821
commit
e373144350
@ -3,6 +3,7 @@
|
||||
package="com.carriez.flutter_hbb">
|
||||
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
@ -20,8 +20,10 @@ const String kPlatformAdditionsIsWayland = "is_wayland";
|
||||
const String kPlatformAdditionsHeadless = "headless";
|
||||
const String kPlatformAdditionsIsInstalled = "is_installed";
|
||||
const String kPlatformAdditionsIddImpl = "idd_impl";
|
||||
const String kPlatformAdditionsRustDeskVirtualDisplays = "rustdesk_virtual_displays";
|
||||
const String kPlatformAdditionsAmyuniVirtualDisplays = "amyuni_virtual_displays";
|
||||
const String kPlatformAdditionsRustDeskVirtualDisplays =
|
||||
"rustdesk_virtual_displays";
|
||||
const String kPlatformAdditionsAmyuniVirtualDisplays =
|
||||
"amyuni_virtual_displays";
|
||||
const String kPlatformAdditionsHasFileClipboard = "has_file_clipboard";
|
||||
const String kPlatformAdditionsSupportedPrivacyModeImpl =
|
||||
"supported_privacy_mode_impl";
|
||||
@ -224,6 +226,7 @@ const kManageExternalStorage = "android.permission.MANAGE_EXTERNAL_STORAGE";
|
||||
const kRequestIgnoreBatteryOptimizations =
|
||||
"android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
|
||||
const kSystemAlertWindow = "android.permission.SYSTEM_ALERT_WINDOW";
|
||||
const kAndroid13Notification = "android.permission.POST_NOTIFICATIONS";
|
||||
|
||||
/// Android channel invoke type key
|
||||
class AndroidChannel {
|
||||
|
@ -322,6 +322,20 @@ class ServerModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> checkRequestNotificationPermission() async {
|
||||
debugPrint("androidVersion $androidVersion");
|
||||
if (androidVersion < 33) {
|
||||
return true;
|
||||
}
|
||||
if (await AndroidPermissionManager.check(kAndroid13Notification)) {
|
||||
debugPrint("notification permission already granted");
|
||||
return true;
|
||||
}
|
||||
var res = await AndroidPermissionManager.request(kAndroid13Notification);
|
||||
debugPrint("notification permission request result: $res");
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Toggle the screen sharing service.
|
||||
toggleService() async {
|
||||
if (_isStart) {
|
||||
@ -348,6 +362,7 @@ class ServerModel with ChangeNotifier {
|
||||
stopService();
|
||||
}
|
||||
} else {
|
||||
await checkRequestNotificationPermission();
|
||||
final res = await parent.target?.dialogManager
|
||||
.show<bool>((setState, close, context) {
|
||||
submit() => close(true);
|
||||
|
Loading…
Reference in New Issue
Block a user