Merge "[VolumePanel] Redirect volume panel action to SystemUI" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
95912773f9
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.util.FeatureFlagUtils;
|
||||||
|
|
||||||
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
||||||
|
|
||||||
@@ -49,8 +50,18 @@ public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
|||||||
case Settings.Panel.ACTION_WIFI:
|
case Settings.Panel.ACTION_WIFI:
|
||||||
return WifiPanel.create(context);
|
return WifiPanel.create(context);
|
||||||
case Settings.Panel.ACTION_VOLUME:
|
case Settings.Panel.ACTION_VOLUME:
|
||||||
|
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);
|
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.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.util.FeatureFlagUtils;
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
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.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class PanelFeatureProviderImplTest {
|
public class PanelFeatureProviderImplTest {
|
||||||
@@ -66,11 +68,27 @@ public class PanelFeatureProviderImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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);
|
mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, Settings.Panel.ACTION_VOLUME);
|
||||||
|
|
||||||
final PanelContent panel = mProvider.getPanel(mContext, mBundle);
|
final PanelContent panel = mProvider.getPanel(mContext, mBundle);
|
||||||
|
|
||||||
assertThat(panel).isInstanceOf(VolumePanel.class);
|
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