From 1d1ac5b5a783e06ecda0adceda7df0af8a5566bc Mon Sep 17 00:00:00 2001 From: erfanian Date: Tue, 31 Oct 2017 09:12:03 -0700 Subject: Disable assisted dialing when the phone is User Locked. Because the phone is one of the few applications that operate when the phone is locked, disable the feature to avoid reading/writing any encrypted preferences while the user is in the locked state. I do not anticipate this being a necessary feature when the device is locked. Bug: 65399148 Test: unit test PiperOrigin-RevId: 174044403 Change-Id: I1b9a2ac677ced2af06455a384bf169c417ffc1a5 --- java/com/android/dialer/assisteddialing/ConcreteCreator.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'java') diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java index 9dc197c89..9244f6934 100644 --- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java +++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java @@ -22,6 +22,7 @@ import android.os.Build; import android.os.Build.VERSION_CODES; import android.preference.PreferenceManager; import android.support.annotation.NonNull; +import android.support.v4.os.UserManagerCompat; import android.telephony.TelephonyManager; import com.android.dialer.assisteddialing.ui.R; import com.android.dialer.common.LogUtil; @@ -65,6 +66,13 @@ public final class ConcreteCreator { throw new NullPointerException("Provided context was null"); } + if (!UserManagerCompat.isUserUnlocked(context)) { + // To avoid any issues reading preferences, we disable the feature when the user is in a + // locked state. + LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "user is locked"); + return new AssistedDialingMediatorStub(); + } + if (!isAssistedDialingEnabled(configProvider)) { LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "feature not enabled"); return new AssistedDialingMediatorStub(); -- cgit v1.2.3