blob: e4c73ea224354a5c051cf7512eb0449c5386a058 [file]
/*
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <aidl/android/nativeservice/BnNativeServiceWrapper.h>
#include <android/binder_auto_utils.h>
#include <android/binder_status.h>
#include <android/native_service.h>
#include <mutex>
#include <set>
using aidl::android::nativeservice::INativeServiceListener;
// A service implementation for test
class NativeServiceWrapper : public aidl::android::nativeservice::BnNativeServiceWrapper {
public:
NativeServiceWrapper() = default;
virtual ~NativeServiceWrapper() = default;
ndk::ScopedAStatus registerListener(
const std::shared_ptr<INativeServiceListener>& listener) override;
ndk::ScopedAStatus isLibraryMarkedPreloaded(bool* result) override;
ndk::ScopedAStatus getParentPid(int* result) override;
void doUnbind();
void doRebind();
private:
std::mutex mutex_; // a mutex for `listeners_`.
std::set<std::shared_ptr<INativeServiceListener>> listeners_;
};