Loading packages/SystemUI/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1054,6 +1054,9 @@ <!-- Text on keyguard screen and in Quick Settings footer indicating that user's device belongs to their organization. [CHAR LIMIT=40] --> <string name="do_disclosure_with_name">This device belongs to <xliff:g id="organization_name" example="Foo, Inc.">%s</xliff:g></string> <!-- Text on keyguard screen and in Quick Settings footer indicating that the user's device is provided by the Creditor. [CHAR LIMIT=60] --> <string name="do_financed_disclosure_with_name">This device is provided by <xliff:g id="organization_name" example="Foo, Inc.">%s</xliff:g></string> <!-- Shows when people have clicked on the phone icon [CHAR LIMIT=60] --> <string name="phone_hint">Swipe from icon for phone</string> Loading packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +19 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar; import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED; import static android.view.View.GONE; import static android.view.View.VISIBLE; Loading @@ -41,6 +42,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.UserInfo; import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Color; import android.hardware.biometrics.BiometricSourceType; import android.hardware.face.FaceManager; Loading Loading @@ -277,10 +279,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal // avoid calling this method since it has an IPC if (whitelistIpcs(this::isOrganizationOwnedDevice)) { final CharSequence organizationName = getOrganizationOwnedDeviceOrganizationName(); final CharSequence disclosure = organizationName != null ? mContext.getResources().getString(R.string.do_disclosure_with_name, organizationName) : mContext.getResources().getText(R.string.do_disclosure_generic); final CharSequence disclosure = getDisclosureText(organizationName); mRotateTextViewController.updateIndication( INDICATION_TYPE_DISCLOSURE, new KeyguardIndication.Builder() Loading @@ -297,6 +296,22 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal } } private CharSequence getDisclosureText(@Nullable CharSequence organizationName) { final Resources packageResources = mContext.getResources(); if (organizationName == null) { return packageResources.getText(R.string.do_disclosure_generic); } else if (mDevicePolicyManager.isDeviceManaged() && mDevicePolicyManager.getDeviceOwnerType( mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()) == DEVICE_OWNER_TYPE_FINANCED) { return packageResources.getString(R.string.do_financed_disclosure_with_name, organizationName); } else { return packageResources.getString(R.string.do_disclosure_with_name, organizationName); } } private void updateOwnerInfo() { if (!isKeyguardLayoutEnabled()) { mRotateTextViewController.hideIndication(INDICATION_TYPE_OWNER_INFO); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar; import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_DEFAULT; import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED; import static android.content.pm.UserInfo.FLAG_MANAGED_PROFILE; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE; Loading @@ -40,6 +42,7 @@ import android.app.Instrumentation; import android.app.admin.DevicePolicyManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.UserInfo; Loading Loading @@ -94,8 +97,12 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { private static final String ORGANIZATION_NAME = "organization"; private static final ComponentName DEVICE_OWNER_COMPONENT = new ComponentName("com.android.foo", "bar"); private String mDisclosureWithOrganization; private String mDisclosureGeneric; private String mFinancedDisclosureWithOrganization; @Mock private DevicePolicyManager mDevicePolicyManager; Loading Loading @@ -156,6 +163,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { mDisclosureWithOrganization = mContext.getString(R.string.do_disclosure_with_name, ORGANIZATION_NAME); mDisclosureGeneric = mContext.getString(R.string.do_disclosure_generic); mFinancedDisclosureWithOrganization = mContext.getString( R.string.do_financed_disclosure_with_name, ORGANIZATION_NAME); when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true); when(mKeyguardUpdateMonitor.isScreenOn()).thenReturn(true); Loading @@ -165,6 +174,11 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { .thenReturn(mIndicationAreaBottom); when(mIndicationArea.findViewById(R.id.keyguard_indication_text)).thenReturn(mTextView); when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()) .thenReturn(DEVICE_OWNER_COMPONENT); when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT)) .thenReturn(DEVICE_OWNER_TYPE_DEFAULT); mWakeLock = new WakeLockFake(); mWakeLockBuilder = new WakeLockFake.Builder(mContext); mWakeLockBuilder.setWakeLock(mWakeLock); Loading Loading @@ -371,6 +385,22 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { verify(mRotateTextViewController).hideIndication(INDICATION_TYPE_DISCLOSURE); } @Test public void disclosure_deviceOwner_financedDeviceWithOrganizationName() { createController(); when(mDevicePolicyManager.isDeviceManaged()).thenReturn(true); when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(ORGANIZATION_NAME); when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT)) .thenReturn(DEVICE_OWNER_TYPE_FINANCED); sendUpdateDisclosureBroadcast(); verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE), mKeyguardIndicationCaptor.capture(), eq(false)); assertThat(mKeyguardIndicationCaptor.getValue().getMessage()) .isEqualTo(mFinancedDisclosureWithOrganization); } @Test public void transientIndication_holdsWakeLock_whenDozing() { createController(); Loading Loading
packages/SystemUI/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1054,6 +1054,9 @@ <!-- Text on keyguard screen and in Quick Settings footer indicating that user's device belongs to their organization. [CHAR LIMIT=40] --> <string name="do_disclosure_with_name">This device belongs to <xliff:g id="organization_name" example="Foo, Inc.">%s</xliff:g></string> <!-- Text on keyguard screen and in Quick Settings footer indicating that the user's device is provided by the Creditor. [CHAR LIMIT=60] --> <string name="do_financed_disclosure_with_name">This device is provided by <xliff:g id="organization_name" example="Foo, Inc.">%s</xliff:g></string> <!-- Shows when people have clicked on the phone icon [CHAR LIMIT=60] --> <string name="phone_hint">Swipe from icon for phone</string> Loading
packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +19 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar; import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED; import static android.view.View.GONE; import static android.view.View.VISIBLE; Loading @@ -41,6 +42,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.UserInfo; import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Color; import android.hardware.biometrics.BiometricSourceType; import android.hardware.face.FaceManager; Loading Loading @@ -277,10 +279,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal // avoid calling this method since it has an IPC if (whitelistIpcs(this::isOrganizationOwnedDevice)) { final CharSequence organizationName = getOrganizationOwnedDeviceOrganizationName(); final CharSequence disclosure = organizationName != null ? mContext.getResources().getString(R.string.do_disclosure_with_name, organizationName) : mContext.getResources().getText(R.string.do_disclosure_generic); final CharSequence disclosure = getDisclosureText(organizationName); mRotateTextViewController.updateIndication( INDICATION_TYPE_DISCLOSURE, new KeyguardIndication.Builder() Loading @@ -297,6 +296,22 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal } } private CharSequence getDisclosureText(@Nullable CharSequence organizationName) { final Resources packageResources = mContext.getResources(); if (organizationName == null) { return packageResources.getText(R.string.do_disclosure_generic); } else if (mDevicePolicyManager.isDeviceManaged() && mDevicePolicyManager.getDeviceOwnerType( mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()) == DEVICE_OWNER_TYPE_FINANCED) { return packageResources.getString(R.string.do_financed_disclosure_with_name, organizationName); } else { return packageResources.getString(R.string.do_disclosure_with_name, organizationName); } } private void updateOwnerInfo() { if (!isKeyguardLayoutEnabled()) { mRotateTextViewController.hideIndication(INDICATION_TYPE_OWNER_INFO); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar; import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_DEFAULT; import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED; import static android.content.pm.UserInfo.FLAG_MANAGED_PROFILE; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE; Loading @@ -40,6 +42,7 @@ import android.app.Instrumentation; import android.app.admin.DevicePolicyManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.UserInfo; Loading Loading @@ -94,8 +97,12 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { private static final String ORGANIZATION_NAME = "organization"; private static final ComponentName DEVICE_OWNER_COMPONENT = new ComponentName("com.android.foo", "bar"); private String mDisclosureWithOrganization; private String mDisclosureGeneric; private String mFinancedDisclosureWithOrganization; @Mock private DevicePolicyManager mDevicePolicyManager; Loading Loading @@ -156,6 +163,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { mDisclosureWithOrganization = mContext.getString(R.string.do_disclosure_with_name, ORGANIZATION_NAME); mDisclosureGeneric = mContext.getString(R.string.do_disclosure_generic); mFinancedDisclosureWithOrganization = mContext.getString( R.string.do_financed_disclosure_with_name, ORGANIZATION_NAME); when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true); when(mKeyguardUpdateMonitor.isScreenOn()).thenReturn(true); Loading @@ -165,6 +174,11 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { .thenReturn(mIndicationAreaBottom); when(mIndicationArea.findViewById(R.id.keyguard_indication_text)).thenReturn(mTextView); when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()) .thenReturn(DEVICE_OWNER_COMPONENT); when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT)) .thenReturn(DEVICE_OWNER_TYPE_DEFAULT); mWakeLock = new WakeLockFake(); mWakeLockBuilder = new WakeLockFake.Builder(mContext); mWakeLockBuilder.setWakeLock(mWakeLock); Loading Loading @@ -371,6 +385,22 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { verify(mRotateTextViewController).hideIndication(INDICATION_TYPE_DISCLOSURE); } @Test public void disclosure_deviceOwner_financedDeviceWithOrganizationName() { createController(); when(mDevicePolicyManager.isDeviceManaged()).thenReturn(true); when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(ORGANIZATION_NAME); when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT)) .thenReturn(DEVICE_OWNER_TYPE_FINANCED); sendUpdateDisclosureBroadcast(); verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE), mKeyguardIndicationCaptor.capture(), eq(false)); assertThat(mKeyguardIndicationCaptor.getValue().getMessage()) .isEqualTo(mFinancedDisclosureWithOrganization); } @Test public void transientIndication_holdsWakeLock_whenDozing() { createController(); Loading