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 24 public class PanelFeatureProviderImpl implements PanelFeatureProvider { 25 26 private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui"; 27 28 @Override getPanel(Context context, Bundle bundle)29 public PanelContent getPanel(Context context, Bundle bundle) { 30 if (context == null) { 31 return null; 32 } 33 34 final String panelType = 35 bundle.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT); 36 final String mediaPackageName = 37 bundle.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME); 38 39 switch (panelType) { 40 case Settings.Panel.ACTION_INTERNET_CONNECTIVITY: 41 // Redirect to the internet dialog in SystemUI. 42 Intent intent = new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY); 43 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND) 44 .setPackage(SYSTEMUI_PACKAGE_NAME); 45 context.sendBroadcast(intent); 46 return null; 47 case Settings.Panel.ACTION_NFC: 48 return NfcPanel.create(context); 49 case Settings.Panel.ACTION_WIFI: 50 return WifiPanel.create(context); 51 case Settings.Panel.ACTION_VOLUME: 52 return VolumePanel.create(context); 53 } 54 55 throw new IllegalStateException("No matching panel for: " + panelType); 56 } 57 } 58