Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e2428f8 authored by Roman Birg's avatar Roman Birg
Browse files

Settings: give better hint when checking BT "Internet access" fails



When attempting to use a Bluetooth device as an internet source, the
host device might have the setting disabled. If the connection fails
(within a 5 second timeout), display a helpful message letting the user
know what might be wrong instead of silently failing.

Change-Id: If1a8583b04c2b682dd5a4bf5fa7e1b538d0c1488
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 37aaf5a8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1231,4 +1231,6 @@
    <string name="lock_to_cyanogen_create_account_msg">Your device uses the Cyanogen OS account password to protect your device even in the event of a factory reset. You will need to create a Cyanogen OS account.</string>
    <string name="lock_to_cyanogen_disable_msg">Disabling this feature will allow unauthorized users to reset your phone to factory defaults if it is stolen. Your personal data may not be protected. Do you want to disable this feature?</string>
    <string name="lock_to_cyanogen_master_clear_warning">Device Protection is enabled. Please disable to continue resetting your device.</string>

    <string name="bluetooth_pan_profile_summary_use_for_error">Connection error; is Bluetooth tethering enabled on this device?</string>
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -35,9 +35,11 @@ import java.util.List;
final class PanProfile implements LocalBluetoothProfile {
    private static final String TAG = "PanProfile";
    private static boolean V = true;
    private static final int CONNECTION_ERROR_TIME_THRESH = 5000; // 5 seconds is plenty of time

    private BluetoothPan mService;
    private boolean mIsProfileReady;
    private long mLastConnectTime = -1;

    // Tethering direction for each device
    private final HashMap<BluetoothDevice, Integer> mDeviceRoleMap =
@@ -83,6 +85,7 @@ final class PanProfile implements LocalBluetoothProfile {
    }

    public boolean connect(BluetoothDevice device) {
        mLastConnectTime = System.currentTimeMillis();
        if (mService == null) return false;
        List<BluetoothDevice> sinks = mService.getConnectedDevices();
        if (sinks != null) {
@@ -137,9 +140,14 @@ final class PanProfile implements LocalBluetoothProfile {
        int state = getConnectionStatus(device);
        switch (state) {
            case BluetoothProfile.STATE_DISCONNECTED:
                if (mLastConnectTime > 0 && (System.currentTimeMillis() - mLastConnectTime)
                        < CONNECTION_ERROR_TIME_THRESH) {
                    return R.string.bluetooth_pan_profile_summary_use_for_error;
                }
                return R.string.bluetooth_pan_profile_summary_use_for;

            case BluetoothProfile.STATE_CONNECTED:
                mLastConnectTime = -1;
                if (isLocalRoleNap(device)) {
                    return R.string.bluetooth_pan_nap_profile_summary_connected;
                } else {