From 6e2821dc1ab96de168a057d25acc1ad87e50e606 Mon Sep 17 00:00:00 2001 From: Benjamin Franz Date: Mon, 25 Jan 2016 16:17:14 +0000 Subject: [PATCH] Read default confirm credentials title from policy Use the organization name as default header text for the work challenge. If an app passes a different header text, this will get priority. Bug: 26638631 Change-Id: I09a5bd7172ff1eed0ff97be02818e838a1a0a520 --- .../settings/ConfirmDeviceCredentialActivity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/com/android/settings/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/ConfirmDeviceCredentialActivity.java index 28c0515ae27..fe22f877a82 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,10 @@ public class ConfirmDeviceCredentialActivity extends Activity { Log.e(TAG, "Invalid intent extra", se); } } + // if the client app did not hand in a title, we check whether there is a policy setting it + if (title == null) { + 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 +90,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; + } }