Merge changes from topic "b235268992_debug_command_tm_dev" into tm-dev am: ae7ebc5107
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18819107 Change-Id: I955fb551d70d7a25069cf855a171fdb5cd6d30bc Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.notification.collection.provider
|
package com.android.systemui.statusbar.notification.collection.provider
|
||||||
|
|
||||||
import android.content.BroadcastReceiver
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.IntentFilter
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.android.systemui.Dumpable
|
import com.android.systemui.Dumpable
|
||||||
@@ -41,17 +37,12 @@ import javax.inject.Inject
|
|||||||
* The only configuration is a list of allowed packages. When this list is empty, the feature is
|
* The only configuration is a list of allowed packages. When this list is empty, the feature is
|
||||||
* disabled. When SystemUI starts up, this feature is disabled.
|
* disabled. When SystemUI starts up, this feature is disabled.
|
||||||
*
|
*
|
||||||
* To enabled filtering, provide the list of packages in a comma-separated list using the command:
|
* To enabled filtering, provide the space-separated list of packages using the command:
|
||||||
*
|
*
|
||||||
* `$ adb shell am broadcast -a com.android.systemui.action.SET_NOTIF_DEBUG_MODE
|
|
||||||
* --esal allowed_packages <comma-separated-packages>`
|
|
||||||
* or
|
|
||||||
* `$ adb shell cmd statusbar notif-filter allowed-pkgs <package> ...`
|
* `$ adb shell cmd statusbar notif-filter allowed-pkgs <package> ...`
|
||||||
*
|
*
|
||||||
* To disable filtering, send the action without a list:
|
* To disable filtering, send the command without any packages, or explicitly reset:
|
||||||
*
|
*
|
||||||
* `$ adb shell am broadcast -a com.android.systemui.action.SET_NOTIF_DEBUG_MODE`
|
|
||||||
* or
|
|
||||||
* `$ adb shell cmd statusbar notif-filter reset`
|
* `$ adb shell cmd statusbar notif-filter reset`
|
||||||
*
|
*
|
||||||
* NOTE: this feature only works on debug builds, and when the broadcaster is root.
|
* NOTE: this feature only works on debug builds, and when the broadcaster is root.
|
||||||
@@ -59,7 +50,6 @@ import javax.inject.Inject
|
|||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
class DebugModeFilterProvider @Inject constructor(
|
class DebugModeFilterProvider @Inject constructor(
|
||||||
private val commandRegistry: CommandRegistry,
|
private val commandRegistry: CommandRegistry,
|
||||||
private val context: Context,
|
|
||||||
dumpManager: DumpManager
|
dumpManager: DumpManager
|
||||||
) : Dumpable {
|
) : Dumpable {
|
||||||
private var allowedPackages: List<String> = emptyList()
|
private var allowedPackages: List<String> = emptyList()
|
||||||
@@ -82,10 +72,7 @@ class DebugModeFilterProvider @Inject constructor(
|
|||||||
listeners.addIfAbsent(listener)
|
listeners.addIfAbsent(listener)
|
||||||
if (needsInitialization) {
|
if (needsInitialization) {
|
||||||
commandRegistry.registerCommand("notif-filter") { NotifFilterCommand() }
|
commandRegistry.registerCommand("notif-filter") { NotifFilterCommand() }
|
||||||
val filter = IntentFilter().apply { addAction(ACTION_SET_NOTIF_DEBUG_MODE) }
|
Log.d(TAG, "Registered notif-filter command")
|
||||||
val permission = NOTIF_DEBUG_MODE_PERMISSION
|
|
||||||
context.registerReceiver(mReceiver, filter, permission, null, Context.RECEIVER_EXPORTED)
|
|
||||||
Log.d(TAG, "Registered: $mReceiver")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,31 +95,8 @@ class DebugModeFilterProvider @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val mReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
|
||||||
override fun onReceive(context: Context, intent: Intent?) {
|
|
||||||
val action = intent?.action
|
|
||||||
if (ACTION_SET_NOTIF_DEBUG_MODE == action) {
|
|
||||||
// TODO(b/235268992) remove
|
|
||||||
Log.d(TAG, "ACTION_SET_NOTIF_DEBUG_MODE enter")
|
|
||||||
allowedPackages = intent.extras?.getStringArrayList(EXTRA_ALLOWED_PACKAGES)
|
|
||||||
?: emptyList()
|
|
||||||
Log.d(TAG, "Updated allowedPackages: $allowedPackages")
|
|
||||||
listeners.forEach(Runnable::run)
|
|
||||||
// TODO(b/235268992) remove
|
|
||||||
Log.d(TAG, "ACTION_SET_NOTIF_DEBUG_MODE leave")
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Malformed intent: $intent")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "DebugModeFilterProvider"
|
private const val TAG = "DebugModeFilterProvider"
|
||||||
private const val ACTION_SET_NOTIF_DEBUG_MODE =
|
|
||||||
"com.android.systemui.action.SET_NOTIF_DEBUG_MODE"
|
|
||||||
private const val NOTIF_DEBUG_MODE_PERMISSION =
|
|
||||||
"com.android.systemui.permission.NOTIF_DEBUG_MODE"
|
|
||||||
private const val EXTRA_ALLOWED_PACKAGES = "allowed_packages"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class NotifFilterCommand : Command {
|
inner class NotifFilterCommand : Command {
|
||||||
|
|||||||
Reference in New Issue
Block a user