Use BluetoothAdapter instead of LocalBluetoothAdapter
LocalBluetoothAdapter only has a few APIs that is not supported by BluetoothAdapter, and lots of LocalBluetoothAdapter function pass parameter to BluetoothAdapter directly. Do the refactor in Settings, use BluetoothAdapter instead of LocalBluetoothAdapter. Bug: 111769754 Test: make -j42 RunSettingsRoboTests Change-Id: I88e5a8377b5d1106c7679e6a8c3fd1ca1a80ea6f
This commit is contained in:
@@ -28,8 +28,6 @@ import android.util.Log;
|
||||
import com.android.internal.app.AlertActivity;
|
||||
import com.android.internal.app.AlertController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
|
||||
/**
|
||||
* RequestPermissionHelperActivity asks the user whether to toggle Bluetooth.
|
||||
@@ -49,7 +47,7 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
|
||||
public static final String EXTRA_APP_LABEL =
|
||||
"com.android.settings.bluetooth.extra.APP_LABEL";
|
||||
|
||||
private LocalBluetoothAdapter mLocalAdapter;
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
private CharSequence mAppLabel;
|
||||
|
||||
@@ -63,7 +61,7 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
|
||||
|
||||
setResult(RESULT_CANCELED);
|
||||
|
||||
// Note: initializes mLocalAdapter and returns true on error
|
||||
// Note: initializes mBluetoothAdapter and returns true on error
|
||||
if (!parseIntent()) {
|
||||
finish();
|
||||
return;
|
||||
@@ -131,20 +129,20 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
|
||||
startActivity(intent);
|
||||
}
|
||||
} else {
|
||||
mLocalAdapter.enable();
|
||||
mBluetoothAdapter.enable();
|
||||
setResult(Activity.RESULT_OK);
|
||||
}
|
||||
} break;
|
||||
|
||||
case RequestPermissionActivity.REQUEST_DISABLE: {
|
||||
mLocalAdapter.disable();
|
||||
mBluetoothAdapter.disable();
|
||||
setResult(Activity.RESULT_OK);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the received Intent and initialize mLocalBluetoothAdapter.
|
||||
* Parse the received Intent and initialize mBluetoothAdapter.
|
||||
* @return true if an error occurred; false otherwise
|
||||
*/
|
||||
private boolean parseIntent() {
|
||||
@@ -167,16 +165,14 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
|
||||
return false;
|
||||
}
|
||||
|
||||
LocalBluetoothManager manager = Utils.getLocalBtManager(this);
|
||||
if (manager == null) {
|
||||
mAppLabel = getIntent().getCharSequenceExtra(EXTRA_APP_LABEL);
|
||||
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (mBluetoothAdapter == null) {
|
||||
Log.e(TAG, "Error: there's a problem starting Bluetooth");
|
||||
return false;
|
||||
}
|
||||
|
||||
mAppLabel = getIntent().getCharSequenceExtra(EXTRA_APP_LABEL);
|
||||
|
||||
mLocalAdapter = manager.getBluetoothAdapter();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user