From 44170e9a844662c45dee86fe77566a80aa228c6e Mon Sep 17 00:00:00 2001 From: duqingquan Date: Thu, 21 Mar 2024 17:57:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0android=20=E8=BE=85=E5=8A=A9?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utssdk/app-android/AndroidManifest.xml | 13 ++++++++ .../CustomAccessibilityService.uts | 31 +++++++++++++++++++ .../utssdk/app-android/index.uts | 2 +- .../utssdk/app-android/res/values/strings.xml | 1 + .../custom_accessibility_service_config.xml | 10 ++++++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts create mode 100644 uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_accessibility_service_config.xml diff --git a/uni_modules/uts-nativepage/utssdk/app-android/AndroidManifest.xml b/uni_modules/uts-nativepage/utssdk/app-android/AndroidManifest.xml index ef24539..64d3ca5 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/AndroidManifest.xml +++ b/uni_modules/uts-nativepage/utssdk/app-android/AndroidManifest.xml @@ -5,6 +5,19 @@ + + + + + + + diff --git a/uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts b/uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts new file mode 100644 index 0000000..873a5dc --- /dev/null +++ b/uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts @@ -0,0 +1,31 @@ +import AccessibilityService from 'android.accessibilityservice.AccessibilityService' +import AccessibilityEvent from 'android.view.accessibility.AccessibilityEvent' + + +export class CustomAccessibilityService extends AccessibilityService { + + constructor (){ + super(); + } + + override onInterrupt():void { + console.log("onInterrupt"); + } + + + override onAccessibilityEvent(event:AccessibilityEvent ):void { + + if(event == null){ + return ; + } + console.log("packagename",event!.getPackageName()) + if("io.dcloud.uniappx" == event!.getPackageName()){ + console.log("辅助服务消息:uniappx 基座打开") + }else if("io.dcloud.HBuilder" == event!.getPackageName()){ + console.log("辅助服务消息:HBuilder 基座被打开") + } + } + + +} + diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts index 24c4a20..59faeb9 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts +++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts @@ -29,7 +29,7 @@ export {DoAppWidget} from "./DoAppWidget.uts" import Application from 'android.app.Application'; import File from 'java.io.File'; import Uri from 'android.net.Uri'; - +export * from './CustomAccessibilityService.uts' export class AppHookProxy implements UTSAndroidHookProxy { override onCreate(application: Application) { diff --git a/uni_modules/uts-nativepage/utssdk/app-android/res/values/strings.xml b/uni_modules/uts-nativepage/utssdk/app-android/res/values/strings.xml index c18dd75..e96c9d6 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/res/values/strings.xml +++ b/uni_modules/uts-nativepage/utssdk/app-android/res/values/strings.xml @@ -12,4 +12,5 @@ Delete Ads This is an app widget description + uniappx 测试辅助服务 \ No newline at end of file diff --git a/uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_accessibility_service_config.xml b/uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_accessibility_service_config.xml new file mode 100644 index 0000000..1171029 --- /dev/null +++ b/uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_accessibility_service_config.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file -- GitLab