• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
16 #ifndef USBD_LOAD_USB_SERVICE_H
17 #define USBD_LOAD_USB_SERVICE_H
18 #include <csignal>
19 #include <cstdlib>
20 #include <hdf_base.h>
21 #include <hdf_log.h>
22 #include "system_ability_definition.h"
23 #include "system_ability_load_callback_stub.h"
24 
25 #define HDF_PROCESS_STACK_SIZE 100000
26 #define SLEEP_DELAY  100
27 #define CHECK_CNT    20
28 #define CHECK_TIME    30
29 
30 namespace OHOS {
31 namespace HDI {
32 namespace Usb {
33 namespace V1_0 {
34 class OnDemandLoadCallback : public SystemAbilityLoadCallbackStub {
35 public:
36     static bool loading_;
37     explicit OnDemandLoadCallback();
38 
39     void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr<IRemoteObject>& remoteObject);
40     void OnLoadSystemAbilityFail(int32_t systemAbilityId);
41 private:
42 };
43 
44 class UsbdLoadUsbService {
45 public:
46     UsbdLoadUsbService() = default;
47     ~UsbdLoadUsbService() = default;
48     static int32_t LoadUsbService();
49     static int32_t RemoveUsbService();
50     static void SetUsbLoadRemoveCount(uint32_t count);
51     static uint32_t GetUsbLoadRemoveCount();
52     static void CloseUsbService();
53 private:
54     static void IncreaseUsbLoadRemoveCount();
55     static void DecreaseUsbLoadRemoveCount();
56     static int32_t UsbLoadWorkEntry(void *para);
57     static int32_t StartThreadUsbLoad();
58     static void UsbRemoveWorkEntry(int32_t sig);
59     static bool alarmRunning_;
60     static uint32_t count_;
61 };
62 } // namespace V1_0
63 } // namespace Usb
64 } // namespace HDI
65 } // namespace OHOS
66 
67 #endif
68