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 import androidx.annotation.Nullable; 26 27 import com.android.settings.Utils; 28 import com.android.settings.flags.Flags; 29 30 @Deprecated(forRemoval = true) 31 public class PanelFeatureProviderImpl implements PanelFeatureProvider { 32 33 @Override 34 @Nullable getPanel(Context context, Bundle bundle)35 public PanelContent getPanel(Context context, Bundle bundle) { 36 if (context == null) { 37 return null; 38 } 39 40 final String panelType = 41 bundle.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT); 42 final String mediaPackageName = 43 bundle.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME); 44 45 switch (panelType) { 46 case Settings.Panel.ACTION_INTERNET_CONNECTIVITY: 47 // Redirect to the internet dialog in SystemUI. 48 Intent intent = new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY); 49 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND) 50 .setPackage(Utils.SYSTEMUI_PACKAGE_NAME); 51 context.sendBroadcast(intent); 52 return null; 53 case Settings.Panel.ACTION_NFC: 54 if (Flags.slicesRetirement()) { 55 Intent nfcIntent = new Intent(Settings.ACTION_NFC_SETTINGS); 56 nfcIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 57 context.startActivity(nfcIntent); 58 return null; 59 } else { 60 return NfcPanel.create(context); 61 } 62 case Settings.Panel.ACTION_WIFI: 63 if (Flags.slicesRetirement()) { 64 Intent wifiIntent = new Intent(Settings.ACTION_WIFI_SETTINGS); 65 wifiIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 66 context.startActivity(wifiIntent); 67 return null; 68 } else { 69 return WifiPanel.create(context); 70 } 71 case Settings.Panel.ACTION_VOLUME: 72 if (FeatureFlagUtils.isEnabled(context, 73 FeatureFlagUtils.SETTINGS_VOLUME_PANEL_IN_SYSTEMUI)) { 74 // Redirect to the volume panel in SystemUI. 75 Intent volumeIntent = new Intent(Settings.Panel.ACTION_VOLUME); 76 volumeIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND).setPackage( 77 Utils.SYSTEMUI_PACKAGE_NAME); 78 context.sendBroadcast(volumeIntent); 79 return null; 80 } else { 81 if (Flags.slicesRetirement()) { 82 Intent volIntent = new Intent(Settings.ACTION_SOUND_SETTINGS); 83 volIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 84 context.startActivity(volIntent); 85 return null; 86 } else { 87 return VolumePanel.create(context); 88 } 89 } 90 } 91 92 throw new IllegalStateException("No matching panel for: " + panelType); 93 } 94 } 95