Added tap behavior to rows in OngoingPrivacyDialog
The rows now direct to Permission Hub information for that app. Test: manual Test: previous Unit tests passing Change-Id: I09e1205ee2340f5095c9c59414ddd9db440915b7 Fixes: 123415277
This commit is contained in:
@@ -2305,8 +2305,8 @@
|
||||
<item quantity="other"><xliff:g id="num_apps" example="3">%1$d</xliff:g> applications are using your <xliff:g id="type" example="camera">%2$s</xliff:g>.</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Action on Ongoing Privacy Dialog to dismiss [CHAR LIMIT=10]-->
|
||||
<string name="ongoing_privacy_dialog_cancel">Cancel</string>
|
||||
<!-- Action for accepting the Ongoing privacy dialog [CHAR LIMIT=10]-->
|
||||
<string name="ongoing_privacy_dialog_ok">Got it</string>
|
||||
|
||||
<!-- Action on Ongoing Privacy Dialog to open privacy hub [CHAR LIMIT=20]-->
|
||||
<string name="ongoing_privacy_dialog_open_settings">View details</string>
|
||||
@@ -2337,6 +2337,7 @@
|
||||
<item quantity="one"><xliff:g id="num_apps" example="1">%d</xliff:g> other app</item>
|
||||
<item quantity="other"><xliff:g id="num_apps" example="3">%d</xliff:g> other apps</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Text for the quick setting tile for sensor privacy [CHAR LIMIT=30] -->
|
||||
<string name="sensor_privacy_mode">Sensors off</string>
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.UserHandle
|
||||
import android.util.IconDrawableFactory
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
@@ -48,6 +49,7 @@ class OngoingPrivacyDialog constructor(
|
||||
R.dimen.ongoing_appops_dialog_icon_margin)
|
||||
private val MAX_ITEMS = context.resources.getInteger(R.integer.ongoing_appops_dialog_max_apps)
|
||||
private val iconFactory = IconDrawableFactory.newInstance(context, true)
|
||||
private var dismissDialog: (() -> Unit)? = null
|
||||
|
||||
init {
|
||||
val a = context.theme.obtainStyledAttributes(
|
||||
@@ -58,8 +60,8 @@ class OngoingPrivacyDialog constructor(
|
||||
|
||||
fun createDialog(): Dialog {
|
||||
val builder = AlertDialog.Builder(context).apply {
|
||||
setNegativeButton(R.string.ongoing_privacy_dialog_cancel, null)
|
||||
setPositiveButton(R.string.ongoing_privacy_dialog_open_settings,
|
||||
setPositiveButton(R.string.ongoing_privacy_dialog_ok, null)
|
||||
setNeutralButton(R.string.ongoing_privacy_dialog_open_settings,
|
||||
object : DialogInterface.OnClickListener {
|
||||
val intent = Intent(Intent.ACTION_REVIEW_PERMISSION_USAGE).putExtra(
|
||||
Intent.EXTRA_DURATION_MILLIS, TimeUnit.MINUTES.toMillis(1))
|
||||
@@ -72,7 +74,9 @@ class OngoingPrivacyDialog constructor(
|
||||
})
|
||||
}
|
||||
builder.setView(getContentView())
|
||||
return builder.create()
|
||||
val dialog = builder.create()
|
||||
dismissDialog = dialog::dismiss
|
||||
return dialog
|
||||
}
|
||||
|
||||
fun getContentView(): View {
|
||||
@@ -116,6 +120,7 @@ class OngoingPrivacyDialog constructor(
|
||||
return contentView
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun addAppItem(
|
||||
itemList: LinearLayout,
|
||||
app: PrivacyApplication,
|
||||
@@ -152,6 +157,16 @@ class OngoingPrivacyDialog constructor(
|
||||
} else {
|
||||
icons.visibility = View.GONE
|
||||
}
|
||||
item.setOnClickListener(object : View.OnClickListener {
|
||||
val intent = Intent(Intent.ACTION_REVIEW_APP_PERMISSION_USAGE)
|
||||
.putExtra(Intent.EXTRA_PACKAGE_NAME, app.packageName)
|
||||
.putExtra(Intent.EXTRA_USER, UserHandle.getUserHandleForUid(app.uid))
|
||||
override fun onClick(v: View?) {
|
||||
Dependency.get(ActivityStarter::class.java)
|
||||
.postStartActivityDismissingKeyguard(intent, 0)
|
||||
dismissDialog?.invoke()
|
||||
}
|
||||
})
|
||||
itemList.addView(item)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ data class PrivacyItem(
|
||||
val application: PrivacyApplication
|
||||
)
|
||||
|
||||
data class PrivacyApplication(val packageName: String, val context: Context)
|
||||
data class PrivacyApplication(val packageName: String, val uid: Int, val context: Context)
|
||||
: Comparable<PrivacyApplication> {
|
||||
|
||||
override fun compareTo(other: PrivacyApplication): Int {
|
||||
|
||||
@@ -59,7 +59,8 @@ class PrivacyItemController @Inject constructor(val context: Context) {
|
||||
@Suppress("DEPRECATION")
|
||||
private val uiHandler = Dependency.get(Dependency.MAIN_HANDLER)
|
||||
private var listening = false
|
||||
val systemApp = PrivacyApplication(context.getString(R.string.device_services), context)
|
||||
val systemApp =
|
||||
PrivacyApplication(context.getString(R.string.device_services), SYSTEM_UID, context)
|
||||
private val callbacks = mutableListOf<WeakReference<Callback>>()
|
||||
|
||||
private val notifyChanges = Runnable {
|
||||
@@ -162,7 +163,7 @@ class PrivacyItemController @Inject constructor(val context: Context) {
|
||||
else -> return null
|
||||
}
|
||||
if (appOpItem.uid == SYSTEM_UID) return PrivacyItem(type, systemApp)
|
||||
val app = PrivacyApplication(appOpItem.packageName, context)
|
||||
val app = PrivacyApplication(appOpItem.packageName, appOpItem.uid, context)
|
||||
return PrivacyItem(type, app)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,16 +27,20 @@ import org.junit.runner.RunWith
|
||||
@SmallTest
|
||||
class PrivacyDialogBuilderTest : SysuiTestCase() {
|
||||
|
||||
companion object {
|
||||
val TEST_UID = 1
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGenerateAppsList() {
|
||||
val bar2 = PrivacyItem(Privacy.TYPE_CAMERA, PrivacyApplication(
|
||||
"Bar", context))
|
||||
"Bar", TEST_UID, context))
|
||||
val bar3 = PrivacyItem(Privacy.TYPE_LOCATION, PrivacyApplication(
|
||||
"Bar", context))
|
||||
"Bar", TEST_UID, context))
|
||||
val foo0 = PrivacyItem(Privacy.TYPE_CAMERA, PrivacyApplication(
|
||||
"Foo", context))
|
||||
"Foo", TEST_UID, context))
|
||||
val baz1 = PrivacyItem(Privacy.TYPE_CAMERA, PrivacyApplication(
|
||||
"Baz", context))
|
||||
"Baz", TEST_UID, context))
|
||||
|
||||
val items = listOf(bar2, foo0, baz1, bar3)
|
||||
|
||||
@@ -55,11 +59,14 @@ class PrivacyDialogBuilderTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun testOrder() {
|
||||
// We want location to always go last, so it will go in the "+ other apps"
|
||||
val appCamera = PrivacyItem(PrivacyType.TYPE_CAMERA, PrivacyApplication("Camera", context))
|
||||
val appCamera = PrivacyItem(PrivacyType.TYPE_CAMERA,
|
||||
PrivacyApplication("Camera", TEST_UID, context))
|
||||
val appMicrophone =
|
||||
PrivacyItem(PrivacyType.TYPE_MICROPHONE, PrivacyApplication("Microphone", context))
|
||||
PrivacyItem(PrivacyType.TYPE_MICROPHONE,
|
||||
PrivacyApplication("Microphone", TEST_UID, context))
|
||||
val appLocation =
|
||||
PrivacyItem(PrivacyType.TYPE_LOCATION, PrivacyApplication("Location", context))
|
||||
PrivacyItem(PrivacyType.TYPE_LOCATION,
|
||||
PrivacyApplication("Location", TEST_UID, context))
|
||||
|
||||
val items = listOf(appLocation, appMicrophone, appCamera)
|
||||
val textBuilder = PrivacyDialogBuilder(context, items)
|
||||
|
||||
Reference in New Issue
Block a user