Add global HTTP proxy to Privacy Settings page

This CL allows the user to see on the Enterprise Privacy Settings
page whether the admin set a global HTTP proxy.

Test: make RunSettingsRoboTests
Bug: 32692748

Change-Id: I3c7c46f806f39c90425fd8e098a749f3cc1e9278
This commit is contained in:
Bartosz Fabianowski
2017-01-11 13:22:52 +01:00
parent fc018e4672
commit 0d22680807
11 changed files with 182 additions and 1 deletions

View File

@@ -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();
}

View File

@@ -96,4 +96,9 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
return managedProfileUserId != -1 &&
VpnUtils.isAlwaysOnVpnSet(mCm, managedProfileUserId);
}
@Override
public boolean isGlobalHttpProxySet() {
return mCm.getGlobalProxy() != null;
}
}

View File

@@ -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;
}

View File

@@ -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;
}
}