Fix discoverability timeout issues. (a) implement timeout logic (b) persist 'never timeout' after reboot (c) code cleanup

Change-Id: Ia7a8611d7212b9201994034d17da1d18e106107b
This commit is contained in:
Srikanth Uppala
2012-04-04 03:32:22 -07:00
committed by Matthew Xie
parent 4e1876a40a
commit 59a97f7a73
3 changed files with 96 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.bluetooth;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.bluetooth.BluetoothAdapter;
import android.util.Log;
public class BluetoothDiscoverableTimeoutReceiver extends BroadcastReceiver {
private static final String TAG = "BluetoothDiscoverableTimeoutReceiver";
@Override
public void onReceive(Context context, Intent intent) {
LocalBluetoothAdapter localBluetoothAdapter = LocalBluetoothAdapter.getInstance();
if(null != localBluetoothAdapter && localBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
Log.d(TAG, "Disable discoverable...");
localBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
} else {
Log.e(TAG, "localBluetoothAdapter is NULL!!");
}
}
};