2nd attempt to fix Slice strict mode.
1. Use real BluetoothAdapter instead of settingslib version. The settingslib version contains calls that violates strictmode rules. 2. Override StrictMode rules in SettingsSliceProvider when it's called in background thread. When in background, the enforcement from Slice framework (StrictMode#ThreadPolicy) is not useful and can be safely ignored. Change-Id: I68523148f4c1dc88a54e207447d21ec439478cdf Bug: 79985175 Test: robotests
This commit is contained in:
@@ -17,8 +17,6 @@ package com.android.settings.bluetooth;
|
||||
|
||||
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
|
||||
|
||||
import static androidx.slice.builders.ListBuilder.ICON_IMAGE;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.app.PendingIntent;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
@@ -83,7 +81,7 @@ public class BluetoothSliceBuilder {
|
||||
* Bluetooth.
|
||||
*/
|
||||
public static Slice getSlice(Context context) {
|
||||
final boolean isBluetoothEnabled = isBluetoothEnabled(context);
|
||||
final boolean isBluetoothEnabled = isBluetoothEnabled();
|
||||
final CharSequence title = context.getText(R.string.bluetooth_settings);
|
||||
final IconCompat icon = IconCompat.createWithResource(context,
|
||||
R.drawable.ic_settings_bluetooth);
|
||||
@@ -119,9 +117,8 @@ public class BluetoothSliceBuilder {
|
||||
// handle it.
|
||||
}
|
||||
|
||||
private static boolean isBluetoothEnabled(Context context) {
|
||||
final LocalBluetoothAdapter adapter = LocalBluetoothManager.getInstance(context,
|
||||
null /* callback */).getBluetoothAdapter();
|
||||
private static boolean isBluetoothEnabled() {
|
||||
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
return adapter.isEnabled();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user