Commit 59bcf064228b3653fad24e9cfff5ee93f0f3e864

Authored by 常守达
1 parent 11c8fd00

feat(ohos): 忽略鸿蒙文件

@@ -45,3 +45,4 @@ app.*.map.json @@ -45,3 +45,4 @@ app.*.map.json
45 /android/app/profile 45 /android/app/profile
46 /android/app/release 46 /android/app/release
47 /scripts/ 47 /scripts/
  48 +/ohos/
1 -/*  
2 -* // Copyright 2013 The Flutter Authors. All rights reserved.  
3 -*/  
4 -import StandardMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StandardMessageCodec';  
5 -import BasicMessageChannel, { Reply } from '@ohos/flutter_ohos/src/main/ets/plugin/common/BasicMessageChannel';  
6 -import { BinaryMessenger,TaskQueue } from '@ohos/flutter_ohos/src/main/ets/plugin/common/BinaryMessenger';  
7 -import MessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/MessageCodec';  
8 -import { ByteBuffer } from '@ohos/flutter_ohos/src/main/ets/util/ByteBuffer';  
9 -  
10 -  
11 -/** Error class for passing custom error details to Flutter via a thrown PlatformException. */  
12 -export class FlutterError implements Error {  
13 -  
14 - /** The error code. */  
15 - public code: string;  
16 -  
17 - /** The error name. */  
18 - public name: string;  
19 -  
20 - /** The error message. */  
21 - public message: string;  
22 - /** The error stack. */  
23 - public stack?: string;  
24 -  
25 - constructor(code: string, name: string, message: string, stack?: string)  
26 - {  
27 - this.code = code;  
28 - this.name = name;  
29 - this.message = message;  
30 - this.stack = stack;  
31 - }  
32 -}  
33 -  
34 -function wrapError(error: Error): Array<Object> {  
35 - let errorList: Array<Object> = new Array<Object>(3);  
36 - if (error instanceof FlutterError) {  
37 - let err: FlutterError = error as FlutterError;  
38 - errorList[0] = err.code;  
39 - errorList[1] = err.name;  
40 - errorList[2] = err.message;  
41 - } else {  
42 - errorList[0] = error.toString();  
43 - errorList[1] = error.name;  
44 - errorList[2] = "Cause: " + error.message + ", Stacktrace: " + error.stack;  
45 - }  
46 - return errorList;  
47 -}  
48 -  
49 -/*  
50 -* Alipay payment result codes.  
51 -*  
52 -* Generated enum from Pigeon that represents data sent in messages.  
53 -*/  
54 -export enum AliPayResultCode {  
55 - SUCCESS,  
56 - CANCEL,  
57 - ERROR,  
58 - UNSUPPORTED  
59 -}  
60 -  
61 -/*  
62 -* Alipay payment result codes.  
63 -*  
64 -* Generated enum Companion class from Pigeon that represents data sent  
65 - in messages.Do not delete otherwise enum type data transfer will be failed  
66 -*/  
67 -export class AliPayResultCodeEnum {  
68 - index: string|null = null;  
69 - constructor(index: string){  
70 - this.index = index;  
71 - }  
72 -}  
73 -  
74 -export class PigeonCodec extends StandardMessageCodec {  
75 - static readonly INSTANCE: PigeonCodec = new PigeonCodec();  
76 -  
77 - getByte(n: number): number {  
78 - let byteArray = new Uint8Array(1);  
79 - byteArray[0] = n;  
80 - return byteArray[0] as number;  
81 - }  
82 - private constructor() {  
83 - super();  
84 - }  
85 -  
86 - readValueOfType(type: number, buffer: ByteBuffer): ESObject {  
87 - switch (type) {  
88 - case this.getByte(129): {  
89 - let value: Object= super.readValue(buffer);  
90 - return value == null ? null : AliPayResultCode[value as number];  
91 - }  
92 - default:  
93 - return super.readValueOfType(type, buffer);  
94 - }  
95 - }  
96 -  
97 - writeValue(stream: ByteBuffer , value: ESObject): ESObject{  
98 - if (value instanceof AliPayResultCodeEnum) {  
99 - stream.writeUint8(this.getByte(129));  
100 - this.writeValue(stream, value == null ? null : AliPayResultCode[value.index as string]);  
101 - } else {  
102 - super.writeValue(stream, value);  
103 - }  
104 - }  
105 -}  
106 -  
107 -/* Generated abstract class from Pigeon that represents a handler of messages from Flutter.*/  
108 -export abstract class AlipayHostApi {  
109 -  
110 - abstract launchAliPay(prepayData: string ): AliPayResultCode;  
111 - /** The codec used by AlipayHostApi. */  
112 - static getCodec(): MessageCodec<Object>{  
113 - return PigeonCodec.INSTANCE;  
114 - }  
115 - /*Sets up an instance of `AlipayHostApi` to handle messages through the `binaryMessenger`.*/  
116 - static setup(binaryMessenger: BinaryMessenger, api: AlipayHostApi | null): void {  
117 - {  
118 - let channel: BasicMessageChannel<Object> =  
119 - new BasicMessageChannel(  
120 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.AlipayHostApi.launchAliPay", AlipayHostApi.getCodec());  
121 - if (api != null) {  
122 - channel.setMessageHandler({  
123 - onMessage(message: Object ,reply: Reply<Object> ) {  
124 - let args: Array<Object> = message as Array<Object>;  
125 - let res: Array<Object> = [];  
126 - try {  
127 - let output: AliPayResultCodeEnum = new AliPayResultCodeEnum(api!.launchAliPay(args[0] as AliPayResultCode).toString());  
128 - res.push(output);  
129 - }  
130 - catch (error) {  
131 - let wrappedError: Array<Object> = wrapError(error);  
132 - res = wrappedError;  
133 - }  
134 - reply.reply(res);  
135 - } });  
136 - } else {  
137 - channel.setMessageHandler(null);  
138 - }  
139 - }  
140 - }  
141 -}  
1 -/*  
2 -* // Copyright 2013 The Flutter Authors. All rights reserved.  
3 -*/  
4 -import StandardMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StandardMessageCodec';  
5 -import BasicMessageChannel, { Reply } from '@ohos/flutter_ohos/src/main/ets/plugin/common/BasicMessageChannel';  
6 -import { BinaryMessenger,TaskQueue } from '@ohos/flutter_ohos/src/main/ets/plugin/common/BinaryMessenger';  
7 -import MessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/MessageCodec';  
8 -import { ByteBuffer } from '@ohos/flutter_ohos/src/main/ets/util/ByteBuffer';  
9 -  
10 -  
11 -/** Error class for passing custom error details to Flutter via a thrown PlatformException. */  
12 -export class FlutterError implements Error {  
13 -  
14 - /** The error code. */  
15 - public code: string;  
16 -  
17 - /** The error name. */  
18 - public name: string;  
19 -  
20 - /** The error message. */  
21 - public message: string;  
22 - /** The error stack. */  
23 - public stack?: string;  
24 -  
25 - constructor(code: string, name: string, message: string, stack?: string)  
26 - {  
27 - this.code = code;  
28 - this.name = name;  
29 - this.message = message;  
30 - this.stack = stack;  
31 - }  
32 -}  
33 -  
34 -function wrapError(error: Error): Array<Object> {  
35 - let errorList: Array<Object> = new Array<Object>(3);  
36 - if (error instanceof FlutterError) {  
37 - let err: FlutterError = error as FlutterError;  
38 - errorList[0] = err.code;  
39 - errorList[1] = err.name;  
40 - errorList[2] = err.message;  
41 - } else {  
42 - errorList[0] = error.toString();  
43 - errorList[1] = error.name;  
44 - errorList[2] = "Cause: " + error.message + ", Stacktrace: " + error.stack;  
45 - }  
46 - return errorList;  
47 -}  
48 -  
49 -/* Generated class from Pigeon that represents data sent in messages.*/  
50 -export class HealthUploadResult {  
51 - private commonUploadSuccess?: boolean;  
52 -  
53 - public setCommonUploadSuccess(commonUploadSuccess:boolean):void {  
54 - this.commonUploadSuccess = commonUploadSuccess;  
55 - }  
56 -  
57 - getCommonUploadSuccess(): boolean | undefined{  
58 - return this.commonUploadSuccess;  
59 - }  
60 -  
61 - private sleepUploadSuccess?: boolean;  
62 -  
63 - public setSleepUploadSuccess(sleepUploadSuccess:boolean):void {  
64 - this.sleepUploadSuccess = sleepUploadSuccess;  
65 - }  
66 -  
67 - getSleepUploadSuccess(): boolean | undefined{  
68 - return this.sleepUploadSuccess;  
69 - }  
70 -  
71 - private errorMessage?: string;  
72 -  
73 - public setErrorMessage(errorMessage:string):void {  
74 - this.errorMessage = errorMessage;  
75 - }  
76 -  
77 - getErrorMessage(): string | undefined{  
78 - return this.errorMessage;  
79 - }  
80 -  
81 - constructor(commonUploadSuccess?: boolean, sleepUploadSuccess?: boolean, errorMessage?: string) {  
82 - this.commonUploadSuccess = commonUploadSuccess;  
83 - this.sleepUploadSuccess = sleepUploadSuccess;  
84 - this.errorMessage = errorMessage;  
85 - }  
86 -  
87 - toList(): Object[] {  
88 - let arr: Object[] = new Array();  
89 - if(this.commonUploadSuccess !==undefined){  
90 - arr.push(this.commonUploadSuccess);  
91 - }  
92 - if(this.sleepUploadSuccess !==undefined){  
93 - arr.push(this.sleepUploadSuccess);  
94 - }  
95 - if(this.errorMessage !==undefined){  
96 - arr.push(this.errorMessage);  
97 - }  
98 - return arr;  
99 - }  
100 -  
101 - static fromList(arr: Object[]): HealthUploadResult {  
102 - let pigeonResult: HealthUploadResult = new HealthUploadResult();  
103 - let commonUploadSuccess: Object = arr[0];  
104 - pigeonResult.setCommonUploadSuccess(commonUploadSuccess as boolean);  
105 - let sleepUploadSuccess: Object = arr[1];  
106 - pigeonResult.setSleepUploadSuccess(sleepUploadSuccess as boolean);  
107 - let errorMessage: Object = arr[2];  
108 - pigeonResult.setErrorMessage(errorMessage as string);  
109 - return pigeonResult;  
110 - }  
111 -}  
112 -  
113 -export class PigeonCodec extends StandardMessageCodec {  
114 - static readonly INSTANCE: PigeonCodec = new PigeonCodec();  
115 -  
116 - getByte(n: number): number {  
117 - let byteArray = new Uint8Array(1);  
118 - byteArray[0] = n;  
119 - return byteArray[0] as number;  
120 - }  
121 - private constructor() {  
122 - super();  
123 - }  
124 -  
125 - readValueOfType(type: number, buffer: ByteBuffer): ESObject {  
126 - switch (type) {  
127 - case this.getByte(129):  
128 - return HealthUploadResult.fromList(super.readValue(buffer) as Object[]);  
129 - default:  
130 - return super.readValueOfType(type, buffer);  
131 - }  
132 - }  
133 -  
134 - writeValue(stream: ByteBuffer , value: ESObject): ESObject{  
135 - if (value instanceof HealthUploadResult) {  
136 - stream.writeUint8(this.getByte(129));  
137 - this.writeValue(stream, (value as HealthUploadResult).toList());  
138 - } else {  
139 - super.writeValue(stream, value);  
140 - }  
141 - }  
142 -}  
143 -  
144 -/* Generated abstract class from Pigeon that represents a handler of messages from Flutter.*/  
145 -export abstract class HealthKitHostApi {  
146 -  
147 - abstract checkHealthAppAuthorization(): boolean;  
148 -  
149 - abstract getHealthServerAuthUrl(): string;  
150 - /* Opens Huawei Health client authorization UI. Returns whether user granted.*/  
151 - abstract requestHealthClientAuthorization(): boolean;  
152 -  
153 - abstract cancelHealthAppAuthorization(): boolean;  
154 - /* Runs native health read and server upload pipeline.*/  
155 - abstract performHealthUpload(): HealthUploadResult;  
156 - /** The codec used by HealthKitHostApi. */  
157 - static getCodec(): MessageCodec<Object>{  
158 - return PigeonCodec.INSTANCE;  
159 - }  
160 - /*Sets up an instance of `HealthKitHostApi` to handle messages through the `binaryMessenger`.*/  
161 - static setup(binaryMessenger: BinaryMessenger, api: HealthKitHostApi | null): void {  
162 - {  
163 - let channel: BasicMessageChannel<Object> =  
164 - new BasicMessageChannel(  
165 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.HealthKitHostApi.checkHealthAppAuthorization", HealthKitHostApi.getCodec());  
166 - if (api != null) {  
167 - channel.setMessageHandler({  
168 - onMessage(message: Object ,reply: Reply<Object> ) {  
169 - let res: Array<Object> = [];  
170 - try {  
171 - let output: boolean = api!.checkHealthAppAuthorization();  
172 - res.push(output);  
173 - }  
174 - catch (error) {  
175 - let wrappedError: Array<Object> = wrapError(error);  
176 - res = wrappedError;  
177 - }  
178 - reply.reply(res);  
179 - } });  
180 - } else {  
181 - channel.setMessageHandler(null);  
182 - }  
183 - }  
184 - {  
185 - let channel: BasicMessageChannel<Object> =  
186 - new BasicMessageChannel(  
187 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.HealthKitHostApi.getHealthServerAuthUrl", HealthKitHostApi.getCodec());  
188 - if (api != null) {  
189 - channel.setMessageHandler({  
190 - onMessage(message: Object ,reply: Reply<Object> ) {  
191 - let res: Array<Object> = [];  
192 - try {  
193 - let output: string = api!.getHealthServerAuthUrl();  
194 - res.push(output);  
195 - }  
196 - catch (error) {  
197 - let wrappedError: Array<Object> = wrapError(error);  
198 - res = wrappedError;  
199 - }  
200 - reply.reply(res);  
201 - } });  
202 - } else {  
203 - channel.setMessageHandler(null);  
204 - }  
205 - }  
206 - {  
207 - let channel: BasicMessageChannel<Object> =  
208 - new BasicMessageChannel(  
209 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.HealthKitHostApi.requestHealthClientAuthorization", HealthKitHostApi.getCodec());  
210 - if (api != null) {  
211 - channel.setMessageHandler({  
212 - onMessage(message: Object ,reply: Reply<Object> ) {  
213 - let res: Array<Object> = [];  
214 - try {  
215 - let output: boolean = api!.requestHealthClientAuthorization();  
216 - res.push(output);  
217 - }  
218 - catch (error) {  
219 - let wrappedError: Array<Object> = wrapError(error);  
220 - res = wrappedError;  
221 - }  
222 - reply.reply(res);  
223 - } });  
224 - } else {  
225 - channel.setMessageHandler(null);  
226 - }  
227 - }  
228 - {  
229 - let channel: BasicMessageChannel<Object> =  
230 - new BasicMessageChannel(  
231 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.HealthKitHostApi.cancelHealthAppAuthorization", HealthKitHostApi.getCodec());  
232 - if (api != null) {  
233 - channel.setMessageHandler({  
234 - onMessage(message: Object ,reply: Reply<Object> ) {  
235 - let res: Array<Object> = [];  
236 - try {  
237 - let output: boolean = api!.cancelHealthAppAuthorization();  
238 - res.push(output);  
239 - }  
240 - catch (error) {  
241 - let wrappedError: Array<Object> = wrapError(error);  
242 - res = wrappedError;  
243 - }  
244 - reply.reply(res);  
245 - } });  
246 - } else {  
247 - channel.setMessageHandler(null);  
248 - }  
249 - }  
250 - {  
251 - let channel: BasicMessageChannel<Object> =  
252 - new BasicMessageChannel(  
253 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.HealthKitHostApi.performHealthUpload", HealthKitHostApi.getCodec());  
254 - if (api != null) {  
255 - channel.setMessageHandler({  
256 - onMessage(message: Object ,reply: Reply<Object> ) {  
257 - let res: Array<Object> = [];  
258 - try {  
259 - let output: HealthUploadResult = api!.performHealthUpload();  
260 - res.push(output);  
261 - }  
262 - catch (error) {  
263 - let wrappedError: Array<Object> = wrapError(error);  
264 - res = wrappedError;  
265 - }  
266 - reply.reply(res);  
267 - } });  
268 - } else {  
269 - channel.setMessageHandler(null);  
270 - }  
271 - }  
272 - }  
273 -}  
1 -/*  
2 -* // Copyright 2013 The Flutter Authors. All rights reserved.  
3 -*/  
4 -import StandardMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StandardMessageCodec';  
5 -import BasicMessageChannel, { Reply } from '@ohos/flutter_ohos/src/main/ets/plugin/common/BasicMessageChannel';  
6 -import { BinaryMessenger,TaskQueue } from '@ohos/flutter_ohos/src/main/ets/plugin/common/BinaryMessenger';  
7 -import MessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/MessageCodec';  
8 -import { ByteBuffer } from '@ohos/flutter_ohos/src/main/ets/util/ByteBuffer';  
9 -  
10 -  
11 -/** Error class for passing custom error details to Flutter via a thrown PlatformException. */  
12 -export class FlutterError implements Error {  
13 -  
14 - /** The error code. */  
15 - public code: string;  
16 -  
17 - /** The error name. */  
18 - public name: string;  
19 -  
20 - /** The error message. */  
21 - public message: string;  
22 - /** The error stack. */  
23 - public stack?: string;  
24 -  
25 - constructor(code: string, name: string, message: string, stack?: string)  
26 - {  
27 - this.code = code;  
28 - this.name = name;  
29 - this.message = message;  
30 - this.stack = stack;  
31 - }  
32 -}  
33 -  
34 -function wrapError(error: Error): Array<Object> {  
35 - let errorList: Array<Object> = new Array<Object>(3);  
36 - if (error instanceof FlutterError) {  
37 - let err: FlutterError = error as FlutterError;  
38 - errorList[0] = err.code;  
39 - errorList[1] = err.name;  
40 - errorList[2] = err.message;  
41 - } else {  
42 - errorList[0] = error.toString();  
43 - errorList[1] = error.name;  
44 - errorList[2] = "Cause: " + error.message + ", Stacktrace: " + error.stack;  
45 - }  
46 - return errorList;  
47 -}  
48 -  
49 -/* Generated class from Pigeon that represents data sent in messages.*/  
50 -export class WearDeviceInfo {  
51 - private deviceId?: string;  
52 -  
53 - public setDeviceId(deviceId:string):void {  
54 - this.deviceId = deviceId;  
55 - }  
56 -  
57 - getDeviceId(): string | undefined{  
58 - return this.deviceId;  
59 - }  
60 -  
61 - private deviceName?: string;  
62 -  
63 - public setDeviceName(deviceName:string):void {  
64 - this.deviceName = deviceName;  
65 - }  
66 -  
67 - getDeviceName(): string | undefined{  
68 - return this.deviceName;  
69 - }  
70 -  
71 - private isConnected?: boolean;  
72 -  
73 - public setIsConnected(isConnected:boolean):void {  
74 - this.isConnected = isConnected;  
75 - }  
76 -  
77 - getIsConnected(): boolean | undefined{  
78 - return this.isConnected;  
79 - }  
80 -  
81 - constructor(deviceId?: string, deviceName?: string, isConnected?: boolean) {  
82 - this.deviceId = deviceId;  
83 - this.deviceName = deviceName;  
84 - this.isConnected = isConnected;  
85 - }  
86 -  
87 - toList(): Object[] {  
88 - let arr: Object[] = new Array();  
89 - if(this.deviceId !==undefined){  
90 - arr.push(this.deviceId);  
91 - }  
92 - if(this.deviceName !==undefined){  
93 - arr.push(this.deviceName);  
94 - }  
95 - if(this.isConnected !==undefined){  
96 - arr.push(this.isConnected);  
97 - }  
98 - return arr;  
99 - }  
100 -  
101 - static fromList(arr: Object[]): WearDeviceInfo {  
102 - let pigeonResult: WearDeviceInfo = new WearDeviceInfo();  
103 - let deviceId: Object = arr[0];  
104 - pigeonResult.setDeviceId(deviceId as string);  
105 - let deviceName: Object = arr[1];  
106 - pigeonResult.setDeviceName(deviceName as string);  
107 - let isConnected: Object = arr[2];  
108 - pigeonResult.setIsConnected(isConnected as boolean);  
109 - return pigeonResult;  
110 - }  
111 -}  
112 -  
113 -export class PigeonCodec extends StandardMessageCodec {  
114 - static readonly INSTANCE: PigeonCodec = new PigeonCodec();  
115 -  
116 - getByte(n: number): number {  
117 - let byteArray = new Uint8Array(1);  
118 - byteArray[0] = n;  
119 - return byteArray[0] as number;  
120 - }  
121 - private constructor() {  
122 - super();  
123 - }  
124 -  
125 - readValueOfType(type: number, buffer: ByteBuffer): ESObject {  
126 - switch (type) {  
127 - case this.getByte(129):  
128 - return WearDeviceInfo.fromList(super.readValue(buffer) as Object[]);  
129 - default:  
130 - return super.readValueOfType(type, buffer);  
131 - }  
132 - }  
133 -  
134 - writeValue(stream: ByteBuffer , value: ESObject): ESObject{  
135 - if (value instanceof WearDeviceInfo) {  
136 - stream.writeUint8(this.getByte(129));  
137 - this.writeValue(stream, (value as WearDeviceInfo).toList());  
138 - } else {  
139 - super.writeValue(stream, value);  
140 - }  
141 - }  
142 -}  
143 -  
144 -/* Generated abstract class from Pigeon that represents a handler of messages from Flutter.*/  
145 -export abstract class WearEngineHostApi {  
146 -  
147 - abstract hasAvailableDevices(): boolean;  
148 -  
149 - abstract checkConnectedDevice(): WearDeviceInfo;  
150 -  
151 - abstract registerMessageReceiver(): boolean;  
152 -  
153 - abstract sendTextMessage(message: string ): boolean;  
154 -  
155 - abstract sendWatchSyncPayload(jsonPayload: string ): boolean;  
156 - /** The codec used by WearEngineHostApi. */  
157 - static getCodec(): MessageCodec<Object>{  
158 - return PigeonCodec.INSTANCE;  
159 - }  
160 - /*Sets up an instance of `WearEngineHostApi` to handle messages through the `binaryMessenger`.*/  
161 - static setup(binaryMessenger: BinaryMessenger, api: WearEngineHostApi | null): void {  
162 - {  
163 - let channel: BasicMessageChannel<Object> =  
164 - new BasicMessageChannel(  
165 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.WearEngineHostApi.hasAvailableDevices", WearEngineHostApi.getCodec());  
166 - if (api != null) {  
167 - channel.setMessageHandler({  
168 - onMessage(message: Object ,reply: Reply<Object> ) {  
169 - let res: Array<Object> = [];  
170 - try {  
171 - let output: boolean = api!.hasAvailableDevices();  
172 - res.push(output);  
173 - }  
174 - catch (error) {  
175 - let wrappedError: Array<Object> = wrapError(error);  
176 - res = wrappedError;  
177 - }  
178 - reply.reply(res);  
179 - } });  
180 - } else {  
181 - channel.setMessageHandler(null);  
182 - }  
183 - }  
184 - {  
185 - let channel: BasicMessageChannel<Object> =  
186 - new BasicMessageChannel(  
187 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.WearEngineHostApi.checkConnectedDevice", WearEngineHostApi.getCodec());  
188 - if (api != null) {  
189 - channel.setMessageHandler({  
190 - onMessage(message: Object ,reply: Reply<Object> ) {  
191 - let res: Array<Object> = [];  
192 - try {  
193 - let output: WearDeviceInfo = api!.checkConnectedDevice();  
194 - res.push(output);  
195 - }  
196 - catch (error) {  
197 - let wrappedError: Array<Object> = wrapError(error);  
198 - res = wrappedError;  
199 - }  
200 - reply.reply(res);  
201 - } });  
202 - } else {  
203 - channel.setMessageHandler(null);  
204 - }  
205 - }  
206 - {  
207 - let channel: BasicMessageChannel<Object> =  
208 - new BasicMessageChannel(  
209 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.WearEngineHostApi.registerMessageReceiver", WearEngineHostApi.getCodec());  
210 - if (api != null) {  
211 - channel.setMessageHandler({  
212 - onMessage(message: Object ,reply: Reply<Object> ) {  
213 - let res: Array<Object> = [];  
214 - try {  
215 - let output: boolean = api!.registerMessageReceiver();  
216 - res.push(output);  
217 - }  
218 - catch (error) {  
219 - let wrappedError: Array<Object> = wrapError(error);  
220 - res = wrappedError;  
221 - }  
222 - reply.reply(res);  
223 - } });  
224 - } else {  
225 - channel.setMessageHandler(null);  
226 - }  
227 - }  
228 - {  
229 - let channel: BasicMessageChannel<Object> =  
230 - new BasicMessageChannel(  
231 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.WearEngineHostApi.sendTextMessage", WearEngineHostApi.getCodec());  
232 - if (api != null) {  
233 - channel.setMessageHandler({  
234 - onMessage(message: Object ,reply: Reply<Object> ) {  
235 - let args: Array<Object> = message as Array<Object>;  
236 - let res: Array<Object> = [];  
237 - try {  
238 - let output: boolean = api!.sendTextMessage(args[0] as string);  
239 - res.push(output);  
240 - }  
241 - catch (error) {  
242 - let wrappedError: Array<Object> = wrapError(error);  
243 - res = wrappedError;  
244 - }  
245 - reply.reply(res);  
246 - } });  
247 - } else {  
248 - channel.setMessageHandler(null);  
249 - }  
250 - }  
251 - {  
252 - let channel: BasicMessageChannel<Object> =  
253 - new BasicMessageChannel(  
254 - binaryMessenger, "dev.flutter.pigeon.doublefeel_flutter.WearEngineHostApi.sendWatchSyncPayload", WearEngineHostApi.getCodec());  
255 - if (api != null) {  
256 - channel.setMessageHandler({  
257 - onMessage(message: Object ,reply: Reply<Object> ) {  
258 - let args: Array<Object> = message as Array<Object>;  
259 - let res: Array<Object> = [];  
260 - try {  
261 - let output: boolean = api!.sendWatchSyncPayload(args[0] as string);  
262 - res.push(output);  
263 - }  
264 - catch (error) {  
265 - let wrappedError: Array<Object> = wrapError(error);  
266 - res = wrappedError;  
267 - }  
268 - reply.reply(res);  
269 - } });  
270 - } else {  
271 - channel.setMessageHandler(null);  
272 - }  
273 - }  
274 - }  
275 -}  
1 -import { PlatformHostApi } from '../pigeon/PlatformApi';  
2 -import { bundleManager } from '@kit.AbilityKit';  
3 -import { deviceInfo } from '@kit.BasicServicesKit';  
4 -import { display } from '@kit.ArkUI';  
5 -import { web_webview } from '@kit.ArkWeb';  
6 -  
7 -/**  
8 - * PlatformApi HarmonyOS implementation.  
9 - *  
10 - * 组装完整 User-Agent,格式与 Android 端保持一致:  
11 - * `{systemWebViewUA} doublefeel/{versionCode}({versionName})({manufacturer}##{brand}##{model}; OpenHarmony{osVersion}; {height}x{width})(huawei)`  
12 - */  
13 -export class PlatformHostApiImpl extends PlatformHostApi {  
14 -  
15 - getFullUserAgent(): string {  
16 - // 1. 系统 WebView UA  
17 - let systemUa = '';  
18 - try {  
19 - systemUa = web_webview.WebviewController.getDefaultUserAgent();  
20 - } catch (_) {  
21 - systemUa = '';  
22 - }  
23 -  
24 - // 2. 版本信息(同步读取 bundleInfo)  
25 - let versionCode = 0;  
26 - let versionName = '';  
27 - try {  
28 - const bundleInfo = bundleManager.getBundleInfoForSelfSync(  
29 - bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT  
30 - );  
31 - versionCode = bundleInfo.versionCode;  
32 - versionName = bundleInfo.versionName;  
33 - } catch (_) {}  
34 -  
35 - // 3. 设备信息(@ohos.deviceInfo 常量,无需异步)  
36 - const manufacturer: string = deviceInfo.manufacture ?? '';  
37 - const brand: string = deviceInfo.brand ?? '';  
38 - const model: string = deviceInfo.productModel ?? '';  
39 - // osFullName 示例:"OpenHarmony 4.1.0",取主版本号数字部分  
40 - const osVersion: string = deviceInfo.osFullName.replace(/[^0-9]/g, '') ?? '';  
41 -  
42 - // 4. 屏幕物理分辨率:长边为 height,短边为 width  
43 - let screenWidth = 0;  
44 - let screenHeight = 0;  
45 - try {  
46 - const defaultDisplay = display.getDefaultDisplaySync();  
47 - const w = defaultDisplay.width;  
48 - const h = defaultDisplay.height;  
49 - screenWidth = Math.min(w, h);  
50 - screenHeight = Math.max(w, h);  
51 - } catch (_) {}  
52 -  
53 - // 5. 组装 customAgent(与 Android DeviceInfoUtils.userAgent 格式一致)  
54 - const customAgent =  
55 - `doublefeel/${versionCode}(${versionName})` +  
56 - `(${manufacturer}##${brand}##${model}; OpenHarmony${osVersion}; ${screenHeight}x${screenWidth})` +  
57 - `(huawei)`;  
58 -  
59 - const full = `${systemUa.trim()} ${customAgent}`.trim();  
60 - return full;  
61 - }  
62 -}