Loading packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +12 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,18 @@ public class LogModule { return buffer; } /** Provides a logging buffer for all logs related to privacy indicators in SystemUI. */ @Provides @SysUISingleton @PrivacyLog public static LogBuffer providePrivacyLogBuffer( LogcatEchoTracker bufferFilter, DumpManager dumpManager) { LogBuffer buffer = new LogBuffer(("PrivacyLog"), 100, 10, bufferFilter); buffer.attach(dumpManager); return buffer; } /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */ @Provides @SysUISingleton Loading packages/SystemUI/src/com/android/systemui/log/dagger/PrivacyLog.java 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.log.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.log.LogBuffer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import javax.inject.Qualifier; /** A {@link LogBuffer} for privacy indicator-related messages. */ @Qualifier @Documented @Retention(RUNTIME) public @interface PrivacyLog { } packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt +19 −8 Original line number Diff line number Diff line Loading @@ -19,20 +19,31 @@ import com.android.systemui.R typealias Privacy = PrivacyType enum class PrivacyType(val nameId: Int, val iconId: Int) { enum class PrivacyType(val nameId: Int, val iconId: Int, val logName: String) { // This is uses the icons used by the corresponding permission groups in the AndroidManifest TYPE_CAMERA(R.string.privacy_type_camera, com.android.internal.R.drawable.perm_group_camera), TYPE_MICROPHONE(R.string.privacy_type_microphone, com.android.internal.R.drawable.perm_group_microphone), TYPE_LOCATION(R.string.privacy_type_location, com.android.internal.R.drawable.perm_group_location); TYPE_CAMERA( R.string.privacy_type_camera, com.android.internal.R.drawable.perm_group_camera, "camera" ), TYPE_MICROPHONE( R.string.privacy_type_microphone, com.android.internal.R.drawable.perm_group_microphone, "microphone" ), TYPE_LOCATION( R.string.privacy_type_location, com.android.internal.R.drawable.perm_group_location, "location" ); fun getName(context: Context) = context.resources.getString(nameId) fun getIcon(context: Context) = context.resources.getDrawable(iconId, context.theme) } data class PrivacyItem(val privacyType: PrivacyType, val application: PrivacyApplication) data class PrivacyItem(val privacyType: PrivacyType, val application: PrivacyApplication) { fun toLog(): String = "(${privacyType.logName}, ${application.packageName}(${application.uid}))" } data class PrivacyApplication(val packageName: String, val uid: Int) packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt +6 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager import com.android.systemui.privacy.logging.PrivacyLogger import com.android.systemui.settings.UserTracker import com.android.systemui.util.DeviceConfigProxy import com.android.systemui.util.concurrency.DelayableExecutor Loading @@ -48,6 +49,7 @@ class PrivacyItemController @Inject constructor( @Background private val bgExecutor: Executor, private val deviceConfigProxy: DeviceConfigProxy, private val userTracker: UserTracker, private val logger: PrivacyLogger, dumpManager: DumpManager ) : Dumpable { Loading Loading @@ -158,6 +160,7 @@ class PrivacyItemController @Inject constructor( } val userId = UserHandle.getUserId(uid) if (userId in currentUserIds) { logger.logUpdatedItemFromAppOps(code, uid, packageName, active) update(false) } } Loading Loading @@ -194,6 +197,7 @@ class PrivacyItemController @Inject constructor( bgExecutor.execute { if (updateUsers) { currentUserIds = userTracker.userProfiles.map { it.id } logger.logCurrentProfilesChanged(currentUserIds) } updateListAndNotifyChanges.run() } Loading Loading @@ -260,6 +264,8 @@ class PrivacyItemController @Inject constructor( } val list = currentUserIds.flatMap { appOpsController.getActiveAppOpsForUser(it) } .mapNotNull { toPrivacyItem(it) }.distinct() logger.logUpdatedPrivacyItemsList( list.joinToString(separator = ", ", transform = PrivacyItem::toLog)) privacyList = list } Loading packages/SystemUI/src/com/android/systemui/privacy/logging/PrivacyLogger.kt 0 → 100644 +87 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.privacy.logging import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogLevel import com.android.systemui.log.LogMessage import com.android.systemui.log.dagger.PrivacyLog import javax.inject.Inject private const val TAG = "PrivacyLog" class PrivacyLogger @Inject constructor( @PrivacyLog private val buffer: LogBuffer ) { fun logUpdatedItemFromAppOps(code: Int, uid: Int, packageName: String, active: Boolean) { log(LogLevel.INFO, { int1 = code int2 = uid str1 = packageName bool1 = active }, { "App Op: $int1 for $str1($int2), active=$bool1" }) } fun logUpdatedPrivacyItemsList(listAsString: String) { log(LogLevel.INFO, { str1 = listAsString }, { "Updated list: $str1" }) } fun logCurrentProfilesChanged(profiles: List<Int>) { log(LogLevel.INFO, { str1 = profiles.toString() }, { "Profiles changed: $str1" }) } fun logChipVisible(visible: Boolean) { log(LogLevel.INFO, { bool1 = visible }, { "Chip visible: $bool1" }) } fun logStatusBarIconsVisible( showCamera: Boolean, showMichrophone: Boolean, showLocation: Boolean ) { log(LogLevel.INFO, { bool1 = showCamera bool2 = showMichrophone bool3 = showLocation }, { "Status bar icons visible: camera=$bool1, microphone=$bool2, location=$bool3" }) } private inline fun log( logLevel: LogLevel, initializer: LogMessage.() -> Unit, noinline printer: LogMessage.() -> String ) { buffer.log(TAG, logLevel, initializer, printer) } } No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +12 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,18 @@ public class LogModule { return buffer; } /** Provides a logging buffer for all logs related to privacy indicators in SystemUI. */ @Provides @SysUISingleton @PrivacyLog public static LogBuffer providePrivacyLogBuffer( LogcatEchoTracker bufferFilter, DumpManager dumpManager) { LogBuffer buffer = new LogBuffer(("PrivacyLog"), 100, 10, bufferFilter); buffer.attach(dumpManager); return buffer; } /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */ @Provides @SysUISingleton Loading
packages/SystemUI/src/com/android/systemui/log/dagger/PrivacyLog.java 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.log.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.log.LogBuffer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import javax.inject.Qualifier; /** A {@link LogBuffer} for privacy indicator-related messages. */ @Qualifier @Documented @Retention(RUNTIME) public @interface PrivacyLog { }
packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt +19 −8 Original line number Diff line number Diff line Loading @@ -19,20 +19,31 @@ import com.android.systemui.R typealias Privacy = PrivacyType enum class PrivacyType(val nameId: Int, val iconId: Int) { enum class PrivacyType(val nameId: Int, val iconId: Int, val logName: String) { // This is uses the icons used by the corresponding permission groups in the AndroidManifest TYPE_CAMERA(R.string.privacy_type_camera, com.android.internal.R.drawable.perm_group_camera), TYPE_MICROPHONE(R.string.privacy_type_microphone, com.android.internal.R.drawable.perm_group_microphone), TYPE_LOCATION(R.string.privacy_type_location, com.android.internal.R.drawable.perm_group_location); TYPE_CAMERA( R.string.privacy_type_camera, com.android.internal.R.drawable.perm_group_camera, "camera" ), TYPE_MICROPHONE( R.string.privacy_type_microphone, com.android.internal.R.drawable.perm_group_microphone, "microphone" ), TYPE_LOCATION( R.string.privacy_type_location, com.android.internal.R.drawable.perm_group_location, "location" ); fun getName(context: Context) = context.resources.getString(nameId) fun getIcon(context: Context) = context.resources.getDrawable(iconId, context.theme) } data class PrivacyItem(val privacyType: PrivacyType, val application: PrivacyApplication) data class PrivacyItem(val privacyType: PrivacyType, val application: PrivacyApplication) { fun toLog(): String = "(${privacyType.logName}, ${application.packageName}(${application.uid}))" } data class PrivacyApplication(val packageName: String, val uid: Int)
packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt +6 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager import com.android.systemui.privacy.logging.PrivacyLogger import com.android.systemui.settings.UserTracker import com.android.systemui.util.DeviceConfigProxy import com.android.systemui.util.concurrency.DelayableExecutor Loading @@ -48,6 +49,7 @@ class PrivacyItemController @Inject constructor( @Background private val bgExecutor: Executor, private val deviceConfigProxy: DeviceConfigProxy, private val userTracker: UserTracker, private val logger: PrivacyLogger, dumpManager: DumpManager ) : Dumpable { Loading Loading @@ -158,6 +160,7 @@ class PrivacyItemController @Inject constructor( } val userId = UserHandle.getUserId(uid) if (userId in currentUserIds) { logger.logUpdatedItemFromAppOps(code, uid, packageName, active) update(false) } } Loading Loading @@ -194,6 +197,7 @@ class PrivacyItemController @Inject constructor( bgExecutor.execute { if (updateUsers) { currentUserIds = userTracker.userProfiles.map { it.id } logger.logCurrentProfilesChanged(currentUserIds) } updateListAndNotifyChanges.run() } Loading Loading @@ -260,6 +264,8 @@ class PrivacyItemController @Inject constructor( } val list = currentUserIds.flatMap { appOpsController.getActiveAppOpsForUser(it) } .mapNotNull { toPrivacyItem(it) }.distinct() logger.logUpdatedPrivacyItemsList( list.joinToString(separator = ", ", transform = PrivacyItem::toLog)) privacyList = list } Loading
packages/SystemUI/src/com/android/systemui/privacy/logging/PrivacyLogger.kt 0 → 100644 +87 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.privacy.logging import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogLevel import com.android.systemui.log.LogMessage import com.android.systemui.log.dagger.PrivacyLog import javax.inject.Inject private const val TAG = "PrivacyLog" class PrivacyLogger @Inject constructor( @PrivacyLog private val buffer: LogBuffer ) { fun logUpdatedItemFromAppOps(code: Int, uid: Int, packageName: String, active: Boolean) { log(LogLevel.INFO, { int1 = code int2 = uid str1 = packageName bool1 = active }, { "App Op: $int1 for $str1($int2), active=$bool1" }) } fun logUpdatedPrivacyItemsList(listAsString: String) { log(LogLevel.INFO, { str1 = listAsString }, { "Updated list: $str1" }) } fun logCurrentProfilesChanged(profiles: List<Int>) { log(LogLevel.INFO, { str1 = profiles.toString() }, { "Profiles changed: $str1" }) } fun logChipVisible(visible: Boolean) { log(LogLevel.INFO, { bool1 = visible }, { "Chip visible: $bool1" }) } fun logStatusBarIconsVisible( showCamera: Boolean, showMichrophone: Boolean, showLocation: Boolean ) { log(LogLevel.INFO, { bool1 = showCamera bool2 = showMichrophone bool3 = showLocation }, { "Status bar icons visible: camera=$bool1, microphone=$bool2, location=$bool3" }) } private inline fun log( logLevel: LogLevel, initializer: LogMessage.() -> Unit, noinline printer: LogMessage.() -> String ) { buffer.log(TAG, logLevel, initializer, printer) } } No newline at end of file