Merge "Add global HTTP proxy to Privacy Settings page"
This commit is contained in:
committed by
Android (Google) Code Review
commit
385155f305
@@ -58,4 +58,9 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
* Returns whether the Profile Owner in the managed profile (if any) set an always-on VPN.
|
||||
*/
|
||||
boolean isAlwaysOnVpnSetInManagedProfile();
|
||||
|
||||
/**
|
||||
* Returns whether the Device Owner set a recommended global HTTP proxy.
|
||||
*/
|
||||
boolean isGlobalHttpProxySet();
|
||||
}
|
||||
|
@@ -96,4 +96,9 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
return managedProfileUserId != -1 &&
|
||||
VpnUtils.isAlwaysOnVpnSet(mCm, managedProfileUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalHttpProxySet() {
|
||||
return mCm.getGlobalProxy() != null;
|
||||
}
|
||||
}
|
||||
|
@@ -63,6 +63,7 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
||||
controllers.add(new SecurityLogsPreferenceController(context));
|
||||
controllers.add(new AlwaysOnVpnPrimaryUserPreferenceController(context));
|
||||
controllers.add(new AlwaysOnVpnManagedProfilePreferenceController(context));
|
||||
controllers.add(new GlobalHttpProxyPreferenceController(context));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class GlobalHttpProxyPreferenceController extends PreferenceController {
|
||||
|
||||
private static final String KEY_GLOBAL_HTTP_PROXY = "global_http_proxy";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public GlobalHttpProxyPreferenceController(Context context) {
|
||||
super(context);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
preference.setVisible(mFeatureProvider.isGlobalHttpProxySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_GLOBAL_HTTP_PROXY;
|
||||
}
|
||||
}
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.vpn2;
|
||||
|
||||
import android.net.ProxyInfo;
|
||||
|
||||
/**
|
||||
* This interface replicates a subset of the android.net.ConnectivityManager (CM). The interface
|
||||
* exists so that we can use a thin wrapper around the CM in production code and a mock in tests.
|
||||
@@ -30,4 +32,11 @@ public interface ConnectivityManagerWrapper {
|
||||
* @see android.net.ConnectivityManager#getAlwaysOnVpnPackageForUser
|
||||
*/
|
||||
String getAlwaysOnVpnPackageForUser(int userId);
|
||||
|
||||
/**
|
||||
* Calls {@code ConnectivityManager.getGlobalProxy()}.
|
||||
*
|
||||
* @see android.net.ConnectivityManager#getGlobalProxy
|
||||
*/
|
||||
ProxyInfo getGlobalProxy();
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.vpn2;
|
||||
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.ProxyInfo;
|
||||
|
||||
public class ConnectivityManagerWrapperImpl implements ConnectivityManagerWrapper {
|
||||
|
||||
@@ -30,4 +31,9 @@ public class ConnectivityManagerWrapperImpl implements ConnectivityManagerWrappe
|
||||
public String getAlwaysOnVpnPackageForUser(int userId) {
|
||||
return mCm.getAlwaysOnVpnPackageForUser(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxyInfo getGlobalProxy() {
|
||||
return mCm.getGlobalProxy();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user