• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.car.settings.sound;
18 
19 import android.os.Bundle;
20 
21 import androidx.fragment.app.FragmentActivity;
22 
23 import com.android.car.settings.common.Logger;
24 
25 /**
26  * An activity hosting {@link AudioRouteSelectionDialogFragment}.
27  */
28 public class AudioRouteSelectionActivity extends FragmentActivity {
29     private static final Logger LOG = new Logger(AudioRouteSelectionActivity.class);
30     public static final String FRAGMENT_TAG = "sound.audio.selection.fragment";
31     public static final String INTENT_ACTION = "com.android.car.settings.AUDIO_ROUTE_SETTINGS";
32 
33     @Override
onCreate(Bundle savedInstanceState)34     protected void onCreate(Bundle savedInstanceState) {
35         super.onCreate(savedInstanceState);
36 
37         // check if the fragment has been preloaded
38         AudioRouteSelectionDialogFragment dialogFragment =
39                 (AudioRouteSelectionDialogFragment) getSupportFragmentManager().findFragmentByTag(
40                         FRAGMENT_TAG);
41         // dismiss the fragment if it is already used
42         if (dialogFragment != null) {
43             dialogFragment.dismiss();
44             dialogFragment = null;
45         }
46 
47         dialogFragment = new AudioRouteSelectionDialogFragment(getApplicationContext());
48         dialogFragment.show(getSupportFragmentManager(), FRAGMENT_TAG);
49     }
50 }
51