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
diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
index 9dc197c..9244f69 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.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 @@
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();