summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res/values/strings.xml5
-rw-r--r--packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyDialog.kt21
-rw-r--r--packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogBuilderTest.kt21
5 files changed, 39 insertions, 15 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 190bd7ae91a2..ffa5de8de2b7 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -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>
diff --git a/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyDialog.kt b/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyDialog.kt
index 26c6d501f2cb..db5c244d95b2 100644
--- a/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyDialog.kt
@@ -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)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt
index 9252167d02bd..dbe87d1d53c6 100644
--- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt
+++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt
@@ -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 {
diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt
index 2339fae2d1ee..f1c3bf299eea 100644
--- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt
+++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt
@@ -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)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogBuilderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogBuilderTest.kt
index d3b3dae2c1cd..f163b88357cf 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogBuilderTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogBuilderTest.kt
@@ -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)