From 6fd84cc878c7df75777644944288cce558c1cd51 Mon Sep 17 00:00:00 2001 From: Benjamin Franz Date: Thu, 6 Aug 2015 18:09:03 +0100 Subject: [PATCH] Use realActivity as indicator for task locking When lock task mode is started, we verify that the package is whitelisted and currently use mCallingPackage as indicator. However, the calling package is not necessarily identical to the package trying to lock itself, so lock task mode sometimes fails. Switching over to using realActivity as package marker. Bug: 22916291 Change-Id: Ifd4df2d634842c8106b0b0f690bcf1faba0ed5fa --- services/core/java/com/android/server/am/TaskRecord.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index 7e2ad2969843b..9da30bff8c94b 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -786,7 +786,8 @@ final class TaskRecord { } boolean isLockTaskWhitelistedLocked() { - if (mCallingPackage == null) { + String pkg = (realActivity != null) ? realActivity.getPackageName() : null; + if (pkg == null) { return false; } String[] packages = mService.mLockTaskPackages.get(userId); @@ -794,7 +795,7 @@ final class TaskRecord { return false; } for (int i = packages.length - 1; i >= 0; --i) { - if (mCallingPackage.equals(packages[i])) { + if (pkg.equals(packages[i])) { return true; } }