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

Commit b1687752 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Bluetooth: Added Shared Preferences to restore tethering setting"

parents 65f11482 833a03f1
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * Provides Bluetooth Pan Device profile, as a service in
@@ -76,6 +77,8 @@ public class PanService extends ProfileService {
    private static final int MESSAGE_DISCONNECT = 2;
    private static final int MESSAGE_CONNECT_STATE_CHANGED = 11;
    private boolean mTetherOn = false;
    private static final String PAN_PREFERENCE_FILE = "PANMGR";
    private static final String PAN_TETHER_SETTING = "TETHERSTATE";

    AsyncChannel mTetherAc;

@@ -320,13 +323,23 @@ public class PanService extends ProfileService {
    }
     boolean isTetheringOn() {
        // TODO(BT) have a variable marking the on/off state
        SharedPreferences tethsetting = getSharedPreferences(PAN_PREFERENCE_FILE, 0);
        mTetherOn = tethsetting.getBoolean(PAN_TETHER_SETTING, false);
        return mTetherOn;
    }

    void setBluetoothTethering(boolean value) {
        if(DBG) Log.d(TAG, "setBluetoothTethering: " + value +", mTetherOn: " + mTetherOn);
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");

        SharedPreferences tethsetting = getSharedPreferences(PAN_PREFERENCE_FILE, 0);
        if(mTetherOn != value) {

            SharedPreferences.Editor editor = tethsetting.edit();
            editor.putBoolean(PAN_TETHER_SETTING, value);

            // Commit the edit!
            editor.commit();
            //drop any existing panu or pan-nap connection when changing the tethering state
            mTetherOn = value;
            List<BluetoothDevice> DevList = getConnectedDevices();