Merge "QS: Do not display specific disclosure when the work profile is off" into sc-dev am: 840870e7cb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15053236 Change-Id: Ia05b8392abed6800c0c1630756d414f2958a3e61
This commit is contained in:
@@ -185,15 +185,22 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
final boolean isProfileOwnerOfOrganizationOwnedDevice =
|
final boolean isProfileOwnerOfOrganizationOwnedDevice =
|
||||||
mSecurityController.isProfileOwnerOfOrganizationOwnedDevice();
|
mSecurityController.isProfileOwnerOfOrganizationOwnedDevice();
|
||||||
final boolean isParentalControlsEnabled = mSecurityController.isParentalControlsEnabled();
|
final boolean isParentalControlsEnabled = mSecurityController.isParentalControlsEnabled();
|
||||||
|
final boolean isWorkProfileOn = mSecurityController.isWorkProfileOn();
|
||||||
|
final boolean hasDisclosableWorkProfilePolicy = hasCACertsInWorkProfile
|
||||||
|
|| vpnNameWorkProfile != null || (hasWorkProfile && isNetworkLoggingEnabled);
|
||||||
// Update visibility of footer
|
// Update visibility of footer
|
||||||
mIsVisible = (isDeviceManaged && !isDemoDevice) || hasCACerts || hasCACertsInWorkProfile
|
mIsVisible = (isDeviceManaged && !isDemoDevice)
|
||||||
|| vpnName != null || vpnNameWorkProfile != null
|
|| hasCACerts
|
||||||
|| isProfileOwnerOfOrganizationOwnedDevice || isParentalControlsEnabled
|
|| vpnName != null
|
||||||
|| (hasWorkProfile && isNetworkLoggingEnabled);
|
|| isProfileOwnerOfOrganizationOwnedDevice
|
||||||
|
|| isParentalControlsEnabled
|
||||||
|
|| (hasDisclosableWorkProfilePolicy && isWorkProfileOn);
|
||||||
// Update the view to be untappable if the device is an organization-owned device with a
|
// Update the view to be untappable if the device is an organization-owned device with a
|
||||||
// managed profile and there is no policy set which requires a privacy disclosure.
|
// managed profile and there is either:
|
||||||
if (mIsVisible && isProfileOwnerOfOrganizationOwnedDevice && !isNetworkLoggingEnabled
|
// a) no policy set which requires a privacy disclosure.
|
||||||
&& !hasCACertsInWorkProfile && vpnNameWorkProfile == null) {
|
// b) a specific work policy set but the work profile is turned off.
|
||||||
|
if (mIsVisible && isProfileOwnerOfOrganizationOwnedDevice
|
||||||
|
&& (!hasDisclosableWorkProfilePolicy || !isWorkProfileOn)) {
|
||||||
mRootView.setClickable(false);
|
mRootView.setClickable(false);
|
||||||
mRootView.findViewById(R.id.footer_icon).setVisibility(View.GONE);
|
mRootView.findViewById(R.id.footer_icon).setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
@@ -204,7 +211,8 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
mFooterTextContent = getFooterText(isDeviceManaged, hasWorkProfile,
|
mFooterTextContent = getFooterText(isDeviceManaged, hasWorkProfile,
|
||||||
hasCACerts, hasCACertsInWorkProfile, isNetworkLoggingEnabled, vpnName,
|
hasCACerts, hasCACertsInWorkProfile, isNetworkLoggingEnabled, vpnName,
|
||||||
vpnNameWorkProfile, organizationName, workProfileOrganizationName,
|
vpnNameWorkProfile, organizationName, workProfileOrganizationName,
|
||||||
isProfileOwnerOfOrganizationOwnedDevice, isParentalControlsEnabled);
|
isProfileOwnerOfOrganizationOwnedDevice, isParentalControlsEnabled,
|
||||||
|
isWorkProfileOn);
|
||||||
// Update the icon
|
// Update the icon
|
||||||
int footerIconId = R.drawable.ic_info_outline;
|
int footerIconId = R.drawable.ic_info_outline;
|
||||||
if (vpnName != null || vpnNameWorkProfile != null) {
|
if (vpnName != null || vpnNameWorkProfile != null) {
|
||||||
@@ -236,7 +244,8 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
boolean hasCACerts, boolean hasCACertsInWorkProfile, boolean isNetworkLoggingEnabled,
|
boolean hasCACerts, boolean hasCACertsInWorkProfile, boolean isNetworkLoggingEnabled,
|
||||||
String vpnName, String vpnNameWorkProfile, CharSequence organizationName,
|
String vpnName, String vpnNameWorkProfile, CharSequence organizationName,
|
||||||
CharSequence workProfileOrganizationName,
|
CharSequence workProfileOrganizationName,
|
||||||
boolean isProfileOwnerOfOrganizationOwnedDevice, boolean isParentalControlsEnabled) {
|
boolean isProfileOwnerOfOrganizationOwnedDevice, boolean isParentalControlsEnabled,
|
||||||
|
boolean isWorkProfileOn) {
|
||||||
if (isParentalControlsEnabled) {
|
if (isParentalControlsEnabled) {
|
||||||
return mContext.getString(R.string.quick_settings_disclosure_parental_controls);
|
return mContext.getString(R.string.quick_settings_disclosure_parental_controls);
|
||||||
}
|
}
|
||||||
@@ -280,7 +289,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
organizationName);
|
organizationName);
|
||||||
}
|
}
|
||||||
} // end if(isDeviceManaged)
|
} // end if(isDeviceManaged)
|
||||||
if (hasCACertsInWorkProfile) {
|
if (hasCACertsInWorkProfile && isWorkProfileOn) {
|
||||||
if (workProfileOrganizationName == null) {
|
if (workProfileOrganizationName == null) {
|
||||||
return mContext.getString(
|
return mContext.getString(
|
||||||
R.string.quick_settings_disclosure_managed_profile_monitoring);
|
R.string.quick_settings_disclosure_managed_profile_monitoring);
|
||||||
@@ -295,7 +304,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
if (vpnName != null && vpnNameWorkProfile != null) {
|
if (vpnName != null && vpnNameWorkProfile != null) {
|
||||||
return mContext.getString(R.string.quick_settings_disclosure_vpns);
|
return mContext.getString(R.string.quick_settings_disclosure_vpns);
|
||||||
}
|
}
|
||||||
if (vpnNameWorkProfile != null) {
|
if (vpnNameWorkProfile != null && isWorkProfileOn) {
|
||||||
return mContext.getString(R.string.quick_settings_disclosure_managed_profile_named_vpn,
|
return mContext.getString(R.string.quick_settings_disclosure_managed_profile_named_vpn,
|
||||||
vpnNameWorkProfile);
|
vpnNameWorkProfile);
|
||||||
}
|
}
|
||||||
@@ -308,7 +317,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
return mContext.getString(R.string.quick_settings_disclosure_named_vpn,
|
return mContext.getString(R.string.quick_settings_disclosure_named_vpn,
|
||||||
vpnName);
|
vpnName);
|
||||||
}
|
}
|
||||||
if (hasWorkProfile && isNetworkLoggingEnabled) {
|
if (hasWorkProfile && isNetworkLoggingEnabled && isWorkProfileOn) {
|
||||||
return mContext.getString(
|
return mContext.getString(
|
||||||
R.string.quick_settings_disclosure_managed_profile_network_activity);
|
R.string.quick_settings_disclosure_managed_profile_network_activity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public interface SecurityController extends CallbackController<SecurityControlle
|
|||||||
boolean isDeviceManaged();
|
boolean isDeviceManaged();
|
||||||
boolean hasProfileOwner();
|
boolean hasProfileOwner();
|
||||||
boolean hasWorkProfile();
|
boolean hasWorkProfile();
|
||||||
|
/** Whether the work profile is turned on. */
|
||||||
|
boolean isWorkProfileOn();
|
||||||
/** Whether this device is organization-owned with a work profile **/
|
/** Whether this device is organization-owned with a work profile **/
|
||||||
boolean isProfileOwnerOfOrganizationOwnedDevice();
|
boolean isProfileOwnerOfOrganizationOwnedDevice();
|
||||||
String getDeviceOwnerName();
|
String getDeviceOwnerName();
|
||||||
@@ -57,7 +59,6 @@ public interface SecurityController extends CallbackController<SecurityControlle
|
|||||||
/** Label for admin */
|
/** Label for admin */
|
||||||
CharSequence getLabel(DeviceAdminInfo info);
|
CharSequence getLabel(DeviceAdminInfo info);
|
||||||
|
|
||||||
|
|
||||||
public interface SecurityControllerCallback {
|
public interface SecurityControllerCallback {
|
||||||
void onStateChanged();
|
void onStateChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,6 +210,12 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi
|
|||||||
return getWorkProfileUserId(mCurrentUserId) != UserHandle.USER_NULL;
|
return getWorkProfileUserId(mCurrentUserId) != UserHandle.USER_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWorkProfileOn() {
|
||||||
|
final UserHandle userHandle = UserHandle.of(getWorkProfileUserId(mCurrentUserId));
|
||||||
|
return userHandle != null && !mUserManager.isQuietModeEnabled(userHandle);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isProfileOwnerOfOrganizationOwnedDevice() {
|
public boolean isProfileOwnerOfOrganizationOwnedDevice() {
|
||||||
return mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile();
|
return mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile();
|
||||||
|
|||||||
@@ -204,6 +204,8 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
public void testTappableView_profileOwnerOfOrgOwnedDevice_networkLoggingEnabled() {
|
public void testTappableView_profileOwnerOfOrgOwnedDevice_networkLoggingEnabled() {
|
||||||
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
|
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
|
||||||
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
|
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
|
||||||
|
when(mSecurityController.isWorkProfileOn()).thenReturn(true);
|
||||||
|
when(mSecurityController.hasWorkProfile()).thenReturn(true);
|
||||||
|
|
||||||
mFooter.refreshState();
|
mFooter.refreshState();
|
||||||
|
|
||||||
@@ -212,6 +214,19 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
assertEquals(View.VISIBLE, mRootView.findViewById(R.id.footer_icon).getVisibility());
|
assertEquals(View.VISIBLE, mRootView.findViewById(R.id.footer_icon).getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUntappableView_profileOwnerOfOrgOwnedDevice_workProfileOff() {
|
||||||
|
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
|
||||||
|
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
|
||||||
|
when(mSecurityController.isWorkProfileOn()).thenReturn(false);
|
||||||
|
|
||||||
|
mFooter.refreshState();
|
||||||
|
|
||||||
|
TestableLooper.get(this).processAllMessages();
|
||||||
|
assertFalse(mRootView.isClickable());
|
||||||
|
assertEquals(View.GONE, mRootView.findViewById(R.id.footer_icon).getVisibility());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNetworkLoggingEnabled_deviceOwner() {
|
public void testNetworkLoggingEnabled_deviceOwner() {
|
||||||
when(mSecurityController.isDeviceManaged()).thenReturn(true);
|
when(mSecurityController.isDeviceManaged()).thenReturn(true);
|
||||||
@@ -237,9 +252,10 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNetworkLoggingEnabled_managedProfileOwner() {
|
public void testNetworkLoggingEnabled_managedProfileOwner_workProfileOn() {
|
||||||
when(mSecurityController.hasWorkProfile()).thenReturn(true);
|
when(mSecurityController.hasWorkProfile()).thenReturn(true);
|
||||||
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
|
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
|
||||||
|
when(mSecurityController.isWorkProfileOn()).thenReturn(true);
|
||||||
mFooter.refreshState();
|
mFooter.refreshState();
|
||||||
|
|
||||||
TestableLooper.get(this).processAllMessages();
|
TestableLooper.get(this).processAllMessages();
|
||||||
@@ -248,6 +264,17 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
mFooterText.getText());
|
mFooterText.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNetworkLoggingEnabled_managedProfileOwner_workProfileOff() {
|
||||||
|
when(mSecurityController.hasWorkProfile()).thenReturn(true);
|
||||||
|
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
|
||||||
|
when(mSecurityController.isWorkProfileOn()).thenReturn(false);
|
||||||
|
mFooter.refreshState();
|
||||||
|
|
||||||
|
TestableLooper.get(this).processAllMessages();
|
||||||
|
assertEquals("", mFooterText.getText());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testManagedCACertsInstalled() {
|
public void testManagedCACertsInstalled() {
|
||||||
when(mSecurityController.isDeviceManaged()).thenReturn(true);
|
when(mSecurityController.isDeviceManaged()).thenReturn(true);
|
||||||
@@ -326,9 +353,10 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWorkProfileCACertsInstalled() {
|
public void testWorkProfileCACertsInstalled_workProfileOn() {
|
||||||
when(mSecurityController.isDeviceManaged()).thenReturn(false);
|
when(mSecurityController.isDeviceManaged()).thenReturn(false);
|
||||||
when(mSecurityController.hasCACertInWorkProfile()).thenReturn(true);
|
when(mSecurityController.hasCACertInWorkProfile()).thenReturn(true);
|
||||||
|
when(mSecurityController.isWorkProfileOn()).thenReturn(true);
|
||||||
mFooter.refreshState();
|
mFooter.refreshState();
|
||||||
|
|
||||||
TestableLooper.get(this).processAllMessages();
|
TestableLooper.get(this).processAllMessages();
|
||||||
@@ -349,6 +377,17 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
mFooterText.getText());
|
mFooterText.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWorkProfileCACertsInstalled_workProfileOff() {
|
||||||
|
when(mSecurityController.isDeviceManaged()).thenReturn(false);
|
||||||
|
when(mSecurityController.hasCACertInWorkProfile()).thenReturn(true);
|
||||||
|
when(mSecurityController.isWorkProfileOn()).thenReturn(false);
|
||||||
|
mFooter.refreshState();
|
||||||
|
|
||||||
|
TestableLooper.get(this).processAllMessages();
|
||||||
|
assertEquals("", mFooterText.getText());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCACertsInstalled() {
|
public void testCACertsInstalled() {
|
||||||
when(mSecurityController.isDeviceManaged()).thenReturn(false);
|
when(mSecurityController.isDeviceManaged()).thenReturn(false);
|
||||||
@@ -375,9 +414,10 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWorkProfileVpnEnabled() {
|
public void testWorkProfileVpnEnabled_workProfileOn() {
|
||||||
when(mSecurityController.isVpnEnabled()).thenReturn(true);
|
when(mSecurityController.isVpnEnabled()).thenReturn(true);
|
||||||
when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2);
|
when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2);
|
||||||
|
when(mSecurityController.isWorkProfileOn()).thenReturn(true);
|
||||||
mFooter.refreshState();
|
mFooter.refreshState();
|
||||||
|
|
||||||
TestableLooper.get(this).processAllMessages();
|
TestableLooper.get(this).processAllMessages();
|
||||||
@@ -388,6 +428,17 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
mFooterText.getText());
|
mFooterText.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWorkProfileVpnEnabled_workProfileOff() {
|
||||||
|
when(mSecurityController.isVpnEnabled()).thenReturn(true);
|
||||||
|
when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2);
|
||||||
|
when(mSecurityController.isWorkProfileOn()).thenReturn(false);
|
||||||
|
mFooter.refreshState();
|
||||||
|
|
||||||
|
TestableLooper.get(this).processAllMessages();
|
||||||
|
assertEquals("", mFooterText.getText());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProfileOwnerOfOrganizationOwnedDeviceNoName() {
|
public void testProfileOwnerOfOrganizationOwnedDeviceNoName() {
|
||||||
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
|
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ public class FakeSecurityController extends BaseLeakChecker<SecurityControllerCa
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWorkProfileOn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isProfileOwnerOfOrganizationOwnedDevice() {
|
public boolean isProfileOwnerOfOrganizationOwnedDevice() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user