Home | History | Annotate | Download | only in bluetooth
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.settings.bluetooth;
     18 
     19 import android.bluetooth.BluetoothAdapter;
     20 import android.content.BroadcastReceiver;
     21 import android.content.Context;
     22 import android.content.Intent;
     23 import android.util.Log;
     24 
     25 import com.android.settingslib.bluetooth.BluetoothEventManager;
     26 
     27 /**
     28  * BluetoothDiscoveryReceiver updates a timestamp when the
     29  * Bluetooth adapter starts or finishes discovery mode. This
     30  * is used to decide whether to open an alert dialog or
     31  * create a notification when we receive a pairing request.
     32  *
     33  * <p>Note that the discovery start/finish intents are also handled
     34  * by {@link BluetoothEventManager} to update the UI, if visible.
     35  */
     36 public final class BluetoothDiscoveryReceiver extends BroadcastReceiver {
     37     private static final String TAG = "BluetoothDiscoveryReceiver";
     38 
     39     @Override
     40     public void onReceive(Context context, Intent intent) {
     41         String action = intent.getAction();
     42         Log.v(TAG, "Received: " + action);
     43 
     44         if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_STARTED) ||
     45                 action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
     46             LocalBluetoothPreferences.persistDiscoveringTimestamp(context);
     47         }
     48     }
     49 }
     50