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
This commit is contained in:
@@ -17,20 +17,32 @@
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.settings.applications.PackageManagerWrapper;
|
||||
import com.android.settings.vpn2.ConnectivityManagerWrapper;
|
||||
import com.android.settings.vpn2.VpnUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFeatureProvider {
|
||||
|
||||
private final DevicePolicyManagerWrapper mDpm;
|
||||
private final PackageManagerWrapper mPm;
|
||||
private final UserManager mUm;
|
||||
private final ConnectivityManagerWrapper mCm;
|
||||
|
||||
private static final int MY_USER_ID = UserHandle.myUserId();
|
||||
|
||||
public EnterprisePrivacyFeatureProviderImpl(DevicePolicyManagerWrapper dpm,
|
||||
PackageManagerWrapper pm) {
|
||||
PackageManagerWrapper pm, UserManager um, ConnectivityManagerWrapper cm) {
|
||||
mDpm = dpm;
|
||||
mPm = pm;
|
||||
mUm = um;
|
||||
mCm = cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,19 +53,47 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
return mDpm.getDeviceOwnerComponentOnAnyUser() != null;
|
||||
}
|
||||
|
||||
private int getManagedProfileUserId() {
|
||||
for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) {
|
||||
if (userInfo.isManagedProfile()) {
|
||||
return userInfo.id;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInCompMode() {
|
||||
return hasDeviceOwner() && getManagedProfileUserId() != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getLastSecurityLogRetrievalTime() {
|
||||
final long timestamp = mDpm.getLastSecurityLogRetrievalTime();
|
||||
return timestamp < 0 ? null : new Date(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getLastBugReportRequestTime() {
|
||||
final long timestamp = mDpm.getLastBugReportRequestTime();
|
||||
return timestamp < 0 ? null : new Date(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getLastNetworkLogRetrievalTime() {
|
||||
final long timestamp = mDpm.getLastNetworkLogRetrievalTime();
|
||||
return timestamp < 0 ? null : new Date(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysOnVpnSetInPrimaryUser() {
|
||||
return VpnUtils.isAlwaysOnVpnSet(mCm, MY_USER_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysOnVpnSetInManagedProfile() {
|
||||
final int managedProfileUserId = getManagedProfileUserId();
|
||||
return managedProfileUserId != -1 &&
|
||||
VpnUtils.isAlwaysOnVpnSet(mCm, managedProfileUserId);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user