Loading framework/java/android/bluetooth/BluetoothAdapter.java +37 −14 Original line number Original line Diff line number Diff line Loading @@ -1189,13 +1189,11 @@ public final class BluetoothAdapter { /** /** * Factory reset bluetooth settings. * Factory reset bluetooth settings. * * * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED} * permission * * @return true to indicate that the config file was successfully cleared * @return true to indicate that the config file was successfully cleared * @hide * @hide */ */ @UnsupportedAppUsage @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean factoryReset() { public boolean factoryReset() { try { try { mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); Loading @@ -1214,13 +1212,12 @@ public final class BluetoothAdapter { /** /** * Get the UUIDs supported by the local Bluetooth adapter. * Get the UUIDs supported by the local Bluetooth adapter. * * * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * @return the UUIDs supported by the local Bluetooth Adapter. * @return the UUIDs supported by the local Bluetooth Adapter. * @hide * @hide */ */ @UnsupportedAppUsage @UnsupportedAppUsage public ParcelUuid[] getUuids() { @RequiresPermission(Manifest.permission.BLUETOOTH) public @NonNull ParcelUuid[] getUuids() { if (getState() != STATE_ON) { if (getState() != STATE_ON) { return null; return null; } } Loading Loading @@ -1476,7 +1473,6 @@ public final class BluetoothAdapter { * will return false. After turning on Bluetooth, * will return false. After turning on Bluetooth, * wait for {@link #ACTION_STATE_CHANGED} with {@link #STATE_ON} * wait for {@link #ACTION_STATE_CHANGED} with {@link #STATE_ON} * to get the updated value. * to get the updated value. * <p>Requires {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} * <p>Applications cannot set the scan mode. They should use * <p>Applications cannot set the scan mode. They should use * <code>startActivityForResult( * <code>startActivityForResult( * BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE}) * BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE}) Loading @@ -1488,8 +1484,8 @@ public final class BluetoothAdapter { * @return true if the scan mode was set, false otherwise * @return true if the scan mode was set, false otherwise * @hide * @hide */ */ @UnsupportedAppUsage(publicAlternatives = "Use {@link #ACTION_REQUEST_DISCOVERABLE}, which " @SystemApi + "shows UI that confirms the user wants to go into discoverable mode.") @RequiresPermission(Manifest.permission.BLUETOOTH) public boolean setScanMode(@ScanMode int mode, int duration) { public boolean setScanMode(@ScanMode int mode, int duration) { if (getState() != STATE_ON) { if (getState() != STATE_ON) { return false; return false; Loading @@ -1507,9 +1503,34 @@ public final class BluetoothAdapter { return false; return false; } } /** @hide */ /** @UnsupportedAppUsage * Set the Bluetooth scan mode of the local Bluetooth adapter. public boolean setScanMode(int mode) { * <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>Applications cannot set the scan mode. They should use * <code>startActivityForResult( * BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE}) * </code>instead. * * @param mode valid scan mode * @return true if the scan mode was set, false otherwise * @hide */ @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH) public boolean setScanMode(@ScanMode int mode) { if (getState() != STATE_ON) { if (getState() != STATE_ON) { return false; return false; } } Loading Loading @@ -1562,6 +1583,8 @@ public final class BluetoothAdapter { * been called recently. * been called recently. * @hide * @hide */ */ @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH) public long getDiscoveryEndMillis() { public long getDiscoveryEndMillis() { try { try { mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); Loading Loading @@ -2060,7 +2083,7 @@ public final class BluetoothAdapter { * BluetoothProfile}. * BluetoothProfile}. * @hide * @hide */ */ public List<Integer> getSupportedProfiles() { public @NonNull List<Integer> getSupportedProfiles() { final ArrayList<Integer> supportedProfiles = new ArrayList<Integer>(); final ArrayList<Integer> supportedProfiles = new ArrayList<Integer>(); try { try { Loading Loading
framework/java/android/bluetooth/BluetoothAdapter.java +37 −14 Original line number Original line Diff line number Diff line Loading @@ -1189,13 +1189,11 @@ public final class BluetoothAdapter { /** /** * Factory reset bluetooth settings. * Factory reset bluetooth settings. * * * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED} * permission * * @return true to indicate that the config file was successfully cleared * @return true to indicate that the config file was successfully cleared * @hide * @hide */ */ @UnsupportedAppUsage @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean factoryReset() { public boolean factoryReset() { try { try { mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); Loading @@ -1214,13 +1212,12 @@ public final class BluetoothAdapter { /** /** * Get the UUIDs supported by the local Bluetooth adapter. * Get the UUIDs supported by the local Bluetooth adapter. * * * <p>Requires {@link android.Manifest.permission#BLUETOOTH} * * @return the UUIDs supported by the local Bluetooth Adapter. * @return the UUIDs supported by the local Bluetooth Adapter. * @hide * @hide */ */ @UnsupportedAppUsage @UnsupportedAppUsage public ParcelUuid[] getUuids() { @RequiresPermission(Manifest.permission.BLUETOOTH) public @NonNull ParcelUuid[] getUuids() { if (getState() != STATE_ON) { if (getState() != STATE_ON) { return null; return null; } } Loading Loading @@ -1476,7 +1473,6 @@ public final class BluetoothAdapter { * will return false. After turning on Bluetooth, * will return false. After turning on Bluetooth, * wait for {@link #ACTION_STATE_CHANGED} with {@link #STATE_ON} * wait for {@link #ACTION_STATE_CHANGED} with {@link #STATE_ON} * to get the updated value. * to get the updated value. * <p>Requires {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} * <p>Applications cannot set the scan mode. They should use * <p>Applications cannot set the scan mode. They should use * <code>startActivityForResult( * <code>startActivityForResult( * BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE}) * BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE}) Loading @@ -1488,8 +1484,8 @@ public final class BluetoothAdapter { * @return true if the scan mode was set, false otherwise * @return true if the scan mode was set, false otherwise * @hide * @hide */ */ @UnsupportedAppUsage(publicAlternatives = "Use {@link #ACTION_REQUEST_DISCOVERABLE}, which " @SystemApi + "shows UI that confirms the user wants to go into discoverable mode.") @RequiresPermission(Manifest.permission.BLUETOOTH) public boolean setScanMode(@ScanMode int mode, int duration) { public boolean setScanMode(@ScanMode int mode, int duration) { if (getState() != STATE_ON) { if (getState() != STATE_ON) { return false; return false; Loading @@ -1507,9 +1503,34 @@ public final class BluetoothAdapter { return false; return false; } } /** @hide */ /** @UnsupportedAppUsage * Set the Bluetooth scan mode of the local Bluetooth adapter. public boolean setScanMode(int mode) { * <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>Applications cannot set the scan mode. They should use * <code>startActivityForResult( * BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE}) * </code>instead. * * @param mode valid scan mode * @return true if the scan mode was set, false otherwise * @hide */ @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH) public boolean setScanMode(@ScanMode int mode) { if (getState() != STATE_ON) { if (getState() != STATE_ON) { return false; return false; } } Loading Loading @@ -1562,6 +1583,8 @@ public final class BluetoothAdapter { * been called recently. * been called recently. * @hide * @hide */ */ @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH) public long getDiscoveryEndMillis() { public long getDiscoveryEndMillis() { try { try { mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); Loading Loading @@ -2060,7 +2083,7 @@ public final class BluetoothAdapter { * BluetoothProfile}. * BluetoothProfile}. * @hide * @hide */ */ public List<Integer> getSupportedProfiles() { public @NonNull List<Integer> getSupportedProfiles() { final ArrayList<Integer> supportedProfiles = new ArrayList<Integer>(); final ArrayList<Integer> supportedProfiles = new ArrayList<Integer>(); try { try { Loading