• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { ServiceExtensionAbility, Want } from '@kit.AbilityKit';
17import { rpc } from '@kit.IPCKit';
18import AdsApiServiceRpcObj from './AdsApiServiceRpcObj';
19import Logger from '../log/HiAdLog';
20
21const TAG: string = 'AdsApiService';
22
23/**
24 * ads kit对外提供的service对象,用于媒体侧交互
25 */
26export default class AdsApiService extends ServiceExtensionAbility {
27  private descriptor: string = 'com.ohos.AdsApiService';
28
29  /**
30   * service初始化回调
31   *
32   * @param want want
33   */
34  onCreate(want: Want): void {
35    Logger.i(TAG, `service onCreate`);
36  }
37
38  /**
39   * service启动回调
40   *
41   * @param want want
42   * @param startId service启动次数
43   */
44  onRequest(want: Want, startId: number): void {
45    Logger.i(TAG, `service onRequest`);
46  }
47
48  /**
49   * service建连回调
50   *
51   * @param want want
52   * @returns 返回给调用端的RPC对象实例,用于商用端给kit发消息
53   */
54  onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject> {
55    Logger.i(TAG, `service onConnect`);
56    return new AdsApiServiceRpcObj(this.descriptor);
57  }
58
59  /**
60   * service断连回调
61   *
62   * @param want want
63   */
64  onDisconnect(want: Want): void {
65    Logger.i(TAG, `service onDisconnect`);
66  }
67
68  /**
69   * service销毁回调
70   */
71  onDestroy(): void {
72    Logger.i(TAG, `service onDestory`);
73  }
74}
75