• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// @ts-nocheck
2/*
3 * Copyright (c) 2022 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
17import rpc from '@ohos.rpc'
18import { KeyboardController } from '../model/KeyboardController.ets'
19import Log from '../model/Log'
20import Want from "@ohos.application.Want"
21
22let TAG: string = 'ServiceExtAbility->'
23
24class StubTest extends rpc.RemoteObject {
25  constructor(des) {
26    if (typeof des === 'string') {
27      super(des);
28    } else {
29      return null;
30    }
31  }
32
33  queryLocalInterface(descriptor) {
34    return null;
35  }
36
37  getInterfaceDescriptor() {
38    return "";
39  };
40
41  sendRequest(code, data, reply, options) {
42    return null;
43  };
44
45  getCallingPid() {
46    return 0;
47  };
48
49  getCallingUid() {
50    return 0;
51  };
52
53  attachLocalInterface(localInterface, descriptor) {
54
55  };
56
57  onRemoteRequest(code, data, reply, option) {
58    Log.showInfo(TAG, 'kikaInput: ' + 'onRemoteRequest')
59    if (code === 1) {
60      Log.showInfo(TAG, 'kikaInput: ' + 'code 1 begin');
61      let op1 = data.readInt();
62      let op2 = data.readInt();
63      reply.writeInt(op1 + op2);
64    } else {
65      Log.showInfo(TAG, 'kikaInput: ' + 'onRemoteRequest code: ' + code);
66    }
67    return true;
68  }
69}
70
71class ServiceExtAbility extends InputMethodExtensionAbility {
72  keyboardController: any;
73
74  onCreate(want) {
75    this.addLog('onCreate want: ' + want.abilityName);
76    this.keyboardController = new KeyboardController(this.context);
77    this.keyboardController.onCreate();
78  }
79
80  onDestroy() {
81    this.addLog('onDestroy');
82    this.keyboardController.onDestroy();
83  }
84
85  addLog(message: string) {
86    Log.showInfo(TAG, 'kikaInput-new: ' + message);
87  }
88}
89
90export default ServiceExtAbility
91