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

Commit 4f58b60c authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Automerger Merge Worker
Browse files

Merge "Adding logging to NotificationShadeWindowController" into tm-qpr-dev am: 56fbcccf

parents aa12d42a 56fbcccf
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.plugins.log

import com.google.errorprone.annotations.CompileTimeConstant

/**
 * Handy for adding basic logging with CompileTimeConstant strings - so logging with no variables.
 * Most likely you want to delegate it to [ConstantStringsLoggerImpl].
 */
interface ConstantStringsLogger {
    fun v(@CompileTimeConstant msg: String)

    fun d(@CompileTimeConstant msg: String)

    fun w(@CompileTimeConstant msg: String)

    fun e(@CompileTimeConstant msg: String)
}
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.plugins.log

import com.google.errorprone.annotations.CompileTimeConstant

class ConstantStringsLoggerImpl(val buffer: LogBuffer, val tag: String) : ConstantStringsLogger {
    override fun v(@CompileTimeConstant msg: String) = buffer.log(tag, LogLevel.VERBOSE, msg)

    override fun d(@CompileTimeConstant msg: String) = buffer.log(tag, LogLevel.DEBUG, msg)

    override fun w(@CompileTimeConstant msg: String) = buffer.log(tag, LogLevel.WARNING, msg)

    override fun e(@CompileTimeConstant msg: String) = buffer.log(tag, LogLevel.ERROR, msg)
}
+4 −9
Original line number Diff line number Diff line
@@ -17,12 +17,13 @@
package com.android.keyguard.logging

import com.android.systemui.log.dagger.KeyguardLog
import com.android.systemui.plugins.log.ConstantStringsLogger
import com.android.systemui.plugins.log.ConstantStringsLoggerImpl
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel.DEBUG
import com.android.systemui.plugins.log.LogLevel.ERROR
import com.android.systemui.plugins.log.LogLevel.INFO
import com.android.systemui.plugins.log.LogLevel.VERBOSE
import com.android.systemui.plugins.log.LogLevel.WARNING
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject

@@ -33,14 +34,8 @@ private const val TAG = "KeyguardLog"
 * temporary logs or logs for smaller classes when creating whole new [LogBuffer] wrapper might be
 * an overkill.
 */
class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuffer) {
    fun d(@CompileTimeConstant msg: String) = buffer.log(TAG, DEBUG, msg)

    fun e(@CompileTimeConstant msg: String) = buffer.log(TAG, ERROR, msg)

    fun v(@CompileTimeConstant msg: String) = buffer.log(TAG, VERBOSE, msg)

    fun w(@CompileTimeConstant msg: String) = buffer.log(TAG, WARNING, msg)
class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuffer) :
    ConstantStringsLogger by ConstantStringsLoggerImpl(buffer, TAG) {

    fun logException(ex: Exception, @CompileTimeConstant logMsg: String) {
        buffer.log(TAG, ERROR, {}, { logMsg }, exception = ex)
+8 −0
Original line number Diff line number Diff line
@@ -94,6 +94,14 @@ public class LogModule {
        return factory.create("LSShadeTransitionLog", 50);
    }

    /** Provides a logging buffer for shade window messages. */
    @Provides
    @SysUISingleton
    @ShadeWindowLog
    public static LogBuffer provideShadeWindowLogBuffer(LogBufferFactory factory) {
        return factory.create("ShadeWindowLog", 600, false);
    }

    /** Provides a logging buffer for Shade messages. */
    @Provides
    @SysUISingleton
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.plugins.log.LogBuffer;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;

import javax.inject.Qualifier;

/** A {@link LogBuffer} for shade window modification messages. */
@Qualifier
@Documented
@Retention(RUNTIME)
public @interface ShadeWindowLog {
}
Loading