diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java index efcc7f92f65..1ff1fcef01d 100644 --- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java @@ -149,20 +149,13 @@ public class BluetoothPermissionActivity extends AlertActivity implements if(DEBUG) Log.i(TAG, "Back button pressed! ignoring"); return; } - private String createRemoteName() - { - String mRemoteName = mDevice != null ? mDevice.getAliasName() : null; - - if (mRemoteName == null) mRemoteName = getString(R.string.unknown); - return mRemoteName; - } // TODO(edjee): createConnectionDialogView, createPhonebookDialogView and createMapDialogView // are similar. Refactor them into one method. // Also, the string resources bluetooth_remember_choice and bluetooth_pb_remember_choice should // be removed. private View createConnectionDialogView() { - String mRemoteName = createRemoteName(); + String mRemoteName = Utils.createRemoteName(this, mDevice); mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); messageView.setText(getString(R.string.bluetooth_connection_dialog_text, @@ -171,7 +164,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements } private View createPhonebookDialogView() { - String mRemoteName = createRemoteName(); + String mRemoteName = Utils.createRemoteName(this, mDevice); mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); messageView.setText(getString(R.string.bluetooth_pb_acceptance_dialog_text, @@ -180,7 +173,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements } private View createMapDialogView() { - String mRemoteName = createRemoteName(); + String mRemoteName = Utils.createRemoteName(this, mDevice); mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); messageView.setText(getString(R.string.bluetooth_map_acceptance_dialog_text, @@ -189,7 +182,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements } private View createSapDialogView() { - String mRemoteName = createRemoteName(); + String mRemoteName = Utils.createRemoteName(this, mDevice); mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); messageView.setText(getString(R.string.bluetooth_sap_acceptance_dialog_text, diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java index fc6b876a7fa..e10a5cff03f 100644 --- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java @@ -135,7 +135,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT, BluetoothDevice.CONNECTION_ACCESS_NO); deleteIntent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, mRequestType); - String deviceAlias = mDevice != null ? mDevice.getAliasName() : null; + String deviceAlias = Utils.createRemoteName(context, mDevice); switch (mRequestType) { case BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS: title = context.getString(R.string.bluetooth_phonebook_request); diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java index 2cbe4733d74..b6928521e23 100755 --- a/src/com/android/settings/bluetooth/Utils.java +++ b/src/com/android/settings/bluetooth/Utils.java @@ -17,6 +17,7 @@ package com.android.settings.bluetooth; import android.app.AlertDialog; +import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.DialogInterface; @@ -126,6 +127,15 @@ public final class Utils { return LocalBluetoothManager.getInstance(context, mOnInitCallback); } + public static String createRemoteName(Context context, BluetoothDevice device) { + String mRemoteName = device != null ? device.getAliasName() : null; + + if (mRemoteName == null) { + mRemoteName = context.getString(R.string.unknown); + } + return mRemoteName; + } + private static final ErrorListener mErrorListener = new ErrorListener() { @Override public void onShowError(Context context, String name, int messageResId) {