BLE peripheral mode (4/4): Settings change for advertising preference.
Change-Id: I5721f136267fe25e55f764bb4a6c53acd45b318b
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.app.QueuedWork;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -46,6 +48,10 @@ final class LocalBluetoothPreferences {
|
||||
|
||||
private static final String KEY_DISCOVERABLE_END_TIMESTAMP = "discoverable_end_timestamp";
|
||||
|
||||
private static final String KEY_ADVERTISEMENT_PREFERENCE = "bt_advertisement_perference";
|
||||
|
||||
private static final boolean DEFAULT_ADVERTISING_ENABLED = false;
|
||||
|
||||
private LocalBluetoothPreferences() {
|
||||
}
|
||||
|
||||
@@ -58,6 +64,17 @@ final class LocalBluetoothPreferences {
|
||||
KEY_DISCOVERABLE_END_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
static boolean isAdvertisingEnabled(Context context) {
|
||||
return getSharedPreferences(context).getBoolean(
|
||||
KEY_ADVERTISEMENT_PREFERENCE, DEFAULT_ADVERTISING_ENABLED);
|
||||
}
|
||||
|
||||
static void setAdvertisingEnabled(Context context, boolean advertisingEnabled) {
|
||||
Editor preferenceEditor = getSharedPreferences(context).edit();
|
||||
preferenceEditor.putBoolean(KEY_ADVERTISEMENT_PREFERENCE, advertisingEnabled);
|
||||
preferenceEditor.apply();
|
||||
}
|
||||
|
||||
static boolean shouldShowDialogInForeground(Context context,
|
||||
String deviceAddress) {
|
||||
LocalBluetoothManager manager = LocalBluetoothManager.getInstance(context);
|
||||
|
Reference in New Issue
Block a user