xref: /aosp_15_r20/hardware/interfaces/camera/provider/2.4/default/service.cpp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker /*
2*4d7e907cSAndroid Build Coastguard Worker  * Copyright 2017 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker  *
4*4d7e907cSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker  *
8*4d7e907cSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker  *
10*4d7e907cSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker  * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker  */
16*4d7e907cSAndroid Build Coastguard Worker 
17*4d7e907cSAndroid Build Coastguard Worker #ifdef LAZY_SERVICE
18*4d7e907cSAndroid Build Coastguard Worker #define LOG_TAG "[email protected]"
19*4d7e907cSAndroid Build Coastguard Worker #else
20*4d7e907cSAndroid Build Coastguard Worker #define LOG_TAG "[email protected]"
21*4d7e907cSAndroid Build Coastguard Worker #endif
22*4d7e907cSAndroid Build Coastguard Worker 
23*4d7e907cSAndroid Build Coastguard Worker #include <android/hardware/camera/provider/2.4/ICameraProvider.h>
24*4d7e907cSAndroid Build Coastguard Worker #include <binder/ProcessState.h>
25*4d7e907cSAndroid Build Coastguard Worker #include <cutils/properties.h>
26*4d7e907cSAndroid Build Coastguard Worker #include <hidl/LegacySupport.h>
27*4d7e907cSAndroid Build Coastguard Worker #include <malloc.h>
28*4d7e907cSAndroid Build Coastguard Worker 
29*4d7e907cSAndroid Build Coastguard Worker using android::status_t;
30*4d7e907cSAndroid Build Coastguard Worker using android::hardware::defaultLazyPassthroughServiceImplementation;
31*4d7e907cSAndroid Build Coastguard Worker using android::hardware::defaultPassthroughServiceImplementation;
32*4d7e907cSAndroid Build Coastguard Worker using android::hardware::camera::provider::V2_4::ICameraProvider;
33*4d7e907cSAndroid Build Coastguard Worker 
34*4d7e907cSAndroid Build Coastguard Worker #ifdef LAZY_SERVICE
35*4d7e907cSAndroid Build Coastguard Worker const bool kLazyService = true;
36*4d7e907cSAndroid Build Coastguard Worker #else
37*4d7e907cSAndroid Build Coastguard Worker const bool kLazyService = false;
38*4d7e907cSAndroid Build Coastguard Worker #endif
39*4d7e907cSAndroid Build Coastguard Worker 
main()40*4d7e907cSAndroid Build Coastguard Worker int main()
41*4d7e907cSAndroid Build Coastguard Worker {
42*4d7e907cSAndroid Build Coastguard Worker     ALOGI("[email protected] legacy service is starting.");
43*4d7e907cSAndroid Build Coastguard Worker     // The camera HAL may communicate to other vendor components via
44*4d7e907cSAndroid Build Coastguard Worker     // /dev/vndbinder
45*4d7e907cSAndroid Build Coastguard Worker     android::ProcessState::initWithDriver("/dev/vndbinder");
46*4d7e907cSAndroid Build Coastguard Worker 
47*4d7e907cSAndroid Build Coastguard Worker     // b/166675194
48*4d7e907cSAndroid Build Coastguard Worker     if (property_get_bool("ro.vendor.camera.provider24.disable_mem_init", false)) {
49*4d7e907cSAndroid Build Coastguard Worker         if (mallopt(M_BIONIC_ZERO_INIT, 0) == 0) {
50*4d7e907cSAndroid Build Coastguard Worker             // Note - heap initialization is only present on devices with Scudo.
51*4d7e907cSAndroid Build Coastguard Worker             // Devices with jemalloc don't have heap-init, and thus the mallopt
52*4d7e907cSAndroid Build Coastguard Worker             // will fail. On these devices, you probably just want to remove the
53*4d7e907cSAndroid Build Coastguard Worker             // property.
54*4d7e907cSAndroid Build Coastguard Worker             ALOGE("Disabling heap initialization failed.");
55*4d7e907cSAndroid Build Coastguard Worker         }
56*4d7e907cSAndroid Build Coastguard Worker     }
57*4d7e907cSAndroid Build Coastguard Worker 
58*4d7e907cSAndroid Build Coastguard Worker     status_t status;
59*4d7e907cSAndroid Build Coastguard Worker     if (kLazyService) {
60*4d7e907cSAndroid Build Coastguard Worker         status = defaultLazyPassthroughServiceImplementation<ICameraProvider>("legacy/0",
61*4d7e907cSAndroid Build Coastguard Worker                                                                               /*maxThreads*/ 6);
62*4d7e907cSAndroid Build Coastguard Worker     } else {
63*4d7e907cSAndroid Build Coastguard Worker         status = defaultPassthroughServiceImplementation<ICameraProvider>("legacy/0",
64*4d7e907cSAndroid Build Coastguard Worker                                                                           /*maxThreads*/ 6);
65*4d7e907cSAndroid Build Coastguard Worker     }
66*4d7e907cSAndroid Build Coastguard Worker     return status;
67*4d7e907cSAndroid Build Coastguard Worker }
68