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

Commit a0c49df0 authored by chchen's avatar chchen
Browse files

Regional: Customize bluetooth name

Customize bluetooth name

Change-Id: I97dfc3d5c11d18f48c5f21ea5941b2b2695337ac
CRs-Fixed: 1088188
parent c441427a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -48,5 +48,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    <!--  operator custom sim icon feature -->
    <bool name="operator_custom_sim_icon">false</bool>

    <!-- Setting customize default bluetooth name -->
    <string name="def_custom_bt_defname"></string>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -2746,4 +2746,6 @@
  <java-symbol type="bool" name="config_softap_extention" />
  <java-symbol type="array" name="config_operatorConsideredDomesticRoaming" />
  <java-symbol type="array" name="config_operatorConsideredDomesticRoamingExceptions" />
  <!-- config softap extention feature -->
  <java-symbol type="string" name="def_custom_bt_defname" />
</resources>
+22 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;

import com.android.settingslib.R;
@@ -122,6 +125,16 @@ public final class BluetoothEventManager {
        registerProfileIntentReceiver();
    }

    // set bluetooth default name
    private void setDefaultBtName() {
        String name = mContext.getResources().getString(
            com.android.internal.R.string.def_custom_bt_defname);
        Log.d(TAG, "custom bluetooth name: " + name);
        if (!TextUtils.isEmpty(name)) {
            mLocalAdapter.setName(name);
        }
    }

    /** Register to start receiving callbacks for Bluetooth events. */
    public void registerCallback(BluetoothCallback callback) {
        synchronized (mCallbacks) {
@@ -177,6 +190,15 @@ public final class BluetoothEventManager {
            }
            // update local profiles and get paired devices
            mLocalAdapter.setBluetoothStateInt(state);
            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
            boolean isFirstBoot = preferences.getBoolean("is_first_boot", true);
            Log.d(TAG,"isFirstBoot: " +isFirstBoot + " state: " + state);
            if (isFirstBoot && state == BluetoothAdapter.STATE_ON) {
                setDefaultBtName();
                SharedPreferences.Editor edit = preferences.edit();
                edit.putBoolean("is_first_boot", false);
                edit.apply();
            }
            // send callback to update UI and possibly start scanning
            synchronized (mCallbacks) {
                for (BluetoothCallback callback : mCallbacks) {