1 /* 2 * Copyright (C) 2016 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 com.android.server.wifi.p2p; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.net.wifi.CoexUnsafeChannel; 22 import android.net.wifi.ScanResult; 23 import android.net.wifi.p2p.WifiP2pConfig; 24 import android.net.wifi.p2p.WifiP2pDirInfo; 25 import android.net.wifi.p2p.WifiP2pDiscoveryConfig; 26 import android.net.wifi.p2p.WifiP2pExtListenParams; 27 import android.net.wifi.p2p.WifiP2pGroup; 28 import android.net.wifi.p2p.WifiP2pGroupList; 29 import android.net.wifi.p2p.WifiP2pManager; 30 import android.net.wifi.p2p.WifiP2pUsdBasedLocalServiceAdvertisementConfig; 31 import android.net.wifi.p2p.WifiP2pUsdBasedServiceDiscoveryConfig; 32 import android.net.wifi.p2p.nsd.WifiP2pServiceInfo; 33 import android.net.wifi.p2p.nsd.WifiP2pUsdBasedServiceConfig; 34 import android.util.Log; 35 36 import com.android.internal.annotations.VisibleForTesting; 37 import com.android.server.wifi.WifiGlobals; 38 import com.android.server.wifi.WifiInjector; 39 import com.android.server.wifi.WifiNative; 40 41 import java.util.List; 42 import java.util.Set; 43 44 public class SupplicantP2pIfaceHal { 45 private static final String TAG = "SupplicantP2pIfaceHal"; 46 private final Object mLock = new Object(); 47 private static boolean sVerboseLoggingEnabled = true; 48 private static boolean sHalVerboseLoggingEnabled = true; 49 private final WifiP2pMonitor mMonitor; 50 private final WifiGlobals mWifiGlobals; 51 private final WifiInjector mWifiInjector; 52 53 // HAL interface object - might be implemented by HIDL or AIDL 54 private ISupplicantP2pIfaceHal mP2pIfaceHal; 55 SupplicantP2pIfaceHal(WifiP2pMonitor monitor, WifiGlobals wifiGlobals, WifiInjector wifiInjector)56 public SupplicantP2pIfaceHal(WifiP2pMonitor monitor, WifiGlobals wifiGlobals, 57 WifiInjector wifiInjector) { 58 mMonitor = monitor; 59 mWifiGlobals = wifiGlobals; 60 mWifiInjector = wifiInjector; 61 mP2pIfaceHal = createP2pIfaceHalMockable(); 62 if (mP2pIfaceHal == null) { 63 Log.wtf(TAG, "Failed to get internal ISupplicantP2pIfaceHal instance."); 64 } 65 } 66 67 /** 68 * Enable verbose logging for all sub modules. 69 */ enableVerboseLogging(boolean verboseEnabled, boolean halVerboseEnabled)70 public static void enableVerboseLogging(boolean verboseEnabled, boolean halVerboseEnabled) { 71 sVerboseLoggingEnabled = verboseEnabled; 72 sHalVerboseLoggingEnabled = halVerboseEnabled; 73 SupplicantP2pIfaceHalHidlImpl.enableVerboseLogging(verboseEnabled, halVerboseEnabled); 74 SupplicantP2pIfaceHalAidlImpl.enableVerboseLogging(verboseEnabled, halVerboseEnabled); 75 } 76 77 /** 78 * Set the debug log level for wpa_supplicant 79 * 80 * @param turnOnVerbose Whether to turn on verbose logging or not. 81 * @return true if request is sent successfully, false otherwise. 82 */ setLogLevel(boolean turnOnVerbose)83 public boolean setLogLevel(boolean turnOnVerbose) { 84 synchronized (mLock) { 85 String methodStr = "setLogLevel"; 86 if (mP2pIfaceHal == null) { 87 return handleNullHal(methodStr); 88 } 89 return mP2pIfaceHal.setLogLevel(turnOnVerbose, 90 mWifiGlobals.getShowKeyVerboseLoggingModeEnabled()); 91 } 92 } 93 94 /** 95 * Initialize the P2P Iface HAL. Creates the internal ISupplicantP2pIfaceHal 96 * object and calls its initialize method. 97 * 98 * @return true if the initialization succeeded 99 */ initialize()100 public boolean initialize() { 101 synchronized (mLock) { 102 if (sVerboseLoggingEnabled) { 103 Log.i(TAG, "Initializing SupplicantP2pIfaceHal."); 104 } 105 if (mP2pIfaceHal == null) { 106 Log.wtf(TAG, "Internal ISupplicantP2pIfaceHal instance does not exist."); 107 return false; 108 } 109 if (!mP2pIfaceHal.initialize()) { 110 Log.e(TAG, "Failed to init ISupplicantP2pIfaceHal, stopping startup."); 111 return false; 112 } 113 setLogLevel(sHalVerboseLoggingEnabled); 114 return true; 115 } 116 } 117 118 /** 119 * Wrapper function to create the ISupplicantP2pIfaceHal object. 120 * Created to be mockable in unit tests. 121 */ 122 @VisibleForTesting createP2pIfaceHalMockable()123 protected ISupplicantP2pIfaceHal createP2pIfaceHalMockable() { 124 synchronized (mLock) { 125 // Prefer AIDL implementation if service is declared. 126 if (SupplicantP2pIfaceHalAidlImpl.serviceDeclared()) { 127 Log.i(TAG, "Initializing SupplicantP2pIfaceHal using AIDL implementation."); 128 return new SupplicantP2pIfaceHalAidlImpl(mMonitor, mWifiInjector); 129 130 } else if (SupplicantP2pIfaceHalHidlImpl.serviceDeclared()) { 131 Log.i(TAG, "Initializing SupplicantP2pIfaceHal using HIDL implementation."); 132 return new SupplicantP2pIfaceHalHidlImpl(mMonitor); 133 } 134 Log.e(TAG, "No HIDL or AIDL service available for SupplicantP2pIfaceHal."); 135 return null; 136 } 137 } 138 139 /** 140 * Setup the P2P iface. 141 * 142 * @param ifaceName Name of the interface. 143 * @return true on success, false otherwise. 144 */ setupIface(@onNull String ifaceName)145 public boolean setupIface(@NonNull String ifaceName) { 146 synchronized (mLock) { 147 String methodStr = "setupIface"; 148 if (mP2pIfaceHal == null) { 149 return handleNullHal(methodStr); 150 } 151 return mP2pIfaceHal.setupIface(ifaceName); 152 } 153 } 154 155 /** 156 * Teardown the P2P interface. 157 * 158 * @param ifaceName Name of the interface. 159 * @return true on success, false otherwise. 160 */ teardownIface(@onNull String ifaceName)161 public boolean teardownIface(@NonNull String ifaceName) { 162 synchronized (mLock) { 163 String methodStr = "teardownIface"; 164 if (mP2pIfaceHal == null) { 165 return handleNullHal(methodStr); 166 } 167 return mP2pIfaceHal.teardownIface(ifaceName); 168 } 169 } 170 171 /** 172 * Signals whether initialization started successfully. 173 */ isInitializationStarted()174 public boolean isInitializationStarted() { 175 synchronized (mLock) { 176 String methodStr = "isInitializationStarted"; 177 if (mP2pIfaceHal == null) { 178 return handleNullHal(methodStr); 179 } 180 return mP2pIfaceHal.isInitializationStarted(); 181 } 182 } 183 184 /** 185 * Signals whether Initialization completed successfully. Only necessary for testing, is not 186 * needed to guard calls etc. 187 */ isInitializationComplete()188 public boolean isInitializationComplete() { 189 synchronized (mLock) { 190 String methodStr = "isInitializationComplete"; 191 if (mP2pIfaceHal == null) { 192 return handleNullHal(methodStr); 193 } 194 return mP2pIfaceHal.isInitializationComplete(); 195 } 196 } 197 198 /** 199 * Initiate a P2P service discovery with a (optional) timeout. 200 * 201 * @param timeout Max time to be spent is performing discovery. 202 * Set to 0 to indefinitely continue discovery until an explicit 203 * |stopFind| is sent. 204 * @return boolean value indicating whether operation was successful. 205 */ find(int timeout)206 public boolean find(int timeout) { 207 synchronized (mLock) { 208 String methodStr = "find"; 209 if (mP2pIfaceHal == null) { 210 return handleNullHal(methodStr); 211 } 212 return mP2pIfaceHal.find(timeout); 213 } 214 } 215 216 /** 217 * Initiate a P2P device discovery with a scan type, a (optional) frequency, and a (optional) 218 * timeout. 219 * 220 * @param type indicates what channels to scan. 221 * Valid values are {@link WifiP2pManager#WIFI_P2P_SCAN_FULL} for doing full P2P scan, 222 * {@link WifiP2pManager#WIFI_P2P_SCAN_SOCIAL} for scanning social channels, 223 * {@link WifiP2pManager#WIFI_P2P_SCAN_SINGLE_FREQ} for scanning a specified frequency. 224 * @param freq is the frequency to be scanned. 225 * The possible values are: 226 * <ul> 227 * <li> A valid frequency for {@link WifiP2pManager#WIFI_P2P_SCAN_SINGLE_FREQ}</li> 228 * <li> {@link WifiP2pManager#WIFI_P2P_SCAN_FREQ_UNSPECIFIED} for 229 * {@link WifiP2pManager#WIFI_P2P_SCAN_FULL} and 230 * {@link WifiP2pManager#WIFI_P2P_SCAN_SOCIAL}</li> 231 * </ul> 232 * @param timeout Max time to be spent is performing discovery. 233 * Set to 0 to indefinitely continue discovery until an explicit 234 * |stopFind| is sent. 235 * @return boolean value indicating whether operation was successful. 236 */ find(@ifiP2pManager.WifiP2pScanType int type, int freq, int timeout)237 public boolean find(@WifiP2pManager.WifiP2pScanType int type, int freq, int timeout) { 238 synchronized (mLock) { 239 String methodStr = "find"; 240 if (mP2pIfaceHal == null) { 241 return handleNullHal(methodStr); 242 } 243 return mP2pIfaceHal.find(type, freq, timeout); 244 } 245 } 246 247 /** 248 * Initiate P2P device discovery with config params. 249 * 250 * See comments for {@link ISupplicantP2pIfaceHal#findWithParams(WifiP2pDiscoveryConfig, int)}. 251 */ findWithParams(WifiP2pDiscoveryConfig config, int timeout)252 public boolean findWithParams(WifiP2pDiscoveryConfig config, int timeout) { 253 synchronized (mLock) { 254 String methodStr = "findWithParams"; 255 if (mP2pIfaceHal == null) { 256 return handleNullHal(methodStr); 257 } 258 return mP2pIfaceHal.findWithParams(config, timeout); 259 } 260 } 261 262 /** 263 * Stop an ongoing P2P service discovery. 264 * 265 * @return boolean value indicating whether operation was successful. 266 */ stopFind()267 public boolean stopFind() { 268 synchronized (mLock) { 269 String methodStr = "stopFind"; 270 if (mP2pIfaceHal == null) { 271 return handleNullHal(methodStr); 272 } 273 return mP2pIfaceHal.stopFind(); 274 } 275 } 276 277 /** 278 * Flush P2P peer table and state. 279 * 280 * @return boolean value indicating whether operation was successful. 281 */ flush()282 public boolean flush() { 283 synchronized (mLock) { 284 String methodStr = "flush"; 285 if (mP2pIfaceHal == null) { 286 return handleNullHal(methodStr); 287 } 288 return mP2pIfaceHal.flush(); 289 } 290 } 291 292 /** 293 * This command can be used to flush all services from the 294 * device. 295 * 296 * @return boolean value indicating whether operation was successful. 297 */ serviceFlush()298 public boolean serviceFlush() { 299 synchronized (mLock) { 300 String methodStr = "serviceFlush"; 301 if (mP2pIfaceHal == null) { 302 return handleNullHal(methodStr); 303 } 304 return mP2pIfaceHal.serviceFlush(); 305 } 306 } 307 308 /** 309 * Turn on/off power save mode for the interface. 310 * 311 * @param groupIfName Group interface name to use. 312 * @param enable Indicate if power save is to be turned on/off. 313 * 314 * @return boolean value indicating whether operation was successful. 315 */ setPowerSave(String groupIfName, boolean enable)316 public boolean setPowerSave(String groupIfName, boolean enable) { 317 synchronized (mLock) { 318 String methodStr = "setPowerSave"; 319 if (mP2pIfaceHal == null) { 320 return handleNullHal(methodStr); 321 } 322 return mP2pIfaceHal.setPowerSave(groupIfName, enable); 323 } 324 } 325 326 /** 327 * Set the Maximum idle time in seconds for P2P groups. 328 * This value controls how long a P2P group is maintained after there 329 * is no other members in the group. As a group owner, this means no 330 * associated stations in the group. As a P2P client, this means no 331 * group owner seen in scan results. 332 * 333 * @param groupIfName Group interface name to use. 334 * @param timeoutInSec Timeout value in seconds. 335 * 336 * @return boolean value indicating whether operation was successful. 337 */ setGroupIdle(String groupIfName, int timeoutInSec)338 public boolean setGroupIdle(String groupIfName, int timeoutInSec) { 339 synchronized (mLock) { 340 String methodStr = "setGroupIdle"; 341 if (mP2pIfaceHal == null) { 342 return handleNullHal(methodStr); 343 } 344 return mP2pIfaceHal.setGroupIdle(groupIfName, timeoutInSec); 345 } 346 } 347 348 /** 349 * Set the postfix to be used for P2P SSID's. 350 * 351 * @param postfix String to be appended to SSID. 352 * 353 * @return boolean value indicating whether operation was successful. 354 */ setSsidPostfix(String postfix)355 public boolean setSsidPostfix(String postfix) { 356 synchronized (mLock) { 357 String methodStr = "setSsidPostfix"; 358 if (mP2pIfaceHal == null) { 359 return handleNullHal(methodStr); 360 } 361 return mP2pIfaceHal.setSsidPostfix(postfix); 362 } 363 } 364 365 /** 366 * Start P2P group formation with a discovered P2P peer. This includes 367 * optional group owner negotiation, group interface setup, provisioning, 368 * and establishing data connection. 369 * 370 * @param config Configuration to use to connect to remote device. 371 * @param joinExistingGroup Indicates that this is a command to join an 372 * existing group as a client. It skips the group owner negotiation 373 * part. This must send a Provision Discovery Request message to the 374 * target group owner before associating for WPS provisioning. 375 * 376 * @return String containing generated pin, if selected provision method 377 * uses PIN. 378 */ connect(WifiP2pConfig config, boolean joinExistingGroup)379 public String connect(WifiP2pConfig config, boolean joinExistingGroup) { 380 synchronized (mLock) { 381 String methodStr = "connect"; 382 if (mP2pIfaceHal == null) { 383 handleNullHal(methodStr); 384 return null; 385 } 386 return mP2pIfaceHal.connect(config, joinExistingGroup); 387 } 388 } 389 390 /** 391 * Cancel an ongoing P2P group formation and joining-a-group related 392 * operation. This operation unauthorizes the specific peer device (if any 393 * had been authorized to start group formation), stops P2P find (if in 394 * progress), stops pending operations for join-a-group, and removes the 395 * P2P group interface (if one was used) that is in the WPS provisioning 396 * step. If the WPS provisioning step has been completed, the group is not 397 * terminated. 398 * 399 * @return boolean value indicating whether operation was successful. 400 */ cancelConnect()401 public boolean cancelConnect() { 402 synchronized (mLock) { 403 String methodStr = "cancelConnect"; 404 if (mP2pIfaceHal == null) { 405 return handleNullHal(methodStr); 406 } 407 return mP2pIfaceHal.cancelConnect(); 408 } 409 } 410 411 /** 412 * Send P2P provision discovery request to the specified peer. The 413 * parameters for this command are the P2P device address of the peer and the 414 * desired configuration method. 415 * 416 * @param config Config class describing peer setup. 417 * 418 * @return boolean value indicating whether operation was successful. 419 */ provisionDiscovery(WifiP2pConfig config)420 public boolean provisionDiscovery(WifiP2pConfig config) { 421 synchronized (mLock) { 422 String methodStr = "provisionDiscovery"; 423 if (mP2pIfaceHal == null) { 424 return handleNullHal(methodStr); 425 } 426 return mP2pIfaceHal.provisionDiscovery(config); 427 } 428 } 429 430 /** 431 * Invite a device to a persistent group. 432 * If the peer device is the group owner of the persistent group, the peer 433 * parameter is not needed. Otherwise it is used to specify which 434 * device to invite. |goDeviceAddress| parameter may be used to override 435 * the group owner device address for Invitation Request should it not be 436 * known for some reason (this should not be needed in most cases). 437 * 438 * @param group Group object to use. 439 * @param peerAddress MAC address of the device to invite. 440 * 441 * @return boolean value indicating whether operation was successful. 442 */ invite(WifiP2pGroup group, String peerAddress)443 public boolean invite(WifiP2pGroup group, String peerAddress) { 444 synchronized (mLock) { 445 String methodStr = "invite"; 446 if (mP2pIfaceHal == null) { 447 return handleNullHal(methodStr); 448 } 449 return mP2pIfaceHal.invite(group, peerAddress); 450 } 451 } 452 453 /** 454 * Reject connection attempt from a peer (specified with a device 455 * address). This is a mechanism to reject a pending group owner negotiation 456 * with a peer and request to automatically block any further connection or 457 * discovery of the peer. 458 * 459 * @param peerAddress MAC address of the device to reject. 460 * 461 * @return boolean value indicating whether operation was successful. 462 */ reject(String peerAddress)463 public boolean reject(String peerAddress) { 464 synchronized (mLock) { 465 String methodStr = "reject"; 466 if (mP2pIfaceHal == null) { 467 return handleNullHal(methodStr); 468 } 469 return mP2pIfaceHal.reject(peerAddress); 470 } 471 } 472 473 /** 474 * Gets the MAC address of the device. 475 * 476 * @return MAC address of the device. 477 */ getDeviceAddress()478 public String getDeviceAddress() { 479 synchronized (mLock) { 480 String methodStr = "getDeviceAddress"; 481 if (mP2pIfaceHal == null) { 482 handleNullHal(methodStr); 483 return null; 484 } 485 return mP2pIfaceHal.getDeviceAddress(); 486 } 487 } 488 489 /** 490 * Gets the operational SSID of the device. 491 * 492 * @param address MAC address of the peer. 493 * 494 * @return SSID of the device. 495 */ getSsid(String address)496 public String getSsid(String address) { 497 synchronized (mLock) { 498 String methodStr = "getSsid"; 499 if (mP2pIfaceHal == null) { 500 handleNullHal(methodStr); 501 return null; 502 } 503 return mP2pIfaceHal.getSsid(address); 504 } 505 } 506 507 /** 508 * Reinvoke a device from a persistent group. 509 * 510 * @param networkId Used to specify the persistent group (valid only for P2P V1 group). 511 * @param peerAddress MAC address of the device to reinvoke. 512 * @param dikId The identifier of device identity key of the device to reinvoke. 513 * (valid only for P2P V2 group). 514 * 515 * @return true, if operation was successful. 516 */ reinvoke(int networkId, String peerAddress, int dikId)517 public boolean reinvoke(int networkId, String peerAddress, int dikId) { 518 synchronized (mLock) { 519 String methodStr = "reinvoke"; 520 if (mP2pIfaceHal == null) { 521 return handleNullHal(methodStr); 522 } 523 return mP2pIfaceHal.reinvoke(networkId, peerAddress, dikId); 524 } 525 } 526 527 /** 528 * Set up a P2P group owner manually (i.e., without group owner 529 * negotiation with a specific peer). This is also known as autonomous 530 * group owner. 531 * 532 * @param networkId Used to specify the restart of a persistent group. 533 * @param isPersistent Used to request a persistent group to be formed. 534 * @param isP2pV2 Used to start a Group Owner that support P2P2 IE. 535 * 536 * @return true, if operation was successful. 537 */ groupAdd(int networkId, boolean isPersistent, boolean isP2pV2)538 public boolean groupAdd(int networkId, boolean isPersistent, boolean isP2pV2) { 539 synchronized (mLock) { 540 String methodStr = "groupAdd"; 541 if (mP2pIfaceHal == null) { 542 return handleNullHal(methodStr); 543 } 544 return mP2pIfaceHal.groupAdd(networkId, isPersistent, isP2pV2); 545 } 546 } 547 548 /** 549 * Set up a P2P group owner manually. 550 * This is a helper method that invokes groupAdd(networkId, isPersistent) internally. 551 * 552 * @param isPersistent Used to request a persistent group to be formed. 553 * @param isP2pV2 Used to start a Group Owner that support P2P2 IE. 554 * 555 * @return true, if operation was successful. 556 */ groupAdd(boolean isPersistent, boolean isP2pV2)557 public boolean groupAdd(boolean isPersistent, boolean isP2pV2) { 558 synchronized (mLock) { 559 // Supplicant expects networkId to be -1 if not supplied. 560 return groupAdd(-1, isPersistent, isP2pV2); 561 } 562 } 563 564 /** 565 * Set up a P2P group as Group Owner or join a group with a configuration. 566 * 567 * @param networkName SSID of the group to be formed 568 * @param passphrase passphrase of the group to be formed 569 * @param isPersistent Used to request a persistent group to be formed. 570 * @param freq prefered frequencty or band of the group to be formed 571 * @param peerAddress peerAddress Group Owner MAC address, only applied for Group Client. 572 * If the MAC is "00:00:00:00:00:00", the device will try to find a peer 573 * whose SSID matches ssid. 574 * @param join join a group or create a group 575 * 576 * @return true, if operation was successful. 577 */ groupAdd(String networkName, String passphrase, @WifiP2pConfig.PccModeConnectionType int connectionType, boolean isPersistent, int freq, String peerAddress, boolean join)578 public boolean groupAdd(String networkName, String passphrase, 579 @WifiP2pConfig.PccModeConnectionType int connectionType, 580 boolean isPersistent, int freq, String peerAddress, boolean join) { 581 synchronized (mLock) { 582 String methodStr = "groupAdd"; 583 if (mP2pIfaceHal == null) { 584 return handleNullHal(methodStr); 585 } 586 return mP2pIfaceHal.groupAdd(networkName, passphrase, connectionType, 587 isPersistent, freq, peerAddress, join); 588 } 589 } 590 591 /** 592 * Terminate a P2P group. If a new virtual network interface was used for 593 * the group, it must also be removed. The network interface name of the 594 * group interface is used as a parameter for this command. 595 * 596 * @param groupName Group interface name to use. 597 * 598 * @return true, if operation was successful. 599 */ groupRemove(String groupName)600 public boolean groupRemove(String groupName) { 601 synchronized (mLock) { 602 String methodStr = "groupRemove"; 603 if (mP2pIfaceHal == null) { 604 return handleNullHal(methodStr); 605 } 606 return mP2pIfaceHal.groupRemove(groupName); 607 } 608 } 609 610 /** 611 * Gets the capability of the group which the device is a 612 * member of. 613 * 614 * @param peerAddress MAC address of the peer. 615 * 616 * @return combination of |GroupCapabilityMask| values. 617 */ getGroupCapability(String peerAddress)618 public int getGroupCapability(String peerAddress) { 619 synchronized (mLock) { 620 String methodStr = "getGroupCapability"; 621 if (mP2pIfaceHal == null) { 622 handleNullHal(methodStr); 623 return -1; 624 } 625 return mP2pIfaceHal.getGroupCapability(peerAddress); 626 } 627 } 628 629 /** 630 * Configure Extended Listen Timing. See comments for 631 * {@link ISupplicantP2pIfaceHal#configureExtListen(boolean, int, int, WifiP2pExtListenParams)} 632 * 633 * @return true, if operation was successful. 634 */ configureExtListen(boolean enable, int periodInMillis, int intervalInMillis, @Nullable WifiP2pExtListenParams extListenParams)635 public boolean configureExtListen(boolean enable, int periodInMillis, int intervalInMillis, 636 @Nullable WifiP2pExtListenParams extListenParams) { 637 synchronized (mLock) { 638 String methodStr = "configureExtListen"; 639 if (mP2pIfaceHal == null) { 640 return handleNullHal(methodStr); 641 } 642 return mP2pIfaceHal.configureExtListen( 643 enable, periodInMillis, intervalInMillis, extListenParams); 644 } 645 } 646 647 /** 648 * Set P2P Listen channel. 649 * 650 * @param listenChannel Wifi channel. eg, 1, 6, 11. 651 * 652 * @return true, if operation was successful. 653 */ setListenChannel(int listenChannel)654 public boolean setListenChannel(int listenChannel) { 655 synchronized (mLock) { 656 String methodStr = "setListenChannel"; 657 if (mP2pIfaceHal == null) { 658 return handleNullHal(methodStr); 659 } 660 return mP2pIfaceHal.setListenChannel(listenChannel); 661 } 662 } 663 664 /** 665 * Set P2P operating channel. 666 * 667 * @param operatingChannel the desired operating channel. 668 * @param unsafeChannels channels which p2p cannot use. 669 * 670 * @return true, if operation was successful. 671 */ setOperatingChannel(int operatingChannel, @NonNull List<CoexUnsafeChannel> unsafeChannels)672 public boolean setOperatingChannel(int operatingChannel, 673 @NonNull List<CoexUnsafeChannel> unsafeChannels) { 674 synchronized (mLock) { 675 String methodStr = "setOperatingChannel"; 676 if (mP2pIfaceHal == null) { 677 return handleNullHal(methodStr); 678 } 679 return mP2pIfaceHal.setOperatingChannel(operatingChannel, unsafeChannels); 680 } 681 } 682 683 /** 684 * This command can be used to add a upnp/bonjour service. 685 * 686 * @param servInfo List of service queries. 687 * 688 * @return true, if operation was successful. 689 */ serviceAdd(WifiP2pServiceInfo servInfo)690 public boolean serviceAdd(WifiP2pServiceInfo servInfo) { 691 synchronized (mLock) { 692 String methodStr = "serviceAdd"; 693 if (mP2pIfaceHal == null) { 694 return handleNullHal(methodStr); 695 } 696 return mP2pIfaceHal.serviceAdd(servInfo); 697 } 698 } 699 700 /** 701 * This command can be used to remove a upnp/bonjour service. 702 * 703 * @param servInfo List of service queries. 704 * 705 * @return true, if operation was successful. 706 */ serviceRemove(WifiP2pServiceInfo servInfo)707 public boolean serviceRemove(WifiP2pServiceInfo servInfo) { 708 synchronized (mLock) { 709 String methodStr = "serviceRemove"; 710 if (mP2pIfaceHal == null) { 711 return handleNullHal(methodStr); 712 } 713 return mP2pIfaceHal.serviceRemove(servInfo); 714 } 715 } 716 717 /** 718 * Schedule a P2P service discovery request. The parameters for this command 719 * are the device address of the peer device (or 00:00:00:00:00:00 for 720 * wildcard query that is sent to every discovered P2P peer that supports 721 * service discovery) and P2P Service Query TLV(s) as hexdump. 722 * 723 * @param peerAddress MAC address of the device to discover. 724 * @param query Hex dump of the query data. 725 * @return identifier Identifier for the request. Can be used to cancel the 726 * request. 727 */ requestServiceDiscovery(String peerAddress, String query)728 public String requestServiceDiscovery(String peerAddress, String query) { 729 synchronized (mLock) { 730 String methodStr = "requestServiceDiscovery"; 731 if (mP2pIfaceHal == null) { 732 handleNullHal(methodStr); 733 return null; 734 } 735 return mP2pIfaceHal.requestServiceDiscovery(peerAddress, query); 736 } 737 } 738 739 /** 740 * Cancel a previous service discovery request. 741 * 742 * @param identifier Identifier for the request to cancel. 743 * @return true, if operation was successful. 744 */ cancelServiceDiscovery(String identifier)745 public boolean cancelServiceDiscovery(String identifier) { 746 synchronized (mLock) { 747 String methodStr = "cancelServiceDiscovery"; 748 if (mP2pIfaceHal == null) { 749 return handleNullHal(methodStr); 750 } 751 return mP2pIfaceHal.cancelServiceDiscovery(identifier); 752 } 753 } 754 755 /** 756 * Send driver command to set Miracast mode. 757 * 758 * @param mode Mode of Miracast. 759 * @return true, if operation was successful. 760 */ setMiracastMode(int mode)761 public boolean setMiracastMode(int mode) { 762 synchronized (mLock) { 763 String methodStr = "setMiracastMode"; 764 if (mP2pIfaceHal == null) { 765 return handleNullHal(methodStr); 766 } 767 return mP2pIfaceHal.setMiracastMode(mode); 768 } 769 } 770 771 /** 772 * Initiate WPS Push Button setup. 773 * The PBC operation requires that a button is also pressed at the 774 * AP/Registrar at about the same time (2 minute window). 775 * 776 * @param groupIfName Group interface name to use. 777 * @param bssid BSSID of the AP. Use empty bssid to indicate wildcard. 778 * @return true, if operation was successful. 779 */ startWpsPbc(String groupIfName, String bssid)780 public boolean startWpsPbc(String groupIfName, String bssid) { 781 synchronized (mLock) { 782 String methodStr = "startWpsPbc"; 783 if (mP2pIfaceHal == null) { 784 return handleNullHal(methodStr); 785 } 786 return mP2pIfaceHal.startWpsPbc(groupIfName, bssid); 787 } 788 } 789 790 /** 791 * Initiate WPS Pin Keypad setup. 792 * 793 * @param groupIfName Group interface name to use. 794 * @param pin 8 digit pin to be used. 795 * @return true, if operation was successful. 796 */ startWpsPinKeypad(String groupIfName, String pin)797 public boolean startWpsPinKeypad(String groupIfName, String pin) { 798 synchronized (mLock) { 799 String methodStr = "startWpsPinKeypad"; 800 if (mP2pIfaceHal == null) { 801 return handleNullHal(methodStr); 802 } 803 return mP2pIfaceHal.startWpsPinKeypad(groupIfName, pin); 804 } 805 } 806 807 /** 808 * Initiate WPS Pin Display setup. 809 * 810 * @param groupIfName Group interface name to use. 811 * @param bssid BSSID of the AP. Use empty bssid to indicate wildcard. 812 * @return generated pin if operation was successful, null otherwise. 813 */ startWpsPinDisplay(String groupIfName, String bssid)814 public String startWpsPinDisplay(String groupIfName, String bssid) { 815 synchronized (mLock) { 816 String methodStr = "startWpsPinDisplay"; 817 if (mP2pIfaceHal == null) { 818 handleNullHal(methodStr); 819 return null; 820 } 821 return mP2pIfaceHal.startWpsPinDisplay(groupIfName, bssid); 822 } 823 } 824 825 /** 826 * Cancel any ongoing WPS operations. 827 * 828 * @param groupIfName Group interface name to use. 829 * @return true, if operation was successful. 830 */ cancelWps(String groupIfName)831 public boolean cancelWps(String groupIfName) { 832 synchronized (mLock) { 833 String methodStr = "cancelWps"; 834 if (mP2pIfaceHal == null) { 835 return handleNullHal(methodStr); 836 } 837 return mP2pIfaceHal.cancelWps(groupIfName); 838 } 839 } 840 841 /** 842 * Enable/Disable Wifi Display. 843 * 844 * @param enable true to enable, false to disable. 845 * @return true, if operation was successful. 846 */ enableWfd(boolean enable)847 public boolean enableWfd(boolean enable) { 848 synchronized (mLock) { 849 String methodStr = "enableWfd"; 850 if (mP2pIfaceHal == null) { 851 return handleNullHal(methodStr); 852 } 853 return mP2pIfaceHal.enableWfd(enable); 854 } 855 } 856 857 /** 858 * Set Wifi Display device info. 859 * 860 * @param info WFD device info as described in section 5.1.2 of WFD technical 861 * specification v1.0.0. 862 * @return true, if operation was successful. 863 */ setWfdDeviceInfo(String info)864 public boolean setWfdDeviceInfo(String info) { 865 synchronized (mLock) { 866 String methodStr = "setWfdDeviceInfo"; 867 if (mP2pIfaceHal == null) { 868 return handleNullHal(methodStr); 869 } 870 return mP2pIfaceHal.setWfdDeviceInfo(info); 871 } 872 } 873 874 /** 875 * Remove network with provided id. 876 * 877 * @param networkId Id of the network to lookup. 878 * @return true, if operation was successful. 879 */ removeNetwork(int networkId)880 public boolean removeNetwork(int networkId) { 881 synchronized (mLock) { 882 String methodStr = "removeNetwork"; 883 if (mP2pIfaceHal == null) { 884 return handleNullHal(methodStr); 885 } 886 return mP2pIfaceHal.removeNetwork(networkId); 887 } 888 } 889 890 /** 891 * Get the persistent group list from wpa_supplicant's p2p mgmt interface 892 * 893 * @param groups WifiP2pGroupList to store persistent groups in 894 * @return true, if list has been modified. 895 */ loadGroups(WifiP2pGroupList groups)896 public boolean loadGroups(WifiP2pGroupList groups) { 897 synchronized (mLock) { 898 String methodStr = "loadGroups"; 899 if (mP2pIfaceHal == null) { 900 return handleNullHal(methodStr); 901 } 902 return mP2pIfaceHal.loadGroups(groups); 903 } 904 } 905 906 /** 907 * Set WPS device name. 908 * 909 * @param name String to be set. 910 * @return true if request is sent successfully, false otherwise. 911 */ setWpsDeviceName(String name)912 public boolean setWpsDeviceName(String name) { 913 synchronized (mLock) { 914 String methodStr = "setWpsDeviceName"; 915 if (mP2pIfaceHal == null) { 916 return handleNullHal(methodStr); 917 } 918 return mP2pIfaceHal.setWpsDeviceName(name); 919 } 920 } 921 922 /** 923 * Set WPS device type. 924 * 925 * @param typeStr Type specified as a string. Used format: <categ>-<OUI>-<subcateg> 926 * @return true if request is sent successfully, false otherwise. 927 */ setWpsDeviceType(String typeStr)928 public boolean setWpsDeviceType(String typeStr) { 929 synchronized (mLock) { 930 String methodStr = "setWpsDeviceType"; 931 if (mP2pIfaceHal == null) { 932 return handleNullHal(methodStr); 933 } 934 return mP2pIfaceHal.setWpsDeviceType(typeStr); 935 } 936 } 937 938 /** 939 * Set WPS config methods 940 * 941 * @param configMethodsStr List of config methods. 942 * @return true if request is sent successfully, false otherwise. 943 */ setWpsConfigMethods(String configMethodsStr)944 public boolean setWpsConfigMethods(String configMethodsStr) { 945 synchronized (mLock) { 946 String methodStr = "setWpsConfigMethods"; 947 if (mP2pIfaceHal == null) { 948 return handleNullHal(methodStr); 949 } 950 return mP2pIfaceHal.setWpsConfigMethods(configMethodsStr); 951 } 952 } 953 954 /** 955 * Get NFC handover request message. 956 * 957 * @return select message if created successfully, null otherwise. 958 */ getNfcHandoverRequest()959 public String getNfcHandoverRequest() { 960 synchronized (mLock) { 961 String methodStr = "getNfcHandoverRequest"; 962 if (mP2pIfaceHal == null) { 963 handleNullHal(methodStr); 964 return null; 965 } 966 return mP2pIfaceHal.getNfcHandoverRequest(); 967 } 968 } 969 970 /** 971 * Get NFC handover select message. 972 * 973 * @return select message if created successfully, null otherwise. 974 */ getNfcHandoverSelect()975 public String getNfcHandoverSelect() { 976 synchronized (mLock) { 977 String methodStr = "getNfcHandoverSelect"; 978 if (mP2pIfaceHal == null) { 979 handleNullHal(methodStr); 980 return null; 981 } 982 return mP2pIfaceHal.getNfcHandoverSelect(); 983 } 984 } 985 986 /** 987 * Report NFC handover select message. 988 * 989 * @return true if reported successfully, false otherwise. 990 */ initiatorReportNfcHandover(String selectMessage)991 public boolean initiatorReportNfcHandover(String selectMessage) { 992 synchronized (mLock) { 993 String methodStr = "initiatorReportNfcHandover"; 994 if (mP2pIfaceHal == null) { 995 return handleNullHal(methodStr); 996 } 997 return mP2pIfaceHal.initiatorReportNfcHandover(selectMessage); 998 } 999 } 1000 1001 /** 1002 * Report NFC handover request message. 1003 * 1004 * @return true if reported successfully, false otherwise. 1005 */ responderReportNfcHandover(String requestMessage)1006 public boolean responderReportNfcHandover(String requestMessage) { 1007 synchronized (mLock) { 1008 String methodStr = "responderReportNfcHandover"; 1009 if (mP2pIfaceHal == null) { 1010 return handleNullHal(methodStr); 1011 } 1012 return mP2pIfaceHal.responderReportNfcHandover(requestMessage); 1013 } 1014 } 1015 1016 /** 1017 * Set the client list for the provided network. 1018 * 1019 * @param networkId Id of the network. 1020 * @param clientListStr Space separated list of clients. 1021 * @return true, if operation was successful. 1022 */ setClientList(int networkId, String clientListStr)1023 public boolean setClientList(int networkId, String clientListStr) { 1024 synchronized (mLock) { 1025 String methodStr = "setClientList"; 1026 if (mP2pIfaceHal == null) { 1027 return handleNullHal(methodStr); 1028 } 1029 return mP2pIfaceHal.setClientList(networkId, clientListStr); 1030 } 1031 } 1032 1033 /** 1034 * Set the client list for the provided network. 1035 * 1036 * @param networkId Id of the network. 1037 * @return Space separated list of clients if successful, null otherwise. 1038 */ getClientList(int networkId)1039 public String getClientList(int networkId) { 1040 synchronized (mLock) { 1041 String methodStr = "getClientList"; 1042 if (mP2pIfaceHal == null) { 1043 handleNullHal(methodStr); 1044 return null; 1045 } 1046 return mP2pIfaceHal.getClientList(networkId); 1047 } 1048 } 1049 1050 /** 1051 * Persist the current configurations to disk. 1052 * 1053 * @return true, if operation was successful. 1054 */ saveConfig()1055 public boolean saveConfig() { 1056 synchronized (mLock) { 1057 String methodStr = "saveConfig"; 1058 if (mP2pIfaceHal == null) { 1059 return handleNullHal(methodStr); 1060 } 1061 return mP2pIfaceHal.saveConfig(); 1062 } 1063 } 1064 1065 /** 1066 * Enable/Disable P2P MAC randomization. 1067 * 1068 * @param enable true to enable, false to disable. 1069 * @return true, if operation was successful. 1070 */ setMacRandomization(boolean enable)1071 public boolean setMacRandomization(boolean enable) { 1072 synchronized (mLock) { 1073 String methodStr = "setMacRandomization"; 1074 if (mP2pIfaceHal == null) { 1075 return handleNullHal(methodStr); 1076 } 1077 return mP2pIfaceHal.setMacRandomization(enable); 1078 } 1079 } 1080 1081 /** 1082 * Set Wifi Display R2 device info. 1083 * 1084 * @param info WFD R2 device info as described in section 5.1.12 of WFD technical 1085 * specification v2.1. 1086 * @return true, if operation was successful. 1087 */ setWfdR2DeviceInfo(String info)1088 public boolean setWfdR2DeviceInfo(String info) { 1089 synchronized (mLock) { 1090 String methodStr = "setWfdR2DeviceInfo"; 1091 if (mP2pIfaceHal == null) { 1092 return handleNullHal(methodStr); 1093 } 1094 return mP2pIfaceHal.setWfdR2DeviceInfo(info); 1095 } 1096 } 1097 1098 /** 1099 * Remove the client with the MAC address from the group. 1100 * 1101 * @param peerAddress Mac address of the client. 1102 * @param isLegacyClient Indicate if client is a legacy client or not. 1103 * @return true if success 1104 */ removeClient(String peerAddress, boolean isLegacyClient)1105 public boolean removeClient(String peerAddress, boolean isLegacyClient) { 1106 synchronized (mLock) { 1107 String methodStr = "removeClient"; 1108 if (mP2pIfaceHal == null) { 1109 return handleNullHal(methodStr); 1110 } 1111 return mP2pIfaceHal.removeClient(peerAddress, isLegacyClient); 1112 } 1113 } 1114 1115 /** 1116 * Set vendor-specific information elements to wpa_supplicant. 1117 * 1118 * @param vendorElements The list of vendor-specific information elements. 1119 * 1120 * @return boolean The value indicating whether operation was successful. 1121 */ setVendorElements(Set<ScanResult.InformationElement> vendorElements)1122 public boolean setVendorElements(Set<ScanResult.InformationElement> vendorElements) { 1123 synchronized (mLock) { 1124 String methodStr = "setVendorElements"; 1125 if (mP2pIfaceHal == null) { 1126 return handleNullHal(methodStr); 1127 } 1128 return mP2pIfaceHal.setVendorElements(vendorElements); 1129 } 1130 } 1131 1132 /** 1133 * Get the supported features. 1134 * 1135 * @return bitmask defined by WifiP2pManager.FEATURE_* 1136 */ getSupportedFeatures()1137 public long getSupportedFeatures() { 1138 if (mP2pIfaceHal instanceof SupplicantP2pIfaceHalHidlImpl) return 0L; 1139 return ((SupplicantP2pIfaceHalAidlImpl) mP2pIfaceHal).getSupportedFeatures(); 1140 } 1141 handleNullHal(String methodStr)1142 private boolean handleNullHal(String methodStr) { 1143 Log.e(TAG, "Cannot call " + methodStr + " because HAL object is null."); 1144 return false; 1145 } 1146 1147 /** 1148 * Configure the IP addresses in supplicant for P2P GO to provide the IP address to 1149 * client in EAPOL handshake. Refer Wi-Fi P2P Technical Specification v1.7 - Section 4.2.8 1150 * IP Address Allocation in EAPOL-Key Frames (4-Way Handshake) for more details. 1151 * The IP addresses are IPV4 addresses and higher-order address bytes are in the 1152 * lower-order int bytes (e.g. 1.2.3.4 is represented as 0x04030201) 1153 * 1154 * @param ipAddressGo The P2P Group Owner IP address. 1155 * @param ipAddressMask The P2P Group owner subnet mask. 1156 * @param ipAddressStart The starting address in the IP address pool. 1157 * @param ipAddressEnd The ending address in the IP address pool. 1158 * @return boolean value indicating whether operation was successful. 1159 */ configureEapolIpAddressAllocationParams(int ipAddressGo, int ipAddressMask, int ipAddressStart, int ipAddressEnd)1160 public boolean configureEapolIpAddressAllocationParams(int ipAddressGo, int ipAddressMask, 1161 int ipAddressStart, int ipAddressEnd) { 1162 synchronized (mLock) { 1163 String methodStr = "configureEapolIpAddressAllocationParams"; 1164 if (mP2pIfaceHal == null) { 1165 return handleNullHal(methodStr); 1166 } 1167 return mP2pIfaceHal.configureEapolIpAddressAllocationParams(ipAddressGo, ipAddressMask, 1168 ipAddressStart, ipAddressEnd); 1169 } 1170 } 1171 1172 /** 1173 * Start an Un-synchronized Service Discovery (USD) based P2P service discovery. 1174 * 1175 * @param usdServiceConfig is the USD based service configuration. 1176 * @param discoveryConfig is the configuration for this service discovery request. 1177 * @param timeoutInSeconds is the maximum time to be spent for this service discovery request. 1178 */ startUsdBasedServiceDiscovery(WifiP2pUsdBasedServiceConfig usdServiceConfig, WifiP2pUsdBasedServiceDiscoveryConfig discoveryConfig, int timeoutInSeconds)1179 public int startUsdBasedServiceDiscovery(WifiP2pUsdBasedServiceConfig usdServiceConfig, 1180 WifiP2pUsdBasedServiceDiscoveryConfig discoveryConfig, int timeoutInSeconds) { 1181 synchronized (mLock) { 1182 String methodStr = "startUsdBasedServiceDiscovery"; 1183 if (mP2pIfaceHal == null) { 1184 handleNullHal(methodStr); 1185 return -1; 1186 } 1187 return mP2pIfaceHal.startUsdBasedServiceDiscovery(usdServiceConfig, discoveryConfig, 1188 timeoutInSeconds); 1189 } 1190 } 1191 1192 /** 1193 * Stop an Un-synchronized Service Discovery (USD) based P2P service discovery. 1194 * 1195 * @param sessionId Identifier to cancel the service discovery instance. 1196 * Use zero to cancel all the service discovery instances. 1197 */ stopUsdBasedServiceDiscovery(int sessionId)1198 public void stopUsdBasedServiceDiscovery(int sessionId) { 1199 synchronized (mLock) { 1200 String methodStr = "stopUsdBasedServiceDiscovery"; 1201 if (mP2pIfaceHal == null) { 1202 handleNullHal(methodStr); 1203 return; 1204 } 1205 mP2pIfaceHal.stopUsdBasedServiceDiscovery(sessionId); 1206 } 1207 } 1208 1209 /** 1210 * Start an Un-synchronized Service Discovery (USD) based P2P service advertisement. 1211 * 1212 * @param usdServiceConfig is the USD based service configuration. 1213 * @param advertisementConfig is the configuration for this service advertisement. 1214 * @param timeoutInSeconds is the maximum time to be spent for this service advertisement. 1215 */ startUsdBasedServiceAdvertisement(WifiP2pUsdBasedServiceConfig usdServiceConfig, WifiP2pUsdBasedLocalServiceAdvertisementConfig advertisementConfig, int timeoutInSeconds)1216 public int startUsdBasedServiceAdvertisement(WifiP2pUsdBasedServiceConfig usdServiceConfig, 1217 WifiP2pUsdBasedLocalServiceAdvertisementConfig advertisementConfig, 1218 int timeoutInSeconds) { 1219 synchronized (mLock) { 1220 String methodStr = "startUsdBasedServiceAdvertisement"; 1221 if (mP2pIfaceHal == null) { 1222 handleNullHal(methodStr); 1223 return -1; 1224 } 1225 return mP2pIfaceHal.startUsdBasedServiceAdvertisement(usdServiceConfig, 1226 advertisementConfig, timeoutInSeconds); 1227 } 1228 } 1229 1230 /** 1231 * Stop an Un-synchronized Service Discovery (USD) based P2P service advertisement. 1232 * 1233 * @param sessionId Identifier to cancel the service advertisement. 1234 * Use zero to cancel all the service advertisement instances. 1235 */ stopUsdBasedServiceAdvertisement(int sessionId)1236 public void stopUsdBasedServiceAdvertisement(int sessionId) { 1237 synchronized (mLock) { 1238 String methodStr = "stopUsdBasedServiceAdvertisement"; 1239 if (mP2pIfaceHal == null) { 1240 handleNullHal(methodStr); 1241 return; 1242 } 1243 mP2pIfaceHal.stopUsdBasedServiceAdvertisement(sessionId); 1244 } 1245 } 1246 1247 /** 1248 * Get the Device Identity Resolution (DIR) Information. 1249 * See {@link WifiP2pDirInfo} for details 1250 * 1251 * @return {@link WifiP2pDirInfo} instance on success, null on failure. 1252 */ getDirInfo()1253 public WifiP2pDirInfo getDirInfo() { 1254 synchronized (mLock) { 1255 String methodStr = "getDirInfo"; 1256 if (mP2pIfaceHal == null) { 1257 handleNullHal(methodStr); 1258 return null; 1259 } 1260 return mP2pIfaceHal.getDirInfo(); 1261 } 1262 } 1263 1264 /** 1265 * Validate the Device Identity Resolution (DIR) Information of a P2P device. 1266 * See {@link WifiP2pDirInfo} for details. 1267 * 1268 * @param dirInfo {@link WifiP2pDirInfo} to validate. 1269 * @return The identifier of device identity key on success, -1 on failure. 1270 */ validateDirInfo(@onNull WifiP2pDirInfo dirInfo)1271 public int validateDirInfo(@NonNull WifiP2pDirInfo dirInfo) { 1272 synchronized (mLock) { 1273 String methodStr = "validateDirInfo"; 1274 if (mP2pIfaceHal == null) { 1275 handleNullHal(methodStr); 1276 return -1; 1277 } 1278 return mP2pIfaceHal.validateDirInfo(dirInfo); 1279 } 1280 } 1281 1282 /** 1283 * Used to authorize a connection request to an existing Group Owner 1284 * interface, to allow a peer device to connect. 1285 * 1286 * @param config Configuration to use for connection. 1287 * @param groupOwnerInterfaceName Group Owner interface name on which the request to connect 1288 * needs to be authorized. 1289 * 1290 * @return boolean value indicating whether operation was successful. 1291 */ authorizeConnectRequestOnGroupOwner( WifiP2pConfig config, String groupOwnerInterfaceName)1292 public boolean authorizeConnectRequestOnGroupOwner( 1293 WifiP2pConfig config, String groupOwnerInterfaceName) { 1294 synchronized (mLock) { 1295 String methodStr = "connect"; 1296 if (mP2pIfaceHal == null) { 1297 handleNullHal(methodStr); 1298 return false; 1299 } 1300 return mP2pIfaceHal.authorizeConnectRequestOnGroupOwner(config, 1301 groupOwnerInterfaceName); 1302 } 1303 } 1304 1305 /** 1306 * Terminate the supplicant daemon & wait for its death. 1307 */ terminate()1308 public void terminate() { 1309 synchronized (mLock) { 1310 String methodStr = "terminate"; 1311 if (mP2pIfaceHal == null) { 1312 handleNullHal(methodStr); 1313 return; 1314 } 1315 mP2pIfaceHal.terminate(); 1316 } 1317 } 1318 1319 /** 1320 * Registers a death notification for supplicant. 1321 * @return Returns true on success. 1322 */ registerDeathHandler(@onNull WifiNative.SupplicantDeathEventHandler handler)1323 public boolean registerDeathHandler(@NonNull WifiNative.SupplicantDeathEventHandler handler) { 1324 synchronized (mLock) { 1325 String methodStr = "registerDeathHandler"; 1326 if (mP2pIfaceHal == null) { 1327 return handleNullHal(methodStr); 1328 } 1329 return mP2pIfaceHal.registerDeathHandler(handler); 1330 } 1331 } 1332 1333 /** 1334 * Deregisters a death notification for supplicant. 1335 * @return Returns true on success. 1336 */ deregisterDeathHandler()1337 public boolean deregisterDeathHandler() { 1338 synchronized (mLock) { 1339 String methodStr = "deregisterDeathHandler"; 1340 if (mP2pIfaceHal == null) { 1341 return handleNullHal(methodStr); 1342 } 1343 return mP2pIfaceHal.deregisterDeathHandler(); 1344 } 1345 } 1346 } 1347