|
16 | 16 |
|
17 | 17 | package android.net.nsd; |
18 | 18 |
|
| 19 | +import android.annotation.SdkConstant; |
| 20 | +import android.annotation.SdkConstant.SdkConstantType; |
19 | 21 | import android.content.Context; |
20 | 22 | import android.os.Binder; |
21 | 23 | import android.os.IBinder; |
@@ -133,6 +135,44 @@ public class NsdManager { |
133 | 135 | private static final String TAG = "NsdManager"; |
134 | 136 | INsdManager mService; |
135 | 137 |
|
| 138 | + /** |
| 139 | + * Broadcast intent action to indicate whether network service discovery is |
| 140 | + * enabled or disabled. An extra {@link #EXTRA_NSD_STATE} provides the state |
| 141 | + * information as int. |
| 142 | + * |
| 143 | + * @see #EXTRA_NSD_STATE |
| 144 | + * @hide |
| 145 | + */ |
| 146 | + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 147 | + public static final String NSD_STATE_CHANGED_ACTION = |
| 148 | + "android.net.nsd.STATE_CHANGED"; |
| 149 | + |
| 150 | + /** |
| 151 | + * The lookup key for an int that indicates whether network service discovery is enabled |
| 152 | + * or disabled. Retrieve it with {@link android.content.Intent#getIntExtra(String,int)}. |
| 153 | + * |
| 154 | + * @see #NSD_STATE_DISABLED |
| 155 | + * @see #NSD_STATE_ENABLED |
| 156 | + * @hide |
| 157 | + */ |
| 158 | + public static final String EXTRA_NSD_STATE = "nsd_state"; |
| 159 | + |
| 160 | + /** |
| 161 | + * Network service discovery is disabled |
| 162 | + * |
| 163 | + * @see #NSD_STATE_CHANGED_ACTION |
| 164 | + * @hide |
| 165 | + */ |
| 166 | + public static final int NSD_STATE_DISABLED = 1; |
| 167 | + |
| 168 | + /** |
| 169 | + * Network service discovery is enabled |
| 170 | + * |
| 171 | + * @see #NSD_STATE_CHANGED_ACTION |
| 172 | + * @hide |
| 173 | + */ |
| 174 | + public static final int NSD_STATE_ENABLED = 2; |
| 175 | + |
136 | 176 | private static final int BASE = Protocol.BASE_NSD_MANAGER; |
137 | 177 |
|
138 | 178 | /** @hide */ |
@@ -188,6 +228,12 @@ public class NsdManager { |
188 | 228 | /** @hide */ |
189 | 229 | public static final int STOP_RESOLVE_SUCCEEDED = BASE + 23; |
190 | 230 |
|
| 231 | + /** @hide */ |
| 232 | + public static final int ENABLE = BASE + 24; |
| 233 | + /** @hide */ |
| 234 | + public static final int DISABLE = BASE + 25; |
| 235 | + |
| 236 | + |
191 | 237 | /** |
192 | 238 | * Create a new Nsd instance. Applications use |
193 | 239 | * {@link android.content.Context#getSystemService Context.getSystemService()} to retrieve |
@@ -312,8 +358,8 @@ public static class Channel { |
312 | 358 | private DnsSdResolveListener mDnsSdResolveListener; |
313 | 359 | private ActionListener mDnsSdStopResolveListener; |
314 | 360 |
|
315 | | - AsyncChannel mAsyncChannel; |
316 | | - ServiceHandler mHandler; |
| 361 | + private AsyncChannel mAsyncChannel; |
| 362 | + private ServiceHandler mHandler; |
317 | 363 | class ServiceHandler extends Handler { |
318 | 364 | ServiceHandler(Looper looper) { |
319 | 365 | super(looper); |
@@ -594,6 +640,13 @@ public void stopServiceResolve(Channel c) { |
594 | 640 | c.mAsyncChannel.sendMessage(STOP_RESOLVE); |
595 | 641 | } |
596 | 642 |
|
| 643 | + /** Internal use only @hide */ |
| 644 | + public void setEnabled(boolean enabled) { |
| 645 | + try { |
| 646 | + mService.setEnabled(enabled); |
| 647 | + } catch (RemoteException e) { } |
| 648 | + } |
| 649 | + |
597 | 650 | /** |
598 | 651 | * Get a reference to NetworkService handler. This is used to establish |
599 | 652 | * an AsyncChannel communication with the service |
|
0 commit comments