Add entry point to launch media output slice

Add media output panel type to launch media output slice.

Bug: 121083246
Test: make -j RunSettingsRoboTests
Change-Id: Ibf706146430e309fef6cbf0e1e86c2d5b78b50d5
This commit is contained in:
hughchen
2018-12-19 19:17:32 +08:00
parent e56df8877a
commit 2177813531
13 changed files with 288 additions and 16 deletions

View File

@@ -16,8 +16,12 @@
package com.android.settings.panel;
import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
import static com.android.settingslib.media.MediaOutputSliceConstants.EXTRA_PACKAGE_NAME;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.Window;
@@ -28,6 +32,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
/**
@@ -37,10 +42,14 @@ public class SettingsPanelActivity extends FragmentActivity {
private final String TAG = "panel_activity";
@VisibleForTesting
final Bundle mBundle = new Bundle();
/**
* Key specifying which Panel the app is requesting.
*/
public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
public static final String KEY_PANEL_PACKAGE_NAME = "PANEL_PACKAGE_NAME";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -53,6 +62,16 @@ public class SettingsPanelActivity extends FragmentActivity {
return;
}
final String packageName =
callingIntent.getStringExtra(EXTRA_PACKAGE_NAME);
if (TextUtils.equals(ACTION_MEDIA_OUTPUT, callingIntent.getAction())
&& TextUtils.isEmpty(packageName)) {
Log.e(TAG, "Null package name, closing Panel Activity");
finish();
return;
}
setContentView(R.layout.settings_panel);
// Move the window to the bottom of screen, and make it take up the entire screen width.
@@ -61,11 +80,11 @@ public class SettingsPanelActivity extends FragmentActivity {
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
final Bundle bundle = new Bundle();
bundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
mBundle.putString(KEY_PANEL_PACKAGE_NAME, packageName);
final PanelFragment panelFragment = new PanelFragment();
panelFragment.setArguments(bundle);
panelFragment.setArguments(mBundle);
final FragmentManager fragmentManager = getSupportFragmentManager();
final Fragment fragment = fragmentManager.findFragmentById(R.id.main_content);