Merge "Update keyguard screen text for a financed device" into sc-dev
This commit is contained in:
@@ -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] -->
|
<!-- 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>
|
<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] -->
|
<!-- Shows when people have clicked on the phone icon [CHAR LIMIT=60] -->
|
||||||
<string name="phone_hint">Swipe from icon for phone</string>
|
<string name="phone_hint">Swipe from icon for phone</string>
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar;
|
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.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.hardware.biometrics.BiometricSourceType;
|
import android.hardware.biometrics.BiometricSourceType;
|
||||||
import android.hardware.face.FaceManager;
|
import android.hardware.face.FaceManager;
|
||||||
@@ -277,10 +279,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
|||||||
// avoid calling this method since it has an IPC
|
// avoid calling this method since it has an IPC
|
||||||
if (whitelistIpcs(this::isOrganizationOwnedDevice)) {
|
if (whitelistIpcs(this::isOrganizationOwnedDevice)) {
|
||||||
final CharSequence organizationName = getOrganizationOwnedDeviceOrganizationName();
|
final CharSequence organizationName = getOrganizationOwnedDeviceOrganizationName();
|
||||||
final CharSequence disclosure = organizationName != null
|
final CharSequence disclosure = getDisclosureText(organizationName);
|
||||||
? mContext.getResources().getString(R.string.do_disclosure_with_name,
|
|
||||||
organizationName)
|
|
||||||
: mContext.getResources().getText(R.string.do_disclosure_generic);
|
|
||||||
mRotateTextViewController.updateIndication(
|
mRotateTextViewController.updateIndication(
|
||||||
INDICATION_TYPE_DISCLOSURE,
|
INDICATION_TYPE_DISCLOSURE,
|
||||||
new KeyguardIndication.Builder()
|
new KeyguardIndication.Builder()
|
||||||
@@ -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() {
|
private void updateOwnerInfo() {
|
||||||
if (!isKeyguardLayoutEnabled()) {
|
if (!isKeyguardLayoutEnabled()) {
|
||||||
mRotateTextViewController.hideIndication(INDICATION_TYPE_OWNER_INFO);
|
mRotateTextViewController.hideIndication(INDICATION_TYPE_OWNER_INFO);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar;
|
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 android.content.pm.UserInfo.FLAG_MANAGED_PROFILE;
|
||||||
|
|
||||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE;
|
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE;
|
||||||
@@ -40,6 +42,7 @@ import android.app.Instrumentation;
|
|||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.app.trust.TrustManager;
|
import android.app.trust.TrustManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
@@ -94,8 +97,12 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
private static final String ORGANIZATION_NAME = "organization";
|
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 mDisclosureWithOrganization;
|
||||||
private String mDisclosureGeneric;
|
private String mDisclosureGeneric;
|
||||||
|
private String mFinancedDisclosureWithOrganization;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DevicePolicyManager mDevicePolicyManager;
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
@@ -156,6 +163,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
|||||||
mDisclosureWithOrganization = mContext.getString(R.string.do_disclosure_with_name,
|
mDisclosureWithOrganization = mContext.getString(R.string.do_disclosure_with_name,
|
||||||
ORGANIZATION_NAME);
|
ORGANIZATION_NAME);
|
||||||
mDisclosureGeneric = mContext.getString(R.string.do_disclosure_generic);
|
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.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
|
||||||
when(mKeyguardUpdateMonitor.isScreenOn()).thenReturn(true);
|
when(mKeyguardUpdateMonitor.isScreenOn()).thenReturn(true);
|
||||||
@@ -165,6 +174,11 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
|||||||
.thenReturn(mIndicationAreaBottom);
|
.thenReturn(mIndicationAreaBottom);
|
||||||
when(mIndicationArea.findViewById(R.id.keyguard_indication_text)).thenReturn(mTextView);
|
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();
|
mWakeLock = new WakeLockFake();
|
||||||
mWakeLockBuilder = new WakeLockFake.Builder(mContext);
|
mWakeLockBuilder = new WakeLockFake.Builder(mContext);
|
||||||
mWakeLockBuilder.setWakeLock(mWakeLock);
|
mWakeLockBuilder.setWakeLock(mWakeLock);
|
||||||
@@ -371,6 +385,22 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
|||||||
verify(mRotateTextViewController).hideIndication(INDICATION_TYPE_DISCLOSURE);
|
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
|
@Test
|
||||||
public void transientIndication_holdsWakeLock_whenDozing() {
|
public void transientIndication_holdsWakeLock_whenDozing() {
|
||||||
createController();
|
createController();
|
||||||
|
|||||||
Reference in New Issue
Block a user