From 0e111e69228f310187e02e5abeb82ab184845f77 Mon Sep 17 00:00:00 2001 From: Benjamin Franz Date: Mon, 1 Feb 2016 17:27:17 +0000 Subject: [PATCH] Revert "Revert "Read default confirm credentials title from policy"" This reverts commit ff3d76dfd4c88bdf52ae9467307a86651bf7cd98. Change-Id: Ibdfdc880629ace541744c2ba1f46393e70ae53f5 --- .../settings/ConfirmDeviceCredentialActivity.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/android/settings/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/ConfirmDeviceCredentialActivity.java index 28c0515ae27..16d068548eb 100644 --- a/src/com/android/settings/ConfirmDeviceCredentialActivity.java +++ b/src/com/android/settings/ConfirmDeviceCredentialActivity.java @@ -19,6 +19,8 @@ package com.android.settings; import android.app.Activity; import android.app.KeyguardManager; +import android.app.admin.DevicePolicyManager; +import android.content.Context; import android.content.Intent; import android.os.Binder; import android.os.Bundle; @@ -72,6 +74,11 @@ public class ConfirmDeviceCredentialActivity extends Activity { Log.e(TAG, "Invalid intent extra", se); } } + // if the client app did not hand in a title and we are about to show the work challenge, + // check whether there is a policy setting the organization name and use that as title + if ((title == null) && Utils.isManagedProfile(UserManager.get(this), userId)) { + title = getTitleFromOrganizationName(userId); + } ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this); if (!helper.launchConfirmationActivity(0 /* request code */, null /* title */, title, details, false /* returnCredentials */, true /* isExternal */, userId)) { @@ -84,4 +91,10 @@ public class ConfirmDeviceCredentialActivity extends Activity { private boolean isInternalActivity() { return this instanceof ConfirmDeviceCredentialActivity.InternalActivity; } + + private String getTitleFromOrganizationName(int userId) { + DevicePolicyManager dpm = (DevicePolicyManager) getSystemService( + Context.DEVICE_POLICY_SERVICE); + return (dpm != null) ? dpm.getOrganizationNameForUser(userId) : null; + } }