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