Exclude webcam and MIDI USB preferences from requiring auth challenge
Webcam / MIDI don't transfer any persistent data to the host device, so it is okay to not guard it by an auth challenge. Auth challenge for webcam use increases friction and reduces usability. Bug: 349370229 Flag: com.android.settings.flags.exclude_webcam_auth_challenge Test: Check when the flag is enabled, webcam / MIDI doesn't require auth Test: Settings robolectric tests Change-Id: Id4c97a635a4c0a9ed14f88fbdda2743e2371dd10 Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
This commit is contained in:
@@ -35,6 +35,8 @@ import android.content.Context;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
@@ -48,6 +50,7 @@ import com.android.settingslib.widget.SelectorWithWidgetPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -82,6 +85,8 @@ public class UsbDetailsFunctionsControllerTest {
|
||||
private FragmentActivity mActivity;
|
||||
@Mock
|
||||
private TetheringManager mTetheringManager;
|
||||
@Rule
|
||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -349,6 +354,30 @@ public class UsbDetailsFunctionsControllerTest {
|
||||
assertThat(mFragment.isUserAuthenticated()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_EXCLUDE_WEBCAM_AUTH_CHALLENGE)
|
||||
public void onRadioButtonClicked_webcamNoAuthNeeded() {
|
||||
mRadioButtonPreference.setKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_UVC));
|
||||
doReturn(UsbManager.FUNCTION_MTP).when(mUsbBackend).getCurrentFunctions();
|
||||
setAuthPassesAutomatically();
|
||||
|
||||
mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
|
||||
|
||||
assertThat(mFragment.isUserAuthenticated()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_EXCLUDE_WEBCAM_AUTH_CHALLENGE)
|
||||
public void onRadioButtonClicked_MidiNoAuthNeeded() {
|
||||
mRadioButtonPreference.setKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MIDI));
|
||||
doReturn(UsbManager.FUNCTION_MTP).when(mUsbBackend).getCurrentFunctions();
|
||||
setAuthPassesAutomatically();
|
||||
|
||||
mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
|
||||
|
||||
assertThat(mFragment.isUserAuthenticated()).isFalse();
|
||||
}
|
||||
|
||||
private void setAuthPassesAutomatically() {
|
||||
Shadows.shadowOf(mContext.getSystemService(KeyguardManager.class))
|
||||
.setIsKeyguardSecure(false);
|
||||
|
||||
Reference in New Issue
Block a user