Merge "[VolumePanel] Redirect volume panel action to SystemUI" into tm-qpr-dev am: 95912773f9
am: 6983f5867c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/19459988 Change-Id: Ic5ec27462b8472b1f1ac7fd268be64764ed139c2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
c0461e645c
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
||||
|
||||
@@ -49,9 +50,19 @@ public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
||||
case Settings.Panel.ACTION_WIFI:
|
||||
return WifiPanel.create(context);
|
||||
case Settings.Panel.ACTION_VOLUME:
|
||||
return VolumePanel.create(context);
|
||||
if (FeatureFlagUtils.isEnabled(context,
|
||||
FeatureFlagUtils.SETTINGS_VOLUME_PANEL_IN_SYSTEMUI)) {
|
||||
// Redirect to the volume panel in SystemUI.
|
||||
Intent volumeIntent = new Intent(Settings.Panel.ACTION_VOLUME);
|
||||
volumeIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND).setPackage(
|
||||
SYSTEMUI_PACKAGE_NAME);
|
||||
context.sendBroadcast(volumeIntent);
|
||||
return null;
|
||||
} else {
|
||||
return VolumePanel.create(context);
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("No matching panel for: " + panelType);
|
||||
throw new IllegalStateException("No matching panel for: " + panelType);
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@@ -35,6 +36,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class PanelFeatureProviderImplTest {
|
||||
@@ -66,11 +68,27 @@ public class PanelFeatureProviderImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPanel_volume_returnsCorrectPanel() {
|
||||
public void getPanel_volumePanel_returnsCorrectPanel() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_VOLUME_PANEL_IN_SYSTEMUI,
|
||||
false);
|
||||
mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, Settings.Panel.ACTION_VOLUME);
|
||||
|
||||
final PanelContent panel = mProvider.getPanel(mContext, mBundle);
|
||||
|
||||
assertThat(panel).isInstanceOf(VolumePanel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPanel_volumePanelFlagEnabled_sendRedirectIntent() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_VOLUME_PANEL_IN_SYSTEMUI,
|
||||
true);
|
||||
mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, Settings.Panel.ACTION_VOLUME);
|
||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
|
||||
mProvider.getPanel(mContext, mBundle);
|
||||
|
||||
verify(mContext).sendBroadcast(intentCaptor.capture());
|
||||
assertThat(intentCaptor.getValue().getAction()).isEqualTo(Settings.Panel.ACTION_VOLUME);
|
||||
assertThat(intentCaptor.getValue().getPackage()).isEqualTo(SYSTEMUI_PACKAGE_NAME);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user