1 package com.android.settingslib.bluetooth; 2 3 import android.bluetooth.BluetoothProfile; 4 import android.content.Context; 5 6 import com.android.settingslib.R; 7 8 public class Utils { 9 public static final boolean V = false; // verbose logging 10 public static final boolean D = true; // regular logging 11 12 private static ErrorListener sErrorListener; 13 getConnectionStateSummary(int connectionState)14 public static int getConnectionStateSummary(int connectionState) { 15 switch (connectionState) { 16 case BluetoothProfile.STATE_CONNECTED: 17 return R.string.bluetooth_connected; 18 case BluetoothProfile.STATE_CONNECTING: 19 return R.string.bluetooth_connecting; 20 case BluetoothProfile.STATE_DISCONNECTED: 21 return R.string.bluetooth_disconnected; 22 case BluetoothProfile.STATE_DISCONNECTING: 23 return R.string.bluetooth_disconnecting; 24 default: 25 return 0; 26 } 27 } 28 showError(Context context, String name, int messageResId)29 static void showError(Context context, String name, int messageResId) { 30 if (sErrorListener != null) { 31 sErrorListener.onShowError(context, name, messageResId); 32 } 33 } 34 setErrorListener(ErrorListener listener)35 public static void setErrorListener(ErrorListener listener) { 36 sErrorListener = listener; 37 } 38 39 public interface ErrorListener { onShowError(Context context, String name, int messageResId)40 void onShowError(Context context, String name, int messageResId); 41 } 42 43 } 44