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();
|
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
|
* 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.
|
* 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);
|
VpnUtils.isAlwaysOnVpnSet(mVm, managedProfileUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGlobalHttpProxySet() {
|
|
||||||
return mCm.getGlobalProxy() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaximumFailedPasswordsBeforeWipeInCurrentUser() {
|
public int getMaximumFailedPasswordsBeforeWipeInCurrentUser() {
|
||||||
ComponentName owner = mDpm.getDeviceOwnerComponentOnCallingUser();
|
ComponentName owner = mDpm.getDeviceOwnerComponentOnCallingUser();
|
||||||
|
@@ -14,26 +14,25 @@
|
|||||||
package com.android.settings.enterprise;
|
package com.android.settings.enterprise;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
public class GlobalHttpProxyPreferenceController extends AbstractPreferenceController implements
|
public class GlobalHttpProxyPreferenceController extends AbstractPreferenceController implements
|
||||||
PreferenceControllerMixin {
|
PreferenceControllerMixin {
|
||||||
|
|
||||||
private static final String KEY_GLOBAL_HTTP_PROXY = "global_http_proxy";
|
private static final String KEY_GLOBAL_HTTP_PROXY = "global_http_proxy";
|
||||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
private final ConnectivityManager mCm;
|
||||||
|
|
||||||
public GlobalHttpProxyPreferenceController(Context context) {
|
public GlobalHttpProxyPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
mCm = context.getSystemService(ConnectivityManager.class);
|
||||||
.getEnterprisePrivacyFeatureProvider(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return mFeatureProvider.isGlobalHttpProxySet();
|
return mCm.getGlobalProxy() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -39,7 +39,6 @@ import android.content.pm.ResolveInfo;
|
|||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.ProxyInfo;
|
|
||||||
import android.net.VpnManager;
|
import android.net.VpnManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -232,16 +231,6 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
|||||||
assertThat(mProvider.isAlwaysOnVpnSetInManagedProfile()).isTrue();
|
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
|
@Test
|
||||||
public void testGetMaximumFailedPasswordsForWipeInCurrentUser() {
|
public void testGetMaximumFailedPasswordsForWipeInCurrentUser() {
|
||||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(null);
|
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(null);
|
||||||
|
@@ -21,11 +21,11 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.ProxyInfo;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
|
||||||
|
|
||||||
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;
|
||||||
@@ -41,25 +41,23 @@ public class GlobalHttpProxyPreferenceControllerTest {
|
|||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private FakeFeatureFactory mFeatureFactory;
|
@Mock
|
||||||
|
private ConnectivityManager mCm;
|
||||||
|
|
||||||
private GlobalHttpProxyPreferenceController mController;
|
private GlobalHttpProxyPreferenceController mController;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
|
||||||
mController = new GlobalHttpProxyPreferenceController(mContext);
|
mController = new GlobalHttpProxyPreferenceController(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable() {
|
public void testIsAvailable() {
|
||||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
|
when(mCm.getGlobalProxy()).thenReturn(null);
|
||||||
.thenReturn(false);
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
|
|
||||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
|
when(mCm.getGlobalProxy()).thenReturn(ProxyInfo.buildDirectProxy("localhost", 123));
|
||||||
.thenReturn(true);
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user