1 #ifndef HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_V7_0_IDEVICESFACTORY_H
2 #define HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_V7_0_IDEVICESFACTORY_H
3 
4 #include <android/hardware/audio/7.0/IDevice.h>
5 #include <android/hardware/audio/7.0/IPrimaryDevice.h>
6 #include <android/hardware/audio/7.0/types.h>
7 #include <android/hidl/base/1.0/IBase.h>
8 
9 #include <android/hidl/manager/1.0/IServiceNotification.h>
10 
11 #include <hidl/HidlSupport.h>
12 #include <hidl/MQDescriptor.h>
13 #include <hidl/Status.h>
14 #include <utils/NativeHandle.h>
15 #include <utils/misc.h>
16 
17 namespace android {
18 namespace hardware {
19 namespace audio {
20 namespace V7_0 {
21 
22 /**
23  * This factory allows a HAL implementation to be split in multiple independent
24  *  devices (called module in the pre-treble API).
25  *  Note that this division is arbitrary and implementation are free
26  *  to only have a Primary.
27  *  The framework will query the devices according to audio_policy_configuration.xml
28  *
29  *  Each device name is arbitrary, provided by the vendor's audio_policy_configuration.xml
30  *  and only used to identify a device in this factory.
31  *  The framework must not interpret the name, treating it as a vendor opaque data
32  *  with the following exception:
33  *  - the "r_submix" device that must be present to support policyMixes (Eg: Android projected).
34  *    Note that this Device is included by default in a build derived from AOSP.
35  *
36  *  Note that on AOSP Oreo (including MR1) the "a2dp" module is not using this API
37  *  but is loaded directly from the system partition using the legacy API
38  *  due to limitations with the Bluetooth framework.
39  */
40 struct IDevicesFactory : public ::android::hidl::base::V1_0::IBase {
41     /**
42      * Type tag for use in template logic that indicates this is a 'pure' class.
43      */
44     typedef ::android::hardware::details::i_tag _hidl_tag;
45 
46     /**
47      * Fully qualified interface name: "[email protected]::IDevicesFactory"
48      */
49     static const char* descriptor;
50 
51     /**
52      * Returns whether this object's implementation is outside of the current process.
53      */
isRemoteIDevicesFactory54     virtual bool isRemote() const override { return false; }
55 
56     /**
57      * Return callback for openDevice
58      */
59     using openDevice_cb = std::function<void(::android::hardware::audio::V7_0::Result retval, const ::android::sp<::android::hardware::audio::V7_0::IDevice>& result)>;
60     /**
61      * Opens an audio device. To close the device, it is necessary to release
62      * references to the returned device object.
63      *
64      * @param device device name.
65      * @return retval operation completion status. Returns INVALID_ARGUMENTS
66      *         if there is no corresponding hardware module found,
67      *         NOT_INITIALIZED if an error occurred while opening the hardware
68      *         module.
69      * @return result the interface for the created device.
70      */
71     virtual ::android::hardware::Return<void> openDevice(const ::android::hardware::hidl_string& device, openDevice_cb _hidl_cb) = 0;
72 
73     /**
74      * Return callback for openPrimaryDevice
75      */
76     using openPrimaryDevice_cb = std::function<void(::android::hardware::audio::V7_0::Result retval, const ::android::sp<::android::hardware::audio::V7_0::IPrimaryDevice>& result)>;
77     /**
78      * Opens the Primary audio device that must be present.
79      * This function is not optional and must return successfully the primary device.
80      *
81      * This device must have the name "primary".
82      *
83      * The telephony stack uses this device to control the audio during a voice call.
84      *
85      * @return retval operation completion status. Must be SUCCESS.
86      *         For debugging, return INVALID_ARGUMENTS if there is no corresponding
87      *         hardware module found, NOT_INITIALIZED if an error occurred
88      *         while opening the hardware module.
89      * @return result the interface for the created device.
90      */
91     virtual ::android::hardware::Return<void> openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) = 0;
92 
93     /**
94      * Return callback for interfaceChain
95      */
96     using interfaceChain_cb = std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& descriptors)>;
97     /*
98      * Provides run-time type information for this object.
99      * For example, for the following interface definition:
100      *     package [email protected];
101      *     interface IParent {};
102      *     interface IChild extends IParent {};
103      * Calling interfaceChain on an IChild object must yield the following:
104      *     ["[email protected]::IChild",
105      *      "[email protected]::IParent"
106      *      "[email protected]::IBase"]
107      *
108      * @return descriptors a vector of descriptors of the run-time type of the
109      *         object.
110      */
111     virtual ::android::hardware::Return<void> interfaceChain(interfaceChain_cb _hidl_cb) override;
112 
113     /*
114      * Emit diagnostic information to the given file.
115      *
116      * Optionally overriden.
117      *
118      * @param fd      File descriptor to dump data to.
119      *                Must only be used for the duration of this call.
120      * @param options Arguments for debugging.
121      *                Must support empty for default debug information.
122      */
123     virtual ::android::hardware::Return<void> debug(const ::android::hardware::hidl_handle& fd, const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& options) override;
124 
125     /**
126      * Return callback for interfaceDescriptor
127      */
128     using interfaceDescriptor_cb = std::function<void(const ::android::hardware::hidl_string& descriptor)>;
129     /*
130      * Provides run-time type information for this object.
131      * For example, for the following interface definition:
132      *     package [email protected];
133      *     interface IParent {};
134      *     interface IChild extends IParent {};
135      * Calling interfaceDescriptor on an IChild object must yield
136      *     "[email protected]::IChild"
137      *
138      * @return descriptor a descriptor of the run-time type of the
139      *         object (the first element of the vector returned by
140      *         interfaceChain())
141      */
142     virtual ::android::hardware::Return<void> interfaceDescriptor(interfaceDescriptor_cb _hidl_cb) override;
143 
144     /**
145      * Return callback for getHashChain
146      */
147     using getHashChain_cb = std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_array<uint8_t, 32>>& hashchain)>;
148     /*
149      * Returns hashes of the source HAL files that define the interfaces of the
150      * runtime type information on the object.
151      * For example, for the following interface definition:
152      *     package [email protected];
153      *     interface IParent {};
154      *     interface IChild extends IParent {};
155      * Calling interfaceChain on an IChild object must yield the following:
156      *     [(hash of IChild.hal),
157      *      (hash of IParent.hal)
158      *      (hash of IBase.hal)].
159      *
160      * SHA-256 is used as the hashing algorithm. Each hash has 32 bytes
161      * according to SHA-256 standard.
162      *
163      * @return hashchain a vector of SHA-1 digests
164      */
165     virtual ::android::hardware::Return<void> getHashChain(getHashChain_cb _hidl_cb) override;
166 
167     /*
168      * This method trigger the interface to enable/disable instrumentation based
169      * on system property hal.instrumentation.enable.
170      */
171     virtual ::android::hardware::Return<void> setHALInstrumentation() override;
172 
173     /*
174      * Registers a death recipient, to be called when the process hosting this
175      * interface dies.
176      *
177      * @param recipient a hidl_death_recipient callback object
178      * @param cookie a cookie that must be returned with the callback
179      * @return success whether the death recipient was registered successfully.
180      */
181     virtual ::android::hardware::Return<bool> linkToDeath(const ::android::sp<::android::hardware::hidl_death_recipient>& recipient, uint64_t cookie) override;
182 
183     /*
184      * Provides way to determine if interface is running without requesting
185      * any functionality.
186      */
187     virtual ::android::hardware::Return<void> ping() override;
188 
189     /**
190      * Return callback for getDebugInfo
191      */
192     using getDebugInfo_cb = std::function<void(const ::android::hidl::base::V1_0::DebugInfo& info)>;
193     /*
194      * Get debug information on references on this interface.
195      * @return info debugging information. See comments of DebugInfo.
196      */
197     virtual ::android::hardware::Return<void> getDebugInfo(getDebugInfo_cb _hidl_cb) override;
198 
199     /*
200      * This method notifies the interface that one or more system properties
201      * have changed. The default implementation calls
202      * (C++)  report_sysprop_change() in libcutils or
203      * (Java) android.os.SystemProperties.reportSyspropChanged,
204      * which in turn calls a set of registered callbacks (eg to update trace
205      * tags).
206      */
207     virtual ::android::hardware::Return<void> notifySyspropsChanged() override;
208 
209     /*
210      * Unregisters the registered death recipient. If this service was registered
211      * multiple times with the same exact death recipient, this unlinks the most
212      * recently registered one.
213      *
214      * @param recipient a previously registered hidl_death_recipient callback
215      * @return success whether the death recipient was unregistered successfully.
216      */
217     virtual ::android::hardware::Return<bool> unlinkToDeath(const ::android::sp<::android::hardware::hidl_death_recipient>& recipient) override;
218 
219     // cast static functions
220     /**
221      * This performs a checked cast based on what the underlying implementation actually is.
222      */
223     static ::android::hardware::Return<::android::sp<::android::hardware::audio::V7_0::IDevicesFactory>> castFrom(const ::android::sp<::android::hardware::audio::V7_0::IDevicesFactory>& parent, bool emitError = false);
224     /**
225      * This performs a checked cast based on what the underlying implementation actually is.
226      */
227     static ::android::hardware::Return<::android::sp<::android::hardware::audio::V7_0::IDevicesFactory>> castFrom(const ::android::sp<::android::hidl::base::V1_0::IBase>& parent, bool emitError = false);
228 
229     // helper methods for interactions with the hwservicemanager
230     /**
231      * This gets the service of this type with the specified instance name. If the
232      * service is currently not available or not in the VINTF manifest on a Trebilized
233      * device, this will return nullptr. This is useful when you don't want to block
234      * during device boot. If getStub is true, this will try to return an unwrapped
235      * passthrough implementation in the same process. This is useful when getting an
236      * implementation from the same partition/compilation group.
237      *
238      * In general, prefer getService(std::string,bool)
239      */
240     static ::android::sp<IDevicesFactory> tryGetService(const std::string &serviceName="default", bool getStub=false);
241     /**
242      * Deprecated. See tryGetService(std::string, bool)
243      */
244     static ::android::sp<IDevicesFactory> tryGetService(const char serviceName[], bool getStub=false)  { std::string str(serviceName ? serviceName : "");      return tryGetService(str, getStub); }
245     /**
246      * Deprecated. See tryGetService(std::string, bool)
247      */
248     static ::android::sp<IDevicesFactory> tryGetService(const ::android::hardware::hidl_string& serviceName, bool getStub=false)  { std::string str(serviceName.c_str());      return tryGetService(str, getStub); }
249     /**
250      * Calls tryGetService("default", bool). This is the recommended instance name for singleton services.
251      */
tryGetServiceIDevicesFactory252     static ::android::sp<IDevicesFactory> tryGetService(bool getStub) { return tryGetService("default", getStub); }
253     /**
254      * This gets the service of this type with the specified instance name. If the
255      * service is not in the VINTF manifest on a Trebilized device, this will return
256      * nullptr. If the service is not available, this will wait for the service to
257      * become available. If the service is a lazy service, this will start the service
258      * and return when it becomes available. If getStub is true, this will try to
259      * return an unwrapped passthrough implementation in the same process. This is
260      * useful when getting an implementation from the same partition/compilation group.
261      */
262     static ::android::sp<IDevicesFactory> getService(const std::string &serviceName="default", bool getStub=false);
263     /**
264      * Deprecated. See getService(std::string, bool)
265      */
266     static ::android::sp<IDevicesFactory> getService(const char serviceName[], bool getStub=false)  { std::string str(serviceName ? serviceName : "");      return getService(str, getStub); }
267     /**
268      * Deprecated. See getService(std::string, bool)
269      */
270     static ::android::sp<IDevicesFactory> getService(const ::android::hardware::hidl_string& serviceName, bool getStub=false)  { std::string str(serviceName.c_str());      return getService(str, getStub); }
271     /**
272      * Calls getService("default", bool). This is the recommended instance name for singleton services.
273      */
getServiceIDevicesFactory274     static ::android::sp<IDevicesFactory> getService(bool getStub) { return getService("default", getStub); }
275     /**
276      * Registers a service with the service manager. For Trebilized devices, the service
277      * must also be in the VINTF manifest.
278      */
279     __attribute__ ((warn_unused_result))::android::status_t registerAsService(const std::string &serviceName="default");
280     /**
281      * Registers for notifications for when a service is registered.
282      */
283     static bool registerForNotifications(
284             const std::string &serviceName,
285             const ::android::sp<::android::hidl::manager::V1_0::IServiceNotification> &notification);
286 };
287 
288 //
289 // type declarations for package
290 //
291 
292 static inline std::string toString(const ::android::sp<::android::hardware::audio::V7_0::IDevicesFactory>& o);
293 
294 //
295 // type header definitions for package
296 //
297 
toString(const::android::sp<::android::hardware::audio::V7_0::IDevicesFactory> & o)298 static inline std::string toString(const ::android::sp<::android::hardware::audio::V7_0::IDevicesFactory>& o) {
299     std::string os = "[class or subclass of ";
300     os += ::android::hardware::audio::V7_0::IDevicesFactory::descriptor;
301     os += "]";
302     os += o->isRemote() ? "@remote" : "@local";
303     return os;
304 }
305 
306 
307 }  // namespace V7_0
308 }  // namespace audio
309 }  // namespace hardware
310 }  // namespace android
311 
312 //
313 // global type declarations for package
314 //
315 
316 
317 #endif  // HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_V7_0_IDEVICESFACTORY_H
318