提交 44170e9a 编写于 作者: 杜庆泉's avatar 杜庆泉

增加android 辅助服务示例

上级 7a5b31c6
...@@ -5,6 +5,19 @@ ...@@ -5,6 +5,19 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application> <application>
<service
android:name="uts.sdk.modules.utsNativepage.CustomAccessibilityService"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService"/>
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/custom_accessibility_service_config" />
</service>
<service android:name="uts.sdk.modules.utsNativepage.ForeService" /> <service android:name="uts.sdk.modules.utsNativepage.ForeService" />
<activity android:name="uts.sdk.modules.utsNativepage.DemoActivity"></activity> <activity android:name="uts.sdk.modules.utsNativepage.DemoActivity"></activity>
<!--桌面widget组件注册--> <!--桌面widget组件注册-->
......
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 基座被打开")
}
}
}
...@@ -29,7 +29,7 @@ export {DoAppWidget} from "./DoAppWidget.uts" ...@@ -29,7 +29,7 @@ export {DoAppWidget} from "./DoAppWidget.uts"
import Application from 'android.app.Application'; import Application from 'android.app.Application';
import File from 'java.io.File'; import File from 'java.io.File';
import Uri from 'android.net.Uri'; import Uri from 'android.net.Uri';
export * from './CustomAccessibilityService.uts'
export class AppHookProxy implements UTSAndroidHookProxy { export class AppHookProxy implements UTSAndroidHookProxy {
override onCreate(application: Application) { override onCreate(application: Application) {
......
...@@ -12,4 +12,5 @@ ...@@ -12,4 +12,5 @@
<string name="dcloud_ad_notification_delete_download">Delete</string> <string name="dcloud_ad_notification_delete_download">Delete</string>
<string name="dcloud_ad_tag_ads">Ads</string> <string name="dcloud_ad_tag_ads">Ads</string>
<string name="app_widget_description">This is an app widget description</string> <string name="app_widget_description">This is an app widget description</string>
<string name="demo_service_name">uniappx 测试辅助服务</string>
</resources> </resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service
xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/demo_service_name"
android:accessibilityEventTypes="typeNotificationStateChanged|typeWindowStateChanged"
android:packageNames="io.dcloud.uniappx,io.dcloud.HBuilder"
android:accessibilityFeedbackType="feedbackGeneric"
android:notificationTimeout="100"
android:accessibilityFlags="flagDefault"
android:canRetrieveWindowContent="true"/>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册