Hide potentially invisible DO Disclosures by default
Hiding/unhiding a pref triggers an animation. DO Disclosures that may not be visible should be hidden by default so that they fade in if applicable, not fade out if not applicable. Also, the network and security logging disclosures should only be shown if logging is currently on or was on in the past and a network log was retrieved at least once. Bug: 32692748 Test: m RunSettingsRoboTests Change-Id: I8c85f2f66ba295f145e5f5e79febb1b1a9bc6ede
This commit is contained in:
@@ -8272,7 +8272,7 @@
|
||||
<!-- Label explaining that the admin can see app usage statistics. [CHAR LIMIT=NONE] -->
|
||||
<string name="enterprise_privacy_usage_stats">Time and data spent in each app on your device</string>
|
||||
<!-- Label explaining that the admin can retrieve network logs on the device. [CHAR LIMIT=NONE] -->
|
||||
<string name="enterprise_privacy_network_logs">Network traffic logs on your device</string>
|
||||
<string name="enterprise_privacy_network_logs">Most recent network traffic log</string>
|
||||
<!-- Label explaining that the admin can request bug reports on the device. [CHAR LIMIT=NONE] -->
|
||||
<string name="enterprise_privacy_bug_reports">Most recent bug report</string>
|
||||
<!-- Label explaining that the admin can retrieve security on from the device. [CHAR LIMIT=NONE] -->
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
<PreferenceCategory android:title="@string/enterprise_privacy_exposure_category">
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="enterprise_data"
|
||||
android:layout_height="wrap_content"
|
||||
android:title="@string/enterprise_privacy_enterprise_data"
|
||||
settings:multiLine="true"/>
|
||||
@@ -36,12 +35,12 @@
|
||||
android:title="@string/enterprise_privacy_installed_packages"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="usage_stats"
|
||||
android:title="@string/enterprise_privacy_usage_stats"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="network_logs"
|
||||
android:title="@string/enterprise_privacy_network_logs"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="bug_reports"
|
||||
@@ -50,6 +49,7 @@
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="security_logs"
|
||||
android:title="@string/enterprise_privacy_security_logs"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
@@ -57,58 +57,70 @@
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="number_enterprise_installed_packages"
|
||||
android:title="@string/enterprise_privacy_enterprise_installed_packages"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="enterprise_privacy_number_location_access_packages"
|
||||
android:title="@string/enterprise_privacy_location_access"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="enterprise_privacy_number_microphone_access_packages"
|
||||
android:title="@string/enterprise_privacy_microphone_access"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="enterprise_privacy_number_camera_access_packages"
|
||||
android:title="@string/enterprise_privacy_camera_access"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="number_enterprise_set_default_apps"
|
||||
android:title="@string/enterprise_privacy_enterprise_set_default_apps"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="always_on_vpn_primary_user"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="always_on_vpn_managed_profile"
|
||||
android:title="@string/enterprise_privacy_always_on_vpn_work"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="input_method"
|
||||
android:title="@string/enterprise_privacy_input_method"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="global_http_proxy"
|
||||
android:title="@string/enterprise_privacy_global_http_proxy"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="ca_certs"
|
||||
android:title="@string/enterprise_privacy_ca_certs"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/enterprise_privacy_device_access_category">
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="lock_device"
|
||||
android:title="@string/enterprise_privacy_lock_device"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="wipe_device"
|
||||
android:title="@string/enterprise_privacy_wipe_device"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="failed_password_wipe_primary_user"
|
||||
android:title="@string/enterprise_privacy_failed_password_wipe_device"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
<com.android.settings.DividerPreference
|
||||
android:key="failed_password_wipe_managed_profile"
|
||||
android:title="@string/enterprise_privacy_failed_password_wipe_work"
|
||||
android:visibility="gone"
|
||||
settings:multiLine="true"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
@@ -80,6 +80,20 @@ public interface DevicePolicyManagerWrapper {
|
||||
int getPermissionGrantState(@Nullable ComponentName admin, String packageName,
|
||||
String permission);
|
||||
|
||||
/**
|
||||
* Calls {@code DevicePolicyManager.isSecurityLoggingEnabled()}.
|
||||
*
|
||||
* @see android.app.admin.DevicePolicyManager#isSecurityLoggingEnabled
|
||||
*/
|
||||
boolean isSecurityLoggingEnabled(@Nullable ComponentName admin);
|
||||
|
||||
/**
|
||||
* Calls {@code DevicePolicyManager.isNetworkLoggingEnabled()}.
|
||||
*
|
||||
* @see android.app.admin.DevicePolicyManager#isNetworkLoggingEnabled
|
||||
*/
|
||||
boolean isNetworkLoggingEnabled(@Nullable ComponentName admin);
|
||||
|
||||
/**
|
||||
* Calls {@code DevicePolicyManager.getLastSecurityLogRetrievalTime()}.
|
||||
*
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.enterprise;
|
||||
import android.annotation.NonNull;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ComponentName;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
@@ -67,6 +68,18 @@ public class DevicePolicyManagerWrapperImpl implements DevicePolicyManagerWrappe
|
||||
return mDpm.getPermissionGrantState(admin, packageName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecurityLoggingEnabled(@Nullable ComponentName admin) {
|
||||
// TODO(b/36584321): Switch to DevicePolicyManager#isSecurityLoggingEnabled once that is
|
||||
// callable by the system.
|
||||
return SystemProperties.getBoolean("persist.logd.security", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkLoggingEnabled(@Nullable ComponentName admin) {
|
||||
return mDpm.isNetworkLoggingEnabled(admin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastSecurityLogRetrievalTime() {
|
||||
return mDpm.getLastSecurityLogRetrievalTime();
|
||||
|
@@ -63,6 +63,16 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
*/
|
||||
Date getLastNetworkLogRetrievalTime();
|
||||
|
||||
/**
|
||||
* Returns whether security logging is currently enabled.
|
||||
*/
|
||||
boolean isSecurityLoggingEnabled();
|
||||
|
||||
/**
|
||||
* Returns whether network logging is currently enabled.
|
||||
*/
|
||||
boolean isNetworkLoggingEnabled();
|
||||
|
||||
/**
|
||||
* Returns whether the Device Owner in the primary user set an always-on VPN.
|
||||
*/
|
||||
|
@@ -131,6 +131,16 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
return timestamp < 0 ? null : new Date(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecurityLoggingEnabled() {
|
||||
return mDpm.isSecurityLoggingEnabled(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkLoggingEnabled() {
|
||||
return mDpm.isNetworkLoggingEnabled(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysOnVpnSetInPrimaryUser() {
|
||||
return VpnUtils.isAlwaysOnVpnSet(mCm, MY_USER_ID);
|
||||
|
@@ -30,6 +30,12 @@ public class NetworkLogsPreferenceController extends AdminActionPreferenceContro
|
||||
return mFeatureProvider.getLastNetworkLogRetrievalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mFeatureProvider.isNetworkLoggingEnabled() ||
|
||||
mFeatureProvider.getLastNetworkLogRetrievalTime() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_NETWORK_LOGS;
|
||||
|
@@ -30,6 +30,12 @@ public class SecurityLogsPreferenceController extends AdminActionPreferenceContr
|
||||
return mFeatureProvider.getLastSecurityLogRetrievalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mFeatureProvider.isSecurityLoggingEnabled() ||
|
||||
mFeatureProvider.getLastSecurityLogRetrievalTime() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_SECURITY_LOGS;
|
||||
|
@@ -21,11 +21,14 @@ import android.content.Context;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link AdminActionPreferenceControllerBase}.
|
||||
*/
|
||||
@@ -47,6 +50,11 @@ public final class AdminActionPreferenceControllerBaseTest extends
|
||||
mDate = date;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return null;
|
||||
|
@@ -20,11 +20,13 @@ import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
@@ -47,6 +49,11 @@ public final class BugReportsPreferenceControllerTest extends
|
||||
.thenReturn(date);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return "bug_reports";
|
||||
|
@@ -176,6 +176,24 @@ public final class EnterprisePrivacyFeatureProviderImplTest {
|
||||
assertThat(mProvider.getLastNetworkLogRetrievalTime()).isEqualTo(TIMESTAMP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSecurityLoggingEnabled() {
|
||||
when(mDevicePolicyManager.isSecurityLoggingEnabled(null)).thenReturn(false);
|
||||
assertThat(mProvider.isSecurityLoggingEnabled()).isFalse();
|
||||
|
||||
when(mDevicePolicyManager.isSecurityLoggingEnabled(null)).thenReturn(true);
|
||||
assertThat(mProvider.isSecurityLoggingEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNetworkLoggingEnabled() {
|
||||
when(mDevicePolicyManager.isNetworkLoggingEnabled(null)).thenReturn(false);
|
||||
assertThat(mProvider.isNetworkLoggingEnabled()).isFalse();
|
||||
|
||||
when(mDevicePolicyManager.isNetworkLoggingEnabled(null)).thenReturn(true);
|
||||
assertThat(mProvider.isNetworkLoggingEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAlwaysOnVpnSetInPrimaryUser() {
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(MY_USER_ID)).thenReturn(null);
|
||||
|
@@ -20,11 +20,13 @@ import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
@@ -47,6 +49,22 @@ public final class NetworkLogsPreferenceControllerTest extends
|
||||
.thenReturn(date);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
setDate(null);
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isNetworkLoggingEnabled())
|
||||
.thenReturn(false);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
|
||||
setDate(new Date());
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
|
||||
setDate(null);
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isNetworkLoggingEnabled())
|
||||
.thenReturn(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return "network_logs";
|
||||
|
@@ -20,11 +20,13 @@ import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
@@ -47,6 +49,22 @@ public final class SecurityLogsPreferenceControllerTest extends
|
||||
.thenReturn(date);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
setDate(null);
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isSecurityLoggingEnabled())
|
||||
.thenReturn(false);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
|
||||
setDate(new Date());
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
|
||||
setDate(null);
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isSecurityLoggingEnabled())
|
||||
.thenReturn(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return "security_logs";
|
||||
|
Reference in New Issue
Block a user