BLE peripheral mode (4/4): Settings change for advertising preference.

Change-Id: I5721f136267fe25e55f764bb4a6c53acd45b318b
This commit is contained in:
Wei Wang
2013-11-19 01:32:10 -08:00
parent 6235eb5466
commit eb56b9ccb8
17 changed files with 582 additions and 54 deletions

View File

@@ -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);