/**
  * Set the Bluetooth scan mode of the local Bluetooth adapter.
  *
  * <p>The Bluetooth scan mode determines if the local adapter is connectable and/or discoverable
  * from remote Bluetooth devices.
  *
  * <p>For privacy reasons, discoverable mode is automatically turned off after <code>duration
  * </code> seconds. For example, 120 seconds should be enough for a remote device to initiate and
  * complete its discovery process.
  *
  * <p>Valid scan mode values are: {@link #SCAN_MODE_NONE}, {@link #SCAN_MODE_CONNECTABLE}, {@link
  * #SCAN_MODE_CONNECTABLE_DISCOVERABLE}.
  *
  * <p>If Bluetooth state is not {@link #STATE_ON}, this API will return false. After turning on
  * Bluetooth, wait for {@link #ACTION_STATE_CHANGED} with {@link #STATE_ON} to get the updated
  * value.
  *
  * <p>Requires {@link android.Manifest.permission#WRITE_SECURE_SETTINGS}
  *
  * <p>Applications cannot set the scan mode. They should use <code>startActivityForResult(
  * BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE})
  * </code>instead.
  *
  * @param mode valid scan mode
  * @param duration time in seconds to apply scan mode, only used for {@link
  *     #SCAN_MODE_CONNECTABLE_DISCOVERABLE}
  * @return true if the scan mode was set, false otherwise
  * @hide
  */
 public boolean setScanMode(int mode, int duration) {
   if (getState() != STATE_ON) return false;
   try {
     return mService.setScanMode(mode, duration);
   } catch (RemoteException e) {
     Log.e(TAG, "", e);
   }
   return false;
 }