Merge "Unsuppress the sensor privacy dialog immediately positive action" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6984f885d6
@@ -28,6 +28,7 @@ import android.hardware.SensorPrivacyManager.EXTRA_SENSOR
|
|||||||
import android.hardware.SensorPrivacyManager.INDIVIDUAL_SENSOR_CAMERA
|
import android.hardware.SensorPrivacyManager.INDIVIDUAL_SENSOR_CAMERA
|
||||||
import android.hardware.SensorPrivacyManager.INDIVIDUAL_SENSOR_MICROPHONE
|
import android.hardware.SensorPrivacyManager.INDIVIDUAL_SENSOR_MICROPHONE
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.android.internal.app.AlertActivity
|
import com.android.internal.app.AlertActivity
|
||||||
@@ -43,10 +44,13 @@ class SensorUseStartedActivity : AlertActivity(), DialogInterface.OnClickListene
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val LOG_TAG = SensorUseStartedActivity::class.java.simpleName
|
private val LOG_TAG = SensorUseStartedActivity::class.java.simpleName
|
||||||
|
|
||||||
|
private const val SUPPRESS_REMINDERS_REMOVAL_DELAY_MILLIS = 2000L
|
||||||
}
|
}
|
||||||
|
|
||||||
private var sensor = -1
|
private var sensor = -1
|
||||||
private lateinit var sensorUsePackageName: String
|
private lateinit var sensorUsePackageName: String
|
||||||
|
private var unsuppressImmediately = false
|
||||||
|
|
||||||
private lateinit var sensorPrivacyManager: SensorPrivacyManager
|
private lateinit var sensorPrivacyManager: SensorPrivacyManager
|
||||||
private lateinit var appOpsManager: AppOpsManager
|
private lateinit var appOpsManager: AppOpsManager
|
||||||
@@ -118,6 +122,7 @@ class SensorUseStartedActivity : AlertActivity(), DialogInterface.OnClickListene
|
|||||||
super.onStart()
|
super.onStart()
|
||||||
|
|
||||||
sensorPrivacyManager.suppressIndividualSensorPrivacyReminders(sensorUsePackageName, true)
|
sensorPrivacyManager.suppressIndividualSensorPrivacyReminders(sensorUsePackageName, true)
|
||||||
|
unsuppressImmediately = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(dialog: DialogInterface?, which: Int) {
|
override fun onClick(dialog: DialogInterface?, which: Int) {
|
||||||
@@ -131,16 +136,16 @@ class SensorUseStartedActivity : AlertActivity(), DialogInterface.OnClickListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDismissSucceeded() {
|
override fun onDismissSucceeded() {
|
||||||
sensorPrivacyManager
|
disableSensorPrivacy()
|
||||||
.setIndividualSensorPrivacyForProfileGroup(sensor, false)
|
|
||||||
setResult(RESULT_OK)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
sensorPrivacyManager.setIndividualSensorPrivacyForProfileGroup(sensor, false)
|
disableSensorPrivacy()
|
||||||
setResult(RESULT_OK)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BUTTON_NEGATIVE -> {
|
||||||
|
unsuppressImmediately = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dismiss()
|
dismiss()
|
||||||
@@ -149,10 +154,24 @@ class SensorUseStartedActivity : AlertActivity(), DialogInterface.OnClickListene
|
|||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
|
||||||
sensorPrivacyManager.suppressIndividualSensorPrivacyReminders(sensorUsePackageName, false)
|
if (unsuppressImmediately) {
|
||||||
|
sensorPrivacyManager
|
||||||
|
.suppressIndividualSensorPrivacyReminders(sensorUsePackageName, false)
|
||||||
|
} else {
|
||||||
|
Handler(mainLooper).postDelayed({
|
||||||
|
sensorPrivacyManager
|
||||||
|
.suppressIndividualSensorPrivacyReminders(sensorUsePackageName, false)
|
||||||
|
}, SUPPRESS_REMINDERS_REMOVAL_DELAY_MILLIS)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
// do not allow backing out
|
// do not allow backing out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun disableSensorPrivacy() {
|
||||||
|
sensorPrivacyManager.setIndividualSensorPrivacyForProfileGroup(sensor, false)
|
||||||
|
unsuppressImmediately = true
|
||||||
|
setResult(RESULT_OK)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -105,8 +105,6 @@ public final class SensorPrivacyService extends SystemService {
|
|||||||
|
|
||||||
private static final String TAG = "SensorPrivacyService";
|
private static final String TAG = "SensorPrivacyService";
|
||||||
|
|
||||||
private static final int SUPPRESS_REMINDERS_REMOVAL_DELAY_MILLIS = 2000;
|
|
||||||
|
|
||||||
/** Version number indicating compatibility parsing the persisted file */
|
/** Version number indicating compatibility parsing the persisted file */
|
||||||
private static final int CURRENT_PERSISTENCE_VERSION = 1;
|
private static final int CURRENT_PERSISTENCE_VERSION = 1;
|
||||||
/** Version number indicating the persisted data needs upgraded to match new internal data
|
/** Version number indicating the persisted data needs upgraded to match new internal data
|
||||||
@@ -756,10 +754,7 @@ public final class SensorPrivacyService extends SystemService {
|
|||||||
|
|
||||||
suppressPackageReminderTokens.add(token);
|
suppressPackageReminderTokens.add(token);
|
||||||
} else {
|
} else {
|
||||||
mHandler.postDelayed(PooledLambda.obtainRunnable(
|
mHandler.removeSuppressPackageReminderToken(key, token);
|
||||||
SensorPrivacyServiceImpl::removeSuppressPackageReminderToken,
|
|
||||||
this, key, token),
|
|
||||||
SUPPRESS_REMINDERS_REMOVAL_DELAY_MILLIS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1110,6 +1105,13 @@ public final class SensorPrivacyService extends SystemService {
|
|||||||
}
|
}
|
||||||
listeners.finishBroadcast();
|
listeners.finishBroadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSuppressPackageReminderToken(Pair<String, UserHandle> key,
|
||||||
|
IBinder token) {
|
||||||
|
sendMessage(PooledLambda.obtainMessage(
|
||||||
|
SensorPrivacyServiceImpl::removeSuppressPackageReminderToken,
|
||||||
|
mSensorPrivacyServiceImpl, key, token));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class DeathRecipient implements IBinder.DeathRecipient {
|
private final class DeathRecipient implements IBinder.DeathRecipient {
|
||||||
|
|||||||
Reference in New Issue
Block a user