Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc018e46 authored by Bartosz Fabianowski's avatar Bartosz Fabianowski
Browse files

Add Always on VPN to Privacy Settings page

This CL adds information about always-on VPNs to the Enterprise
Privacy Settings page.

Test: make RunSettingsRoboTests
Bug: 32692748

Change-Id: I2b59e2ec4c55308b323aaa478cd9c847fe0b4b55
parent 78427d74
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -8003,6 +8003,12 @@
    <string name="enterprise_privacy_security_logs">Your most recent security log</string>
    <!-- Label indicating that the date at which the admin last took a particular action was "never" (i.e. the admin never took the action so far). -->
    <string name="enterprise_privacy_never">Never</string>
    <!-- Label explaining that an always-on VPN was set by the admin for the entire device. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_always_on_vpn_device">Always-on VPN turned on</string>
    <!-- Label explaining that an always-on VPN was set by the admin in the personal profile. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_always_on_vpn_personal">Always-on VPN turned on in your personal profile</string>
    <!-- Label explaining that an always-on VPN was set by the admin in the work profile. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_always_on_vpn_work">Always-on VPN turned on in your work profile</string>
    <!-- Preference label for the Photos & Videos storage section. [CHAR LIMIT=50] -->
    <string name="storage_photos_videos">Photos &amp; Videos</string>
+9 −0
Original line number Diff line number Diff line
@@ -59,6 +59,15 @@
    </PreferenceCategory>

    <PreferenceCategory android:title="@string/enterprise_privacy_exposure_changes_category">
        <com.android.settings.DividerPreference
                android:key="always_on_vpn_primary_user"
                settings:allowDividerBelow="true"
                settings:multiLine="true"/>
        <com.android.settings.DividerPreference
                android:key="always_on_vpn_managed_profile"
                android:title="@string/enterprise_privacy_always_on_vpn_work"
                settings:allowDividerBelow="true"
                settings:multiLine="true"/>
    </PreferenceCategory>

    <PreferenceCategory android:title="@string/enterprise_privacy_device_access_category">
+47 −0
Original line number Diff line number Diff line
/*
 * 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 AlwaysOnVpnManagedProfilePreferenceController extends PreferenceController {

    private static final String KEY_ALWAYS_ON_VPN_MANAGED_PROFILE = "always_on_vpn_managed_profile";
    private final EnterprisePrivacyFeatureProvider mFeatureProvider;

    public AlwaysOnVpnManagedProfilePreferenceController(Context context) {
        super(context);
        mFeatureProvider = FeatureFactory.getFactory(context)
                .getEnterprisePrivacyFeatureProvider(context);
    }

    @Override
    public void updateState(Preference preference) {
        preference.setVisible(mFeatureProvider.isAlwaysOnVpnSetInManagedProfile());
    }

    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    public String getPreferenceKey() {
        return KEY_ALWAYS_ON_VPN_MANAGED_PROFILE;
    }
}
+51 −0
Original line number Diff line number Diff line
/*
 * 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.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.overlay.FeatureFactory;

public class AlwaysOnVpnPrimaryUserPreferenceController extends PreferenceController {

    private static final String KEY_ALWAYS_ON_VPN_PRIMARY_USER = "always_on_vpn_primary_user";
    private final EnterprisePrivacyFeatureProvider mFeatureProvider;

    public AlwaysOnVpnPrimaryUserPreferenceController(Context context) {
        super(context);
        mFeatureProvider = FeatureFactory.getFactory(context)
                .getEnterprisePrivacyFeatureProvider(context);
    }

    @Override
    public void updateState(Preference preference) {
        preference.setTitle(mFeatureProvider.isInCompMode()
                ? R.string.enterprise_privacy_always_on_vpn_personal
                : R.string.enterprise_privacy_always_on_vpn_device);
        preference.setVisible(mFeatureProvider.isAlwaysOnVpnSetInPrimaryUser());
    }

    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    public String getPreferenceKey() {
        return KEY_ALWAYS_ON_VPN_PRIMARY_USER;
    }
}
+16 −0
Original line number Diff line number Diff line
@@ -25,6 +25,12 @@ public interface EnterprisePrivacyFeatureProvider {
     */
    boolean hasDeviceOwner();

    /**
     * Returns whether the device is in COMP mode (primary user managed by a Device Owner app and
     * work profile managed by a Profile Owner app).
     */
    boolean isInCompMode();

    /**
     * Returns the time at which the Device Owner last retrieved security logs, or {@code null} if
     * logs were never retrieved by the Device Owner on this device.
@@ -42,4 +48,14 @@ public interface EnterprisePrivacyFeatureProvider {
     * logs were never retrieved by the Device Owner on this device.
     */
    Date getLastNetworkLogRetrievalTime();

    /**
     * Returns whether the Device Owner in the primary user set an always-on VPN.
     */
    boolean isAlwaysOnVpnSetInPrimaryUser();

    /**
     * Returns whether the Profile Owner in the managed profile (if any) set an always-on VPN.
     */
    boolean isAlwaysOnVpnSetInManagedProfile();
}
Loading