• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.panel;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.provider.Settings;
23 import android.util.FeatureFlagUtils;
24 
25 public class PanelFeatureProviderImpl implements PanelFeatureProvider {
26 
27     private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
28 
29     @Override
getPanel(Context context, Bundle bundle)30     public PanelContent getPanel(Context context, Bundle bundle) {
31         if (context == null) {
32             return null;
33         }
34 
35         final String panelType =
36                 bundle.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
37         final String mediaPackageName =
38                 bundle.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
39 
40         switch (panelType) {
41             case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
42                 // Redirect to the internet dialog in SystemUI.
43                 Intent intent = new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
44                 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
45                         .setPackage(SYSTEMUI_PACKAGE_NAME);
46                 context.sendBroadcast(intent);
47                 return null;
48             case Settings.Panel.ACTION_NFC:
49                 return NfcPanel.create(context);
50             case Settings.Panel.ACTION_WIFI:
51                 return WifiPanel.create(context);
52             case Settings.Panel.ACTION_VOLUME:
53                 if (FeatureFlagUtils.isEnabled(context,
54                         FeatureFlagUtils.SETTINGS_VOLUME_PANEL_IN_SYSTEMUI)) {
55                     // Redirect to the volume panel in SystemUI.
56                     Intent volumeIntent = new Intent(Settings.Panel.ACTION_VOLUME);
57                     volumeIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND).setPackage(
58                             SYSTEMUI_PACKAGE_NAME);
59                     context.sendBroadcast(volumeIntent);
60                     return null;
61                 } else {
62                     return VolumePanel.create(context);
63                 }
64         }
65 
66         throw new IllegalStateException("No matching panel for: " + panelType);
67     }
68 }
69