• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 DEVICE_INFO_SERVICE_H
17 #define DEVICE_INFO_SERVICE_H
18 
19 #include <atomic>
20 #include <mutex>
21 #include "beget_ext.h"
22 #include "iremote_stub.h"
23 #include "system_ability.h"
24 #include "device_info_stub.h"
25 
26 namespace OHOS {
27 namespace device_info {
28 
29 class DeviceInfoService : public SystemAbility, public DeviceInfoStub {
30 public:
31     DECLARE_SYSTEM_ABILITY(DeviceInfoService);
32     DISALLOW_COPY_AND_MOVE(DeviceInfoService);
33     explicit DeviceInfoService(int32_t systemAbilityId, bool runOnCreate = true)
SystemAbility(systemAbilityId,runOnCreate)34         : SystemAbility(systemAbilityId, runOnCreate)
35     {
36     }
~DeviceInfoService()37     ~DeviceInfoService() override {}
38 
39     int32_t GetUdid(std::string& result) override;
40     int32_t GetSerialID(std::string& result) override;
41     int32_t GetDiskSN(std::string& result) override;
42     int32_t CallbackEnter(uint32_t code) override;
43     int32_t CallbackExit(uint32_t code, int32_t result) override;
44 
45     static constexpr int ERR_FAIL = -1;
46 protected:
47     bool CheckPermission(const std::string &permission);
48     void OnStart(void) override;
49     void OnStop(void) override;
50     int Dump(int fd, const std::vector<std::u16string>& args) override;
51     void ThreadForUnloadSa(void);
52     std::atomic_bool threadStarted_ { false };
53 };
54 
55 } // namespace device_info
56 } // namespace OHOS
57 #endif // DEVICE_INFO_SERVICE_H