Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6350a117 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add dumpsys logging for location op" into main

parents 5e076a0b b2454f9a
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -137,6 +137,18 @@ constructor(
                            code in USER_INDEPENDENT_OPS
                    ) {
                        logger.logUpdatedItemFromAppOps(code, uid, packageName, active)

                        val procInfo =
                            (activityManager.runningAppProcesses
                                ?: emptyList()).find { it.uid == uid }
                        val importance = procInfo?.importance ?: -1 // Use -1 if process not found
                        logger.logLocationAppOps(
                            uid,
                            packageName,
                            importance,
                            !isBackgroundApp(uid)
                        )

                        dispatchOnPrivacyItemsChanged()
                    }
                }
@@ -255,7 +267,7 @@ constructor(
                    .filter { item -> item.code == AppOpsManager.OP_FINE_LOCATION }
                    .distinct()
            val locationOpBySystem = locationOp.any { item -> isSystemApp(item) }
            val locationOpByBackground = locationOp.any { item -> isBackgroundApp(item) }
            val locationOpByBackground = locationOp.any { item -> isBackgroundApp(item.uid) }
            synchronized(lock) {
                lastLocationIndicator = items.any { it.privacyType == PrivacyType.TYPE_LOCATION }
                lastLocationIndicatorWithSystem = lastLocationIndicator || locationOpBySystem
@@ -378,7 +390,7 @@ constructor(

        if (item.code == AppOpsManager.OP_FINE_LOCATION) {
            val isSystem = isSystemApp(item)
            val isBackground = isBackgroundApp(item)
            val isBackground = isBackgroundApp(item.uid)
            if (isSystem) {
                synchronized(lock) { hasSystemLocationAccess = true }
            }
@@ -444,9 +456,9 @@ constructor(
     * <p>TODO(b/422799135): refactor isSystemApp() and isBackgroundApp(). Before this is fixed,
     * make sure to update PermissionUsageHelper when changing this method.
     */
    private fun isBackgroundApp(item: AppOpItem): Boolean {
    private fun isBackgroundApp(uid: Int): Boolean {
        for (processInfo in activityManager.runningAppProcesses) {
            if (processInfo.uid == item.uid) {
            if (processInfo.uid == uid) {
                return (processInfo.importance >
                    ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE)
            }
+15 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.privacy.logging

import android.app.ActivityManager
import android.content.Context
import android.icu.text.SimpleDateFormat
import android.permission.PermissionGroupUsage
import com.android.systemui.log.LogBuffer
@@ -45,6 +47,19 @@ class PrivacyLogger @Inject constructor(
        })
    }

    fun logLocationAppOps(uid: Int, packageName: String, importance: Int, isForeground: Boolean) {
        log(
            LogLevel.INFO, {
                int1 = uid
                int2 = importance
                str1 = packageName
                bool1 = isForeground
            },
            {
                "Location Op: $str1($int1) importance=$int2 isFg=$bool1"
            })
    }

    fun logUpdatedItemFromMediaProjection(uid: Int, packageName: String, active: Boolean) {
        log(LogLevel.INFO, {
            int1 = uid