Remove ConnectivityManager from EnterprisePrivacyFeatureProvider.
It is only used in GlobalHttpPreferenceController. Move it there. Bug: 173331190 Test: atest SettingsRoboTests Change-Id: I62c589679052b276927d057d3d5d084bbfb57626
This commit is contained in:
@@ -84,11 +84,6 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
*/
|
||||
boolean isAlwaysOnVpnSetInManagedProfile();
|
||||
|
||||
/**
|
||||
* Returns whether the Device Owner set a recommended global HTTP proxy.
|
||||
*/
|
||||
boolean isGlobalHttpProxySet();
|
||||
|
||||
/**
|
||||
* Returns the number of failed login attempts that the Device Owner or Profile Owner allows
|
||||
* before the current user is wiped, or zero if no such limit is set.
|
||||
|
@@ -146,11 +146,6 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
VpnUtils.isAlwaysOnVpnSet(mVm, managedProfileUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalHttpProxySet() {
|
||||
return mCm.getGlobalProxy() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumFailedPasswordsBeforeWipeInCurrentUser() {
|
||||
ComponentName owner = mDpm.getDeviceOwnerComponentOnCallingUser();
|
||||
|
@@ -14,26 +14,25 @@
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
public class GlobalHttpProxyPreferenceController extends AbstractPreferenceController implements
|
||||
PreferenceControllerMixin {
|
||||
|
||||
private static final String KEY_GLOBAL_HTTP_PROXY = "global_http_proxy";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
private final ConnectivityManager mCm;
|
||||
|
||||
public GlobalHttpProxyPreferenceController(Context context) {
|
||||
super(context);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
mCm = context.getSystemService(ConnectivityManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mFeatureProvider.isGlobalHttpProxySet();
|
||||
return mCm.getGlobalProxy() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -39,7 +39,6 @@ import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.ProxyInfo;
|
||||
import android.net.VpnManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -232,16 +231,6 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
assertThat(mProvider.isAlwaysOnVpnSetInManagedProfile()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsGlobalHttpProxySet() {
|
||||
when(mConnectivityManger.getGlobalProxy()).thenReturn(null);
|
||||
assertThat(mProvider.isGlobalHttpProxySet()).isFalse();
|
||||
|
||||
when(mConnectivityManger.getGlobalProxy())
|
||||
.thenReturn(ProxyInfo.buildDirectProxy("localhost", 123));
|
||||
assertThat(mProvider.isGlobalHttpProxySet()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMaximumFailedPasswordsForWipeInCurrentUser() {
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(null);
|
||||
|
@@ -21,11 +21,11 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.ProxyInfo;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -41,25 +41,23 @@ public class GlobalHttpProxyPreferenceControllerTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
@Mock
|
||||
private ConnectivityManager mCm;
|
||||
|
||||
private GlobalHttpProxyPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mController = new GlobalHttpProxyPreferenceController(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
|
||||
.thenReturn(false);
|
||||
when(mCm.getGlobalProxy()).thenReturn(null);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
|
||||
.thenReturn(true);
|
||||
when(mCm.getGlobalProxy()).thenReturn(ProxyInfo.buildDirectProxy("localhost", 123));
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user