Delay unmuting sensor when device is unlocked

The sensor privacy service also checks if the device is locked before
unmuting as an extra layer of security. It appears that the callback
when requesting unlock is invoked before the state in KeyguardManager is
updatd so we need to delay our call to unmute.

Test: Set pin and unblock camera
Fixes: 189946442
Change-Id: Ic9bf1a6abb9073acb11d9b569efcc665eacff63f
This commit is contained in:
Evan Severson
2021-06-04 10:04:58 -07:00
parent 7a19e4a94e
commit 26c2f8d320

View File

@@ -32,6 +32,7 @@ import android.widget.ImageView
import com.android.internal.app.AlertActivity
import com.android.internal.widget.DialogTitle
import com.android.systemui.R
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.statusbar.phone.KeyguardDismissUtil
import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController
import com.android.systemui.statusbar.policy.KeyguardStateController
@@ -46,13 +47,15 @@ import javax.inject.Inject
class SensorUseStartedActivity @Inject constructor(
private val sensorPrivacyController: IndividualSensorPrivacyController,
private val keyguardStateController: KeyguardStateController,
private val keyguardDismissUtil: KeyguardDismissUtil
private val keyguardDismissUtil: KeyguardDismissUtil,
@Background private val bgHandler: Handler
) : AlertActivity(), DialogInterface.OnClickListener {
companion object {
private val LOG_TAG = SensorUseStartedActivity::class.java.simpleName
private const val SUPPRESS_REMINDERS_REMOVAL_DELAY_MILLIS = 2000L
private const val UNLOCK_DELAY_MILLIS = 200L
private const val CAMERA = SensorPrivacyManager.Sensors.CAMERA
private const val MICROPHONE = SensorPrivacyManager.Sensors.MICROPHONE
@@ -179,9 +182,12 @@ class SensorUseStartedActivity @Inject constructor(
BUTTON_POSITIVE -> {
if (keyguardStateController.isMethodSecure && keyguardStateController.isShowing) {
keyguardDismissUtil.executeWhenUnlocked({
disableSensorPrivacy()
bgHandler.postDelayed({
disableSensorPrivacy()
}, UNLOCK_DELAY_MILLIS)
false
}, false, false)
}, false, true)
} else {
disableSensorPrivacy()
}
@@ -201,7 +207,7 @@ class SensorUseStartedActivity @Inject constructor(
sensorPrivacyController
.suppressSensorPrivacyReminders(sensorUsePackageName, false)
} else {
Handler(mainLooper).postDelayed({
bgHandler.postDelayed({
sensorPrivacyController
.suppressSensorPrivacyReminders(sensorUsePackageName, false)
}, SUPPRESS_REMINDERS_REMOVAL_DELAY_MILLIS)