blob: 15e7a78047659e3a253a96b780ef85c3bc605f87 [file] [log] [blame]
#include "aidl/android/aidl/tests/permission/IProtected.h"
#include <android/binder_parcel_utils.h>
#include <aidl/android/aidl/tests/permission/BnProtected.h>
#include <aidl/android/aidl/tests/permission/BpProtected.h>
namespace aidl {
namespace android {
namespace aidl {
namespace tests {
namespace permission {
static binder_status_t _aidl_android_aidl_tests_permission_IProtected_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
(void)_aidl_in;
(void)_aidl_out;
binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
std::shared_ptr<BnProtected> _aidl_impl = std::static_pointer_cast<BnProtected>(::ndk::ICInterface::asInterface(_aidl_binder));
switch (_aidl_code) {
case (FIRST_CALL_TRANSACTION + 0 /*PermissionProtected*/): {
::ndk::ScopedAStatus _aidl_status = _aidl_impl->PermissionProtected();
_aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
if (_aidl_ret_status != STATUS_OK) break;
if (!AStatus_isOk(_aidl_status.get())) break;
break;
}
case (FIRST_CALL_TRANSACTION + 1 /*MultiplePermissionsAll*/): {
::ndk::ScopedAStatus _aidl_status = _aidl_impl->MultiplePermissionsAll();
_aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
if (_aidl_ret_status != STATUS_OK) break;
if (!AStatus_isOk(_aidl_status.get())) break;
break;
}
case (FIRST_CALL_TRANSACTION + 2 /*MultiplePermissionsAny*/): {
::ndk::ScopedAStatus _aidl_status = _aidl_impl->MultiplePermissionsAny();
_aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
if (_aidl_ret_status != STATUS_OK) break;
if (!AStatus_isOk(_aidl_status.get())) break;
break;
}
}
return _aidl_ret_status;
}
static AIBinder_Class* _g_aidl_android_aidl_tests_permission_IProtected_clazz = ::ndk::ICInterface::defineClass(IProtected::descriptor, _aidl_android_aidl_tests_permission_IProtected_onTransact);
BpProtected::BpProtected(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
BpProtected::~BpProtected() {}
::ndk::ScopedAStatus BpProtected::PermissionProtected() {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
(FIRST_CALL_TRANSACTION + 0 /*PermissionProtected*/),
_aidl_in.getR(),
_aidl_out.getR(),
0
#ifdef BINDER_STABILITY_SUPPORT
| FLAG_PRIVATE_LOCAL
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IProtected::getDefaultImpl()) {
_aidl_status = IProtected::getDefaultImpl()->PermissionProtected();
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
::ndk::ScopedAStatus BpProtected::MultiplePermissionsAll() {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
(FIRST_CALL_TRANSACTION + 1 /*MultiplePermissionsAll*/),
_aidl_in.getR(),
_aidl_out.getR(),
0
#ifdef BINDER_STABILITY_SUPPORT
| FLAG_PRIVATE_LOCAL
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IProtected::getDefaultImpl()) {
_aidl_status = IProtected::getDefaultImpl()->MultiplePermissionsAll();
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
::ndk::ScopedAStatus BpProtected::MultiplePermissionsAny() {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
(FIRST_CALL_TRANSACTION + 2 /*MultiplePermissionsAny*/),
_aidl_in.getR(),
_aidl_out.getR(),
0
#ifdef BINDER_STABILITY_SUPPORT
| FLAG_PRIVATE_LOCAL
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IProtected::getDefaultImpl()) {
_aidl_status = IProtected::getDefaultImpl()->MultiplePermissionsAny();
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
// Source for BnProtected
BnProtected::BnProtected() {}
BnProtected::~BnProtected() {}
::ndk::SpAIBinder BnProtected::createBinder() {
AIBinder* binder = AIBinder_new(_g_aidl_android_aidl_tests_permission_IProtected_clazz, static_cast<void*>(this));
#ifdef BINDER_STABILITY_SUPPORT
AIBinder_markCompilationUnitStability(binder);
#endif // BINDER_STABILITY_SUPPORT
return ::ndk::SpAIBinder(binder);
}
// Source for IProtected
const char* IProtected::descriptor = "android.aidl.tests.permission.IProtected";
IProtected::IProtected() {}
IProtected::~IProtected() {}
std::shared_ptr<IProtected> IProtected::fromBinder(const ::ndk::SpAIBinder& binder) {
if (!AIBinder_associateClass(binder.get(), _g_aidl_android_aidl_tests_permission_IProtected_clazz)) { return nullptr; }
std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
if (interface) {
return std::static_pointer_cast<IProtected>(interface);
}
return ::ndk::SharedRefBase::make<BpProtected>(binder);
}
binder_status_t IProtected::writeToParcel(AParcel* parcel, const std::shared_ptr<IProtected>& instance) {
return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
}
binder_status_t IProtected::readFromParcel(const AParcel* parcel, std::shared_ptr<IProtected>* instance) {
::ndk::SpAIBinder binder;
binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
if (status != STATUS_OK) return status;
*instance = IProtected::fromBinder(binder);
return STATUS_OK;
}
bool IProtected::setDefaultImpl(const std::shared_ptr<IProtected>& impl) {
// Only one user of this interface can use this function
// at a time. This is a heuristic to detect if two different
// users in the same process use this function.
assert(!IProtected::default_impl);
if (impl) {
IProtected::default_impl = impl;
return true;
}
return false;
}
const std::shared_ptr<IProtected>& IProtected::getDefaultImpl() {
return IProtected::default_impl;
}
std::shared_ptr<IProtected> IProtected::default_impl = nullptr;
::ndk::ScopedAStatus IProtectedDefault::PermissionProtected() {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::ScopedAStatus IProtectedDefault::MultiplePermissionsAll() {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::ScopedAStatus IProtectedDefault::MultiplePermissionsAny() {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::SpAIBinder IProtectedDefault::asBinder() {
return ::ndk::SpAIBinder();
}
bool IProtectedDefault::isRemote() {
return false;
}
} // namespace permission
} // namespace tests
} // namespace aidl
} // namespace android
} // namespace aidl