1 /* 2 * Copyright (C) 2024-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 16 #ifndef DEVICE_AUTH_SA_H 17 #define DEVICE_AUTH_SA_H 18 19 #include <atomic> 20 #include "system_ability.h" 21 #include "iremote_broker.h" 22 #include "iremote_stub.h" 23 #include "nocopyable.h" 24 25 #include "ipc_dev_auth_stub.h" 26 27 namespace OHOS { 28 29 constexpr int SA_ID_DEVAUTH_SERVICE = 4701; 30 31 class DeviceAuthAbility : public SystemAbility, public ServiceDevAuth { 32 DECLARE_SYSTEM_ABILITY(DeviceAuthAbility); 33 34 public: 35 DISALLOW_COPY_AND_MOVE(DeviceAuthAbility); 36 DeviceAuthAbility(int saId, bool runOnCreate); 37 virtual ~DeviceAuthAbility(); 38 39 int32_t Dump(int32_t fd, const std::vector<std::u16string> &args) override; 40 int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, 41 MessageParcel &reply, MessageOption &option) override; 42 43 static sptr<DeviceAuthAbility> GetInstance(); 44 static void DestroyInstance(); 45 46 protected: 47 void OnStart() override; 48 void OnStop() override; 49 void OnActive(const SystemAbilityOnDemandReason &activeReason) override; 50 int32_t OnIdle(const SystemAbilityOnDemandReason &idleReason) override; 51 void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; 52 void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; 53 54 private: 55 DeviceAuthAbility(); 56 std::recursive_mutex instanceMutex_; 57 bool isUnloading_{false}; 58 }; 59 60 } // namespace OHOS 61 62 #endif