diff options
author | Xin Li <delphij@google.com> | 2023-08-28 22:13:10 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2023-08-28 22:13:10 +0000 |
commit | bd49f9e63cc092c4f87ddc681ca7bbea16424f73 (patch) | |
tree | 4ece4767605d73236d38ca4947df2ad5d4a4cf49 | |
parent | a85aab40e99578899e934248bf7b7a8887f2e61d (diff) | |
parent | 2a7e56725dde223eb749aa2d4231c9f52d9a4ccd (diff) | |
download | interfaces-bd49f9e63cc092c4f87ddc681ca7bbea16424f73.tar.gz |
Merge "Merge Android U (ab/10368041)" into aosp-main-future
156 files changed, 6767 insertions, 148 deletions
diff --git a/automotive/display/aidl/Android.bp b/automotive/display/aidl/Android.bp index 7edde63..8b2b7af 100644 --- a/automotive/display/aidl/Android.bp +++ b/automotive/display/aidl/Android.bp @@ -22,6 +22,9 @@ aidl_interface { srcs: ["android/frameworks/automotive/display/*.aidl"], stability: "vintf", imports: ["android.hardware.common-V2"], + include_dirs: [ + "frameworks/native/aidl/gui", + ], backend: { cpp: { enabled: false, @@ -34,6 +37,9 @@ aidl_interface { vndk: { enabled: false, }, + additional_shared_libraries: [ + "libnativewindow", + ], }, }, versions_with_info: [ @@ -41,6 +47,11 @@ aidl_interface { version: "1", imports: ["android.hardware.common-V2"], }, - ], + { + version: "2", + imports: ["android.hardware.common-V2"], + }, + ], + frozen: true, } diff --git a/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/.hash b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/.hash new file mode 100644 index 0000000..7e91586 --- /dev/null +++ b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/.hash @@ -0,0 +1 @@ +c9dbd700b8b71be6703e499f4ff798be245b088e diff --git a/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/DisplayDesc.aidl b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/DisplayDesc.aidl new file mode 100644 index 0000000..476f79f --- /dev/null +++ b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/DisplayDesc.aidl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.display; +@VintfStability +parcelable DisplayDesc { + int width; + int height; + long layer; + android.frameworks.automotive.display.Rotation orientation; +} diff --git a/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/ICarDisplayProxy.aidl b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/ICarDisplayProxy.aidl new file mode 100644 index 0000000..0a40d16 --- /dev/null +++ b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/ICarDisplayProxy.aidl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.display; +@VintfStability +interface ICarDisplayProxy { + long[] getDisplayIdList(); + android.frameworks.automotive.display.DisplayDesc getDisplayInfo(in long id); + /** + * @deprecated As of android.frameworks.automotive.display-V2, this method is deprecated and replaced with getSurface(). + */ + android.hardware.common.NativeHandle getHGraphicBufferProducer(in long id); + void hideWindow(in long id); + void showWindow(in long id); + android.view.Surface getSurface(in long id); +} diff --git a/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/Rotation.aidl b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/Rotation.aidl new file mode 100644 index 0000000..8c4c374 --- /dev/null +++ b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/2/android/frameworks/automotive/display/Rotation.aidl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.display; +@Backing(type="int") @VintfStability +enum Rotation { + ROTATION_0 = 0, + ROTATION_90 = 1, + ROTATION_180 = 2, + ROTATION_270 = 3, +} diff --git a/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/current/android/frameworks/automotive/display/ICarDisplayProxy.aidl b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/current/android/frameworks/automotive/display/ICarDisplayProxy.aidl index 643623a..0a40d16 100644 --- a/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/current/android/frameworks/automotive/display/ICarDisplayProxy.aidl +++ b/automotive/display/aidl/aidl_api/android.frameworks.automotive.display/current/android/frameworks/automotive/display/ICarDisplayProxy.aidl @@ -36,7 +36,11 @@ package android.frameworks.automotive.display; interface ICarDisplayProxy { long[] getDisplayIdList(); android.frameworks.automotive.display.DisplayDesc getDisplayInfo(in long id); + /** + * @deprecated As of android.frameworks.automotive.display-V2, this method is deprecated and replaced with getSurface(). + */ android.hardware.common.NativeHandle getHGraphicBufferProducer(in long id); void hideWindow(in long id); void showWindow(in long id); + android.view.Surface getSurface(in long id); } diff --git a/automotive/display/aidl/android/frameworks/automotive/display/ICarDisplayProxy.aidl b/automotive/display/aidl/android/frameworks/automotive/display/ICarDisplayProxy.aidl index e09c4bc..e79e549 100644 --- a/automotive/display/aidl/android/frameworks/automotive/display/ICarDisplayProxy.aidl +++ b/automotive/display/aidl/android/frameworks/automotive/display/ICarDisplayProxy.aidl @@ -18,16 +18,21 @@ package android.frameworks.automotive.display; import android.frameworks.automotive.display.DisplayDesc; import android.hardware.common.NativeHandle; +import android.view.Surface; /** * ICarDisplayProxy is an interface implemented by the car display proxy daemon and allows * the vendor processes to render their contents on the display via SurfaceFlinger. * - * To obtain a Surface associated with the target display, a client needs to call + * A client can obtain a Surface associated with the target display via + * ICarDisplayProxy.getSurface() and control the visibility of the target surface via + * ICarDisplayProxy.showWindow() and ICarDisplayProxy.hideWindow(). + * + * If a client uses ICarDisplayProxy.getHGraphicBufferProducer(), which is deprecated with + * android.frameworks.automotive.display-V2, a client should call * ICarDisplayProxy.getHGraphicBufferProducer() and convert a returned NativeHandle into * HGraphicBufferProducer. libbufferqueueconverter provides getSurfaceFromHGPB() to get - * the surface from a converted HGraphicBufferProducer. A client can control the visibility - * of a target surface via ICarDisplayProxy.showWindow() and ICarDisplayProxy.hideWindow(). + * the surface from a converted HGraphicBufferProducer. */ @VintfStability interface ICarDisplayProxy { @@ -55,6 +60,8 @@ interface ICarDisplayProxy { * @throws STATUS_FAILED_TRANSACTION if it fails to create the surface or read the display * information * STATUS_BAD_VALUE if it fails to create HGraphicBufferProducer + * @deprecated As of android.frameworks.automotive.display-V2, this method is deprecated and + * replaced with getSurface(). */ NativeHandle getHGraphicBufferProducer(in long id); @@ -77,4 +84,15 @@ interface ICarDisplayProxy { * Other STATUS_* if it fails to apply a SurfaceFlinger transaction. */ void showWindow(in long id); + + /** + * Gets a Surface associated with the target display. + * + * @param in id A stable ID of a target display. + * @return android.view.Surface object. + * @throws STATUS_FAILED_TRANSACTION if it fails to create the surface or read the display + * information + * STATUS_BAD_VALUE if it fails to create a Surface object. + */ + Surface getSurface(in long id); } diff --git a/automotive/display/aidl/vts/functional/Android.bp b/automotive/display/aidl/vts/functional/Android.bp new file mode 100644 index 0000000..657e47b --- /dev/null +++ b/automotive/display/aidl/vts/functional/Android.bp @@ -0,0 +1,53 @@ +// +// Copyright (C) 2023 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. +// + +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_test { + name: "VtsHalCarDisplayTargetTest", + srcs: [ + ":libgui_frame_event_aidl", + "./**/*.cpp", + ], + defaults: [ + "VtsHalTargetTestDefaults", + "use_libaidlvintf_gtest_helper_static", + ], + shared_libs: [ + "android.hardware.graphics.bufferqueue@2.0", + "android.hidl.token@1.0-utils", + "libbinder", + "libbinder_ndk", + "libnativewindow", + "libui", + "libgui", + ], + static_libs: [ + "android.frameworks.automotive.display-V2-ndk", + "android.hardware.common-V2-ndk", + "libaidlcommonsupport", + "libbufferqueueconverter", + ], + header_libs: [ + "libgui_aidl_headers", + ], + test_suites: [ + "general-tests", + "vts", + ], +} diff --git a/automotive/display/aidl/vts/functional/VtsHalCarDisplayTargetTest.cpp b/automotive/display/aidl/vts/functional/VtsHalCarDisplayTargetTest.cpp new file mode 100644 index 0000000..b3e4b5b --- /dev/null +++ b/automotive/display/aidl/vts/functional/VtsHalCarDisplayTargetTest.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2023 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. + */ + +#define LOG_TAG "VtsHalCarDisplayTest" + +#include <aidl/Gtest.h> +#include <aidl/Vintf.h> +#include <aidl/android/frameworks/automotive/display/DisplayDesc.h> +#include <aidl/android/frameworks/automotive/display/ICarDisplayProxy.h> +#include <aidlcommonsupport/NativeHandle.h> +#include <android-base/logging.h> +#include <android/binder_ibinder.h> +#include <android/binder_manager.h> +#include <android/binder_process.h> +#include <android/binder_status.h> +#include <bufferqueueconverter/BufferQueueConverter.h> + +namespace { + +using ::aidl::android::frameworks::automotive::display::DisplayDesc; +using ::aidl::android::frameworks::automotive::display::ICarDisplayProxy; +using ::aidl::android::hardware::common::NativeHandle; + +android::sp<HGraphicBufferProducer> convertNativeHandleToHGBP(const NativeHandle& aidlHandle) { + native_handle_t* handle = ::android::dupFromAidl(aidlHandle); + if (handle == nullptr || handle->numFds != 0 || + handle->numInts < std::ceil(sizeof(size_t) / sizeof(int))) { + LOG(ERROR) << "Invalid native handle"; + return nullptr; + } + android::hardware::hidl_vec<uint8_t> halToken; + halToken.setToExternal(reinterpret_cast<uint8_t*>(const_cast<int*>(&(handle->data[1]))), + handle->data[0]); + android::sp<HGraphicBufferProducer> hgbp = + HGraphicBufferProducer::castFrom(::android::retrieveHalInterface(halToken)); + return std::move(hgbp); +} + +} // namespace + +// The main test class for Automotive Display Service +class CarDisplayAidlTest : public ::testing::TestWithParam<std::string> { + public: + void SetUp() override { + // Make sure we can connect to the service + std::string serviceName = GetParam(); + AIBinder* binder = AServiceManager_waitForService(serviceName.data()); + ASSERT_NE(binder, nullptr); + mDisplayProxy = ICarDisplayProxy::fromBinder(ndk::SpAIBinder(binder)); + ASSERT_NE(mDisplayProxy, nullptr); + LOG(INFO) << "Test target service: " << serviceName; + + loadDisplayList(); + } + + void TearDown() override { + mDisplayProxy.reset(); + mDisplayIds.clear(); + } + + protected: + void loadDisplayList() { + ASSERT_TRUE(mDisplayProxy->getDisplayIdList(&mDisplayIds).isOk()); + LOG(INFO) << "We have " << mDisplayIds.size() << " displays."; + } + + std::shared_ptr<ICarDisplayProxy> mDisplayProxy; + std::vector<int64_t> mDisplayIds; +}; + +TEST_P(CarDisplayAidlTest, getIGBPObject) { + LOG(INFO) << "Test getHGraphicBufferProducer method"; + + for (const auto& id : mDisplayIds) { + // Get a display info. + DisplayDesc desc; + ASSERT_TRUE(mDisplayProxy->getDisplayInfo(id, &desc).isOk()); + + // Get a HGBP object as a native handle object. + NativeHandle handle; + ASSERT_TRUE(mDisplayProxy->getHGraphicBufferProducer(id, &handle).isOk()); + + // Convert a native handle object into a HGBP object. + android::sp<android::hardware::graphics::bufferqueue::V2_0::IGraphicBufferProducer> + gfxBufferProducer = convertNativeHandleToHGBP(handle); + ASSERT_NE(gfxBufferProducer, nullptr); + + // Create a Surface object. + android::SurfaceHolderUniquePtr surfaceHolder = getSurfaceFromHGBP(gfxBufferProducer); + ASSERT_NE(surfaceHolder, nullptr); + + // Verify the size. + ANativeWindow* nativeWindow = getNativeWindow(surfaceHolder.get()); + ASSERT_EQ(desc.width, ANativeWindow_getWidth(nativeWindow)); + ASSERT_EQ(desc.height, ANativeWindow_getHeight(nativeWindow)); + } +} + +TEST_P(CarDisplayAidlTest, showWindow) { + LOG(INFO) << "Test showWindow method"; + for (const auto& id : mDisplayIds) { + ASSERT_TRUE(mDisplayProxy->showWindow(id).isOk()); + } +} + +TEST_P(CarDisplayAidlTest, hideWindow) { + LOG(INFO) << "Test hideWindow method"; + + for (const auto& id : mDisplayIds) { + ASSERT_TRUE(mDisplayProxy->hideWindow(id).isOk()); + } +} + +TEST_P(CarDisplayAidlTest, getSurface) { + LOG(INFO) << "Test getSurface method"; + + for (const auto& id : mDisplayIds) { + // Get a display info. + DisplayDesc desc; + ASSERT_TRUE(mDisplayProxy->getDisplayInfo(id, &desc).isOk()); + + // Get a Surface object. + aidl::android::view::Surface shimSurface; + ASSERT_TRUE(mDisplayProxy->getSurface(id, &shimSurface).isOk()); + + // Verify the size. + ANativeWindow* nativeWindow = shimSurface.get(); + ASSERT_EQ(desc.width, ANativeWindow_getWidth(nativeWindow)); + ASSERT_EQ(desc.height, ANativeWindow_getHeight(nativeWindow)); + } +} + +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CarDisplayAidlTest); +INSTANTIATE_TEST_SUITE_P( + PerInstance, CarDisplayAidlTest, + testing::ValuesIn(android::getAidlHalInstanceNames(ICarDisplayProxy::descriptor)), + android::PrintInstanceNameToString); + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ABinderProcess_setThreadPoolMaxThreadCount(/* numThreads= */ 1); + ABinderProcess_startThreadPool(); + return RUN_ALL_TESTS(); +} diff --git a/automotive/powerpolicy/aidl/Android.bp b/automotive/powerpolicy/aidl/Android.bp index 97fd58d..6fbe047 100644 --- a/automotive/powerpolicy/aidl/Android.bp +++ b/automotive/powerpolicy/aidl/Android.bp @@ -38,7 +38,18 @@ aidl_interface { enabled: true, }, }, - versions: ["1"], + versions_with_info: [ + { + version: "1", + imports: [], + }, + { + version: "2", + imports: [], + }, + + ], + frozen: true, } aidl_interface { diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/.hash b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/.hash new file mode 100644 index 0000000..ec975f3 --- /dev/null +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/.hash @@ -0,0 +1 @@ +94ecd099d77943d070e40a17a65389d2c1f1445d diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl new file mode 100644 index 0000000..dced3c4 --- /dev/null +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.powerpolicy; +@VintfStability +parcelable CarPowerPolicy { + @utf8InCpp String policyId; + android.frameworks.automotive.powerpolicy.PowerComponent[] enabledComponents; + android.frameworks.automotive.powerpolicy.PowerComponent[] disabledComponents; + int[] enabledCustomComponents = {}; + int[] disabledCustomComponents = {}; +} diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl new file mode 100644 index 0000000..e2d0f8a --- /dev/null +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.powerpolicy; +@VintfStability +parcelable CarPowerPolicyFilter { + android.frameworks.automotive.powerpolicy.PowerComponent[] components; + int[] customComponents = {}; +} diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/ICarPowerPolicyChangeCallback.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/ICarPowerPolicyChangeCallback.aidl new file mode 100644 index 0000000..c5574a1 --- /dev/null +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/ICarPowerPolicyChangeCallback.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.powerpolicy; +@VintfStability +interface ICarPowerPolicyChangeCallback { + oneway void onPolicyChanged(in android.frameworks.automotive.powerpolicy.CarPowerPolicy policy); +} diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.aidl new file mode 100644 index 0000000..6372fa3 --- /dev/null +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.aidl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.powerpolicy; +@VintfStability +interface ICarPowerPolicyServer { + android.frameworks.automotive.powerpolicy.CarPowerPolicy getCurrentPowerPolicy(); + boolean getPowerComponentState(in android.frameworks.automotive.powerpolicy.PowerComponent componentId); + void registerPowerPolicyChangeCallback(in android.frameworks.automotive.powerpolicy.ICarPowerPolicyChangeCallback callback, in android.frameworks.automotive.powerpolicy.CarPowerPolicyFilter filter); + void unregisterPowerPolicyChangeCallback(in android.frameworks.automotive.powerpolicy.ICarPowerPolicyChangeCallback callback); +} diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/PowerComponent.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/PowerComponent.aidl new file mode 100644 index 0000000..6c933df --- /dev/null +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/2/android/frameworks/automotive/powerpolicy/PowerComponent.aidl @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2020 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.powerpolicy; +@Backing(type="int") @VintfStability +enum PowerComponent { + AUDIO = 1, + MEDIA = 2, + DISPLAY = 3, + BLUETOOTH = 4, + WIFI = 5, + CELLULAR = 6, + ETHERNET = 7, + PROJECTION = 8, + NFC = 9, + INPUT = 10, + VOICE_INTERACTION = 11, + VISUAL_INTERACTION = 12, + TRUSTED_DEVICE_DETECTION = 13, + LOCATION = 14, + MICROPHONE = 15, + CPU = 16, + MINIMUM_CUSTOM_COMPONENT_VALUE = 1000, +} diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl index 3750dbb..dced3c4 100644 --- a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl @@ -12,7 +12,8 @@ * 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. - *//////////////////////////////////////////////////////////////////////////////// + */ +/////////////////////////////////////////////////////////////////////////////// // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // /////////////////////////////////////////////////////////////////////////////// @@ -36,4 +37,6 @@ parcelable CarPowerPolicy { @utf8InCpp String policyId; android.frameworks.automotive.powerpolicy.PowerComponent[] enabledComponents; android.frameworks.automotive.powerpolicy.PowerComponent[] disabledComponents; + int[] enabledCustomComponents = {}; + int[] disabledCustomComponents = {}; } diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl index 45792a6..e2d0f8a 100644 --- a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl @@ -12,7 +12,8 @@ * 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. - *//////////////////////////////////////////////////////////////////////////////// + */ +/////////////////////////////////////////////////////////////////////////////// // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // /////////////////////////////////////////////////////////////////////////////// @@ -34,4 +35,5 @@ package android.frameworks.automotive.powerpolicy; @VintfStability parcelable CarPowerPolicyFilter { android.frameworks.automotive.powerpolicy.PowerComponent[] components; + int[] customComponents = {}; } diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/ICarPowerPolicyChangeCallback.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/ICarPowerPolicyChangeCallback.aidl index aa6777e..c5574a1 100644 --- a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/ICarPowerPolicyChangeCallback.aidl +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/ICarPowerPolicyChangeCallback.aidl @@ -12,7 +12,8 @@ * 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. - *//////////////////////////////////////////////////////////////////////////////// + */ +/////////////////////////////////////////////////////////////////////////////// // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // /////////////////////////////////////////////////////////////////////////////// diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.aidl index e75bfd0..6372fa3 100644 --- a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.aidl +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.aidl @@ -12,7 +12,8 @@ * 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. - *//////////////////////////////////////////////////////////////////////////////// + */ +/////////////////////////////////////////////////////////////////////////////// // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // /////////////////////////////////////////////////////////////////////////////// diff --git a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/PowerComponent.aidl b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/PowerComponent.aidl index 2b289f6..6c933df 100644 --- a/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/PowerComponent.aidl +++ b/automotive/powerpolicy/aidl/aidl_api/android.frameworks.automotive.powerpolicy/current/android/frameworks/automotive/powerpolicy/PowerComponent.aidl @@ -12,7 +12,8 @@ * 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. - *//////////////////////////////////////////////////////////////////////////////// + */ +/////////////////////////////////////////////////////////////////////////////// // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // /////////////////////////////////////////////////////////////////////////////// @@ -49,4 +50,5 @@ enum PowerComponent { LOCATION = 14, MICROPHONE = 15, CPU = 16, + MINIMUM_CUSTOM_COMPONENT_VALUE = 1000, } diff --git a/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl b/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl index 80267e6..9128786 100644 --- a/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl +++ b/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicy.aidl @@ -38,4 +38,14 @@ parcelable CarPowerPolicy { * List of power components to be disabled. */ PowerComponent[] disabledComponents; + + /** + * List of custom power components to be enabled. + */ + int[] enabledCustomComponents = {}; + + /** + * List of custom power components to be disabled. + */ + int[] disabledCustomComponents = {}; } diff --git a/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl b/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl index 86289cd..fbe329a 100644 --- a/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl +++ b/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.aidl @@ -29,4 +29,9 @@ parcelable CarPowerPolicyFilter { * List of power components of interest. */ PowerComponent[] components; + + /** + * List of custom power components of interest + */ + int[] customComponents = {}; } diff --git a/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/PowerComponent.aidl b/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/PowerComponent.aidl index d92cdaf..8fa3b13 100644 --- a/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/PowerComponent.aidl +++ b/automotive/powerpolicy/aidl/android/frameworks/automotive/powerpolicy/PowerComponent.aidl @@ -103,4 +103,9 @@ enum PowerComponent { * state when system gets out of sleep state. */ CPU = 16, + + /** + * This is minimal value for custom OEM component values. + */ + MINIMUM_CUSTOM_COMPONENT_VALUE = 1000, } diff --git a/automotive/powerpolicy/aidl/vts/Android.bp b/automotive/powerpolicy/aidl/vts/Android.bp index 39ebbe6..a382bc0 100644 --- a/automotive/powerpolicy/aidl/vts/Android.bp +++ b/automotive/powerpolicy/aidl/vts/Android.bp @@ -32,11 +32,11 @@ cc_test { "libbinder_ndk", ], static_libs: [ - "android.frameworks.automotive.powerpolicy-V1-ndk", + "android.frameworks.automotive.powerpolicy-V2-ndk", "libgmock", ], test_suites: [ "general-tests", "vts", ], -}
\ No newline at end of file +} diff --git a/automotive/powerpolicy/aidl/vts/VtsAidlPowerPolicyTargetTest.cpp b/automotive/powerpolicy/aidl/vts/VtsAidlPowerPolicyTargetTest.cpp index 402d291..454c3f1 100644 --- a/automotive/powerpolicy/aidl/vts/VtsAidlPowerPolicyTargetTest.cpp +++ b/automotive/powerpolicy/aidl/vts/VtsAidlPowerPolicyTargetTest.cpp @@ -21,6 +21,7 @@ #include <aidl/android/frameworks/automotive/powerpolicy/CarPowerPolicyFilter.h> #include <aidl/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.h> #include <aidl/android/frameworks/automotive/powerpolicy/PowerComponent.h> +#include <android-base/stringprintf.h> #include <android/binder_auto_utils.h> #include <android/binder_manager.h> #include <android/binder_status.h> @@ -40,6 +41,7 @@ using ::android::ProcessState; using ::android::status_t; using ::android::String16; using ::android::UNKNOWN_ERROR; +using ::android::base::StringPrintf; using ::ndk::ScopedAStatus; using ::ndk::SpAIBinder; @@ -76,9 +78,12 @@ TEST_P(PowerPolicyAidlTest, TestGetCurrentPowerPolicy) { TEST_P(PowerPolicyAidlTest, TestGetPowerComponentState) { bool state; for (const auto componentId : ndk::enum_range<PowerComponent>()) { + if (componentId >= PowerComponent::MINIMUM_CUSTOM_COMPONENT_VALUE) { + continue; + } ScopedAStatus status = powerPolicyServer->getPowerComponentState(componentId, &state); - - ASSERT_TRUE(status.isOk()); + std::string errMsg = StringPrintf("Getting state of component(%d) fails", componentId); + ASSERT_TRUE(status.isOk()) << errMsg; } } diff --git a/automotive/telemetry/aidl/Android.bp b/automotive/telemetry/aidl/Android.bp index 6379c35..944a94c 100644 --- a/automotive/telemetry/aidl/Android.bp +++ b/automotive/telemetry/aidl/Android.bp @@ -32,7 +32,7 @@ aidl_interface { enabled: true, }, java: { - sdk_version: "module_current", + sdk_version: "module_current", min_sdk_version: "31", apex_available: [ "//apex_available:platform", @@ -44,9 +44,22 @@ aidl_interface { enabled: true, }, }, + versions_with_info: [ + { + version: "1", + imports: [], + }, + { + version: "2", + imports: [], + }, + + ], + frozen: true, + // Run "m android.frameworks.automotive.telemetry-freeze-api" to bump the version. Freeze the // version only during the release. // Run "m android.frameworks.automotive.telemetry-update-api" to update the // "aidl_api/.../current/" dir. - versions: ["1"], + } diff --git a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/.hash b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/.hash new file mode 100644 index 0000000..a556cca --- /dev/null +++ b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/.hash @@ -0,0 +1 @@ +0067842a41ff513323a7f23d835aace691d1509d diff --git a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/CallbackConfig.aidl b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/CallbackConfig.aidl new file mode 100644 index 0000000..7351883 --- /dev/null +++ b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/CallbackConfig.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021, 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.telemetry; +@VintfStability +parcelable CallbackConfig { + int[] carDataIds; +} diff --git a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/CarData.aidl b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/CarData.aidl new file mode 100644 index 0000000..4e400b1 --- /dev/null +++ b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/CarData.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021, 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.telemetry; +@VintfStability +parcelable CarData { + int id; + byte[] content; +} diff --git a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/ICarTelemetry.aidl b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/ICarTelemetry.aidl new file mode 100644 index 0000000..531c955 --- /dev/null +++ b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/ICarTelemetry.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021, 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.telemetry; +@VintfStability +interface ICarTelemetry { + void write(in android.frameworks.automotive.telemetry.CarData[] dataList); + void addCallback(in android.frameworks.automotive.telemetry.CallbackConfig config, in android.frameworks.automotive.telemetry.ICarTelemetryCallback callback); + void removeCallback(in android.frameworks.automotive.telemetry.ICarTelemetryCallback callback); +} diff --git a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl new file mode 100644 index 0000000..2241e29 --- /dev/null +++ b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/2/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022, 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.telemetry; +@VintfStability +interface ICarTelemetryCallback { + void onChange(in int[] ids); +} diff --git a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/CallbackConfig.aidl b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/CallbackConfig.aidl new file mode 100644 index 0000000..7351883 --- /dev/null +++ b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/CallbackConfig.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021, 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.telemetry; +@VintfStability +parcelable CallbackConfig { + int[] carDataIds; +} diff --git a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/ICarTelemetry.aidl b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/ICarTelemetry.aidl index bdf5631..531c955 100644 --- a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/ICarTelemetry.aidl +++ b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/ICarTelemetry.aidl @@ -35,4 +35,6 @@ package android.frameworks.automotive.telemetry; @VintfStability interface ICarTelemetry { void write(in android.frameworks.automotive.telemetry.CarData[] dataList); + void addCallback(in android.frameworks.automotive.telemetry.CallbackConfig config, in android.frameworks.automotive.telemetry.ICarTelemetryCallback callback); + void removeCallback(in android.frameworks.automotive.telemetry.ICarTelemetryCallback callback); } diff --git a/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl new file mode 100644 index 0000000..2241e29 --- /dev/null +++ b/automotive/telemetry/aidl/aidl_api/android.frameworks.automotive.telemetry/current/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022, 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.automotive.telemetry; +@VintfStability +interface ICarTelemetryCallback { + void onChange(in int[] ids); +} diff --git a/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/CallbackConfig.aidl b/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/CallbackConfig.aidl new file mode 100644 index 0000000..c477e63 --- /dev/null +++ b/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/CallbackConfig.aidl @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021, 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. + */ + +package android.frameworks.automotive.telemetry; + +/** + * Configurations associated with a ICarTelemetryCallback. + * + * <p>Contents of this object should not be parsed by Android framework. + * + * <p>Please see {@link ICarTelemetry#addCallback(CallbackConfig, ICarTelemetryCallback)}. + */ +@VintfStability +parcelable CallbackConfig { + /** + * A list of CarData IDs that the callback is interested in. + * + * <p>The callback will only be invoked for the IDs declared in the CallbackConfig. + */ + int[] carDataIds; +} diff --git a/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/ICarTelemetry.aidl b/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/ICarTelemetry.aidl index f3256d5..c71d670 100644 --- a/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/ICarTelemetry.aidl +++ b/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/ICarTelemetry.aidl @@ -16,7 +16,9 @@ package android.frameworks.automotive.telemetry; +import android.frameworks.automotive.telemetry.CallbackConfig; import android.frameworks.automotive.telemetry.CarData; +import android.frameworks.automotive.telemetry.ICarTelemetryCallback; /** * This service collects data from varios other services, buffers them, and delivers to the @@ -33,4 +35,21 @@ interface ICarTelemetry { * @throws IllegalArgumentException if total {@code dataList#content} size is more than 10KB. */ void write(in CarData[] dataList); + + /** + * Adds a ICarTelemetryCallback. + * + * <p>Make sure to call {@code removeCallback} when the callback is no longer active + * or when the CallbackConfig needs to be updated. + * + * @param callback The callback to receive cartelemetryd updates. + */ + void addCallback(in CallbackConfig config, in ICarTelemetryCallback callback); + + /** + * Removes a ICarTelemetryCallback from receiving updates from cartelemetryd. + * + * @param callback The callback to receive cartelemetryd updates. + */ + void removeCallback(in ICarTelemetryCallback callback); } diff --git a/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl b/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl new file mode 100644 index 0000000..ea7de80 --- /dev/null +++ b/automotive/telemetry/aidl/android/frameworks/automotive/telemetry/ICarTelemetryCallback.aidl @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022, 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. + */ + +package android.frameworks.automotive.telemetry; + +/** + * Callback for cartelemetryd, used by vendor data-collecting components. + * + * <p>When this interface is extended in the future, the service must check the interface + * version to ensure compatibility. See + * https://source.android.com/docs/core/architecture/aidl/stable-aidl#querying-the-interface-version-of-the-remote-object + */ +@VintfStability +interface ICarTelemetryCallback { + + /** + * Notifies client of currently active CarData IDs that the callback is associated with. + * + * This is the new set of IDs that we want them to publish. + */ + void onChange(in int[] ids); +} diff --git a/automotive/telemetry/aidl/vts/functional/Android.bp b/automotive/telemetry/aidl/vts/functional/Android.bp index fafe437..82009bd 100644 --- a/automotive/telemetry/aidl/vts/functional/Android.bp +++ b/automotive/telemetry/aidl/vts/functional/Android.bp @@ -28,7 +28,7 @@ cc_test { static_libs: [ "libgflags", "libgmock", - "android.frameworks.automotive.telemetry-V1-ndk", + "android.frameworks.automotive.telemetry-V2-ndk", ], test_suites: [ "general-tests", diff --git a/automotive/telemetry/aidl/vts/functional/VtsHalCarTelemetryTest.cpp b/automotive/telemetry/aidl/vts/functional/VtsHalCarTelemetryTest.cpp index 763a381..5aa606a 100644 --- a/automotive/telemetry/aidl/vts/functional/VtsHalCarTelemetryTest.cpp +++ b/automotive/telemetry/aidl/vts/functional/VtsHalCarTelemetryTest.cpp @@ -17,6 +17,8 @@ #include <aidl/Gtest.h> #include <aidl/Vintf.h> +#include <aidl/android/frameworks/automotive/telemetry/BnCarTelemetryCallback.h> +#include <aidl/android/frameworks/automotive/telemetry/CallbackConfig.h> #include <aidl/android/frameworks/automotive/telemetry/CarData.h> #include <aidl/android/frameworks/automotive/telemetry/ICarTelemetry.h> #include <android-base/logging.h> @@ -35,8 +37,26 @@ namespace frameworks { namespace automotive { namespace telemetry { +using ::aidl::android::frameworks::automotive::telemetry::BnCarTelemetryCallback; +using ::aidl::android::frameworks::automotive::telemetry::CallbackConfig; using ::aidl::android::frameworks::automotive::telemetry::CarData; using ::aidl::android::frameworks::automotive::telemetry::ICarTelemetry; +using ::ndk::ScopedAStatus; + +class MockCarTelemetryCallback : public BnCarTelemetryCallback { + public: + MockCarTelemetryCallback() {} + + ScopedAStatus onChange([[maybe_unused]] const std::vector<int32_t>& ids) override { + return ScopedAStatus::ok(); + } +}; + +CallbackConfig buildConfig(const std::vector<int32_t>& ids) { + CallbackConfig config; + config.carDataIds = ids; + return config; +} CarData buildCarData(int id, const std::vector<uint8_t>& content) { CarData msg; @@ -66,6 +86,47 @@ TEST_P(CarTelemetryTest, writeReturnsOk) { EXPECT_TRUE(status.isOk()) << status.getMessage(); } +TEST_P(CarTelemetryTest, AddCallbackReturnsOk) { + CallbackConfig config = buildConfig({101, 102, 103}); + std::shared_ptr<MockCarTelemetryCallback> callback = + ndk::SharedRefBase::make<MockCarTelemetryCallback>(); + + auto status = mService->addCallback(config, callback); + + EXPECT_TRUE(status.isOk()) << status.getMessage(); +} + +TEST_P(CarTelemetryTest, AddCallbackErrorsWhenDuplicate) { + CallbackConfig config = buildConfig({101, 102, 103}); + std::shared_ptr<MockCarTelemetryCallback> callback = + ndk::SharedRefBase::make<MockCarTelemetryCallback>(); + mService->addCallback(config, callback); + + auto status = mService->addCallback(config, callback); + + EXPECT_FALSE(status.isOk()) << status.getMessage(); +} + +TEST_P(CarTelemetryTest, RemoveCallbackReturnsOk) { + CallbackConfig config = buildConfig({101, 102, 103}); + std::shared_ptr<MockCarTelemetryCallback> callback = + ndk::SharedRefBase::make<MockCarTelemetryCallback>(); + mService->addCallback(config, callback); + + auto status = mService->removeCallback(callback); + + EXPECT_TRUE(status.isOk()) << status.getMessage(); +} + +TEST_P(CarTelemetryTest, RemoveCallbackErrorsForNonexistentCallback) { + std::shared_ptr<MockCarTelemetryCallback> callback = + ndk::SharedRefBase::make<MockCarTelemetryCallback>(); + + auto status = mService->removeCallback(callback); + + EXPECT_FALSE(status.isOk()) << status.getMessage(); +} + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CarTelemetryTest); INSTANTIATE_TEST_SUITE_P( AutomotiveHal, CarTelemetryTest, diff --git a/cameraservice/common/aidl/Android.bp b/cameraservice/common/aidl/Android.bp new file mode 100644 index 0000000..9916d3c --- /dev/null +++ b/cameraservice/common/aidl/Android.bp @@ -0,0 +1,32 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +aidl_interface { + name: "android.frameworks.cameraservice.common", + vendor_available: true, + srcs: ["android/frameworks/cameraservice/common/*.aidl"], + stability: "vintf", + frozen: true, + backend: { + cpp: { + enabled: false, + }, + java: { + enabled: false, + }, + ndk: { + vndk: { + enabled: true, + }, + }, + }, + vndk_use_version: "1", + versions_with_info: [ + { + version: "1", + imports: [], + }, + ], + +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/.hash b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/.hash new file mode 100644 index 0000000..b6195c4 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/.hash @@ -0,0 +1 @@ +4866f510363316b02a311bd8fa256f1fd073bc1d diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/CameraMetadataType.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/CameraMetadataType.aidl new file mode 100644 index 0000000..bce3c87 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/CameraMetadataType.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@Backing(type="int") @VintfStability +enum CameraMetadataType { + BYTE = 0, + INT32 = 1, + FLOAT = 2, + INT64 = 3, + DOUBLE = 4, + RATIONAL = 5, +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl new file mode 100644 index 0000000..0c5d73c --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@VintfStability +parcelable ProviderIdAndVendorTagSections { + long providerId; + android.frameworks.cameraservice.common.VendorTagSection[] vendorTagSections; +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/Status.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/Status.aidl new file mode 100644 index 0000000..4bef589 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/Status.aidl @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@Backing(type="int") @VintfStability +enum Status { + NO_ERROR = 0, + PERMISSION_DENIED = 1, + ALREADY_EXISTS = 2, + ILLEGAL_ARGUMENT = 3, + DISCONNECTED = 4, + TIMED_OUT = 5, + DISABLED = 6, + CAMERA_IN_USE = 7, + MAX_CAMERAS_IN_USE = 8, + DEPRECATED_HAL = 9, + INVALID_OPERATION = 10, + UNKNOWN_ERROR = 11, +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/TagBoundaryId.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/TagBoundaryId.aidl new file mode 100644 index 0000000..ee6ffa0 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/TagBoundaryId.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@Backing(type="long") @VintfStability +enum TagBoundaryId { + AOSP = 0x0, + VENDOR = 0x80000000L, +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/VendorTag.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/VendorTag.aidl new file mode 100644 index 0000000..22b9d5e --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/VendorTag.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@VintfStability +parcelable VendorTag { + long tagId; + String tagName; + android.frameworks.cameraservice.common.CameraMetadataType tagType; +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/VendorTagSection.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/VendorTagSection.aidl new file mode 100644 index 0000000..8b741f9 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/1/android/frameworks/cameraservice/common/VendorTagSection.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@VintfStability +parcelable VendorTagSection { + String sectionName; + android.frameworks.cameraservice.common.VendorTag[] tags; +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/CameraMetadataType.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/CameraMetadataType.aidl new file mode 100644 index 0000000..bce3c87 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/CameraMetadataType.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@Backing(type="int") @VintfStability +enum CameraMetadataType { + BYTE = 0, + INT32 = 1, + FLOAT = 2, + INT64 = 3, + DOUBLE = 4, + RATIONAL = 5, +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl new file mode 100644 index 0000000..0c5d73c --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@VintfStability +parcelable ProviderIdAndVendorTagSections { + long providerId; + android.frameworks.cameraservice.common.VendorTagSection[] vendorTagSections; +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/Status.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/Status.aidl new file mode 100644 index 0000000..4bef589 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/Status.aidl @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@Backing(type="int") @VintfStability +enum Status { + NO_ERROR = 0, + PERMISSION_DENIED = 1, + ALREADY_EXISTS = 2, + ILLEGAL_ARGUMENT = 3, + DISCONNECTED = 4, + TIMED_OUT = 5, + DISABLED = 6, + CAMERA_IN_USE = 7, + MAX_CAMERAS_IN_USE = 8, + DEPRECATED_HAL = 9, + INVALID_OPERATION = 10, + UNKNOWN_ERROR = 11, +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/TagBoundaryId.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/TagBoundaryId.aidl new file mode 100644 index 0000000..ee6ffa0 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/TagBoundaryId.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@Backing(type="long") @VintfStability +enum TagBoundaryId { + AOSP = 0x0, + VENDOR = 0x80000000L, +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/VendorTag.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/VendorTag.aidl new file mode 100644 index 0000000..22b9d5e --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/VendorTag.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@VintfStability +parcelable VendorTag { + long tagId; + String tagName; + android.frameworks.cameraservice.common.CameraMetadataType tagType; +} diff --git a/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/VendorTagSection.aidl b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/VendorTagSection.aidl new file mode 100644 index 0000000..8b741f9 --- /dev/null +++ b/cameraservice/common/aidl/aidl_api/android.frameworks.cameraservice.common/current/android/frameworks/cameraservice/common/VendorTagSection.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.common; +@VintfStability +parcelable VendorTagSection { + String sectionName; + android.frameworks.cameraservice.common.VendorTag[] tags; +} diff --git a/cameraservice/common/aidl/android/frameworks/cameraservice/common/CameraMetadataType.aidl b/cameraservice/common/aidl/android/frameworks/cameraservice/common/CameraMetadataType.aidl new file mode 100644 index 0000000..ccb2aeb --- /dev/null +++ b/cameraservice/common/aidl/android/frameworks/cameraservice/common/CameraMetadataType.aidl @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.common; + +/** + * Camera metadata type. + */ +@VintfStability +@Backing(type="int") +enum CameraMetadataType { + /** + * Unsigned 8-bit integer (uint8_t) + */ + BYTE = 0, + /** + * Signed 32-bit integer (int32_t) + */ + INT32 = 1, + /** + * 32-bit float (float) + */ + FLOAT = 2, + /** + * Signed 64-bit integer (int64_t) + */ + INT64 = 3, + /** + * 64-bit float (double) + */ + DOUBLE = 4, + /** + * A 64-bit fraction (camera_metadata_rational_t) + */ + RATIONAL = 5, +} diff --git a/cameraservice/common/aidl/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl b/cameraservice/common/aidl/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl new file mode 100644 index 0000000..b7d4653 --- /dev/null +++ b/cameraservice/common/aidl/android/frameworks/cameraservice/common/ProviderIdAndVendorTagSections.aidl @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.common; + +import android.frameworks.cameraservice.common.VendorTagSection; + +@VintfStability +parcelable ProviderIdAndVendorTagSections { + /** + * provider id + */ + long providerId; + /** + * List of VendorTagSections provided by this provider + */ + VendorTagSection[] vendorTagSections; +} diff --git a/cameraservice/common/aidl/android/frameworks/cameraservice/common/Status.aidl b/cameraservice/common/aidl/android/frameworks/cameraservice/common/Status.aidl new file mode 100644 index 0000000..2cf868a --- /dev/null +++ b/cameraservice/common/aidl/android/frameworks/cameraservice/common/Status.aidl @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.common; + +/** + * All camera service and device AIDL calls may return the following + * status codes + */ +@VintfStability +@Backing(type="int") +enum Status { + /** + * Call succeeded. + */ + NO_ERROR = 0, + /** + * Call failed due to inadequete permissions. + */ + PERMISSION_DENIED = 1, + /** + * Call tried added something that already existed, eg: add a duplicate + * listener. + */ + ALREADY_EXISTS = 2, + /** + * Call received illegal argument. + */ + ILLEGAL_ARGUMENT = 3, + /** + * The camera device is no longer connected. + */ + DISCONNECTED = 4, + /** + * Request timed out. + */ + TIMED_OUT = 5, + /** + * The device has been disabled by policy. + */ + DISABLED = 6, + /** + * The camera device is currently in use. + */ + CAMERA_IN_USE = 7, + /** + * Too many cameras are connected, more cameras cannot be opened. + */ + MAX_CAMERAS_IN_USE = 8, + /** + * Camera server is using a camera HAL version that does not support + * the current version of android.frameworks.cameraservice.service.ICameraService + * and android.frameworks.cameraservice.device.ICameraDeviceUser. + */ + DEPRECATED_HAL = 9, + /** + * An invalid operation was attempted by the client. Eg: a waitUntilIdle() + * call was made, with active repeating requests. + */ + INVALID_OPERATION = 10, + /** + * An unknown error was encountered by the camera subsystem. + */ + UNKNOWN_ERROR = 11, +} diff --git a/cameraservice/common/aidl/android/frameworks/cameraservice/common/TagBoundaryId.aidl b/cameraservice/common/aidl/android/frameworks/cameraservice/common/TagBoundaryId.aidl new file mode 100644 index 0000000..963bfd3 --- /dev/null +++ b/cameraservice/common/aidl/android/frameworks/cameraservice/common/TagBoundaryId.aidl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.common; + +/** + * Boundaries for VendorTag tagIds. + */ +@VintfStability +@Backing(type="long") +enum TagBoundaryId { + /** + * First valid tag id for android-defined tags. + */ + AOSP = 0x0, + /** + * First valid tag id for vendor extension tags. + */ + VENDOR = 0x80000000L // 1 << 31 +} diff --git a/cameraservice/common/aidl/android/frameworks/cameraservice/common/VendorTag.aidl b/cameraservice/common/aidl/android/frameworks/cameraservice/common/VendorTag.aidl new file mode 100644 index 0000000..3ba1621 --- /dev/null +++ b/cameraservice/common/aidl/android/frameworks/cameraservice/common/VendorTag.aidl @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.common; + +import android.frameworks.cameraservice.common.CameraMetadataType; + +/** + * A single vendor-unique metadata tag. + * The full name of the tag is <sectionName>.<tagName> + */ +@VintfStability +parcelable VendorTag { + /** + * Tag identifier, must be >= TagBoundaryId::VENDOR. + */ + long tagId; + /** + * Name of tag, not including section name. + */ + String tagName; + + CameraMetadataType tagType; +} diff --git a/cameraservice/common/aidl/android/frameworks/cameraservice/common/VendorTagSection.aidl b/cameraservice/common/aidl/android/frameworks/cameraservice/common/VendorTagSection.aidl new file mode 100644 index 0000000..dbe8b91 --- /dev/null +++ b/cameraservice/common/aidl/android/frameworks/cameraservice/common/VendorTagSection.aidl @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.common; + +import android.frameworks.cameraservice.common.VendorTag; + +/** + * A set of related vendor tags. + */ +@VintfStability +parcelable VendorTagSection { + /** + * Section name; must be namespaced within vendor's name. + */ + String sectionName; + /** + * List of tags in this section + */ + VendorTag[] tags; +} diff --git a/cameraservice/device/aidl/Android.bp b/cameraservice/device/aidl/Android.bp new file mode 100644 index 0000000..f22ad83 --- /dev/null +++ b/cameraservice/device/aidl/Android.bp @@ -0,0 +1,41 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +aidl_interface { + name: "android.frameworks.cameraservice.device", + vendor_available: true, + srcs: ["android/frameworks/cameraservice/device/*.aidl"], + stability: "vintf", + imports: [ + "android.frameworks.cameraservice.common-V1", + "android.hardware.common.fmq-V1", + "android.hardware.common-V2", + ], + frozen: true, + backend: { + cpp: { + enabled: false, + }, + java: { + enabled: false, + }, + ndk: { + vndk: { + enabled: true, + }, + }, + }, + vndk_use_version: "1", + versions_with_info: [ + { + version: "1", + imports: [ + "android.frameworks.cameraservice.common-V1", + "android.hardware.common.fmq-V1", + "android.hardware.common-V2", + ], + }, + ], + +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/.hash b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/.hash new file mode 100644 index 0000000..7bbd225 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/.hash @@ -0,0 +1 @@ +acf6819da94dc452c4fa1e831c96f324a2be805a diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CameraMetadata.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CameraMetadata.aidl new file mode 100644 index 0000000..08a1310 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CameraMetadata.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable CameraMetadata { + byte[] metadata; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl new file mode 100644 index 0000000..c1d1761 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +union CaptureMetadataInfo { + long fmqMetadataSize; + android.frameworks.cameraservice.device.CameraMetadata metadata; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureRequest.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureRequest.aidl new file mode 100644 index 0000000..a19dd10 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureRequest.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable CaptureRequest { + android.frameworks.cameraservice.device.PhysicalCameraSettings[] physicalCameraSettings; + android.frameworks.cameraservice.device.StreamAndWindowId[] streamAndWindowIds; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureResultExtras.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureResultExtras.aidl new file mode 100644 index 0000000..2bd2253 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/CaptureResultExtras.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable CaptureResultExtras { + int requestId; + int burstId; + long frameNumber; + int partialResultCount; + int errorStreamId; + String errorPhysicalCameraId; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ErrorCode.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ErrorCode.aidl new file mode 100644 index 0000000..9c361f0 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ErrorCode.aidl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@Backing(type="int") @VintfStability +enum ErrorCode { + CAMERA_INVALID_ERROR = (-1) /* -1 */, + CAMERA_DISCONNECTED = 0, + CAMERA_DEVICE = 1, + CAMERA_SERVICE = 2, + CAMERA_REQUEST = 3, + CAMERA_RESULT = 4, + CAMERA_BUFFER = 5, + CAMERA_DISABLED = 6, + CAMERA_UNKNOWN_ERROR = 7, +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl new file mode 100644 index 0000000..093ff80 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +interface ICameraDeviceCallback { + oneway void onCaptureStarted(in android.frameworks.cameraservice.device.CaptureResultExtras resultExtras, in long timestamp); + oneway void onDeviceError(in android.frameworks.cameraservice.device.ErrorCode errorCode, in android.frameworks.cameraservice.device.CaptureResultExtras resultExtras); + oneway void onDeviceIdle(); + oneway void onPrepared(in int streamId); + oneway void onRepeatingRequestError(in long lastFrameNumber, in int repeatingRequestId); + oneway void onResultReceived(in android.frameworks.cameraservice.device.CaptureMetadataInfo result, in android.frameworks.cameraservice.device.CaptureResultExtras resultExtras, in android.frameworks.cameraservice.device.PhysicalCaptureResultInfo[] physicalCaptureResultInfos); +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl new file mode 100644 index 0000000..1b9b2c2 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +interface ICameraDeviceUser { + void beginConfigure(); + long cancelRepeatingRequest(); + android.frameworks.cameraservice.device.CameraMetadata createDefaultRequest(in android.frameworks.cameraservice.device.TemplateId templateId); + int createStream(in android.frameworks.cameraservice.device.OutputConfiguration outputConfiguration); + void deleteStream(in int streamId); + void disconnect(); + void endConfigure(in android.frameworks.cameraservice.device.StreamConfigurationMode operatingMode, in android.frameworks.cameraservice.device.CameraMetadata sessionParams, in long startTimeNs); + long flush(); + android.hardware.common.fmq.MQDescriptor<byte,android.hardware.common.fmq.SynchronizedReadWrite> getCaptureRequestMetadataQueue(); + android.hardware.common.fmq.MQDescriptor<byte,android.hardware.common.fmq.SynchronizedReadWrite> getCaptureResultMetadataQueue(); + boolean isSessionConfigurationSupported(in android.frameworks.cameraservice.device.SessionConfiguration sessionConfiguration); + void prepare(in int streamId); + android.frameworks.cameraservice.device.SubmitInfo submitRequestList(in android.frameworks.cameraservice.device.CaptureRequest[] requestList, in boolean isRepeating); + void updateOutputConfiguration(in int streamId, in android.frameworks.cameraservice.device.OutputConfiguration outputConfiguration); + void waitUntilIdle(); +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/OutputConfiguration.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/OutputConfiguration.aidl new file mode 100644 index 0000000..8943815 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/OutputConfiguration.aidl @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable OutputConfiguration { + android.hardware.common.NativeHandle[] windowHandles; + android.frameworks.cameraservice.device.OutputConfiguration.Rotation rotation; + int windowGroupId; + String physicalCameraId; + int width; + int height; + boolean isDeferred; + @Backing(type="int") @VintfStability + enum Rotation { + R0 = 0, + R90 = 1, + R180 = 2, + R270 = 3, + } + @Backing(type="int") @VintfStability + enum WindowGroupId { + NONE = (-1) /* -1 */, + } +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl new file mode 100644 index 0000000..622b3a1 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable PhysicalCameraSettings { + String id; + android.frameworks.cameraservice.device.CaptureMetadataInfo settings; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl new file mode 100644 index 0000000..7d1b1a9 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable PhysicalCaptureResultInfo { + String physicalCameraId; + android.frameworks.cameraservice.device.CaptureMetadataInfo physicalCameraMetadata; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/SessionConfiguration.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/SessionConfiguration.aidl new file mode 100644 index 0000000..f6f3773 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/SessionConfiguration.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable SessionConfiguration { + android.frameworks.cameraservice.device.OutputConfiguration[] outputStreams; + int inputWidth; + int inputHeight; + int inputFormat; + android.frameworks.cameraservice.device.StreamConfigurationMode operationMode; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/StreamAndWindowId.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/StreamAndWindowId.aidl new file mode 100644 index 0000000..23da63a --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/StreamAndWindowId.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable StreamAndWindowId { + int streamId; + int windowId; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl new file mode 100644 index 0000000..ff888f5 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@Backing(type="int") @VintfStability +enum StreamConfigurationMode { + NORMAL_MODE = 0, + CONSTRAINED_HIGH_SPEED_MODE = 1, + VENDOR_MODE_0 = 0x8000, + VENDOR_MODE_1, + VENDOR_MODE_2, + VENDOR_MODE_3, + VENDOR_MODE_4, + VENDOR_MODE_5, + VENDOR_MODE_6, + VENDOR_MODE_7, +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/SubmitInfo.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/SubmitInfo.aidl new file mode 100644 index 0000000..5154ed3 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/SubmitInfo.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable SubmitInfo { + int requestId; + long lastFrameNumber; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/TemplateId.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/TemplateId.aidl new file mode 100644 index 0000000..89c5d68 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/1/android/frameworks/cameraservice/device/TemplateId.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@Backing(type="int") @VintfStability +enum TemplateId { + PREVIEW = 1, + STILL_CAPTURE = 2, + RECORD = 3, + VIDEO_SNAPSHOT = 4, + ZERO_SHUTTER_LAG = 5, + MANUAL = 6, +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CameraMetadata.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CameraMetadata.aidl new file mode 100644 index 0000000..08a1310 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CameraMetadata.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable CameraMetadata { + byte[] metadata; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl new file mode 100644 index 0000000..c1d1761 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +union CaptureMetadataInfo { + long fmqMetadataSize; + android.frameworks.cameraservice.device.CameraMetadata metadata; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureRequest.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureRequest.aidl new file mode 100644 index 0000000..a19dd10 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureRequest.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable CaptureRequest { + android.frameworks.cameraservice.device.PhysicalCameraSettings[] physicalCameraSettings; + android.frameworks.cameraservice.device.StreamAndWindowId[] streamAndWindowIds; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureResultExtras.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureResultExtras.aidl new file mode 100644 index 0000000..2bd2253 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/CaptureResultExtras.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable CaptureResultExtras { + int requestId; + int burstId; + long frameNumber; + int partialResultCount; + int errorStreamId; + String errorPhysicalCameraId; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ErrorCode.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ErrorCode.aidl new file mode 100644 index 0000000..9c361f0 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ErrorCode.aidl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@Backing(type="int") @VintfStability +enum ErrorCode { + CAMERA_INVALID_ERROR = (-1) /* -1 */, + CAMERA_DISCONNECTED = 0, + CAMERA_DEVICE = 1, + CAMERA_SERVICE = 2, + CAMERA_REQUEST = 3, + CAMERA_RESULT = 4, + CAMERA_BUFFER = 5, + CAMERA_DISABLED = 6, + CAMERA_UNKNOWN_ERROR = 7, +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl new file mode 100644 index 0000000..093ff80 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +interface ICameraDeviceCallback { + oneway void onCaptureStarted(in android.frameworks.cameraservice.device.CaptureResultExtras resultExtras, in long timestamp); + oneway void onDeviceError(in android.frameworks.cameraservice.device.ErrorCode errorCode, in android.frameworks.cameraservice.device.CaptureResultExtras resultExtras); + oneway void onDeviceIdle(); + oneway void onPrepared(in int streamId); + oneway void onRepeatingRequestError(in long lastFrameNumber, in int repeatingRequestId); + oneway void onResultReceived(in android.frameworks.cameraservice.device.CaptureMetadataInfo result, in android.frameworks.cameraservice.device.CaptureResultExtras resultExtras, in android.frameworks.cameraservice.device.PhysicalCaptureResultInfo[] physicalCaptureResultInfos); +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl new file mode 100644 index 0000000..1b9b2c2 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +interface ICameraDeviceUser { + void beginConfigure(); + long cancelRepeatingRequest(); + android.frameworks.cameraservice.device.CameraMetadata createDefaultRequest(in android.frameworks.cameraservice.device.TemplateId templateId); + int createStream(in android.frameworks.cameraservice.device.OutputConfiguration outputConfiguration); + void deleteStream(in int streamId); + void disconnect(); + void endConfigure(in android.frameworks.cameraservice.device.StreamConfigurationMode operatingMode, in android.frameworks.cameraservice.device.CameraMetadata sessionParams, in long startTimeNs); + long flush(); + android.hardware.common.fmq.MQDescriptor<byte,android.hardware.common.fmq.SynchronizedReadWrite> getCaptureRequestMetadataQueue(); + android.hardware.common.fmq.MQDescriptor<byte,android.hardware.common.fmq.SynchronizedReadWrite> getCaptureResultMetadataQueue(); + boolean isSessionConfigurationSupported(in android.frameworks.cameraservice.device.SessionConfiguration sessionConfiguration); + void prepare(in int streamId); + android.frameworks.cameraservice.device.SubmitInfo submitRequestList(in android.frameworks.cameraservice.device.CaptureRequest[] requestList, in boolean isRepeating); + void updateOutputConfiguration(in int streamId, in android.frameworks.cameraservice.device.OutputConfiguration outputConfiguration); + void waitUntilIdle(); +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/OutputConfiguration.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/OutputConfiguration.aidl new file mode 100644 index 0000000..8943815 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/OutputConfiguration.aidl @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable OutputConfiguration { + android.hardware.common.NativeHandle[] windowHandles; + android.frameworks.cameraservice.device.OutputConfiguration.Rotation rotation; + int windowGroupId; + String physicalCameraId; + int width; + int height; + boolean isDeferred; + @Backing(type="int") @VintfStability + enum Rotation { + R0 = 0, + R90 = 1, + R180 = 2, + R270 = 3, + } + @Backing(type="int") @VintfStability + enum WindowGroupId { + NONE = (-1) /* -1 */, + } +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl new file mode 100644 index 0000000..622b3a1 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable PhysicalCameraSettings { + String id; + android.frameworks.cameraservice.device.CaptureMetadataInfo settings; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl new file mode 100644 index 0000000..7d1b1a9 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable PhysicalCaptureResultInfo { + String physicalCameraId; + android.frameworks.cameraservice.device.CaptureMetadataInfo physicalCameraMetadata; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/SessionConfiguration.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/SessionConfiguration.aidl new file mode 100644 index 0000000..f6f3773 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/SessionConfiguration.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable SessionConfiguration { + android.frameworks.cameraservice.device.OutputConfiguration[] outputStreams; + int inputWidth; + int inputHeight; + int inputFormat; + android.frameworks.cameraservice.device.StreamConfigurationMode operationMode; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/StreamAndWindowId.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/StreamAndWindowId.aidl new file mode 100644 index 0000000..23da63a --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/StreamAndWindowId.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable StreamAndWindowId { + int streamId; + int windowId; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl new file mode 100644 index 0000000..ff888f5 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@Backing(type="int") @VintfStability +enum StreamConfigurationMode { + NORMAL_MODE = 0, + CONSTRAINED_HIGH_SPEED_MODE = 1, + VENDOR_MODE_0 = 0x8000, + VENDOR_MODE_1, + VENDOR_MODE_2, + VENDOR_MODE_3, + VENDOR_MODE_4, + VENDOR_MODE_5, + VENDOR_MODE_6, + VENDOR_MODE_7, +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/SubmitInfo.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/SubmitInfo.aidl new file mode 100644 index 0000000..5154ed3 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/SubmitInfo.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@VintfStability +parcelable SubmitInfo { + int requestId; + long lastFrameNumber; +} diff --git a/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/TemplateId.aidl b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/TemplateId.aidl new file mode 100644 index 0000000..89c5d68 --- /dev/null +++ b/cameraservice/device/aidl/aidl_api/android.frameworks.cameraservice.device/current/android/frameworks/cameraservice/device/TemplateId.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.device; +@Backing(type="int") @VintfStability +enum TemplateId { + PREVIEW = 1, + STILL_CAPTURE = 2, + RECORD = 3, + VIDEO_SNAPSHOT = 4, + ZERO_SHUTTER_LAG = 5, + MANUAL = 6, +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/CameraMetadata.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/CameraMetadata.aidl new file mode 100644 index 0000000..9e7903e --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/CameraMetadata.aidl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +/** + * Wrapper parcelable for CameraMetadata. + * See system/camera_metadata.h for the structure of the serialized metadata. + */ +@VintfStability +parcelable CameraMetadata { + /** + * A serialized metadata buffer created by libcamera_metadata. + * Access by casting to a camera_metadata* and using libcamera_metadata methods. + */ + byte[] metadata; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl new file mode 100644 index 0000000..e1950ea --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureMetadataInfo.aidl @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +import android.frameworks.cameraservice.device.CameraMetadata; + +/** + * Either size of the capture request / result metadata sent through FMQ or + * the request / result metadata itself. + * If the server of the metadata chooses to use FMQ, it must set the + * fmqMetadataSize field to the size(> 0) of the metadata held by the FMQ. + * Otherwise, the metadata field must contain the metadata. + */ +@VintfStability +union CaptureMetadataInfo { + long fmqMetadataSize; + CameraMetadata metadata; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureRequest.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureRequest.aidl new file mode 100644 index 0000000..f515e70 --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureRequest.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +import android.frameworks.cameraservice.device.PhysicalCameraSettings; +import android.frameworks.cameraservice.device.StreamAndWindowId; + +/** + * This must contain the information which needs to be submitted with a capture + * request, typically to be used with submitRequestList. + */ +@VintfStability +parcelable CaptureRequest { + /** + * The physical camera settings associated with this CaptureRequest. + * + * Note: The first capture settings should always match the logical + * camera id. + */ + PhysicalCameraSettings[] physicalCameraSettings; + /** + * A list of (streamId, windowId) pairs which uniquely identifies the + * native windows associated with this CaptureRequest. + */ + StreamAndWindowId[] streamAndWindowIds; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureResultExtras.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureResultExtras.aidl new file mode 100644 index 0000000..eb36dc5 --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/CaptureResultExtras.aidl @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +/** + * Information about a capture, available to a device client on various + * conditions through ICameraDeviceUserCallback callbacks. + */ +@VintfStability +parcelable CaptureResultExtras { + /** + * An integer to index the request sequence that this result belongs to. + */ + int requestId; + /** + * An integer to index this result inside a request sequence, starting from 0. + */ + int burstId; + /** + * A 64bit integer to index the frame number associated with this result. + */ + long frameNumber; + /** + * The partial result count (index) for this capture result. + */ + int partialResultCount; + /** + * For buffer drop errors, the stream ID for the stream that lost a buffer. + * Otherwise -1. + */ + int errorStreamId; + /** + * For capture result errors, the physical camera ID in case the respective request contains + * a reference to physical camera device. Empty otherwise. + * When filled, contains one of the values in ACAMERA_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS entry + * in the static metadata of the logical multicamera to which the request was made. + */ + String errorPhysicalCameraId; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/ErrorCode.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/ErrorCode.aidl new file mode 100644 index 0000000..792e97f --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/ErrorCode.aidl @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +/** + * Error codes for onDeviceError + */ +@VintfStability +@Backing(type="int") +enum ErrorCode { + /** + * To indicate all invalid error codes. + */ + CAMERA_INVALID_ERROR = -1, + /** + * Camera operation has failed because the camera device has been closed, + * possibly because a higher priority client has taken ownership of the + * device. + */ + CAMERA_DISCONNECTED = 0, + /** + * The camera device has encountered a fatal error and needs to be + * re-opened to use it again. + */ + CAMERA_DEVICE = 1, + /** + * The camera service has encountered a fatal error. + */ + CAMERA_SERVICE = 2, + /** + * The camera device encountered an error while processing a request. + * No output will be produced for this request. Subsequent requests are + * unaffected. + */ + CAMERA_REQUEST = 3, + /** + * The camera device encountered an error while producing an output result + * metadata buffer for a request. Output stream buffers for it must still + * be available. + */ + CAMERA_RESULT = 4, + /** + * A camera device encountered an error occurred due to which an output + * buffer was lost. + */ + CAMERA_BUFFER = 5, + /** + * The camera device has been disabled and cannot be opened. + */ + CAMERA_DISABLED = 6, + /** + * Camera operation has failed due to an unknown cause. + */ + CAMERA_UNKNOWN_ERROR = 7, +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl new file mode 100644 index 0000000..a6f1898 --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/ICameraDeviceCallback.aidl @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +import android.frameworks.cameraservice.device.CaptureResultExtras; +import android.frameworks.cameraservice.device.ErrorCode; +import android.frameworks.cameraservice.device.CaptureMetadataInfo; +import android.frameworks.cameraservice.device.PhysicalCaptureResultInfo; + +@VintfStability +oneway interface ICameraDeviceCallback { + /** + * Callback called when capture starts. + * + * @param resultExtras data structure containing information about the + * frame number, request id, etc, of the request. + * @param timestamp corresponding to the start (in nanoseconds) + */ + void onCaptureStarted(in CaptureResultExtras resultExtras, in long timestamp); + + /** + * Callback called when the device encounters an error. + * + * @param errorCode the error code corresponding to the error. + * @param resultExtras data structure containing information about the + * frame number, request id, etc, of the request on which the device + * error occurred, in case the errorCode was CAMERA_BUFFER. + */ + void onDeviceError(in ErrorCode errorCode, in CaptureResultExtras resultExtras); + + /** + * Callback called when the device is idle. + */ + void onDeviceIdle(); + + /** + * Callback called when the surfaces corresponding to the stream with stream id 'streamId' + * have been prepared. + * + * This callback will only be called as a response to the ICameraDeviceUser.prepare() call. + * + * @param streamId the stream id of the stream on which ICameraDeviceUser.prepare() was called. + */ + void onPrepared(in int streamId); + + /** + * Repeating request encountered an error and was stopped. + * + * @param lastFrameNumber Frame number of the last frame of the streaming + * request. + * @param repeatingRequestId the ID of the repeating request + * being stopped + */ + void onRepeatingRequestError(in long lastFrameNumber, in int repeatingRequestId); + + /** + * Callback called when a capture request is completed. + * + * Note: The framework must call this callback serially if it opts to + * utilize an fmq for either the result metadata and/or any of the + * physicalCaptureResultInfo.physicalCameraMetadata values. + * + * @param result result metadata + * @param resultExtras data structure containing information about the + * frame number, request id, etc of the request. + * @param physicalCaptureResultInfos a list of physicalCaptureResultInfo, + * which contains the camera id and metadata related to the physical + * cameras involved for the particular capture request, if any. + */ + void onResultReceived(in CaptureMetadataInfo result, in CaptureResultExtras resultExtras, + in PhysicalCaptureResultInfo[] physicalCaptureResultInfos); +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl new file mode 100644 index 0000000..2cf9a08 --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/ICameraDeviceUser.aidl @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +import android.frameworks.cameraservice.device.CameraMetadata; +import android.frameworks.cameraservice.device.CaptureRequest; +import android.frameworks.cameraservice.device.OutputConfiguration; +import android.frameworks.cameraservice.device.SessionConfiguration; +import android.frameworks.cameraservice.device.StreamConfigurationMode; +import android.frameworks.cameraservice.device.SubmitInfo; +import android.frameworks.cameraservice.device.TemplateId; +import android.hardware.common.fmq.MQDescriptor; +import android.hardware.common.fmq.SynchronizedReadWrite; + +@VintfStability +interface ICameraDeviceUser { + + /** + * Begin device configuration. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + */ + void beginConfigure(); + + /** + * Cancel the current repeating request. + * + * The current repeating request may be stopped by camera device due to an + * error. + * + * @throws ServiceSpecificException with the following values: + * Status::INVALID_OPERATION when there is no active repeating request + * + * @return the frame number of the last frame that will be + * produced from this repeating request. If there are no inflight + * repeating requests, this will return -1 as the frameNumber. + * If the status is not NO_ERROR, the frame number should not be + * used. + */ + long cancelRepeatingRequest(); + + /** + * Create a default capture request for capturing an image. + * + * @param templateId the type of capture request to be created. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return the settings metadata of the request. + */ + CameraMetadata createDefaultRequest(in TemplateId templateId); + + /** + * Create an output stream based on the given output configuration. + * + * Note: createStream() must only be called within a beginConfigure() and an + * endConfigure() block. + * + * @param outputConfiguration size, format, and other parameters for the + * stream + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return stream ID of the new stream generated. + */ + int createStream(in OutputConfiguration outputConfiguration); + + /** + * delete the stream specified by streamId. + * + * Note: deleteStream() must only be called within a beginConfigure() and an + * endConfigure() block. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @param streamId the stream id of the stream to be deleted + */ + void deleteStream(in int streamId); + + /** + * disconnect from using the camera device. + * This method must block till in-flight requests are completed and stop + * all the requests submitted through submitRequestList(). + */ + void disconnect(); + + /** + * End the device configuration. + * + * endConfigure must be called after stream configuration is complete + * (i.e. after a call to beginConfigure and subsequent + * createStream/deleteStream calls). It must be called before any + * requests can be submitted. + * + * @param operatingMode The kind of session to create; either NORMAL_MODE, + * CONSTRAINED_HIGH_SPEED_MODE, or one of the vendor modes. + * @param sessionParams Session-wide camera parameters. Empty session + * parameters are legal inputs. + * @param startTimeNs indicate the timestamp when session configuration + * starts. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + */ + void endConfigure(in StreamConfigurationMode operatingMode, in CameraMetadata sessionParams, in long startTimeNs); + + /** + * flush all the requests pending on the device. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return the frame number of the last frame flushed. + */ + long flush(); + + /** + * Retrieve the fast message queue to be optionally used in CaptureRequests, + * to pass the settings metadata. + * If the client decides to use FMQ, it must: + * - Call getCaptureRequestMetadataQueue to retrieve the fast message queue + * - In submitRequestList calls, for each request set the fmqMetadataSize + * in the settings field of physicalCameraSettings, to the size of the + * metadata. + * + * @return the queue that the client writes the request settings + * metadata to. + */ + MQDescriptor<byte, SynchronizedReadWrite> getCaptureRequestMetadataQueue(); + + /** + * Retrieve the fast message queue used along with + * ICameraDeviceCallback.onResultReceived. + * + * Note: The client's use of this function does not affect the hidl + * service's decision to use / not use FMQ to pass result metadata to the + * client. + * + * Clients implementing the callback must: + * - Retrieve the queue using getCaptureResultMetadataQueue. + * - In the implementation of ICameraDeviceCallback.onResultReceived, if + * PhysicalCaptureResultInfo.physicalCameraMetadata has a valid + * fmqMetadataSize (which is > 0), the metadata must be read from the FMQ, + * else, it must be read from the metadata field. + * The same applies to resultMetadata. + * + * @return the queue that the client reads the result metadata from. + */ + MQDescriptor<byte, SynchronizedReadWrite> getCaptureResultMetadataQueue(); + + /** + * Check whether a particular session configuration has camera device + * support. + * + * @param sessionConfiguration Specific session configuration to be verified. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return true - in case the stream combination is supported. + * false - in case there is no device support. + */ + boolean isSessionConfigurationSupported(in SessionConfiguration sessionConfiguration); + + /** + * + * <p>Pre-allocate buffers for a stream.</p> + * + * <p>Normally, the image buffers for a given stream are allocated on-demand, + * to minimize startup latency and memory overhead.</p> + * + * <p>However, in some cases, it may be desirable for the buffers to be allocated before + * any requests targeting the window are actually submitted to the device. Large buffers + * may take some time to allocate, which can result in delays in submitting requests until + * sufficient buffers are allocated to reach steady-state behavior. Such delays can cause + * bursts to take longer than desired, or cause skips or stutters in preview output.</p> + * + * <p>The prepare() call can be used by clients to perform this pre-allocation. + * It may only be called for a given output stream before that stream is used as a target for a + * request. The number of buffers allocated is the sum of the count needed by the consumer + * providing the output stream, and the maximum number needed by the camera device to fill its + * pipeline. + * Since this may be a larger number than what is actually required for steady-state operation, + * using this call may result in higher memory consumption than the normal on-demand behavior + * results in. This method will also delay the time to first output to a given stream, + * in exchange for smoother frame rate once the allocation is complete.</p> + * + * <p>For example, a client that creates an + * {@link AImageReader} with a maxImages argument of 10, + * but only uses 3 simultaneous {@link AImage}s at once, would normally only cause those 3 + * images to be allocated (plus what is needed by the camera device for smooth operation). + * But using prepare() on the {@link AImageReader}'s window will result in all 10 + * {@link AImage}s being allocated. So clients using this method should exercise caution + * while using this call.</p> + * + * <p>Once allocation is complete, ICameraDeviceCallback.onPrepared + * will be invoked with the stream provided to this method. Between the prepare call and the + * ICameraDeviceCallback.onPrepared() call, the output provided to prepare must not be used as + * a target of a capture qequest submitted + * to this session.</p> + * + * @param streamId the stream id of the stream for which buffer pre-allocation is to be done. + */ + void prepare(in int streamId); + + /** + * Submit a list of capture requests. + * + * Note: Clients must call submitRequestList() serially if they opt + * to utilize an fmq (obtained by calling getCaptureRequestMetadataQueue) + * for any CaptureRequest's physicalCameraSettings metadata. + * + * @param requestList The list of CaptureRequests + * @param isRepeating Whether the set of requests repeats indefinitely. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return SubmitInfo data structure containing the request id of the + * capture request and the frame number of the last frame that will + * be produced(In case the request is not repeating. Otherwise it + * contains the frame number of the last request, of the previus + * batch of repeating requests, if any. If there is no previous + * batch, the frame number returned will be -1.) + */ + SubmitInfo submitRequestList(in CaptureRequest[] requestList, in boolean isRepeating); + + /** + * Update a previously set output configuration. + * + * Note: It is legal to call this method outside of + * beginConfigure()/endConfigure() blocks and also when the device + * is not idle. + * + * @param streamId the stream id whose output configuration needs to be + * updated. + * @param outputConfiguration the new outputConfiguration. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + */ + void updateOutputConfiguration(in int streamId, in OutputConfiguration outputConfiguration); + + /** + * Block until the device is idle. + * + * Note: This method will not block if there are active repeating requests. + * + * @throws ServiceSpecificException with the following values: + * Status::INVALID_OPERATION if there are active repeating requests. + */ + void waitUntilIdle(); +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/OutputConfiguration.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/OutputConfiguration.aidl new file mode 100644 index 0000000..449b80d --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/OutputConfiguration.aidl @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +import android.hardware.common.NativeHandle; + +/** + * This describes camera output. It has configurations specific to a + * capture session. + */ +@VintfStability +parcelable OutputConfiguration { + /** + * Rotation values for camera output + */ + @VintfStability + @Backing(type="int") + enum Rotation { + R0 = 0, + R90 = 1, + R180 = 2, + R270 = 3, + } + @VintfStability + @Backing(type="int") + enum WindowGroupId { + NONE = -1, + } + /** + * These must be handles to ANativeWindows owned by AImageReader, + * obtained by using AImageReader_getWindowNativeHandle. Ref: + * (frameworks/av/media/ndk/include/media/NdkImageReader.h). + * When this vector has more than one window handle, native window surface + * sharing is enabled. Clients may take advantage of this in advanced use + * cases when they would require create more streams than the limits the + * camera device imposes [1]. In this case, more than one window must be + * attached to an OutputConfiguration so that they map to one camera stream. + * The outputs will share memory buffers whenever possible. Due to buffer + * sharing, client should be careful while adding native window outputs that + * modify their input data. If such cases exist, client must have additional + * mechanisms to synchronize read and write accesses between consumers. + * [1]: Ref : frameworks/av/camera/ndk/include/camera/NdkCameraDevice.h + */ + NativeHandle[] windowHandles; + /** + * The rotation value for the camera output for this configuration. + * Only Rotation::R0 is guaranteed to be supported. + */ + Rotation rotation; + /** + * A windowGroupId is used to identify which window group this output window belongs to. A + * window group is a group of output windows that are not intended to receive camera output + * buffer streams simultaneously. The ICameraDevice may be able to share the buffers used + * by all the windows from the same window group, therefore may reduce the overall memory + * footprint. The client must only set the same set id for the streams that are not + * simultaneously streaming. For OutputConfigurations not belonging to any + * window group the client must set windowGroupId to WindowGroupId::NONE. + */ + int windowGroupId; + /** + * The id of the physical camera id, that this OutputConfiguration is meant + * for. If the no physical camera id is expected, this must be an empty + * string. + */ + String physicalCameraId; + /** + * The width of the output stream. + * + * Note: this must only be used when using deferred streams. Otherwise, it + * must be set to 0. + */ + int width; + /** + * The height of the output stream. + * + * Note: this must only be used when using deferred streams. Otherwise, it + * must be set to 0. + */ + int height; + /** + * This must be set to true, if this OutputConfiguration contains handles to + * deferred native windows. + * Ref:frameworks/base/core/java/android/hardware/camera2/params/OutputConfiguration.java + */ + boolean isDeferred; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl new file mode 100644 index 0000000..0e690cf --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/PhysicalCameraSettings.aidl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +import android.frameworks.cameraservice.device.CaptureMetadataInfo; + +/** + * Data structure tying camera id and settings metadata. + * + */ +@VintfStability +parcelable PhysicalCameraSettings { + String id; + CaptureMetadataInfo settings; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl new file mode 100644 index 0000000..ea41f4b --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/PhysicalCaptureResultInfo.aidl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +import android.frameworks.cameraservice.device.CaptureMetadataInfo; + +/** + * This ties physical camera metadata to a particular camera device for a + * particular capture result. + */ +@VintfStability +parcelable PhysicalCaptureResultInfo { + String physicalCameraId; + CaptureMetadataInfo physicalCameraMetadata; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/SessionConfiguration.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/SessionConfiguration.aidl new file mode 100644 index 0000000..ab578d8 --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/SessionConfiguration.aidl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +import android.frameworks.cameraservice.device.OutputConfiguration; +import android.frameworks.cameraservice.device.StreamConfigurationMode; + +@VintfStability +parcelable SessionConfiguration { + /** + * A vector containing all output configurations + */ + OutputConfiguration[] outputStreams; + /** + * Input stream width + * + * Note: this must be <= 0 if there is no input stream. + */ + int inputWidth; + /** + * Input stream height + * + * Note: this must be <= 0 if there is no input stream. + */ + int inputHeight; + /** + * Input stream format + * + * Note: this must be one of the AIMAGE_FORMATS defined in + * frameworks/av/media/ndk/include/media/NdkImage.h. + */ + int inputFormat; + /** + * Operation mode of camera device + */ + StreamConfigurationMode operationMode; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/StreamAndWindowId.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/StreamAndWindowId.aidl new file mode 100644 index 0000000..74518a2 --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/StreamAndWindowId.aidl @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +/** + * Data structure tying stream id and window id for a native window. + */ +@VintfStability +parcelable StreamAndWindowId { + /** + * This must be the stream id corresponding to the native window (the streamId + * returned from the createStream() method, which took in the + * OutputConfiguration which contained this native window) + */ + int streamId; + /** + * This must be the array index of the of the window handle corresponding to + * the native window, which was packaged with the OutputConfiguration. + */ + int windowId; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl new file mode 100644 index 0000000..792c92c --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/StreamConfigurationMode.aidl @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +/** + * This defines the general operation mode for the HAL (for a given stream + * configuration) where modes besides NORMAL have different semantics, and + * usually limit the generality of the API in exchange for higher performance in + * some particular area. + */ +@VintfStability +@Backing(type="int") +enum StreamConfigurationMode { + /** + * Normal stream configuration operation mode. This is the default camera + * operation mode, where all semantics of HAL APIs and metadata controls + * apply. + */ + NORMAL_MODE = 0, + /** + * Special constrained high speed operation mode for devices that can not + * support high speed output in NORMAL mode. + */ + CONSTRAINED_HIGH_SPEED_MODE = 1, + /** + * A set of vendor-defined operating modes, for custom default camera + * application features that can't be implemented in a fully flexible + * fashion required for NORMAL_MODE. + */ + VENDOR_MODE_0 = 0x8000, + VENDOR_MODE_1, + VENDOR_MODE_2, + VENDOR_MODE_3, + VENDOR_MODE_4, + VENDOR_MODE_5, + VENDOR_MODE_6, + VENDOR_MODE_7, +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/SubmitInfo.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/SubmitInfo.aidl new file mode 100644 index 0000000..6a29a9f --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/SubmitInfo.aidl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +/** + * The status information returned for a successful capture request submission. + * + * This includes the request ID for the newly submitted capture request, and the + * last frame number of either the previous repeating request (for repeating + * requests), or of the request(s) just submitted (for single-shot capture). + */ +@VintfStability +parcelable SubmitInfo { + int requestId; + long lastFrameNumber; +} diff --git a/cameraservice/device/aidl/android/frameworks/cameraservice/device/TemplateId.aidl b/cameraservice/device/aidl/android/frameworks/cameraservice/device/TemplateId.aidl new file mode 100644 index 0000000..776738f --- /dev/null +++ b/cameraservice/device/aidl/android/frameworks/cameraservice/device/TemplateId.aidl @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.device; + +/** + * TemplateId to be used with createDefaultRequest + */ +@VintfStability +@Backing(type="int") +enum TemplateId { + /** + * Create a request suitable for a camera preview window. Specifically, this + * means that high frame rate is given priority over the highest-quality + * post-processing. + */ + PREVIEW = 1, + /** + * Create a request suitable for still image capture. Specifically, this + * means prioritizing image quality over frame rate + */ + STILL_CAPTURE = 2, + /** + * Create a request suitable for video recording. Specifically, this means + * that a stable frame rate is used, and post-processing is set for + * recording quality. + */ + RECORD = 3, + /** + * Create a request suitable for still image capture while recording + * video. Specifically, this means maximizing image quality without + * disrupting the ongoing recording. + */ + VIDEO_SNAPSHOT = 4, + /** + * Create a request suitable for zero shutter lag still capture. This means + * means maximizing image quality without compromising preview frame rate. + */ + ZERO_SHUTTER_LAG = 5, + /** + * A basic template for direct application control of capture + * parameters. All automatic control is disabled (auto-exposure, auto-white + * balance, auto-focus), and post-processing parameters are set to preview + * quality. The manual capture parameters (exposure, sensitivity, and so on) + * are set to reasonable defaults, but should be overridden by the + * application depending on the intended use case. + */ + MANUAL = 6, +} diff --git a/cameraservice/service/aidl/Android.bp b/cameraservice/service/aidl/Android.bp new file mode 100644 index 0000000..7b9cb3c --- /dev/null +++ b/cameraservice/service/aidl/Android.bp @@ -0,0 +1,39 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +aidl_interface { + name: "android.frameworks.cameraservice.service", + vendor_available: true, + srcs: ["android/frameworks/cameraservice/service/*.aidl"], + stability: "vintf", + imports: [ + "android.frameworks.cameraservice.common-V1", + "android.frameworks.cameraservice.device-V1", + ], + frozen: true, + backend: { + cpp: { + enabled: false, + }, + java: { + enabled: false, + }, + ndk: { + vndk: { + enabled: true, + }, + }, + }, + vndk_use_version: "1", + versions_with_info: [ + { + version: "1", + imports: [ + "android.frameworks.cameraservice.common-V1", + "android.frameworks.cameraservice.device-V1", + ], + }, + ], + +} diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/.hash b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/.hash new file mode 100644 index 0000000..9053457 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/.hash @@ -0,0 +1 @@ +9af5caea9ed28139c7005ead2e2c851351a4caa1 diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl new file mode 100644 index 0000000..a809751 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.service; +@Backing(type="int") @VintfStability +enum CameraDeviceStatus { + STATUS_NOT_AVAILABLE = (-2) /* -2 */, + STATUS_UNKNOWN = (-1) /* -1 */, + STATUS_NOT_PRESENT = 0, + STATUS_PRESENT = 1, + STATUS_ENUMERATING = 2, +} diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/CameraStatusAndId.aidl b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/CameraStatusAndId.aidl new file mode 100644 index 0000000..4a92a45 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/CameraStatusAndId.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.service; +@VintfStability +parcelable CameraStatusAndId { + android.frameworks.cameraservice.service.CameraDeviceStatus deviceStatus; + String cameraId; + String[] unavailPhysicalCameraIds; +} diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/ICameraService.aidl b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/ICameraService.aidl new file mode 100644 index 0000000..9bca528 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/ICameraService.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.service; +@VintfStability +interface ICameraService { + android.frameworks.cameraservice.service.CameraStatusAndId[] addListener(in android.frameworks.cameraservice.service.ICameraServiceListener listener); + android.frameworks.cameraservice.device.ICameraDeviceUser connectDevice(in android.frameworks.cameraservice.device.ICameraDeviceCallback callback, in String cameraId); + android.frameworks.cameraservice.device.CameraMetadata getCameraCharacteristics(in String cameraId); + android.frameworks.cameraservice.common.ProviderIdAndVendorTagSections[] getCameraVendorTagSections(); + void removeListener(in android.frameworks.cameraservice.service.ICameraServiceListener listener); +} diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/ICameraServiceListener.aidl b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/ICameraServiceListener.aidl new file mode 100644 index 0000000..fcce780 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/1/android/frameworks/cameraservice/service/ICameraServiceListener.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.service; +@VintfStability +interface ICameraServiceListener { + oneway void onPhysicalCameraStatusChanged(in android.frameworks.cameraservice.service.CameraDeviceStatus status, in String cameraId, in String physicalCameraId); + oneway void onStatusChanged(in android.frameworks.cameraservice.service.CameraDeviceStatus status, in String cameraId); +} diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl new file mode 100644 index 0000000..a809751 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.service; +@Backing(type="int") @VintfStability +enum CameraDeviceStatus { + STATUS_NOT_AVAILABLE = (-2) /* -2 */, + STATUS_UNKNOWN = (-1) /* -1 */, + STATUS_NOT_PRESENT = 0, + STATUS_PRESENT = 1, + STATUS_ENUMERATING = 2, +} diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/CameraStatusAndId.aidl b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/CameraStatusAndId.aidl new file mode 100644 index 0000000..4a92a45 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/CameraStatusAndId.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.service; +@VintfStability +parcelable CameraStatusAndId { + android.frameworks.cameraservice.service.CameraDeviceStatus deviceStatus; + String cameraId; + String[] unavailPhysicalCameraIds; +} diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/ICameraService.aidl b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/ICameraService.aidl new file mode 100644 index 0000000..9bca528 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/ICameraService.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.service; +@VintfStability +interface ICameraService { + android.frameworks.cameraservice.service.CameraStatusAndId[] addListener(in android.frameworks.cameraservice.service.ICameraServiceListener listener); + android.frameworks.cameraservice.device.ICameraDeviceUser connectDevice(in android.frameworks.cameraservice.device.ICameraDeviceCallback callback, in String cameraId); + android.frameworks.cameraservice.device.CameraMetadata getCameraCharacteristics(in String cameraId); + android.frameworks.cameraservice.common.ProviderIdAndVendorTagSections[] getCameraVendorTagSections(); + void removeListener(in android.frameworks.cameraservice.service.ICameraServiceListener listener); +} diff --git a/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/ICameraServiceListener.aidl b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/ICameraServiceListener.aidl new file mode 100644 index 0000000..fcce780 --- /dev/null +++ b/cameraservice/service/aidl/aidl_api/android.frameworks.cameraservice.service/current/android/frameworks/cameraservice/service/ICameraServiceListener.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.cameraservice.service; +@VintfStability +interface ICameraServiceListener { + oneway void onPhysicalCameraStatusChanged(in android.frameworks.cameraservice.service.CameraDeviceStatus status, in String cameraId, in String physicalCameraId); + oneway void onStatusChanged(in android.frameworks.cameraservice.service.CameraDeviceStatus status, in String cameraId); +} diff --git a/cameraservice/service/aidl/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl b/cameraservice/service/aidl/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl new file mode 100644 index 0000000..d7c7ee1 --- /dev/null +++ b/cameraservice/service/aidl/android/frameworks/cameraservice/service/CameraDeviceStatus.aidl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.service; + +/** + * The current status of the device. + */ +@VintfStability +@Backing(type="int") +enum CameraDeviceStatus { + /** + * Camera is in use by another app and cannot be used exclusively. + */ + STATUS_NOT_AVAILABLE = -2, + /** + * Use to initialize variables only. + */ + STATUS_UNKNOWN = -1, + /** + * Device physically unplugged + */ + STATUS_NOT_PRESENT = 0, + /** + * Device physically has been plugged in and the camera can be used + * exclusively. + */ + STATUS_PRESENT = 1, + /** + * Device physically has been plugged in but it will not be connect-able + * until enumeration is complete. + */ + STATUS_ENUMERATING = 2, +} diff --git a/cameraservice/service/aidl/android/frameworks/cameraservice/service/CameraStatusAndId.aidl b/cameraservice/service/aidl/android/frameworks/cameraservice/service/CameraStatusAndId.aidl new file mode 100644 index 0000000..1020f87 --- /dev/null +++ b/cameraservice/service/aidl/android/frameworks/cameraservice/service/CameraStatusAndId.aidl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.service; + +import android.frameworks.cameraservice.service.CameraDeviceStatus; + +/** + * The camera Id and its corresponding CameraDeviceStatus + */ +@VintfStability +parcelable CameraStatusAndId { + CameraDeviceStatus deviceStatus; + String cameraId; + /** + * The physical cameras that are unavailable to use (via physical streams) + * for this logical multi-camera. + */ + String[] unavailPhysicalCameraIds; +} diff --git a/cameraservice/service/aidl/android/frameworks/cameraservice/service/ICameraService.aidl b/cameraservice/service/aidl/android/frameworks/cameraservice/service/ICameraService.aidl new file mode 100644 index 0000000..ed5bc62 --- /dev/null +++ b/cameraservice/service/aidl/android/frameworks/cameraservice/service/ICameraService.aidl @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.service; + +import android.frameworks.cameraservice.common.ProviderIdAndVendorTagSections; +import android.frameworks.cameraservice.device.CameraMetadata; +import android.frameworks.cameraservice.device.ICameraDeviceCallback; +import android.frameworks.cameraservice.device.ICameraDeviceUser; +import android.frameworks.cameraservice.service.CameraStatusAndId; +import android.frameworks.cameraservice.service.ICameraServiceListener; + +@VintfStability +interface ICameraService { + /** + * Add listener for changes to camera device status. + * + * Also returns the set of currently-known camera IDs and state of each + * device. Adding multiple listeners must result in the callbacks defined by + * ICameraServiceListener being called on all of them, on change of device + * status. + * + * - The listener contains an onPhysicalCameraStatusChanged function, + * which is called by the camera service when a physical camera backing a + * logical multi-camera becomes unavailable or available again. + * - The function returns a vector of the newer version of CameraStatusAndId + * which contains unavailable physical cameras if the specified camera is a + * logical multi-camera. + * + * @param listener the listener interface to be added. The cameraserver will + * call callbacks on this interface when a camera device's status + * changes. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return a list of CameraStatusAndIds which stores the deviceIds, + * their corresponding statuses, and the unavailable physical camera Ids + * if the device is a logical multi-camera. + */ + CameraStatusAndId[] addListener(in ICameraServiceListener listener); + + /** + * connectDevice + * + * Return an ICameraDeviceUser interface for the requested cameraId. + * + * Note: The client must have camera permissions to call this method + * successfully. + * + * @param callback the ICameraDeviceCallback interface which will get called + * the cameraserver when capture is started, results are received + * etc. + * @param cameraId the cameraId of the camera device to connect to. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return ICameraDeviceUser interface to the camera device requested. + */ + ICameraDeviceUser connectDevice(in ICameraDeviceCallback callback, + in String cameraId); + + /** + * Read the static camera metadata for a camera device. + * + * @param cameraId the camera id of the camera device, whose metadata is + * being requested. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return the static metadata of the camera device requested. + */ + CameraMetadata getCameraCharacteristics(in String cameraId); + + /** + * Read in the provider ids and corresponding vendor tag sections from the camera server. + * Intended to be used by the native code of CameraMetadata to correctly + * interpret camera metadata with vendor tags. + * + * Note: VendorTag caches may be created in process, by clients. An AIDL api + * is not provided for this. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + * @return the list of provider ids and corresponding vendor tag sections. + */ + ProviderIdAndVendorTagSections[] getCameraVendorTagSections(); + + /** + * Remove listener for changes to camera device status. + * + * @param listener the listener to be removed from receiving callbacks on + * changes to device state. + * + * @throws ServiceSpecificException on failure with error code set to Status corresponding to + * the specific failure. + */ + void removeListener(in ICameraServiceListener listener); +} diff --git a/cameraservice/service/aidl/android/frameworks/cameraservice/service/ICameraServiceListener.aidl b/cameraservice/service/aidl/android/frameworks/cameraservice/service/ICameraServiceListener.aidl new file mode 100644 index 0000000..2608028 --- /dev/null +++ b/cameraservice/service/aidl/android/frameworks/cameraservice/service/ICameraServiceListener.aidl @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2022 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. + */ + +package android.frameworks.cameraservice.service; + +import android.frameworks.cameraservice.service.CameraDeviceStatus; + +@VintfStability +oneway interface ICameraServiceListener { + /** + * Callback called by cameraservice when the status of a physical + * camera device backing a logical camera changes + * + * @param status the current device status + * @param cameraId the logical camera device that the physical camera + * device belongs to + * @param physicalCameraId the physical camera device whose status + * change is being reported + */ + void onPhysicalCameraStatusChanged(in CameraDeviceStatus status, in String cameraId, + in String physicalCameraId); + + /** + * Callback called by cameraservice when the status of a camera device + * changes + * + * @param status the current device status + * @param cameraId the camera device whose status change is being reported + */ + void onStatusChanged(in CameraDeviceStatus status, in String cameraId); +} diff --git a/cameraservice/vts/functional/Android.bp b/cameraservice/vts/functional/Android.bp index 1bca510..b162060 100644 --- a/cameraservice/vts/functional/Android.bp +++ b/cameraservice/vts/functional/Android.bp @@ -44,3 +44,33 @@ cc_test { test_suites: ["vts"], } + +cc_test { + name: "VtsAidlCameraServiceTargetTest", + defaults: [ + "VtsHalTargetTestDefaults", + ], + + vendor: true, + srcs: ["VtsAidlCameraServiceTargetTest.cpp"], + static_libs: [ + "android.hardware.common-V2-ndk", + "android.hardware.common.fmq-V1-ndk", + "android.hardware.camera.common-helper", + "android.frameworks.cameraservice.common-V1-ndk", + "android.frameworks.cameraservice.device-V1-ndk", + "android.frameworks.cameraservice.service-V1-ndk", + "libaidlcommonsupport", + "libfmq", + "libarect", + ], + shared_libs: [ + "libbinder_ndk", + "libcamera_metadata", + "libmediandk", + "libnativewindow", + "liblog", + ], + + test_suites: ["vts"], +} diff --git a/cameraservice/vts/functional/VtsAidlCameraServiceTargetTest.cpp b/cameraservice/vts/functional/VtsAidlCameraServiceTargetTest.cpp new file mode 100644 index 0000000..9b5eab9 --- /dev/null +++ b/cameraservice/vts/functional/VtsAidlCameraServiceTargetTest.cpp @@ -0,0 +1,598 @@ +/* + * Copyright (C) 2022 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. + */ + +#define LOG_TAG "VtsAidlCameraServiceTargetTest" +// #define LOG_NDEBUG 0 + +#include <CameraMetadata.h> +#include <aidl/android/frameworks/cameraservice/device/BnCameraDeviceCallback.h> +#include <aidl/android/frameworks/cameraservice/device/CaptureRequest.h> +#include <aidl/android/frameworks/cameraservice/device/ICameraDeviceUser.h> +#include <aidl/android/frameworks/cameraservice/device/OutputConfiguration.h> +#include <aidl/android/frameworks/cameraservice/device/StreamConfigurationMode.h> +#include <aidl/android/frameworks/cameraservice/device/SubmitInfo.h> +#include <aidl/android/frameworks/cameraservice/device/TemplateId.h> +#include <aidl/android/frameworks/cameraservice/service/BnCameraServiceListener.h> +#include <aidl/android/frameworks/cameraservice/service/CameraStatusAndId.h> +#include <aidl/android/frameworks/cameraservice/service/ICameraService.h> +#include <aidlcommonsupport/NativeHandle.h> +#include <android/binder_manager.h> +#include <android/binder_process.h> +#include <android/log.h> +#include <fmq/AidlMessageQueue.h> +#include <gtest/gtest.h> +#include <hidl/GtestPrinter.h> +#include <media/NdkImageReader.h> +#include <stdint.h> +#include <system/camera_metadata.h> +#include <system/graphics.h> +#include <utils/Condition.h> +#include <utils/Mutex.h> +#include <utils/StrongPointer.h> + +#include <algorithm> +#include <string> +#include <unordered_map> +#include <unordered_set> +#include <vector> + +namespace android { + +using ::aidl::android::frameworks::cameraservice::device::BnCameraDeviceCallback; +using ::aidl::android::frameworks::cameraservice::device::CaptureMetadataInfo; +using ::aidl::android::frameworks::cameraservice::device::CaptureRequest; +using ::aidl::android::frameworks::cameraservice::device::CaptureResultExtras; +using ::aidl::android::frameworks::cameraservice::device::ErrorCode; +using ::aidl::android::frameworks::cameraservice::device::ICameraDeviceUser; +using ::aidl::android::frameworks::cameraservice::device::OutputConfiguration; +using ::aidl::android::frameworks::cameraservice::device::PhysicalCaptureResultInfo; +using ::aidl::android::frameworks::cameraservice::device::StreamConfigurationMode; +using ::aidl::android::frameworks::cameraservice::device::SubmitInfo; +using ::aidl::android::frameworks::cameraservice::device::TemplateId; +using ::aidl::android::frameworks::cameraservice::service::BnCameraServiceListener; +using ::aidl::android::frameworks::cameraservice::service::CameraDeviceStatus; +using ::aidl::android::frameworks::cameraservice::service::CameraStatusAndId; +using ::aidl::android::frameworks::cameraservice::service::ICameraService; +using ::aidl::android::hardware::common::fmq::MQDescriptor; +using ::android::hardware::camera::common::helper::CameraMetadata; +using ::ndk::SpAIBinder; + +using AidlCameraMetadata = ::aidl::android::frameworks::cameraservice::device::CameraMetadata; +using RequestMetadataQueue = AidlMessageQueue<int8_t, SynchronizedReadWrite>; + +static constexpr int kCaptureRequestCount = 10; +static constexpr int kVGAImageWidth = 640; +static constexpr int kVGAImageHeight = 480; +static constexpr int kNumRequests = 4; + +#define IDLE_TIMEOUT 2000000000 // ns + +class CameraServiceListener : public BnCameraServiceListener { + std::map<std::string, CameraDeviceStatus> mCameraStatuses; + // map: logical camera id -> set of unavailable physical camera ids + std::map<std::string, std::set<std::string>> mUnavailablePhysicalCameras; + mutable Mutex mLock; + + public: + ~CameraServiceListener() override = default; + + ndk::ScopedAStatus onStatusChanged(CameraDeviceStatus in_status, + const std::string& in_cameraId) override { + Mutex::Autolock l(mLock); + mCameraStatuses[in_cameraId] = in_status; + return ndk::ScopedAStatus::ok(); + } + + ndk::ScopedAStatus onPhysicalCameraStatusChanged( + CameraDeviceStatus in_status, const std::string& in_cameraId, + const std::string& in_physicalCameraId) override { + Mutex::Autolock l(mLock); + ALOGI("%s: Physical camera %s : %s status changed to %d", __FUNCTION__, in_cameraId.c_str(), + in_physicalCameraId.c_str(), in_status); + + EXPECT_NE(mCameraStatuses.find(in_cameraId), mCameraStatuses.end()); + EXPECT_EQ(mCameraStatuses[in_cameraId], CameraDeviceStatus::STATUS_PRESENT); + + if (in_status == CameraDeviceStatus::STATUS_PRESENT) { + auto res = mUnavailablePhysicalCameras[in_cameraId].erase(in_physicalCameraId); + EXPECT_EQ(res, 1); + } else { + auto res = mUnavailablePhysicalCameras[in_cameraId].emplace(in_physicalCameraId); + EXPECT_TRUE(res.second); + } + return ndk::ScopedAStatus::ok(); + } + + void initializeStatuses(const std::vector<CameraStatusAndId>& statuses) { + Mutex::Autolock l(mLock); + + for (auto& status : statuses) { + mCameraStatuses[status.cameraId] = status.deviceStatus; + for (auto& physicalId : status.unavailPhysicalCameraIds) { + mUnavailablePhysicalCameras[status.cameraId].emplace(physicalId); + } + } + } +}; + +// ICameraDeviceCallback implementation +class CameraDeviceCallback : public BnCameraDeviceCallback { + public: + enum LocalCameraDeviceStatus { + IDLE, + ERROR, + RUNNING, + RESULT_RECEIVED, + UNINITIALIZED, + REPEATING_REQUEST_ERROR, + }; + + protected: + bool mError = false; + LocalCameraDeviceStatus mLastStatus = UNINITIALIZED; + mutable std::vector<LocalCameraDeviceStatus> mStatusesHit; + // stream id -> prepared count; + mutable std::unordered_map<int, int> mStreamsPreparedCount; + mutable Mutex mLock; + mutable Condition mStatusCondition; + mutable Condition mPreparedCondition; + + public: + CameraDeviceCallback() {} + + ndk::ScopedAStatus onDeviceError(ErrorCode in_errorCode, + const CaptureResultExtras& /*in_resultExtras*/) override { + ALOGE("%s: onDeviceError occurred with: %d", __FUNCTION__, static_cast<int>(in_errorCode)); + Mutex::Autolock l(mLock); + mError = true; + mLastStatus = ERROR; + mStatusesHit.push_back(mLastStatus); + mStatusCondition.broadcast(); + return ndk::ScopedAStatus::ok(); + } + + ndk::ScopedAStatus onDeviceIdle() override { + Mutex::Autolock l(mLock); + mLastStatus = IDLE; + mStatusesHit.push_back(mLastStatus); + mStatusCondition.broadcast(); + return ndk::ScopedAStatus::ok(); + } + + ndk::ScopedAStatus onCaptureStarted(const CaptureResultExtras& /*in_resultExtras*/, + int64_t /*in_timestamp*/) override { + Mutex::Autolock l(mLock); + mLastStatus = RUNNING; + mStatusesHit.push_back(mLastStatus); + mStatusCondition.broadcast(); + return ndk::ScopedAStatus::ok(); + } + + ndk::ScopedAStatus onResultReceived( + const CaptureMetadataInfo& /*in_result*/, const CaptureResultExtras& /*in_resultExtras*/, + const std::vector<PhysicalCaptureResultInfo>& /*in_physicalCaptureResultInfos*/) override { + Mutex::Autolock l(mLock); + mLastStatus = RESULT_RECEIVED; + mStatusesHit.push_back(mLastStatus); + mStatusCondition.broadcast(); + return ndk::ScopedAStatus::ok(); + } + + ndk::ScopedAStatus onRepeatingRequestError(int64_t /*in_lastFrameNumber*/, + int32_t /*in_repeatingRequestId*/) override { + Mutex::Autolock l(mLock); + mLastStatus = REPEATING_REQUEST_ERROR; + mStatusesHit.push_back(mLastStatus); + mStatusCondition.broadcast(); + return ndk::ScopedAStatus::ok(); + } + + ndk::ScopedAStatus onPrepared(int32_t streamId) override { + Mutex::Autolock l(mLock); + if (mStreamsPreparedCount.find(streamId) == mStreamsPreparedCount.end()) { + mStreamsPreparedCount[streamId] = 0; + } + mStreamsPreparedCount[streamId]++; + mPreparedCondition.broadcast(); + return ndk::ScopedAStatus::ok(); + } + + bool waitForPreparedCount(int streamId, int count) const { + Mutex::Autolock l(mLock); + if ((mStreamsPreparedCount.find(streamId) != mStreamsPreparedCount.end()) && + (mStreamsPreparedCount[streamId] == count)) { + return true; + } + + while ((mStreamsPreparedCount.find(streamId) == mStreamsPreparedCount.end()) || + (mStreamsPreparedCount[streamId] < count)) { + if (mPreparedCondition.waitRelative(mLock, IDLE_TIMEOUT) != android::OK) { + return false; + } + } + return (mStreamsPreparedCount[streamId] == count); + } + + // Test helper functions: + bool waitForStatus(LocalCameraDeviceStatus status) const { + Mutex::Autolock l(mLock); + if (mLastStatus == status) { + return true; + } + + while (std::find(mStatusesHit.begin(), mStatusesHit.end(), status) == mStatusesHit.end()) { + if (mStatusCondition.waitRelative(mLock, IDLE_TIMEOUT) != android::OK) { + mStatusesHit.clear(); + return false; + } + } + mStatusesHit.clear(); + + return true; + } + + bool waitForIdle() const { return waitForStatus(IDLE); } +}; + +static bool convertFromAidlCloned(const AidlCameraMetadata& metadata, CameraMetadata* rawMetadata) { + const camera_metadata* buffer = (camera_metadata_t*)(metadata.metadata.data()); + size_t expectedSize = metadata.metadata.size(); + int ret = validate_camera_metadata_structure(buffer, &expectedSize); + if (ret == OK || ret == CAMERA_METADATA_VALIDATION_SHIFTED) { + *rawMetadata = buffer; // assignment operator clones + } else { + ALOGE("%s: Malformed camera metadata received from caller", __FUNCTION__); + return false; + } + return true; +} + +struct StreamConfiguration { + int32_t width = -1; + int32_t height = -1; +}; + +class VtsAidlCameraServiceTargetTest : public ::testing::TestWithParam<std::string> { + public: + void SetUp() override { + bool success = ABinderProcess_setThreadPoolMaxThreadCount(5); + ASSERT_TRUE(success); + ABinderProcess_startThreadPool(); + + SpAIBinder cameraServiceBinder = + SpAIBinder(AServiceManager_checkService(GetParam().c_str())); + ASSERT_NE(cameraServiceBinder.get(), nullptr); + + std::shared_ptr<ICameraService> cameraService = + ICameraService::fromBinder(cameraServiceBinder); + ASSERT_NE(cameraService.get(), nullptr); + mCameraService = cameraService; + } + + void TearDown() override {} + + // creates an outputConfiguration with no deferred streams + static OutputConfiguration createOutputConfiguration(const std::vector<native_handle_t*>& nhs) { + OutputConfiguration output; + output.rotation = OutputConfiguration::Rotation::R0; + output.windowGroupId = -1; + output.width = 0; + output.height = 0; + output.isDeferred = false; + output.windowHandles.reserve(nhs.size()); + for (auto nh : nhs) { + output.windowHandles.push_back(::android::makeToAidl(nh)); + } + return output; + } + + static void initializeCaptureRequestPartial(CaptureRequest* captureRequest, int32_t streamId, + const std::string& cameraId, size_t settingsSize) { + captureRequest->physicalCameraSettings.resize(1); + captureRequest->physicalCameraSettings[0].id = cameraId; + captureRequest->streamAndWindowIds.resize(1); + captureRequest->streamAndWindowIds[0].streamId = streamId; + captureRequest->streamAndWindowIds[0].windowId = 0; + // Write the settings metadata into the fmq. + captureRequest->physicalCameraSettings[0] + .settings.set<CaptureMetadataInfo::fmqMetadataSize>(settingsSize); + } + + static bool doesCapabilityExist(const CameraMetadata& characteristics, int capability) { + camera_metadata_ro_entry rawEntry = + characteristics.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES); + EXPECT_TRUE(rawEntry.count > 0); + for (size_t i = 0; i < rawEntry.count; i++) { + if (rawEntry.data.u8[i] == capability) { + return true; + } + } + return false; + } + + static bool isSecureOnlyDevice(const CameraMetadata& characteristics) { + camera_metadata_ro_entry rawEntry = + characteristics.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES); + EXPECT_TRUE(rawEntry.count > 0); + if (rawEntry.count == 1 && + rawEntry.data.u8[0] == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SECURE_IMAGE_DATA) { + return true; + } + return false; + } + + // Return the first advertised available stream sizes for the given format + // and use-case. + static StreamConfiguration getStreamConfiguration(const CameraMetadata& characteristics, + uint32_t tag, int32_t chosenUse, + int32_t chosenFormat) { + camera_metadata_ro_entry rawEntry = characteristics.find(tag); + StreamConfiguration streamConfig; + const size_t STREAM_FORMAT_OFFSET = 0; + const size_t STREAM_WIDTH_OFFSET = 1; + const size_t STREAM_HEIGHT_OFFSET = 2; + const size_t STREAM_INOUT_OFFSET = 3; + const size_t STREAM_CONFIG_SIZE = 4; + if (rawEntry.count < STREAM_CONFIG_SIZE) { + return streamConfig; + } + EXPECT_TRUE((rawEntry.count % STREAM_CONFIG_SIZE) == 0); + for (size_t i = 0; i < rawEntry.count; i += STREAM_CONFIG_SIZE) { + int32_t format = rawEntry.data.i32[i + STREAM_FORMAT_OFFSET]; + int32_t use = rawEntry.data.i32[i + STREAM_INOUT_OFFSET]; + if (format == chosenFormat && use == chosenUse) { + streamConfig.width = rawEntry.data.i32[i + STREAM_WIDTH_OFFSET]; + streamConfig.height = rawEntry.data.i32[i + STREAM_HEIGHT_OFFSET]; + return streamConfig; + } + } + return streamConfig; + } + void BasicCameraTests(bool prepareWindows) { + std::shared_ptr<CameraServiceListener> listener = + ::ndk::SharedRefBase::make<CameraServiceListener>(); + std::vector<CameraStatusAndId> cameraStatuses; + + ndk::ScopedAStatus ret = mCameraService->addListener(listener, &cameraStatuses); + EXPECT_TRUE(ret.isOk()); + listener->initializeStatuses(cameraStatuses); + + for (const auto& it : cameraStatuses) { + CameraMetadata rawMetadata; + if (it.deviceStatus != CameraDeviceStatus::STATUS_PRESENT) { + continue; + } + AidlCameraMetadata aidlMetadata; + ret = mCameraService->getCameraCharacteristics(it.cameraId, &aidlMetadata); + EXPECT_TRUE(ret.isOk()); + bool cStatus = convertFromAidlCloned(aidlMetadata, &rawMetadata); + EXPECT_TRUE(cStatus); + EXPECT_FALSE(rawMetadata.isEmpty()); + + std::shared_ptr<CameraDeviceCallback> callbacks = + ndk::SharedRefBase::make<CameraDeviceCallback>(); + std::shared_ptr<ICameraDeviceUser> deviceRemote = nullptr; + ret = mCameraService->connectDevice(callbacks, it.cameraId, &deviceRemote); + EXPECT_TRUE(ret.isOk()); + EXPECT_TRUE(deviceRemote != nullptr); + + MQDescriptor<int8_t, SynchronizedReadWrite> mqDesc; + ret = deviceRemote->getCaptureRequestMetadataQueue(&mqDesc); + EXPECT_TRUE(ret.isOk()); + std::shared_ptr<RequestMetadataQueue> requestMQ = + std::make_shared<RequestMetadataQueue>(mqDesc); + EXPECT_TRUE(requestMQ->isValid()); + EXPECT_TRUE((requestMQ->availableToWrite() >= 0)); + + AImageReader* reader = nullptr; + bool isDepthOnlyDevice = + !doesCapabilityExist(rawMetadata, + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE) && + doesCapabilityExist(rawMetadata, + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT); + int chosenImageFormat = AIMAGE_FORMAT_YUV_420_888; + int chosenImageWidth = kVGAImageWidth; + int chosenImageHeight = kVGAImageHeight; + bool isSecureOnlyCamera = isSecureOnlyDevice(rawMetadata); + status_t mStatus = OK; + if (isSecureOnlyCamera) { + StreamConfiguration secureStreamConfig = getStreamConfiguration( + rawMetadata, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED); + EXPECT_TRUE(secureStreamConfig.width != -1); + EXPECT_TRUE(secureStreamConfig.height != -1); + chosenImageFormat = AIMAGE_FORMAT_PRIVATE; + chosenImageWidth = secureStreamConfig.width; + chosenImageHeight = secureStreamConfig.height; + mStatus = AImageReader_newWithUsage( + chosenImageWidth, chosenImageHeight, chosenImageFormat, + AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT, kCaptureRequestCount, &reader); + + } else { + if (isDepthOnlyDevice) { + StreamConfiguration depthStreamConfig = getStreamConfiguration( + rawMetadata, ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS, + ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT, + HAL_PIXEL_FORMAT_Y16); + EXPECT_TRUE(depthStreamConfig.width != -1); + EXPECT_TRUE(depthStreamConfig.height != -1); + chosenImageFormat = AIMAGE_FORMAT_DEPTH16; + chosenImageWidth = depthStreamConfig.width; + chosenImageHeight = depthStreamConfig.height; + } + mStatus = AImageReader_new(chosenImageWidth, chosenImageHeight, chosenImageFormat, + kCaptureRequestCount, &reader); + } + + EXPECT_EQ(mStatus, AMEDIA_OK); + native_handle_t* wh = nullptr; + mStatus = AImageReader_getWindowNativeHandle(reader, &wh); + EXPECT_TRUE(mStatus == AMEDIA_OK && wh != nullptr); + + ret = deviceRemote->beginConfigure(); + EXPECT_TRUE(ret.isOk()); + + OutputConfiguration output = createOutputConfiguration({wh}); + int32_t streamId = -1; + ret = deviceRemote->createStream(output, &streamId); + EXPECT_TRUE(ret.isOk()); + EXPECT_TRUE(streamId >= 0); + + AidlCameraMetadata sessionParams; + ret = deviceRemote->endConfigure(StreamConfigurationMode::NORMAL_MODE, sessionParams, + systemTime()); + EXPECT_TRUE(ret.isOk()); + + if (prepareWindows) { + ret = deviceRemote->prepare(streamId); + EXPECT_TRUE(ret.isOk()); + EXPECT_TRUE(callbacks->waitForPreparedCount(streamId, 1)); + + ret = deviceRemote->prepare(streamId); + // We should get another callback; + EXPECT_TRUE(ret.isOk()); + EXPECT_TRUE(callbacks->waitForPreparedCount(streamId, 2)); + } + AidlCameraMetadata aidlSettingsMetadata; + ret = deviceRemote->createDefaultRequest(TemplateId::PREVIEW, &aidlSettingsMetadata); + EXPECT_TRUE(ret.isOk()); + EXPECT_GE(aidlSettingsMetadata.metadata.size(), 0); + std::vector<CaptureRequest> captureRequests; + captureRequests.resize(kNumRequests); + for (int i = 0; i < kNumRequests; i++) { + CaptureRequest& captureRequest = captureRequests[i]; + initializeCaptureRequestPartial(&captureRequest, streamId, it.cameraId, + aidlSettingsMetadata.metadata.size()); + // Write the settings metadata into the fmq. + bool written = requestMQ->write( + reinterpret_cast<int8_t*>(aidlSettingsMetadata.metadata.data()), + aidlSettingsMetadata.metadata.size()); + EXPECT_TRUE(written); + } + + SubmitInfo info; + // Test a single capture + ret = deviceRemote->submitRequestList(captureRequests, false, &info); + EXPECT_TRUE(ret.isOk()); + EXPECT_GE(info.requestId, 0); + EXPECT_TRUE(callbacks->waitForStatus( + CameraDeviceCallback::LocalCameraDeviceStatus::RESULT_RECEIVED)); + EXPECT_TRUE(callbacks->waitForIdle()); + + // Test repeating requests + CaptureRequest captureRequest; + initializeCaptureRequestPartial(&captureRequest, streamId, it.cameraId, + aidlSettingsMetadata.metadata.size()); + + bool written = + requestMQ->write(reinterpret_cast<int8_t*>(aidlSettingsMetadata.metadata.data()), + aidlSettingsMetadata.metadata.size()); + EXPECT_TRUE(written); + + ret = deviceRemote->submitRequestList({captureRequest}, true, &info); + EXPECT_TRUE(ret.isOk()); + EXPECT_TRUE(callbacks->waitForStatus( + CameraDeviceCallback::LocalCameraDeviceStatus::RESULT_RECEIVED)); + + int64_t lastFrameNumber = -1; + ret = deviceRemote->cancelRepeatingRequest(&lastFrameNumber); + EXPECT_TRUE(ret.isOk()); + EXPECT_GE(lastFrameNumber, 0); + + // Test waitUntilIdle() + auto statusRet = deviceRemote->waitUntilIdle(); + EXPECT_TRUE(statusRet.isOk()); + + // Test deleteStream() + statusRet = deviceRemote->deleteStream(streamId); + EXPECT_TRUE(statusRet.isOk()); + + ret = deviceRemote->disconnect(); + EXPECT_TRUE(ret.isOk()); + } + ret = mCameraService->removeListener(listener); + EXPECT_TRUE(ret.isOk()); + } + + std::shared_ptr<ICameraService> mCameraService = nullptr; +}; + +// Basic AIDL calls for ICameraService +TEST_P(VtsAidlCameraServiceTargetTest, BasicCameraLifeCycleTest) { + BasicCameraTests(/*prepareWindows*/ false); + BasicCameraTests(/*prepareWindows*/ true); +} + +TEST_P(VtsAidlCameraServiceTargetTest, CameraServiceListenerTest) { + std::shared_ptr<CameraServiceListener> listener = + ndk::SharedRefBase::make<CameraServiceListener>(); + if (mCameraService == nullptr) return; + + std::vector<CameraStatusAndId> cameraStatuses; + ndk::ScopedAStatus ret = mCameraService->addListener(listener, &cameraStatuses); + EXPECT_TRUE(ret.isOk()); + listener->initializeStatuses(cameraStatuses); + + for (const auto& it : cameraStatuses) { + CameraMetadata rawMetadata; + AidlCameraMetadata aidlCameraMetadata; + ret = mCameraService->getCameraCharacteristics(it.cameraId, &aidlCameraMetadata); + EXPECT_TRUE(ret.isOk()); + bool cStatus = convertFromAidlCloned(aidlCameraMetadata, &rawMetadata); + EXPECT_TRUE(cStatus); + EXPECT_FALSE(rawMetadata.isEmpty()); + + bool isLogicalCamera = doesCapabilityExist( + rawMetadata, ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA); + if (!isLogicalCamera) { + EXPECT_TRUE(it.unavailPhysicalCameraIds.empty()); + continue; + } + camera_metadata_entry entry = rawMetadata.find(ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS); + EXPECT_GT(entry.count, 0); + + std::unordered_set<std::string> validPhysicalIds; + const uint8_t* ids = entry.data.u8; + size_t start = 0; + for (size_t i = 0; i < entry.count; i++) { + if (ids[i] == '\0') { + if (start != i) { + std::string currentId(reinterpret_cast<const char*>(ids + start)); + validPhysicalIds.emplace(currentId); + } + start = i + 1; + } + } + + std::unordered_set<std::string> unavailablePhysicalIds(it.unavailPhysicalCameraIds.begin(), + it.unavailPhysicalCameraIds.end()); + EXPECT_EQ(unavailablePhysicalIds.size(), it.unavailPhysicalCameraIds.size()); + for (auto& unavailablePhysicalId : unavailablePhysicalIds) { + EXPECT_NE(validPhysicalIds.find(unavailablePhysicalId), validPhysicalIds.end()); + } + } + + ret = mCameraService->removeListener(listener); + EXPECT_TRUE(ret.isOk()); +} + +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VtsAidlCameraServiceTargetTest); +INSTANTIATE_TEST_SUITE_P(PerInstance, VtsAidlCameraServiceTargetTest, + testing::ValuesIn({std::string(ICameraService::descriptor) + "/default"}), + android::hardware::PrintInstanceNameToString); + +} // namespace android diff --git a/sensorservice/aidl/Android.bp b/sensorservice/aidl/Android.bp index 3183cb1..35eea3e 100644 --- a/sensorservice/aidl/Android.bp +++ b/sensorservice/aidl/Android.bp @@ -9,7 +9,7 @@ aidl_interface { srcs: ["android/frameworks/sensorservice/*.aidl"], stability: "vintf", imports: [ - "android.hardware.sensors-V1", + "android.hardware.sensors-V2", "android.hardware.common-V2", ], backend: { @@ -20,4 +20,15 @@ aidl_interface { enabled: false, }, }, + versions_with_info: [ + { + version: "1", + imports: [ + "android.hardware.sensors-V2", + "android.hardware.common-V2", + ], + }, + ], + frozen: true, + } diff --git a/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/.hash b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/.hash new file mode 100644 index 0000000..1b15961 --- /dev/null +++ b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/.hash @@ -0,0 +1 @@ +514f08f7a595501066b94e5de878d240b4d49456 diff --git a/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IDirectReportChannel.aidl b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IDirectReportChannel.aidl new file mode 100644 index 0000000..09c491a --- /dev/null +++ b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IDirectReportChannel.aidl @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.sensorservice; +@VintfStability +interface IDirectReportChannel { + int configure(in int sensorHandle, in android.hardware.sensors.ISensors.RateLevel rate); +} diff --git a/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IEventQueue.aidl b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IEventQueue.aidl new file mode 100644 index 0000000..118a1c7 --- /dev/null +++ b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IEventQueue.aidl @@ -0,0 +1,24 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.sensorservice; +@VintfStability +interface IEventQueue { + void disableSensor(in int sensorHandle); + void enableSensor(in int sensorHandle, in int samplingPeriodUs, in long maxBatchReportLatencyUs); +} diff --git a/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IEventQueueCallback.aidl b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IEventQueueCallback.aidl new file mode 100644 index 0000000..2aaf91a --- /dev/null +++ b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/IEventQueueCallback.aidl @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.sensorservice; +@VintfStability +interface IEventQueueCallback { + oneway void onEvent(in android.hardware.sensors.Event event); +} diff --git a/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/ISensorManager.aidl b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/ISensorManager.aidl new file mode 100644 index 0000000..85cae01 --- /dev/null +++ b/sensorservice/aidl/aidl_api/android.frameworks.sensorservice/1/android/frameworks/sensorservice/ISensorManager.aidl @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.sensorservice; +@VintfStability +interface ISensorManager { + android.frameworks.sensorservice.IDirectReportChannel createAshmemDirectChannel(in android.hardware.common.Ashmem mem, in long size); + android.frameworks.sensorservice.IEventQueue createEventQueue(in android.frameworks.sensorservice.IEventQueueCallback callback); + android.frameworks.sensorservice.IDirectReportChannel createGrallocDirectChannel(in ParcelFileDescriptor buffer, in long size); + android.hardware.sensors.SensorInfo getDefaultSensor(in android.hardware.sensors.SensorType type); + android.hardware.sensors.SensorInfo[] getSensorList(); + const int RESULT_NOT_EXIST = 1; + const int RESULT_NO_MEMORY = 2; + const int RESULT_NO_INIT = 3; + const int RESULT_PERMISSION_DENIED = 4; + const int RESULT_BAD_VALUE = 5; + const int RESULT_INVALID_OPERATION = 6; + const int RESULT_UNKNOWN_ERROR = 7; +} diff --git a/sensorservice/aidl/vts/Android.bp b/sensorservice/aidl/vts/Android.bp index 41806f1..0d7c34a 100644 --- a/sensorservice/aidl/vts/Android.bp +++ b/sensorservice/aidl/vts/Android.bp @@ -29,7 +29,7 @@ cc_test { shared_libs: [ "libcutils", "libbinder_ndk", - "android.hardware.sensors-V1-ndk", + "android.hardware.sensors-V2-ndk", "android.frameworks.sensorservice-V1-ndk", ], static_libs: [ diff --git a/sensorservice/libsensorndkbridge/ALooper.cpp b/sensorservice/libsensorndkbridge/ALooper.cpp index d3ddbff..a4cb8cf 100644 --- a/sensorservice/libsensorndkbridge/ALooper.cpp +++ b/sensorservice/libsensorndkbridge/ALooper.cpp @@ -23,16 +23,14 @@ #include <android-base/logging.h> using android::Mutex; -using android::sp; -using android::wp; ALooper::ALooper() : mAwoken(false) { } -void ALooper::signalSensorEvents(wp<ASensorEventQueue> queue) { +void ALooper::signalSensorEvents(const std::shared_ptr<ASensorEventQueue>& queue) { Mutex::Autolock autoLock(mLock); - mReadyQueues.insert(queue); + mReadyQueues.push_back(std::weak_ptr<ASensorEventQueue>(queue)); mCondition.signal(); } @@ -74,7 +72,7 @@ int ALooper::pollOnce( result = ALOOPER_POLL_CALLBACK; for (auto& queue : mReadyQueues) { - sp<ASensorEventQueue> promotedQueue = queue.promote(); + std::shared_ptr<ASensorEventQueue> promotedQueue = queue.lock(); if (promotedQueue != nullptr) { promotedQueue->dispatchCallback(); } @@ -91,7 +89,13 @@ int ALooper::pollOnce( return result; } -void ALooper::invalidateSensorQueue(wp<ASensorEventQueue> queue) { +void ALooper::invalidateSensorQueue(const std::shared_ptr<ASensorEventQueue>& queue) { Mutex::Autolock autoLock(mLock); - mReadyQueues.erase(queue); + + mReadyQueues.erase(std::remove_if(mReadyQueues.begin(), mReadyQueues.end(), + [&](const std::weak_ptr<ASensorEventQueue>& ptr) { + std::shared_ptr<ASensorEventQueue> in = ptr.lock(); + return (in == nullptr) || (in == queue); + }), + mReadyQueues.end()); } diff --git a/sensorservice/libsensorndkbridge/ALooper.h b/sensorservice/libsensorndkbridge/ALooper.h index 5fa2b62..4a9093f 100644 --- a/sensorservice/libsensorndkbridge/ALooper.h +++ b/sensorservice/libsensorndkbridge/ALooper.h @@ -23,25 +23,25 @@ #include <utils/Mutex.h> #include <utils/RefBase.h> -#include <set> +#include <vector> struct ASensorEventQueue; struct ALooper { ALooper(); - void signalSensorEvents(android::wp<ASensorEventQueue> queue); + void signalSensorEvents(const std::shared_ptr<ASensorEventQueue>& queue); void wake(); int pollOnce(int timeoutMillis, int *outFd, int *outEvents, void **outData); - void invalidateSensorQueue(android::wp<ASensorEventQueue> queue); + void invalidateSensorQueue(const std::shared_ptr<ASensorEventQueue>& queue); private: android::Mutex mLock; android::Condition mCondition; - std::set<android::wp<ASensorEventQueue>> mReadyQueues; + std::vector<std::weak_ptr<ASensorEventQueue>> mReadyQueues; bool mAwoken; DISALLOW_COPY_AND_ASSIGN(ALooper); diff --git a/sensorservice/libsensorndkbridge/ASensorEventQueue.cpp b/sensorservice/libsensorndkbridge/ASensorEventQueue.cpp index bf24f68..2969da1 100644 --- a/sensorservice/libsensorndkbridge/ASensorEventQueue.cpp +++ b/sensorservice/libsensorndkbridge/ASensorEventQueue.cpp @@ -20,14 +20,12 @@ #define LOG_TAG "libsensorndkbridge" #include <android-base/logging.h> +#include <android/binder_auto_utils.h> -using android::sp; -using android::frameworks::sensorservice::V1_0::Result; -using android::hardware::sensors::V1_0::SensorInfo; -using android::OK; +using aidl::android::hardware::sensors::SensorInfo; using android::BAD_VALUE; using android::Mutex; -using android::hardware::Return; +using android::OK; ASensorEventQueue::ASensorEventQueue(ALooper* looper, ALooper_callbackFunc callback, void* data) : mLooper(looper), @@ -36,7 +34,7 @@ ASensorEventQueue::ASensorEventQueue(ALooper* looper, ALooper_callbackFunc callb mRequestAdditionalInfo(false), mValid(true) {} -void ASensorEventQueue::setImpl(const sp<IEventQueue> &queueImpl) { +void ASensorEventQueue::setImpl(const std::shared_ptr<IEventQueue>& queueImpl) { mQueueImpl = queueImpl; } @@ -44,10 +42,9 @@ int ASensorEventQueue::registerSensor( ASensorRef sensor, int32_t samplingPeriodUs, int64_t maxBatchReportLatencyUs) { - Return<Result> ret = mQueueImpl->enableSensor( - reinterpret_cast<const SensorInfo *>(sensor)->sensorHandle, - samplingPeriodUs, - maxBatchReportLatencyUs); + ndk::ScopedAStatus ret = + mQueueImpl->enableSensor(reinterpret_cast<const SensorInfo*>(sensor)->sensorHandle, + samplingPeriodUs, maxBatchReportLatencyUs); if (!ret.isOk()) { return BAD_VALUE; @@ -77,8 +74,8 @@ int ASensorEventQueue::requestAdditionalInfoEvents(bool enable) { } int ASensorEventQueue::disableSensor(ASensorRef sensor) { - Return<Result> ret = mQueueImpl->disableSensor( - reinterpret_cast<const SensorInfo *>(sensor)->sensorHandle); + ndk::ScopedAStatus ret = + mQueueImpl->disableSensor(reinterpret_cast<const SensorInfo*>(sensor)->sensorHandle); return ret.isOk() ? OK : BAD_VALUE; } @@ -106,7 +103,7 @@ int ASensorEventQueue::hasEvents() const { return !mQueue.empty(); } -Return<void> ASensorEventQueue::onEvent(const Event &event) { +ndk::ScopedAStatus ASensorEventQueue::onEvent(const Event& event) { LOG(VERBOSE) << "ASensorEventQueue::onEvent"; if (static_cast<int32_t>(event.sensorType) != ASENSOR_TYPE_ADDITIONAL_INFO || @@ -127,17 +124,16 @@ Return<void> ASensorEventQueue::onEvent(const Event &event) { Mutex::Autolock autoLock(mLock); mQueue.emplace_back(); sensors_event_t* sensorEvent = &mQueue[mQueue.size() - 1]; - android::hardware::sensors::V1_0::implementation::convertToSensorEvent(event, - sensorEvent); + android::hardware::sensors::implementation::convertToSensorEvent(event, sensorEvent); } Mutex::Autolock autoLock(mValidLock); if (mValid) { - mLooper->signalSensorEvents(this); + mLooper->signalSensorEvents(this->ref<ASensorEventQueue>()); } } - return android::hardware::Void(); + return ndk::ScopedAStatus::ok(); } void ASensorEventQueue::dispatchCallback() { @@ -159,7 +155,7 @@ void ASensorEventQueue::invalidate() { Mutex::Autolock autoLock(mValidLock); mValid = false; } - mLooper->invalidateSensorQueue(this); + mLooper->invalidateSensorQueue(this->ref<ASensorEventQueue>()); setImpl(nullptr); } diff --git a/sensorservice/libsensorndkbridge/ASensorEventQueue.h b/sensorservice/libsensorndkbridge/ASensorEventQueue.h index 7139d34..6c7f5c4 100644 --- a/sensorservice/libsensorndkbridge/ASensorEventQueue.h +++ b/sensorservice/libsensorndkbridge/ASensorEventQueue.h @@ -18,31 +18,32 @@ #define A_SENSOR_EVENT_QUEUE_H_ -#include <android/frameworks/sensorservice/1.0/IEventQueue.h> -#include <android/frameworks/sensorservice/1.0/IEventQueueCallback.h> +#include <aidl/android/frameworks/sensorservice/BnEventQueueCallback.h> +#include <aidl/android/frameworks/sensorservice/IEventQueue.h> +#include <aidl/sensors/convert.h> +#include <android-base/macros.h> +#include <android/binder_auto_utils.h> #include <android/looper.h> #include <android/sensor.h> -#include <android-base/macros.h> -#include <sensors/convert.h> #include <utils/Mutex.h> +#include <utils/RefBase.h> #include <atomic> struct ALooper; -struct ASensorEventQueue - : public android::frameworks::sensorservice::V1_0::IEventQueueCallback { - using Event = android::hardware::sensors::V1_0::Event; - using IEventQueue = android::frameworks::sensorservice::V1_0::IEventQueue; +struct ASensorEventQueue : public aidl::android::frameworks::sensorservice::BnEventQueueCallback { + using Event = aidl::android::hardware::sensors::Event; + using IEventQueue = aidl::android::frameworks::sensorservice::IEventQueue; ASensorEventQueue( ALooper *looper, ALooper_callbackFunc callback, void *data); - android::hardware::Return<void> onEvent(const Event &event) override; + ndk::ScopedAStatus onEvent(const Event& event) override; - void setImpl(const android::sp<IEventQueue> &queueImpl); + void setImpl(const std::shared_ptr<IEventQueue>& queueImpl); int registerSensor( ASensorRef sensor, @@ -67,7 +68,7 @@ private: ALooper *mLooper; ALooper_callbackFunc mCallback; void *mData; - android::sp<IEventQueue> mQueueImpl; + std::shared_ptr<IEventQueue> mQueueImpl; android::Mutex mLock; std::vector<sensors_event_t> mQueue; diff --git a/sensorservice/libsensorndkbridge/ASensorManager.cpp b/sensorservice/libsensorndkbridge/ASensorManager.cpp index de552e0..a7180ed 100644 --- a/sensorservice/libsensorndkbridge/ASensorManager.cpp +++ b/sensorservice/libsensorndkbridge/ASensorManager.cpp @@ -19,25 +19,25 @@ #include "ASensorManager.h" #define LOG_TAG "libsensorndkbridge" +#include <aidl/sensors/convert.h> #include <android-base/logging.h> +#include <android/binder_auto_utils.h> +#include <android/binder_ibinder_platform.h> +#include <android/binder_manager.h> +#include <android/binder_process.h> #include <android/looper.h> -#include <hidl/HidlTransportSupport.h> -#include <sensors/convert.h> - -using android::hardware::sensors::V1_0::SensorInfo; -using android::frameworks::sensorservice::V1_0::IEventQueue; -using android::frameworks::sensorservice::V1_0::ISensorManager; -using android::frameworks::sensorservice::V1_0::Result; -using android::hardware::sensors::V1_0::SensorType; -using android::sp; -using android::wp; + +#include <thread> + +using aidl::android::frameworks::sensorservice::IEventQueue; +using aidl::android::frameworks::sensorservice::ISensorManager; +using aidl::android::hardware::sensors::SensorInfo; +using aidl::android::hardware::sensors::SensorType; +using android::BAD_VALUE; using android::Mutex; -using android::status_t; -using android::OK; using android::NO_INIT; -using android::BAD_VALUE; -using android::hardware::hidl_vec; -using android::hardware::Return; +using android::OK; +using android::status_t; static Mutex gLock; @@ -57,8 +57,7 @@ ASensorManager *ASensorManager::getInstance() { return sInstance; } -void ASensorManager::SensorDeathRecipient::serviceDied( - uint64_t, const wp<::android::hidl::base::V1_0::IBase>&) { +void ASensorManager::serviceDied(void*) { LOG(ERROR) << "Sensor service died. Cleanup sensor manager instance!"; Mutex::Autolock autoLock(gLock); delete sInstance; @@ -67,14 +66,22 @@ void ASensorManager::SensorDeathRecipient::serviceDied( ASensorManager::ASensorManager() : mInitCheck(NO_INIT) { - mManager = ISensorManager::getService(); + if (!ABinderProcess_isThreadPoolStarted()) { + std::thread([]() { + ABinderProcess_joinThreadPool(); + LOG(ERROR) << "SHOULD NOT EXIT"; + }).detach(); + LOG(ERROR) << "The user of libsensorndkbridge did not start a threadpool"; + } + const std::string name = std::string() + ISensorManager::descriptor + "/default"; + mManager = + ISensorManager::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService(name.c_str()))); if (mManager != NULL) { - mDeathRecipient = new SensorDeathRecipient(); - Return<bool> linked = mManager->linkToDeath(mDeathRecipient, /*cookie*/ 0); - if (!linked.isOk()) { - LOG(ERROR) << "Transaction error in linking to sensor service death: " << - linked.description().c_str(); - } else if (!linked) { + mDeathRecipient = + ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied)); + auto linked = + AIBinder_linkToDeath(mManager->asBinder().get(), mDeathRecipient.get(), nullptr); + if (linked != OK) { LOG(WARNING) << "Unable to link to sensor service death notifications"; } else { LOG(DEBUG) << "Link to sensor service death notification successful"; @@ -93,16 +100,11 @@ int ASensorManager::getSensorList(ASensorList *out) { Mutex::Autolock autoLock(mLock); if (mSensorList == NULL) { - Return<void> ret = - mManager->getSensorList([&](const auto &list, auto result) { - if (result != Result::OK) { - return; - } - - mSensors = list; - }); + ndk::ScopedAStatus ret = mManager->getSensorList(&mSensors); - (void)ret.isOk(); + if (!ret.isOk()) { + LOG(ERROR) << "Failed to get sensor list: " << ret; + } mSensorList.reset(new ASensorRef[mSensors.size()]); for (size_t i = 0; i < mSensors.size(); ++i) { @@ -123,24 +125,21 @@ ASensorRef ASensorManager::getDefaultSensor(int type) { ASensorRef defaultSensor = NULL; - Return<void> ret = mManager->getDefaultSensor( - static_cast<SensorType>(type), - [&](const auto &sensor, auto result) { - if (result != Result::OK) { - return; - } + SensorInfo sensor; + + ndk::ScopedAStatus ret = mManager->getDefaultSensor(static_cast<SensorType>(type), &sensor); - for (size_t i = 0; i < mSensors.size(); ++i) { - if (sensor == mSensors[i]) { - defaultSensor = - reinterpret_cast<ASensorRef>(&mSensors[i]); + if (!ret.isOk()) { + LOG(ERROR) << "Failed to get default sensor of type " << type << " with error: " << ret; + } - break; - } - } - }); + for (size_t i = 0; i < mSensors.size(); ++i) { + if (sensor == mSensors[i]) { + defaultSensor = reinterpret_cast<ASensorRef>(&mSensors[i]); - (void)ret.isOk(); + break; + } + } return defaultSensor; } @@ -158,28 +157,23 @@ ASensorEventQueue *ASensorManager::createEventQueue( void *data) { LOG(VERBOSE) << "ASensorManager::createEventQueue"; - sp<ASensorEventQueue> queue = - new ASensorEventQueue(looper, callback, data); + std::shared_ptr<ASensorEventQueue> queue = + ndk::SharedRefBase::make<ASensorEventQueue>(looper, callback, data); - ::android::hardware::setMinSchedulerPolicy(queue, SCHED_FIFO, 98); - Result result; - Return<void> ret = - mManager->createEventQueue( - queue, [&](const sp<IEventQueue> &queueImpl, auto tmpResult) { - result = tmpResult; - if (result != Result::OK) { - return; - } + AIBinder_setMinSchedulerPolicy(queue->asBinder().get(), SCHED_FIFO, 98); + std::shared_ptr<IEventQueue> eventQueue; + ndk::ScopedAStatus ret = mManager->createEventQueue(queue, &eventQueue); - queue->setImpl(queueImpl); - }); - - if (!ret.isOk() || result != Result::OK) { - LOG(ERROR) << "FAILED to create event queue"; + if (!ret.isOk()) { + LOG(ERROR) << "FAILED to create event queue: " << ret; return NULL; } + queue->setImpl(eventQueue); - queue->incStrong(NULL /* id */); + { + Mutex::Autolock autoLock(mQueuesLock); + mQueues.push_back(queue); + } LOG(VERBOSE) << "Returning event queue " << queue.get(); return queue.get(); @@ -190,8 +184,14 @@ void ASensorManager::destroyEventQueue(ASensorEventQueue *queue) { queue->invalidate(); - queue->decStrong(NULL /* id */); - queue = NULL; + { + Mutex::Autolock autoLock(mQueuesLock); + mQueues.erase(std::remove_if(mQueues.begin(), mQueues.end(), + [&](const std::shared_ptr<ASensorEventQueue>& ptr) { + return ptr.get() == queue; + }), + mQueues.end()); + } } //////////////////////////////////////////////////////////////////////////////// @@ -374,7 +374,7 @@ float ASensor_getResolution(ASensor const* sensor) { int ASensor_getMinDelay(ASensor const* sensor) { RETURN_IF_SENSOR_IS_NULL(ASENSOR_DELAY_INVALID); - return reinterpret_cast<const SensorInfo *>(sensor)->minDelay; + return reinterpret_cast<const SensorInfo*>(sensor)->minDelayUs; } int ASensor_getFifoMaxEventCount(ASensor const* sensor) { diff --git a/sensorservice/libsensorndkbridge/ASensorManager.h b/sensorservice/libsensorndkbridge/ASensorManager.h index 4e91122..e45cbfe 100644 --- a/sensorservice/libsensorndkbridge/ASensorManager.h +++ b/sensorservice/libsensorndkbridge/ASensorManager.h @@ -18,8 +18,8 @@ #define A_SENSOR_MANAGER_H_ +#include <aidl/android/frameworks/sensorservice/ISensorManager.h> #include <android-base/macros.h> -#include <android/frameworks/sensorservice/1.0/ISensorManager.h> #include <android/sensor.h> #include <utils/Mutex.h> #include <utils/RefBase.h> @@ -48,26 +48,23 @@ struct ASensorManager { // ALooper. void destroyEventQueue(ASensorEventQueue *queue); -private: + static void serviceDied(void* cookie); - struct SensorDeathRecipient : public android::hardware::hidl_death_recipient - { - // hidl_death_recipient interface - virtual void serviceDied(uint64_t cookie, - const ::android::wp<::android::hidl::base::V1_0::IBase>& who) override; - }; - - using ISensorManager = android::frameworks::sensorservice::V1_0::ISensorManager; - using SensorInfo = android::hardware::sensors::V1_0::SensorInfo; + private: + using ISensorManager = aidl::android::frameworks::sensorservice::ISensorManager; + using SensorInfo = aidl::android::hardware::sensors::SensorInfo; static ASensorManager *sInstance; - android::sp<SensorDeathRecipient> mDeathRecipient = nullptr; + ndk::ScopedAIBinder_DeathRecipient mDeathRecipient; android::status_t mInitCheck; - android::sp<ISensorManager> mManager; + std::shared_ptr<ISensorManager> mManager; + + mutable android::Mutex mQueuesLock; + std::vector<std::shared_ptr<ASensorEventQueue>> mQueues; mutable android::Mutex mLock; - android::hardware::hidl_vec<SensorInfo> mSensors; + std::vector<SensorInfo> mSensors; std::unique_ptr<ASensorRef[]> mSensorList; DISALLOW_COPY_AND_ASSIGN(ASensorManager); diff --git a/sensorservice/libsensorndkbridge/Android.bp b/sensorservice/libsensorndkbridge/Android.bp index 33b9619..f5de01c 100644 --- a/sensorservice/libsensorndkbridge/Android.bp +++ b/sensorservice/libsensorndkbridge/Android.bp @@ -24,16 +24,19 @@ cc_library_shared { "ASensorEventQueue.cpp", "ASensorManager.cpp", ], - cflags: ["-Wall", "-Werror"], + cflags: [ + "-Wall", + "-Werror", + ], shared_libs: [ "libbase", - "libhidlbase", + "libbinder_ndk", "libutils", - "android.frameworks.sensorservice@1.0", - "android.hardware.sensors@1.0", + "android.frameworks.sensorservice-V1-ndk", + "android.hardware.sensors-V2-ndk", ], static_libs: [ - "android.hardware.sensors@1.0-convert", + "android.hardware.sensors-V1-convert", ], header_libs: [ @@ -43,4 +46,11 @@ cc_library_shared { export_header_lib_headers: [ "libandroid_sensor_headers", ], + + export_shared_lib_headers: [ + "android.frameworks.sensorservice-V1-ndk", + ], + export_static_lib_headers: [ + "android.hardware.sensors-V1-convert", + ], } diff --git a/sensorservice/utils/Android.bp b/sensorservice/utils/Android.bp new file mode 100644 index 0000000..1617700 --- /dev/null +++ b/sensorservice/utils/Android.bp @@ -0,0 +1,31 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_library_static { + name: "libsensorndkutils", + srcs: [ + "direct_channel_buffer_reader.cc", + ], + cflags: ["-Wall", "-Werror"], + shared_libs: [ + "libbase", + ], + header_libs: [ + "libhardware_headers", + ], + host_supported: true, +} + +cc_test { + name: "libsensorndkutils_test", + srcs: ["direct_channel_buffer_reader_test.cc"], + shared_libs: [ + "libbase", + ], + static_libs: [ + "libgtest", + "libsensorndkutils", + ], + host_supported: true, +} diff --git a/sensorservice/utils/direct_channel_buffer_reader.cc b/sensorservice/utils/direct_channel_buffer_reader.cc new file mode 100644 index 0000000..b639405 --- /dev/null +++ b/sensorservice/utils/direct_channel_buffer_reader.cc @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2022 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. + */ + +#include "direct_channel_buffer_reader.h" + +#include <android-base/logging.h> +#include <hardware/sensors.h> + +namespace { + +// DirectChannelBufferReader::Read() keeps reading until it catches up with the +// write head. To avoid infinite reads in case of corrupted buffer, put an upper +// bound on number of reads. Read() would read at most +// <kMaxReadRounds * buffer_size_samples> samples. +constexpr int kMaxReadRounds = 2; + +} // namespace + +DirectChannelBufferReader::DirectChannelBufferReader(const sensors_event_t* direct_channel_buffer, + int buffer_size_samples) + : direct_channel_buffer_(direct_channel_buffer), buffer_size_samples_(buffer_size_samples) {} + +int DirectChannelBufferReader::Read(int* num_samples_skipped) { + int num_samples_read = 0; + int64_t last_atomic_counter_before_read = last_atomic_counter_; + // Keep reading samples until reaching the write head. + // Example: 1 2 3 4 0 + // ^ + // head + // + // Example: 11 12 13 14 5 6 7 8 9 10 + // ^ + // head + // + // Example: UINT32_MAX-1 UINT32_MAX 1 UINT32_MAX-3 UINT32_MAX-2 + // ^ + // head + // + // Here is a more interesting corner case: + // 1 2 <- samples obtained in previous calls to Read() + // 1 2 3 + // ^ + // Got a new sample. Keep reading. + // + // 1 2 3 14 15 16 7 + // -------- ^ + // Reached the head but only got 3 samples with + // consecutive counter values. Sample 3 may be + // corrupted so it should be discarded. Also we + // are still missing sample 8-13. Keep reading. + // + // 1 2 3 14 15 16 7 8 9 10 (Got 8-10. Keep reading) + // + // 11 12 13 14 15 16 7 8 9 10 + // ^ + // Reached the head and got all 10 consecutive + // samples. Stop reading. Sample 3 was discarded + // when buffer_ was truncated. + while (true) { + buffer_.push_back(ReadOneSample(index_)); + num_samples_read++; + int64_t atomic_counter = static_cast<uint32_t>(buffer_.back().reserved0); + bool reached_zero_counter_head = atomic_counter == 0; + bool reached_regular_head = + atomic_counter == + ((last_atomic_counter_ + UINT32_MAX - buffer_size_samples_) % UINT32_MAX) + 1; + bool has_enough_consecutive_samples = streak_ >= buffer_size_samples_; + if (reached_zero_counter_head || (reached_regular_head && has_enough_consecutive_samples)) { + buffer_.pop_back(); + num_samples_read--; + // At this point the samples in <buffer_> are guaranteed to be free + // of corruption from data race. Here's the proof. + // Case 1: reached_zero_counter_head = true. The writer has not + // started overwriting any samples so all samples that have been + // read so far are valid. + // Case 2: reached_regular_head = true. E.g. suppose + // last_atomic_counter_ = 15 and buffer_size_samples_ = 10, now + // buffer_ would be [7, 8, 9, 10, 11, 12, 13, 14, 15]. The fact that we just + // saw a counter value of 6 means the writer has not start + // overwriting samples 7-15 yet. Therefore these samples are all + // valid. + break; + } + if (atomic_counter != (last_atomic_counter_ % UINT32_MAX) + 1) { + streak_ = 0; + } + streak_++; + last_atomic_counter_ = atomic_counter; + index_ = (index_ + 1) % buffer_size_samples_; + TruncateBuffer(); + if (num_samples_read > kMaxReadRounds * buffer_size_samples_) { + buffer_.clear(); + return kErrorHeadOfBufferNotFound; + } + } + num_samples_read = std::min(num_samples_read, buffer_size_samples_ - 1); + if (num_samples_skipped != nullptr) { + *num_samples_skipped = + last_atomic_counter_ - last_atomic_counter_before_read - num_samples_read; + } + return num_samples_read; +} + +const sensors_event_t DirectChannelBufferReader::ReadOneSample(int index) { + sensors_event_t event; + // reserved0 is the atomic counter and should be read first. + event.reserved0 = direct_channel_buffer_[index].reserved0; + event.version = direct_channel_buffer_[index].version; + event.sensor = direct_channel_buffer_[index].sensor; + event.type = direct_channel_buffer_[index].type; + event.timestamp = direct_channel_buffer_[index].timestamp; + event.u64.data[0] = direct_channel_buffer_[index].u64.data[0]; + event.u64.data[1] = direct_channel_buffer_[index].u64.data[1]; + event.u64.data[2] = direct_channel_buffer_[index].u64.data[2]; + event.u64.data[3] = direct_channel_buffer_[index].u64.data[3]; + event.u64.data[4] = direct_channel_buffer_[index].u64.data[4]; + event.u64.data[5] = direct_channel_buffer_[index].u64.data[5]; + event.u64.data[6] = direct_channel_buffer_[index].u64.data[6]; + event.u64.data[7] = direct_channel_buffer_[index].u64.data[7]; + return event; +} + +void DirectChannelBufferReader::TruncateBuffer() { + while (buffer_.size() > buffer_size_samples_ - 1) { + buffer_.pop_front(); + } +} diff --git a/sensorservice/utils/direct_channel_buffer_reader.h b/sensorservice/utils/direct_channel_buffer_reader.h new file mode 100644 index 0000000..5c91ea5 --- /dev/null +++ b/sensorservice/utils/direct_channel_buffer_reader.h @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2022 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 <hardware/sensors.h> + +#include <algorithm> +#include <deque> + +// A utility class that reads sensor samples from a direct channel buffer. +// Direct channel operates in a lockless manner and uses an atomic counter for +// synchronization. This class implements the counter based synchronization +// protocol and therefore guarantees data consistency. See +// https://developer.android.com/reference/android/hardware/SensorDirectChannel +// for more details on the atomic counter. +// +// Besides reading samples, the reader also supports keeping track of recently +// obtained samples. +// +// DirectChannelBufferReader is not thread safe. It's the caller's responsibility +// to serialize the calls, including the access to the returned sample +// container. +// +// Example usage: +// DirectChannelBufferReader reader(buf, 100); +// +// int num_samples = reader.Read(); +// const std::deque<sensors_event_t>& samples = reader.GetSampleContainer(); +// for (auto it = samples.end() - num_samples; it != samples.end(); it++) { +// HandleNewSamples(*it); +// } +// +// int num_samples_skipped; +// reader.Read(&num_samples_skipped); +// if (num_samples_skipped > 0) { +// ReportMissedSamples(num_samples_skipped); +// } +// +// +// Another example: +// +// DirectChannelBufferReader reader(buf, 100); +// +// std::vector<sensors_event_t> Query(int start_time, int end_time) { +// reader.Read(); +// std::vector<sensors_event_t> output; +// for (auto& sample : reader_.GetSampleContainer()) { +// if (sample.timestamp >= start_time && sample.timestamp < end_time) { +// output.push_back(sample); +// } +// } +// return output; +// } + +class DirectChannelBufferReader { + public: + static constexpr int kErrorHeadOfBufferNotFound = -1; + + // Constructor + // direct_channel_buffer: Pointer to the shared buffer where sensor samples + // are written into. + // buffer_size_samples: The size of direct_channel_buffer in number of + // samples. + DirectChannelBufferReader(const sensors_event_t* direct_channel_buffer, + int buffer_size_samples); + + virtual ~DirectChannelBufferReader() {} + + // Attempts to read samples from the direct channel buffer. Returns + // the number of samples read, or kErrorHeadOfBufferNotFound if the reader + // can not find the write head e.g. due to corrupted data in the buffer. + // The function is non-blocking and returns 0 if new samples are not available. + // The caller should control its polling based on external factors like + // events in a different subsystem (e.g. camera frame ready) + // After the call completes, the caller can use GetSampleContainer() to + // access the samples. Sometimes it may be possible for one or more samples + // in the direct channel buffer to be overwritten by the writter before the + // reader has a chance to read it, e.g. when the reader does not keep up + // with the writer. The number of samples that were lost / skipped is + // written to <num_samples_skipped>, if the argument is not null. + int Read(int* num_samples_skipped = nullptr); + + // Returns the container that holds recent samples. New samples are appended + // to the end of the container when Read() is called. Samples from previous + // rounds of Read() are kept around in the container, except when the total + // samples exceeds <buffer_size_samples> - 1, in which case older samples + // would be truncated. The caller is free to remove samples from the + // container, e.g. after the samples are consumed. + // + // Calls to the returned container must be synchronized with calls to this + // instance of DirectChannelBufferReader. + std::deque<sensors_event_t>& GetSampleContainer() { return buffer_; } + + protected: + // For test only. + virtual const sensors_event_t ReadOneSample(int index); + + private: + // Truncates the head of <buffer_> until its size <= buffer_size_samples - 1. + void TruncateBuffer(); + + // Points to the direct channel buffer where the sensor writes samples into. + const volatile sensors_event_t* direct_channel_buffer_; + + // The number of samples that <direct_channel_buffer_> is able to hold. + const int buffer_size_samples_; + + // The atomic counter value of the last valid sample. + int64_t last_atomic_counter_ = 0; + + // The index into <direct_channel_buffer_> that should be read next time. + int index_ = 0; + + // The number of successive sensors_event_t reads with consecutive atomic + // counters values. + // E.g. 1 => streak_ = 1 + // 5 6 7 => streak_ = 3 + // 1 2 3 14 => streak_ = 1 + // 1 2 3 14 15 => streak_ = 2 + int streak_ = 0; + + // The buffer holding recent samples. + std::deque<sensors_event_t> buffer_; +}; diff --git a/sensorservice/utils/direct_channel_buffer_reader_test.cc b/sensorservice/utils/direct_channel_buffer_reader_test.cc new file mode 100644 index 0000000..07ea8d1 --- /dev/null +++ b/sensorservice/utils/direct_channel_buffer_reader_test.cc @@ -0,0 +1,337 @@ +/* + * Copyright (C) 2022 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. + */ + +#include "direct_channel_buffer_reader.h" + +#include <android-base/logging.h> +#include <android-base/thread_annotations.h> +#include <gtest/gtest.h> +#include <stdlib.h> + +#include <condition_variable> +#include <mutex> +#include <thread> + +namespace { + +// A derived class of DirectChannelBufferReader that allows blocking memory read +// for concurrency tests. +class TestableDirectChannelBufferReader : public DirectChannelBufferReader { + public: + TestableDirectChannelBufferReader(const sensors_event_t* direct_channel_buffer, + int buffer_size_samples) + : DirectChannelBufferReader(direct_channel_buffer, buffer_size_samples) {} + + const sensors_event_t ReadOneSample(int index) { + { + std::unique_lock lk(mutex_); + reader_waiting_ = true; + lk.unlock(); + cv_.notify_one(); + } + { + std::unique_lock lk(mutex_); + cv_.wait(lk, [this] { return !should_block_reads_ || num_reads_unblocked_ > 0; }); + reader_waiting_ = false; + auto return_value = DirectChannelBufferReader::ReadOneSample(index); + num_reads_unblocked_--; + lk.unlock(); + cv_.notify_one(); + return return_value; + } + } + + void BlockReads() { + std::unique_lock lk(mutex_); + should_block_reads_ = true; + num_reads_unblocked_ = 0; + lk.unlock(); + cv_.notify_one(); + } + + void UnblockReads() { + std::unique_lock lk(mutex_); + should_block_reads_ = false; + lk.unlock(); + cv_.notify_one(); + } + + void UnblockAndWaitForReads(int num_reads) { + { + std::unique_lock lk(mutex_); + CHECK_EQ(num_reads_unblocked_, 0); + num_reads_unblocked_ = num_reads; + lk.unlock(); + cv_.notify_one(); + } + { + std::unique_lock lk(mutex_); + // Only proceed when reads are all done AND the reader is blocked again. + // This way we ensure nothing is done on the reader thread (like sample + // validation) when more samples are being written. + cv_.wait(lk, [this] { return num_reads_unblocked_ == 0 && reader_waiting_; }); + } + } + + private: + std::mutex mutex_; + std::condition_variable cv_; + bool should_block_reads_ GUARDED_BY(mutex_) = false; + bool reader_waiting_ GUARDED_BY(mutex_) = false; + int num_reads_unblocked_ GUARDED_BY(mutex_) = 0; +}; + +class DirectChannelBufferReaderTest : public ::testing::Test { + protected: + DirectChannelBufferReaderTest() : buffer_{}, reader_(&buffer_[0], kBufferSize) {} + + void WriteOneSample() { + WritePartialSample(); + FinishWritingSample(); + } + + void WritePartialSample() { buffer_[next_buffer_index_].timestamp = next_atomic_counter_; } + + void FinishWritingSample() { + buffer_[next_buffer_index_].data[0] = next_atomic_counter_; + buffer_[next_buffer_index_].reserved0 = next_atomic_counter_; + next_buffer_index_ = (next_buffer_index_ + 1) % kBufferSize; + next_atomic_counter_ = (next_atomic_counter_ % UINT32_MAX) + 1; + } + + void WriteHalfSample() { + if (buffer_[next_buffer_index_].timestamp != next_atomic_counter_) { + WritePartialSample(); + } else { + FinishWritingSample(); + } + } + + void ValidateReaderSamples() { + auto& samples = reader_.GetSampleContainer(); + for (int i = 0; i < samples.size(); i++) { + int64_t expected_value = + ((next_atomic_counter_ - samples.size() + i - 1 + UINT32_MAX) % UINT32_MAX) + 1; + EXPECT_EQ(static_cast<uint32_t>(samples[i].reserved0), expected_value) << " i = " << i; + EXPECT_EQ(samples[i].timestamp, expected_value); + EXPECT_EQ(samples[i].data[0], expected_value); + } + } + + void StartReaderThread() { + reader_.BlockReads(); + reader_thread_ = std::make_unique<std::thread>([this] { + while (keep_reading_) { + reader_.Read(); + // At this point we want to validate the samples and check the values + // against next_atomic_counter_. To prevent next_atomic_counter_ from + // being modified by the writer thread, we make the writer thread + // blocked inside UnblockAndWaitForReads() until the validation is done + // and reader_.Read() is called again. + ValidateReaderSamples(); + } + }); + } + + void StopAndJoinReaderThread() { + reader_.UnblockReads(); + keep_reading_ = false; + reader_thread_->join(); + } + + static constexpr int kBufferSize = 20; + std::array<sensors_event_t, kBufferSize> buffer_; + TestableDirectChannelBufferReader reader_; + + int next_buffer_index_ = 0; + int64_t next_atomic_counter_ = 1; + + std::unique_ptr<std::thread> reader_thread_; + bool keep_reading_ = true; +}; + +TEST_F(DirectChannelBufferReaderTest, ReturnNoDataForEmptyBuffer) { + EXPECT_EQ(reader_.Read(), 0); + EXPECT_EQ(reader_.GetSampleContainer().size(), 0); +} + +TEST_F(DirectChannelBufferReaderTest, ReturnOneSample) { + WriteOneSample(); + EXPECT_EQ(reader_.Read(), 1); + EXPECT_EQ(reader_.GetSampleContainer().size(), 1); +} + +TEST_F(DirectChannelBufferReaderTest, ReturnSamplesWithFullBuffer) { + for (int i = 0; i < kBufferSize; i++) { + WriteOneSample(); + } + EXPECT_EQ(reader_.Read(), kBufferSize - 1); + EXPECT_EQ(reader_.GetSampleContainer().size(), kBufferSize - 1); + ValidateReaderSamples(); +} + +TEST_F(DirectChannelBufferReaderTest, ReturnSamplesWithInterleavedWriteRead) { + WriteOneSample(); + EXPECT_EQ(reader_.Read(), 1); + WriteOneSample(); + WriteOneSample(); + EXPECT_EQ(reader_.Read(), 2); + EXPECT_EQ(reader_.GetSampleContainer().size(), 3); + ValidateReaderSamples(); +} + +TEST_F(DirectChannelBufferReaderTest, ReturnNothingAfterPartialWrite) { + WriteOneSample(); + EXPECT_EQ(reader_.Read(), 1); + WritePartialSample(); + EXPECT_EQ(reader_.Read(), 0); + FinishWritingSample(); + EXPECT_EQ(reader_.Read(), 1); + EXPECT_EQ(reader_.GetSampleContainer().size(), 2); + ValidateReaderSamples(); +} + +TEST_F(DirectChannelBufferReaderTest, DiscardPartiallyWrittenSample) { + WriteOneSample(); + EXPECT_EQ(reader_.Read(), 1); + for (int i = 0; i < kBufferSize; i++) { + WriteOneSample(); + } + // State of the buffer: 21 2 3 4 5 .... 20 + // ^ + // Both read and write head point here + + WritePartialSample(); + // State of the buffer: 21 2 3 4 5 .... 20 + // ^ + // Partially overwritten with sample 22 + // The next Read() should get sample 3-21. Sample 2 should be discarded. + EXPECT_EQ(reader_.Read(), kBufferSize - 1); + EXPECT_EQ(reader_.GetSampleContainer().front().timestamp, 3); + EXPECT_EQ(reader_.GetSampleContainer().back().timestamp, 21); +} + +TEST_F(DirectChannelBufferReaderTest, ReturnCorrectSamplesAfterWriterOverflow) { + WriteOneSample(); + reader_.Read(); + for (int i = 0; i < kBufferSize + 5; i++) { + WriteOneSample(); + } + EXPECT_EQ(reader_.Read(), kBufferSize - 1); + EXPECT_EQ(reader_.GetSampleContainer().size(), kBufferSize - 1); + ValidateReaderSamples(); +} + +TEST_F(DirectChannelBufferReaderTest, ReturnNumOfSkippedSamples) { + WriteOneSample(); + reader_.Read(); + for (int i = 0; i < kBufferSize + 5; i++) { + WriteOneSample(); + } + int num_samples_skipped = 0; + reader_.Read(&num_samples_skipped); + EXPECT_EQ(num_samples_skipped, 6); +} + +TEST_F(DirectChannelBufferReaderTest, WrapAroundUINT32Max) { + next_atomic_counter_ = UINT32_MAX - 3; + for (int i = 0; i < kBufferSize; i++) { + WriteOneSample(); + } + EXPECT_EQ(reader_.Read(), kBufferSize - 1); + EXPECT_EQ(reader_.GetSampleContainer().size(), kBufferSize - 1); + ValidateReaderSamples(); +} + +TEST_F(DirectChannelBufferReaderTest, ConcurrentWriteReadSequence) { + WriteOneSample(); + // Buffer: 1 0 0 0 ... + // Writer head: ^ + + reader_.Read(); + // Buffer: 1 0 0 0 ... + // Writer head: ^ + // What reader sees so far: 1 + + StartReaderThread(); + for (int i = 0; i < kBufferSize; i++) { + WriteOneSample(); + } + // Buffer: 21 2 3 4 ... + // Writer head: ^ + // What reader sees so far: 1 + + WriteHalfSample(); + // Buffer: 21 <counter:2,content:22> 3 4 ... + // Writer head: ^ + // What reader sees so far: 1 + + reader_.UnblockAndWaitForReads(2); + // Buffer: 21 <counter:2,content:22> 3 4 ... + // Writer head: ^ + // What reader sees so far: 1 2* 3 + // (sample 2 is corrupted) + + WriteHalfSample(); + // Buffer: 21 22 3 4 5 ... + // Writer head: ^ + // What reader sees so far: 1 2 3 + + WriteOneSample(); + WriteOneSample(); + // Buffer: 21 22 23 24 5 6 ... + // Writer head: ^ + // What reader sees so far: 1 2 3 + + WriteHalfSample(); + // Buffer: 21 22 23 24 <counter:5,content:25> 6 ... + // Writer head: ^ + // What reader sees so far: 1 2 3 + + StopAndJoinReaderThread(); + // Buffer: 21 22 23 24 <counter:5,content:25> 6 ... + // Writer head: ^ + // What reader sees so far: 21 22 23 24 5* 6 ... + // (sample 5 is corrupted) + // + // The validation performed on the reader thread would ensure that sample 2 + // and 5 were not returned. +} + +TEST_F(DirectChannelBufferReaderTest, GeneratedConcurrentWriteReadSequence) { + constexpr int kNumRounds = 5000; + constexpr int kMaxReadWritePerRound = kBufferSize + 5; + StartReaderThread(); + // For deterministic results, use an arbitrary fixed seed for random number + // generator. + srand(12345); + for (int i = 0; i < kNumRounds; i++) { + bool write = rand() % 2 == 0; + if (write) { + // Multiply by 2 since each call only writes half a sample. + int num_writes = rand() % (kMaxReadWritePerRound * 2); + for (int j = 0; j < num_writes; j++) { + WriteHalfSample(); + } + } else { + int num_reads = rand() % kMaxReadWritePerRound; + reader_.UnblockAndWaitForReads(num_reads); + } + } + StopAndJoinReaderThread(); +} + +} // namespace diff --git a/stats/aidl/Android.bp b/stats/aidl/Android.bp index fceab9e..26302b7 100644 --- a/stats/aidl/Android.bp +++ b/stats/aidl/Android.bp @@ -39,6 +39,12 @@ aidl_interface { version: "1", imports: [], }, + { + version: "2", + imports: [], + }, + ], host_supported: true, + frozen: true, } diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/.hash b/stats/aidl/aidl_api/android.frameworks.stats/2/.hash new file mode 100644 index 0000000..55fa1ff --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/.hash @@ -0,0 +1 @@ +7afdd459ab55ba70fdae6987d3296514822c03a4 diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/Annotation.aidl b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/Annotation.aidl new file mode 100644 index 0000000..825db0d --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/Annotation.aidl @@ -0,0 +1,39 @@ +// +// Copyright (C) 2023 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@VintfStability +parcelable Annotation { + android.frameworks.stats.AnnotationId annotationId = android.frameworks.stats.AnnotationId.UNKNOWN; + android.frameworks.stats.AnnotationValue value; +} diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationId.aidl b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationId.aidl new file mode 100644 index 0000000..63e6efa --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationId.aidl @@ -0,0 +1,56 @@ +// +// Copyright (C) 2023 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@Backing(type="int") @VintfStability +enum AnnotationId { + UNKNOWN = 0, + IS_UID = 1, + TRUNCATE_TIMESTAMP = 2, + PRIMARY_FIELD = 3, + EXCLUSIVE_STATE = 4, + PRIMARY_FIELD_FIRST_UID = 5, + DEFAULT_STATE = 6, + TRIGGER_STATE_RESET = 7, + STATE_NESTED = 8, + RESTRICTION_CATEGORY = 9, + FIELD_RESTRICTION_PERIPHERAL_DEVICE_INFO = 10, + FIELD_RESTRICTION_APP_USAGE = 11, + FIELD_RESTRICTION_APP_ACTIVITY = 12, + FIELD_RESTRICTION_HEALTH_CONNECT = 13, + FIELD_RESTRICTION_ACCESSIBILITY = 14, + FIELD_RESTRICTION_SYSTEM_SEARCH = 15, + FIELD_RESTRICTION_USER_ENGAGEMENT = 16, + FIELD_RESTRICTION_AMBIENT_SENSING = 17, + FIELD_RESTRICTION_DEMOGRAPHIC_CLASSIFICATION = 18, +} diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationSet.aidl b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationSet.aidl new file mode 100644 index 0000000..4d78469 --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationSet.aidl @@ -0,0 +1,39 @@ +// +// Copyright (C) 2023 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@VintfStability +parcelable AnnotationSet { + int valueIndex; + android.frameworks.stats.Annotation[] annotations; +} diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationValue.aidl b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationValue.aidl new file mode 100644 index 0000000..316ee19 --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/AnnotationValue.aidl @@ -0,0 +1,39 @@ +// +// Copyright (C) 2023 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@VintfStability +union AnnotationValue { + int intValue; + boolean boolValue; +} diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/IStats.aidl b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/IStats.aidl new file mode 100644 index 0000000..5be1d2f --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/IStats.aidl @@ -0,0 +1,38 @@ +// +// Copyright (C) 2021 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@VintfStability +interface IStats { + oneway void reportVendorAtom(in android.frameworks.stats.VendorAtom vendorAtom); +} diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/RestrictionCategory.aidl b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/RestrictionCategory.aidl new file mode 100644 index 0000000..e94e59c --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/RestrictionCategory.aidl @@ -0,0 +1,42 @@ +// +// Copyright (C) 2023 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@Backing(type="int") @VintfStability +enum RestrictionCategory { + UNKNOWN = 0, + DIAGNOSTIC = 1, + SYSTEM_INTELLIGENCE = 2, + AUTHENTICATION = 3, + FRAUD_AND_ABUSE = 4, +} diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/VendorAtom.aidl b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/VendorAtom.aidl new file mode 100644 index 0000000..3174d5f --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/VendorAtom.aidl @@ -0,0 +1,42 @@ +// +// Copyright (C) 2021 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@VintfStability +parcelable VendorAtom { + String reverseDomainName; + int atomId; + android.frameworks.stats.VendorAtomValue[] values; + @nullable android.frameworks.stats.AnnotationSet[] valuesAnnotations; + @nullable android.frameworks.stats.Annotation[] atomAnnotations; +} diff --git a/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/VendorAtomValue.aidl b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/VendorAtomValue.aidl new file mode 100644 index 0000000..0c9c39c --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/2/android/frameworks/stats/VendorAtomValue.aidl @@ -0,0 +1,48 @@ +// +// Copyright (C) 2021 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@VintfStability +union VendorAtomValue { + int intValue; + long longValue; + float floatValue; + String stringValue; + boolean boolValue; + @nullable int[] repeatedIntValue; + @nullable long[] repeatedLongValue; + @nullable float[] repeatedFloatValue; + @nullable String[] repeatedStringValue; + @nullable boolean[] repeatedBoolValue; + @nullable byte[] byteArrayValue; +} diff --git a/stats/aidl/aidl_api/android.frameworks.stats/current/android/frameworks/stats/AnnotationId.aidl b/stats/aidl/aidl_api/android.frameworks.stats/current/android/frameworks/stats/AnnotationId.aidl index 848b5e9..63e6efa 100644 --- a/stats/aidl/aidl_api/android.frameworks.stats/current/android/frameworks/stats/AnnotationId.aidl +++ b/stats/aidl/aidl_api/android.frameworks.stats/current/android/frameworks/stats/AnnotationId.aidl @@ -43,4 +43,14 @@ enum AnnotationId { DEFAULT_STATE = 6, TRIGGER_STATE_RESET = 7, STATE_NESTED = 8, + RESTRICTION_CATEGORY = 9, + FIELD_RESTRICTION_PERIPHERAL_DEVICE_INFO = 10, + FIELD_RESTRICTION_APP_USAGE = 11, + FIELD_RESTRICTION_APP_ACTIVITY = 12, + FIELD_RESTRICTION_HEALTH_CONNECT = 13, + FIELD_RESTRICTION_ACCESSIBILITY = 14, + FIELD_RESTRICTION_SYSTEM_SEARCH = 15, + FIELD_RESTRICTION_USER_ENGAGEMENT = 16, + FIELD_RESTRICTION_AMBIENT_SENSING = 17, + FIELD_RESTRICTION_DEMOGRAPHIC_CLASSIFICATION = 18, } diff --git a/stats/aidl/aidl_api/android.frameworks.stats/current/android/frameworks/stats/RestrictionCategory.aidl b/stats/aidl/aidl_api/android.frameworks.stats/current/android/frameworks/stats/RestrictionCategory.aidl new file mode 100644 index 0000000..e94e59c --- /dev/null +++ b/stats/aidl/aidl_api/android.frameworks.stats/current/android/frameworks/stats/RestrictionCategory.aidl @@ -0,0 +1,42 @@ +// +// Copyright (C) 2023 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. +// +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.frameworks.stats; +@Backing(type="int") @VintfStability +enum RestrictionCategory { + UNKNOWN = 0, + DIAGNOSTIC = 1, + SYSTEM_INTELLIGENCE = 2, + AUTHENTICATION = 3, + FRAUD_AND_ABUSE = 4, +} diff --git a/stats/aidl/android/frameworks/stats/AnnotationId.aidl b/stats/aidl/android/frameworks/stats/AnnotationId.aidl index 31aa8ac..7f05512 100644 --- a/stats/aidl/android/frameworks/stats/AnnotationId.aidl +++ b/stats/aidl/android/frameworks/stats/AnnotationId.aidl @@ -64,4 +64,64 @@ enum AnnotationId { * This should only be used with binary state atoms. */ STATE_NESTED = 8, + + /** + * Annotation ID constant to indicate the restriction category of an atom. + * This annotation must only be attached to the atom id. This is an int annotation. + */ + RESTRICTION_CATEGORY = 9, + + /** + * Annotation ID to indicate that a field of an atom contains peripheral device info. + * This is a bool annotation. + */ + FIELD_RESTRICTION_PERIPHERAL_DEVICE_INFO = 10, + + /** + * Annotation ID to indicate that a field of an atom contains app usage information. + * This is a bool annotation. + */ + FIELD_RESTRICTION_APP_USAGE = 11, + + /** + * Annotation ID to indicate that a field of an atom contains app activity information. + * This is a bool annotation. + */ + FIELD_RESTRICTION_APP_ACTIVITY = 12, + + /** + * Annotation ID to indicate that a field of an atom contains health connect information. + * This is a bool annotation. + */ + FIELD_RESTRICTION_HEALTH_CONNECT = 13, + + /** + * Annotation ID to indicate that a field of an atom contains accessibility information. + * This is a bool annotation. + */ + FIELD_RESTRICTION_ACCESSIBILITY = 14, + + /** + * Annotation ID to indicate that a field of an atom contains system search information. + * This is a bool annotation. + */ + FIELD_RESTRICTION_SYSTEM_SEARCH = 15, + + /** + * Annotation ID to indicate that a field of an atom contains user engagement information. + * This is a bool annotation. + */ + FIELD_RESTRICTION_USER_ENGAGEMENT = 16, + + /** + * Annotation ID to indicate that a field of an atom contains ambient sensing information. + * This is a bool annotation. + */ + FIELD_RESTRICTION_AMBIENT_SENSING = 17, + + /** + * Annotation ID to indicate that a field of an atom contains demographic classification + * information. This is a bool annotation. + */ + FIELD_RESTRICTION_DEMOGRAPHIC_CLASSIFICATION = 18, } diff --git a/stats/aidl/android/frameworks/stats/RestrictionCategory.aidl b/stats/aidl/android/frameworks/stats/RestrictionCategory.aidl new file mode 100644 index 0000000..3411d68 --- /dev/null +++ b/stats/aidl/android/frameworks/stats/RestrictionCategory.aidl @@ -0,0 +1,46 @@ +// +// Copyright (C) 2023 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. +// +package android.frameworks.stats; + +/* + * Mimics packages/modules/StatsD/lib/libstatssocket/include/stats_annotations.h + * These ids must stay consistent with those in stats_annotations.h + */ +@VintfStability +@Backing(type="int") +enum RestrictionCategory { + UNKNOWN = 0, + + /** + * Restriction category for atoms about diagnostics. + */ + DIAGNOSTIC = 1, + + /** + * Restriction category for atoms about system intelligence. + */ + SYSTEM_INTELLIGENCE = 2, + + /** + * Restriction category for atoms about authentication. + */ + AUTHENTICATION = 3, + + /** + * Restriction category for atoms about fraud and abuse. + */ + FRAUD_AND_ABUSE = 4, +} diff --git a/stats/aidl/vts/functional/Android.bp b/stats/aidl/vts/functional/Android.bp index d96cf97..f530f00 100644 --- a/stats/aidl/vts/functional/Android.bp +++ b/stats/aidl/vts/functional/Android.bp @@ -25,7 +25,7 @@ cc_test { "use_libaidlvintf_gtest_helper_static", ], srcs: [ - "VtsHalStatsTargetTest.cpp", + "VtsHalStatsTargetTest.cpp" ], shared_libs: [ "libbinder_ndk", @@ -36,6 +36,6 @@ cc_test { ], test_suites: [ "general-tests", - "vts", + "vts" ], } |