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

Commit ce28f538 authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge changes I696de567,I98fb31c7 into main

* changes:
  Move CustomTile specific stuff behind the interface in TileServices
  Migrate secondary non-critical functionality from QSTileImpl
parents 5f35f3fa 031b9313
Loading
Loading
Loading
Loading
+36 −4
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import com.android.systemui.log.LogcatEchoTrackerProd;
import com.android.systemui.log.table.TableLogBuffer;
import com.android.systemui.log.table.TableLogBufferFactory;
import com.android.systemui.qs.QSFragmentLegacy;
import com.android.systemui.qs.pipeline.shared.QSPipelineFlagsRepository;
import com.android.systemui.qs.pipeline.shared.TileSpec;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.util.Compile;
import com.android.systemui.util.wakelock.WakeLockLog;
@@ -37,6 +39,9 @@ import com.android.systemui.util.wakelock.WakeLockLog;
import dagger.Module;
import dagger.Provides;

import java.util.HashMap;
import java.util.Map;

/**
 * Dagger module for providing instances of {@link LogBuffer}.
 */
@@ -173,9 +178,36 @@ public class LogModule {
    @Provides
    @SysUISingleton
    @QSLog
    public static LogBuffer provideQuickSettingsLogBuffer(LogBufferFactory factory) {
    public static LogBuffer provideQuickSettingsLogBuffer(
            LogBufferFactory factory,
            QSPipelineFlagsRepository flags
    ) {
        if (flags.getPipelineTilesEnabled()) {
            // we use
            return factory.create("QSLog", 450 /* maxSize */, false /* systrace */);
        } else {
            return factory.create("QSLog", 700 /* maxSize */, false /* systrace */);
        }
    }

    /**
     * Provides a logging buffer for all logs related to Quick Settings tiles. This LogBuffer is
     * unique for each tile.
     * go/qs-tile-refactor
     */
    @Provides
    @QSTilesDefaultLog
    public static LogBuffer provideQuickSettingsTilesLogBuffer(LogBufferFactory factory) {
        return factory.create("QSTileLog", 25 /* maxSize */, false /* systrace */);
    }

    @Provides
    @QSTilesLogBuffers
    public static Map<TileSpec, LogBuffer> provideQuickSettingsTilesLogBufferCache() {
        final Map<TileSpec, LogBuffer> buffers = new HashMap<>();
        // Add chatty buffers here
        return buffers;
    }

    /** Provides a logging buffer for logs related to Quick Settings configuration. */
    @Provides
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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 javax.inject.Qualifier

/**
 * A default [com.android.systemui.log.LogBuffer] for QS tiles messages. It's used exclusively in
 * [com.android.systemui.qs.tiles.base.logging.QSTileLogger]. If you need to increase it for you
 * tile, add one to the map provided by the [QSTilesLogBuffers]
 */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class QSTilesDefaultLog
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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 javax.inject.Qualifier

/**
 * Provides a map with custom [com.android.systemui.log.LogBuffer] for QS tiles messages. Add
 * buffers to it when the tile needs to be more verbose and the default buffer provided by
 * [QSTilesDefaultLog] is not enough.
 *
 * This is not a multibinding. Add new logs directly to [LogModule]
 */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class QSTilesLogBuffers
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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 QS tiles messages. It's used exclusively in
 * {@link com.android.systemui.qs.tiles.base.logging.QSTileLogger}
 */
@Qualifier
@Documented
@Retention(RUNTIME)
public @interface QSTilesVerboseLog {
}
+14 −3
Original line number Diff line number Diff line
@@ -72,7 +72,8 @@ import dagger.assisted.Assisted;
import dagger.assisted.AssistedFactory;
import dagger.assisted.AssistedInject;

public class CustomTile extends QSTileImpl<State> implements TileChangeListener {
public class CustomTile extends QSTileImpl<State> implements TileChangeListener,
        CustomTileInterface {
    public static final String PREFIX = "custom(";

    private static final long CUSTOM_STALE_TIMEOUT = DateUtils.HOUR_IN_MILLIS;
@@ -181,7 +182,8 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
    private void updateDefaultTileAndIcon() {
        try {
            PackageManager pm = mUserContext.getPackageManager();
            int flags = PackageManager.MATCH_DIRECT_BOOT_UNAWARE | PackageManager.MATCH_DIRECT_BOOT_AWARE;
            int flags = PackageManager.MATCH_DIRECT_BOOT_UNAWARE
                    | PackageManager.MATCH_DIRECT_BOOT_AWARE;
            if (isSystemApp(pm)) {
                flags |= PackageManager.MATCH_DISABLED_COMPONENTS;
            }
@@ -252,10 +254,12 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
        }
    }

    @Override
    public int getUser() {
        return mUser;
    }

    @Override
    public ComponentName getComponent() {
        return mComponent;
    }
@@ -265,6 +269,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
        return super.populate(logMaker).setComponentName(mComponent);
    }

    @Override
    public Tile getQsTile() {
        // TODO(b/191145007) Move to background thread safely
        updateDefaultTileAndIcon();
@@ -276,6 +281,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
     *
     * @param tile tile populated with state to apply
     */
    @Override
    public void updateTileState(Tile tile, int appUid) {
        mServiceUid = appUid;
        // This comes from a binder call IQSService.updateQsTile
@@ -310,10 +316,12 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
        mTile.setState(tile.getState());
    }

    @Override
    public void onDialogShown() {
        mIsShowingDialog = true;
    }

    @Override
    public void onDialogHidden() {
        mIsShowingDialog = false;
        try {
@@ -507,6 +515,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
        return mComponent.getPackageName();
    }

    @Override
    public void startUnlockAndRun() {
        mActivityStarter.postQSRunnableDismissingKeyguard(() -> {
            try {
@@ -518,8 +527,10 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener

    /**
     * Starts an {@link android.app.Activity}
     *
     * @param pendingIntent A PendingIntent for an Activity to be launched immediately.
     */
    @Override
    public void startActivityAndCollapse(PendingIntent pendingIntent) {
        if (!pendingIntent.isActivity()) {
            Log.i(TAG, "Intent not for activity.");
Loading