1 /*
2  * Copyright 2020 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.media;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.BroadcastReceiver;
21 import android.content.Context;
22 import android.content.Intent;
23 import android.text.TextUtils;
24 
25 import com.android.settings.R;
26 import com.android.settings.bluetooth.BluetoothPairingDetail;
27 import com.android.settings.core.SubSettingLauncher;
28 import com.android.settingslib.media.MediaOutputConstants;
29 
30 /**
31  * BroadcastReceiver for handling media output intent
32  */
33 public class BluetoothPairingReceiver extends BroadcastReceiver {
34     @Override
onReceive(Context context, Intent intent)35     public void onReceive(Context context, Intent intent) {
36         if (TextUtils.equals(MediaOutputConstants.ACTION_LAUNCH_BLUETOOTH_PAIRING,
37                 intent.getAction())) {
38             context.startActivity(new SubSettingLauncher(context)
39                     .setDestination(BluetoothPairingDetail.class.getName())
40                     .setTitleRes(R.string.bluetooth_pairing_page_title)
41                     .setSourceMetricsCategory(SettingsEnums.BLUETOOTH_PAIRING_RECEIVER)
42                     .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
43                     .toIntent());
44         }
45     }
46 }
47