1 /* 2 * Copyright (c) 2023 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_CLOUD_OAID_SERVICE_STUB_H 17 #define OHOS_CLOUD_OAID_SERVICE_STUB_H 18 19 #include <fstream> 20 #include <vector> 21 #include <map> 22 #include <string> 23 #include <pthread.h> 24 #include "cJSON.h" 25 #include "oaid_service_interface.h" 26 #include "ipc_skeleton.h" 27 #include "iremote_stub.h" 28 #include "event_handler.h" 29 #include "event_runner.h" 30 31 namespace OHOS { 32 namespace Cloud { 33 class OAIDServiceStub : public IRemoteStub<IOAIDService> { 34 public: 35 OAIDServiceStub(); 36 virtual ~OAIDServiceStub() override; 37 38 /* * 39 * Handle remote request. 40 * 41 * @param data Input param. 42 * @param reply Output param. 43 * @param option Message option. 44 * @return int32_t, return ERR_OK on success, others on failure. 45 */ 46 int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; 47 48 int32_t RegisterObserver(const sptr<IRemoteConfigObserver>& observer) override; 49 50 private: 51 int32_t OnGetOAID(MessageParcel& data, MessageParcel& reply); 52 int32_t OnResetOAID(MessageParcel& data, MessageParcel& reply); 53 int32_t SendCode(uint32_t code, MessageParcel &data, MessageParcel &reply); 54 int32_t HandleRegisterControlConfigObserver(MessageParcel& data, MessageParcel& reply); 55 56 bool CheckPermission(const std::string &permissionName); 57 bool CheckSystemApp(); 58 void ExitIdleState(); 59 void PostDelayUnloadTask(); 60 int32_t ValidateResetOAIDPermission(std::string bundleName, MessageParcel &reply); 61 62 std::shared_ptr<AppExecFwk::EventHandler> unloadHandler_; 63 std::mutex init_eventHandler_Mutex_; 64 }; 65 } // namespace Cloud 66 } // namespace OHOS 67 68 #endif // OHOS_CLOUD_OAID_SERVICE_STUB_H