1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.net.mdns.aidl;
18 
19 import android.net.mdns.aidl.DiscoveryInfo;
20 import android.net.mdns.aidl.GetAddressInfo;
21 import android.net.mdns.aidl.IMDnsEventListener;
22 import android.net.mdns.aidl.RegistrationInfo;
23 import android.net.mdns.aidl.ResolutionInfo;
24 
25 /** {@hide} */
26 interface IMDns {
27     /**
28      * Start the MDNSResponder daemon.
29      *
30      * @throws ServiceSpecificException with unix errno EALREADY if daemon is already running.
31      * @throws UnsupportedOperationException on Android V and after.
32      * @deprecated unimplemented on V+.
33      */
startDaemon()34     void startDaemon();
35 
36     /**
37      * Stop the MDNSResponder daemon.
38      *
39      * @throws ServiceSpecificException with unix errno EBUSY if daemon is still in use.
40      * @throws UnsupportedOperationException on Android V and after.
41      * @deprecated unimplemented on V+.
42      */
stopDaemon()43     void stopDaemon();
44 
45     /**
46      * Start registering a service.
47      * This operation will send a service registration request to MDNSResponder. Register a listener
48      * via IMDns#registerEventListener to get the registration result SERVICE_REGISTERED/
49      * SERVICE_REGISTRATION_FAILED from callback IMDnsEventListener#onServiceRegistrationStatus.
50      *
51      * @param info The service information to register.
52      *
53      * @throws ServiceSpecificException with one of the following error values:
54      *         - Unix errno EBUSY if request id is already in use.
55      *         - kDNSServiceErr_* list in dns_sd.h if registration fail.
56      * @throws UnsupportedOperationException on Android U and after.
57      * @deprecated unimplemented on U+.
58      */
registerService(in RegistrationInfo info)59     void registerService(in RegistrationInfo info);
60 
61     /**
62      * Start discovering services.
63      * This operation will send a request to MDNSResponder to discover services. Register a listener
64      * via IMDns#registerEventListener to get the discovery result SERVICE_FOUND/SERVICE_LOST/
65      * SERVICE_DISCOVERY_FAILED from callback IMDnsEventListener#onServiceDiscoveryStatus.
66      *
67      * @param info The service to discover.
68      *
69      * @throws ServiceSpecificException with one of the following error values:
70      *         - Unix errno EBUSY if request id is already in use.
71      *         - kDNSServiceErr_* list in dns_sd.h if discovery fail.
72      * @throws UnsupportedOperationException on Android U and after.
73      * @deprecated unimplemented on U+.
74      */
discover(in DiscoveryInfo info)75     void discover(in DiscoveryInfo info);
76 
77     /**
78      * Start resolving the target service.
79      * This operation will send a request to MDNSResponder to resolve the target service. Register a
80      * listener via IMDns#registerEventListener to get the resolution result SERVICE_RESOLVED/
81      * SERVICE_RESOLUTION_FAILED from callback IMDnsEventListener#onServiceResolutionStatus.
82      *
83      * @param info The service to resolve.
84      *
85      * @throws ServiceSpecificException with one of the following error values:
86      *         - Unix errno EBUSY if request id is already in use.
87      *         - kDNSServiceErr_* list in dns_sd.h if resolution fail.
88      * @throws UnsupportedOperationException on Android U and after.
89      * @deprecated unimplemented on U+.
90      */
resolve(in ResolutionInfo info)91     void resolve(in ResolutionInfo info);
92 
93     /**
94      * Start getting the target service address.
95      * This operation will send a request to MDNSResponder to get the target service address.
96      * Register a listener via IMDns#registerEventListener to get the query result
97      * SERVICE_GET_ADDR_SUCCESS/SERVICE_GET_ADDR_FAILED from callback
98      * IMDnsEventListener#onGettingServiceAddressStatus.
99      *
100      * @param info the getting service address information.
101      *
102      * @throws ServiceSpecificException with one of the following error values:
103      *         - Unix errno EBUSY if request id is already in use.
104      *         - kDNSServiceErr_* list in dns_sd.h if getting address fail.
105      * @throws UnsupportedOperationException on Android U and after.
106      * @deprecated unimplemented on U+.
107      */
getServiceAddress(in GetAddressInfo info)108     void getServiceAddress(in GetAddressInfo info);
109 
110     /**
111      * Stop a operation which's requested before.
112      *
113      * @param id the operation id to be stopped.
114      *
115      * @throws ServiceSpecificException with unix errno ESRCH if request id is not in use.
116      * @throws UnsupportedOperationException on Android U and after.
117      * @deprecated unimplemented on U+.
118      */
stopOperation(int id)119     void stopOperation(int id);
120 
121     /**
122      * Register an event listener.
123      *
124      * @param listener The listener to be registered.
125      *
126      * @throws ServiceSpecificException with one of the following error values:
127      *         - Unix errno EINVAL if listener is null.
128      *         - Unix errno EEXIST if register duplicated listener.
129      * @throws UnsupportedOperationException on Android U and after.
130      * @deprecated unimplemented on U+.
131      */
registerEventListener(in IMDnsEventListener listener)132     void registerEventListener(in IMDnsEventListener listener);
133 
134     /**
135      * Unregister an event listener.
136      *
137      * @param listener The listener to be unregistered.
138      *
139      * @throws ServiceSpecificException with unix errno EINVAL if listener is null.
140      * @throws UnsupportedOperationException on Android U and after.
141      * @deprecated unimplemented on U+.
142      */
unregisterEventListener(in IMDnsEventListener listener)143     void unregisterEventListener(in IMDnsEventListener listener);
144 }
145 
146