当前位置: 首页 > news >正文

Lineageos 22.1(Android 15)通知栏添加截图开关

一、前言

通知栏添加截图要注意一个问题,就是截图的时候要关闭通知栏,不然就直接截图通知栏了,然后就没有意义了。

二、添加快捷开关

在下面的路径下添加开关,使用dagger注解注入即可。
lineageos/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/tiles/

/*
 * Copyright (C) 2014 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.qs.tiles;

import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.service.quicksettings.Tile;

import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.ScreenshotHelper;
import com.android.systemui.animation.Expandable;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.QsEventLogger;
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.res.R;
import com.android.systemui.shade.NotificationPanelViewController;

import javax.inject.Inject;

import androidx.annotation.Nullable;
import dagger.Lazy;

import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_ACCESSIBILITY_ACTIONS;
import static com.android.systemui.res.R.string.quick_settings_flashlight_label;

/**
 * Quick settings tile: Control flashlight
 **/
public class ScreenShotTile extends QSTileImpl<QSTile.State>  {

    public static final String TILE_SPEC = "screenshot";
    private final ScreenshotHelper mScreenshotHelper;
    private final Lazy<NotificationPanelViewController> mShadeViewControllerLazy;
    private boolean requestScreenShot=false;
    @Inject
    public ScreenShotTile(
            QSHost host,
            QsEventLogger uiEventLogger,
            @Background Looper backgroundLooper,
            @Main Handler mainHandler,
            FalsingManager falsingManager,
            MetricsLogger metricsLogger,
            StatusBarStateController statusBarStateController,
            ActivityStarter activityStarter,
            QSLogger qsLogger,
            Lazy<NotificationPanelViewController> shadeViewControllerLazy
    ) {
        super(host, uiEventLogger, backgroundLooper, mainHandler, falsingManager, metricsLogger,
                statusBarStateController, activityStarter, qsLogger);
        mScreenshotHelper = new ScreenshotHelper(mContext);
        mShadeViewControllerLazy = shadeViewControllerLazy;
        mShadeViewControllerLazy.get().setIOnPannelExpandListener(() -> {
            if(requestScreenShot){

                mScreenshotHelper.takeScreenshot(
                        SCREENSHOT_ACCESSIBILITY_ACTIONS, new Handler(Looper.getMainLooper()), uri -> {
                            //do something
                            requestScreenShot=false;
                        });
            }

        });

    }

    @Override
    protected void handleDestroy() {
        super.handleDestroy();
    }

    @Override
    public BooleanState newTileState() {
        BooleanState state = new BooleanState();
        state.handlesLongClick = false;
        return state;
    }

    @Override
    protected void handleUserSwitch(int newUserId) {
    }

    @Override
    public Intent getLongClickIntent() {
        return new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
    }

    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    protected void handleClick(@Nullable Expandable expandable) {

        mContext.getMainExecutor().execute(()->{
            requestScreenShot=true;
            mShadeViewControllerLazy.get().collapse(true,false /* delayed */, 1.0f );
        });

    }

    @Override
    protected void handleUpdateState(State state, Object arg) {
        state.icon = ResourceIcon.get(R.drawable.qs_flashlight_icon_off);
        state.label="ScreenShot";
        state.stateDescription = mContext.getString(quick_settings_flashlight_label);
        state.secondaryLabel="";
        state.state= Tile.STATE_ACTIVE;

    }

    @Override
    public CharSequence getTileLabel() {
        return "Screen shot";
    }

    @Override
    protected void handleLongClick(@Nullable Expandable expandable) {
        handleClick(expandable);
    }


    @Override
    public int getMetricsCategory() {
        return 0;
    }

}

加上finishi方法的回调
lineageos/frameworks/base/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java

  IOnPannelExpandListener  mIOnPannelExpandListener=null;

    public void setIOnPannelExpandListener(IOnPannelExpandListener IOnPannelExpandListener) {
        mIOnPannelExpandListener = IOnPannelExpandListener;
    }

    public interface IOnPannelExpandListener{
        void onExpandingFinished();
    }

    private void onExpandingFinished() {
        if (!SceneContainerFlag.isEnabled()) {
            mNotificationStackScrollLayoutController.onExpansionStopped();
        }
        mHeadsUpManager.onExpandingFinished();
        mConversationNotificationManager.onNotificationPanelExpandStateChanged(isFullyCollapsed());
        mIsExpandingOrCollapsing = false;
        mMediaHierarchyManager.setCollapsingShadeFromQS(false);
        mMediaHierarchyManager.setQsExpanded(mQsController.getExpanded());
        if (isFullyCollapsed()) {
           //加上下面的通知代码
            if(mIOnPannelExpandListener!=null){
                mIOnPannelExpandListener.onExpandingFinished();
            }
            DejankUtils.postAfterTraversal(() -> setListening(false));

            // Workaround b/22639032: Make sure we invalidate something because else RenderThread
            // thinks we are actually drawing a frame put in reality we don't, so RT doesn't go
            // ahead with rendering and we jank.
            mView.postOnAnimation(
                    () -> mView.getParent().invalidateChild(mView, M_DUMMY_DIRTY_RECT));
        } else {
            setListening(true);
        }
        if (mBarState != SHADE) {
            // TODO(b/277909752): remove below logs when bug is fixed
            mShadeLog.d("onExpandingFinished called");
            if (mSplitShadeEnabled && !mQsController.getExpanded()) {
                mShadeLog.d("onExpandingFinished called before QS got expanded");
            }
            // updating qsExpandImmediate is done in onPanelStateChanged for unlocked shade but
            // on keyguard panel state is always OPEN so we need to have that extra update
            mQsController.setExpandImmediate(false);
        }
        setShowShelfOnly(false);
        mQsController.setTwoFingerExpandPossible(false);
        mShadeHeadsUpTracker.updateTrackingHeadsUp(null);
        mExpandingFromHeadsUp = false;
        setPanelScrimMinFraction(0.0f);
        // Reset status bar alpha so alpha can be calculated upon updating view state.
        setKeyguardStatusBarAlpha(-1f);


    }

开关配置,上面下面都要加自定义的
/media/arcxea/stat/lineageos/frameworks/base/packages/SystemUI/res/values/config.xml

<!-- The default tiles to display in QuickSettings -->
    <string name="quick_settings_tiles_default" translatable="false">
        internet,bt,screenshot,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,custom(com.android.permissioncontroller/.permission.service.v33.SafetyCenterQsTileService)
    </string>
       <!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
    <string name="quick_settings_tiles_stock" translatable="false">
        internet,screenshot,wifi,cell,bt,flashlight,dnd,alarm,airplane,nfc,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,font_scaling,record_issue,hearing_devices,ambient_display,aod,caffeine,heads_up,powershare,profiles,reading_mode,sync,usb_tether,vpn
    </string>

接入dagger2的配置,照葫芦画瓢,参照其他的写就行了,这时候已经配置完成。

lineageos/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/PolicyModule.kt

/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use mHost 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.statusbar.policy

import android.hardware.SensorPrivacyManager.Sensors.CAMERA
import android.hardware.SensorPrivacyManager.Sensors.MICROPHONE
import android.os.UserManager.DISALLOW_CAMERA_TOGGLE
import android.os.UserManager.DISALLOW_CONFIG_LOCATION
import android.os.UserManager.DISALLOW_MICROPHONE_TOGGLE
import android.os.UserManager.DISALLOW_SHARE_LOCATION
import com.android.systemui.Flags
import com.android.systemui.modes.shared.ModesUi
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.AlarmTile
import com.android.systemui.qs.tiles.CameraToggleTile
import com.android.systemui.qs.tiles.DndTile
import com.android.systemui.qs.tiles.FlashlightTile
import com.android.systemui.qs.tiles.LocationTile
import com.android.systemui.qs.tiles.MicrophoneToggleTile
import com.android.systemui.qs.tiles.ModesTile
import com.android.systemui.qs.tiles.ScreenShotTile
import com.android.systemui.qs.tiles.UiModeNightTile
import com.android.systemui.qs.tiles.WorkModeTile
import com.android.systemui.qs.tiles.base.interactor.QSTileAvailabilityInteractor
import com.android.systemui.qs.tiles.base.viewmodel.QSTileViewModelFactory
import com.android.systemui.qs.tiles.impl.alarm.domain.AlarmTileMapper
import com.android.systemui.qs.tiles.impl.alarm.domain.interactor.AlarmTileDataInteractor
import com.android.systemui.qs.tiles.impl.alarm.domain.interactor.AlarmTileUserActionInteractor
import com.android.systemui.qs.tiles.impl.alarm.domain.model.AlarmTileModel
import com.android.systemui.qs.tiles.impl.flashlight.domain.FlashlightMapper
import com.android.systemui.qs.tiles.impl.flashlight.domain.interactor.FlashlightTileDataInteractor
import com.android.systemui.qs.tiles.impl.flashlight.domain.interactor.FlashlightTileUserActionInteractor
import com.android.systemui.qs.tiles.impl.flashlight.domain.model.FlashlightTileModel
import com.android.systemui.qs.tiles.impl.location.domain.LocationTileMapper
import com.android.systemui.qs.tiles.impl.location.domain.interactor.LocationTileDataInteractor
import com.android.systemui.qs.tiles.impl.location.domain.interactor.LocationTileUserActionInteractor
import com.android.systemui.qs.tiles.impl.location.domain.model.LocationTileModel
import com.android.systemui.qs.tiles.impl.modes.domain.interactor.ModesTileDataInteractor
import com.android.systemui.qs.tiles.impl.modes.domain.interactor.ModesTileUserActionInteractor
import com.android.systemui.qs.tiles.impl.modes.domain.model.ModesTileModel
import com.android.systemui.qs.tiles.impl.modes.ui.ModesTileMapper
import com.android.systemui.qs.tiles.impl.sensorprivacy.SensorPrivacyToggleTileDataInteractor
import com.android.systemui.qs.tiles.impl.sensorprivacy.domain.SensorPrivacyToggleTileUserActionInteractor
import com.android.systemui.qs.tiles.impl.sensorprivacy.domain.model.SensorPrivacyToggleTileModel
import com.android.systemui.qs.tiles.impl.sensorprivacy.ui.SensorPrivacyTileResources
import com.android.systemui.qs.tiles.impl.sensorprivacy.ui.SensorPrivacyToggleTileMapper
import com.android.systemui.qs.tiles.impl.uimodenight.domain.UiModeNightTileMapper
import com.android.systemui.qs.tiles.impl.uimodenight.domain.interactor.UiModeNightTileDataInteractor
import com.android.systemui.qs.tiles.impl.uimodenight.domain.interactor.UiModeNightTileUserActionInteractor
import com.android.systemui.qs.tiles.impl.uimodenight.domain.model.UiModeNightTileModel
import com.android.systemui.qs.tiles.impl.work.domain.interactor.WorkModeTileDataInteractor
import com.android.systemui.qs.tiles.impl.work.domain.interactor.WorkModeTileUserActionInteractor
import com.android.systemui.qs.tiles.impl.work.domain.model.WorkModeTileModel
import com.android.systemui.qs.tiles.impl.work.ui.WorkModeTileMapper
import com.android.systemui.qs.tiles.viewmodel.QSTileConfig
import com.android.systemui.qs.tiles.viewmodel.QSTilePolicy
import com.android.systemui.qs.tiles.viewmodel.QSTileUIConfig
import com.android.systemui.qs.tiles.viewmodel.QSTileViewModel
import com.android.systemui.qs.tiles.viewmodel.StubQSTileViewModel
import com.android.systemui.res.R
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.multibindings.IntoMap
import dagger.multibindings.StringKey
import javax.inject.Provider

@Module
interface PolicyModule {

    /** Inject WorkModeTile into tileMap in QSModule */
    @Binds
    @IntoMap
    @StringKey(WorkModeTile.TILE_SPEC)
    fun bindWorkModeTile(workModeTile: WorkModeTile): QSTileImpl<*>

    @Binds
    @IntoMap
    @StringKey(FLASHLIGHT_TILE_SPEC)
    fun provideAirplaneModeAvailabilityInteractor(
        impl: FlashlightTileDataInteractor
    ): QSTileAvailabilityInteractor

    @Binds
    @IntoMap
    @StringKey(LOCATION_TILE_SPEC)
    fun provideLocationAvailabilityInteractor(
        impl: LocationTileDataInteractor
    ): QSTileAvailabilityInteractor

    @Binds
    @IntoMap
    @StringKey(ALARM_TILE_SPEC)
    fun provideAlarmAvailabilityInteractor(
        impl: AlarmTileDataInteractor
    ): QSTileAvailabilityInteractor

    @Binds
    @IntoMap
    @StringKey(UIMODENIGHT_TILE_SPEC)
    fun provideUiModeNightAvailabilityInteractor(
        impl: UiModeNightTileDataInteractor
    ): QSTileAvailabilityInteractor

    @Binds
    @IntoMap
    @StringKey(WORK_MODE_TILE_SPEC)
    fun provideWorkModeAvailabilityInteractor(
        impl: WorkModeTileDataInteractor
    ): QSTileAvailabilityInteractor

    companion object {
        const val FLASHLIGHT_TILE_SPEC = "flashlight"
        const val LOCATION_TILE_SPEC = "location"
        const val ALARM_TILE_SPEC = "alarm"
        const val UIMODENIGHT_TILE_SPEC = "dark"
        const val WORK_MODE_TILE_SPEC = "work"
        const val CAMERA_TOGGLE_TILE_SPEC = "cameratoggle"
        const val MIC_TOGGLE_TILE_SPEC = "mictoggle"
        const val DND_TILE_SPEC = "dnd"
        const val SCREENSHOT_TILE_SPEC = "screenshot"



        /** Inject screenshot config */
        @Provides
        @IntoMap
        @StringKey(SCREENSHOT_TILE_SPEC)
        fun provideScreenShotTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            QSTileConfig(
                tileSpec = TileSpec.create(SCREENSHOT_TILE_SPEC),
                uiConfig =
                QSTileUIConfig.Resource(
                    iconRes = R.drawable.qs_flashlight_icon_off,
                    labelRes = R.string.quick_settings_flashlight_label,
                ),
                instanceId = uiEventLogger.getNewInstanceId(),
                category = TileCategory.UTILITIES,
            )

        /** Inject ScreenShotTile into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(SCREENSHOT_TILE_SPEC)
        fun provideScreenShotTileViewModel(
            factory: QSTileViewModelFactory.Static<FlashlightTileModel>,
            mapper: FlashlightMapper,
            stateInteractor: FlashlightTileDataInteractor,
            userActionInteractor: FlashlightTileUserActionInteractor,
        ): QSTileViewModel =
            factory.create(
                TileSpec.create(SCREENSHOT_TILE_SPEC),
                userActionInteractor,
                stateInteractor,
                mapper,
            )




        /** Inject DndTile or ModesTile into tileMap in QSModule based on feature flag */
        @Provides
        @IntoMap
        @StringKey(DND_TILE_SPEC)
        fun bindDndOrModesTile(
            // Using providers to make sure that the unused tile isn't initialised at all if the
            // flag is off.
            dndTile: Provider<DndTile>,
            modesTile: Provider<ModesTile>,
        ): QSTileImpl<*> {
            return if (ModesUi.isEnabled) modesTile.get() else dndTile.get()
        }

        /** Inject flashlight config */
        @Provides
        @IntoMap
        @StringKey(FLASHLIGHT_TILE_SPEC)
        fun provideFlashlightTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            QSTileConfig(
                tileSpec = TileSpec.create(FLASHLIGHT_TILE_SPEC),
                uiConfig =
                    QSTileUIConfig.Resource(
                        iconRes = R.drawable.qs_flashlight_icon_off,
                        labelRes = R.string.quick_settings_flashlight_label,
                    ),
                instanceId = uiEventLogger.getNewInstanceId(),
                category = TileCategory.UTILITIES,
            )

        /** Inject FlashlightTile into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(FLASHLIGHT_TILE_SPEC)
        fun provideFlashlightTileViewModel(
            factory: QSTileViewModelFactory.Static<FlashlightTileModel>,
            mapper: FlashlightMapper,
            stateInteractor: FlashlightTileDataInteractor,
            userActionInteractor: FlashlightTileUserActionInteractor,
        ): QSTileViewModel =
            factory.create(
                TileSpec.create(FLASHLIGHT_TILE_SPEC),
                userActionInteractor,
                stateInteractor,
                mapper,
            )

        /** Inject location config */
        @Provides
        @IntoMap
        @StringKey(LOCATION_TILE_SPEC)
        fun provideLocationTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            QSTileConfig(
                tileSpec = TileSpec.create(LOCATION_TILE_SPEC),
                uiConfig =
                    QSTileUIConfig.Resource(
                        iconRes = R.drawable.qs_location_icon_off,
                        labelRes = R.string.quick_settings_location_label,
                    ),
                instanceId = uiEventLogger.getNewInstanceId(),
                policy =
                    QSTilePolicy.Restricted(
                        listOf(DISALLOW_SHARE_LOCATION, DISALLOW_CONFIG_LOCATION)
                    ),
                category = TileCategory.PRIVACY,
            )

        /** Inject LocationTile into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(LOCATION_TILE_SPEC)
        fun provideLocationTileViewModel(
            factory: QSTileViewModelFactory.Static<LocationTileModel>,
            mapper: LocationTileMapper,
            stateInteractor: LocationTileDataInteractor,
            userActionInteractor: LocationTileUserActionInteractor,
        ): QSTileViewModel =
            factory.create(
                TileSpec.create(LOCATION_TILE_SPEC),
                userActionInteractor,
                stateInteractor,
                mapper,
            )

        /** Inject alarm config */
        @Provides
        @IntoMap
        @StringKey(ALARM_TILE_SPEC)
        fun provideAlarmTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            QSTileConfig(
                tileSpec = TileSpec.create(ALARM_TILE_SPEC),
                uiConfig =
                    QSTileUIConfig.Resource(
                        iconRes = R.drawable.ic_alarm,
                        labelRes = R.string.status_bar_alarm,
                    ),
                instanceId = uiEventLogger.getNewInstanceId(),
                category = TileCategory.UTILITIES,
            )

        /** Inject AlarmTile into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(ALARM_TILE_SPEC)
        fun provideAlarmTileViewModel(
            factory: QSTileViewModelFactory.Static<AlarmTileModel>,
            mapper: AlarmTileMapper,
            stateInteractor: AlarmTileDataInteractor,
            userActionInteractor: AlarmTileUserActionInteractor,
        ): QSTileViewModel =
            factory.create(
                TileSpec.create(ALARM_TILE_SPEC),
                userActionInteractor,
                stateInteractor,
                mapper,
            )

        /** Inject uimodenight config */
        @Provides
        @IntoMap
        @StringKey(UIMODENIGHT_TILE_SPEC)
        fun provideUiModeNightTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            QSTileConfig(
                tileSpec = TileSpec.create(UIMODENIGHT_TILE_SPEC),
                uiConfig =
                    QSTileUIConfig.Resource(
                        iconRes = R.drawable.qs_light_dark_theme_icon_off,
                        labelRes = R.string.quick_settings_ui_mode_night_label,
                    ),
                instanceId = uiEventLogger.getNewInstanceId(),
                category = TileCategory.DISPLAY,
            )

        /** Inject uimodenight into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(UIMODENIGHT_TILE_SPEC)
        fun provideUiModeNightTileViewModel(
            factory: QSTileViewModelFactory.Static<UiModeNightTileModel>,
            mapper: UiModeNightTileMapper,
            stateInteractor: UiModeNightTileDataInteractor,
            userActionInteractor: UiModeNightTileUserActionInteractor,
        ): QSTileViewModel =
            factory.create(
                TileSpec.create(UIMODENIGHT_TILE_SPEC),
                userActionInteractor,
                stateInteractor,
                mapper,
            )

        /** Inject work mode tile config */
        @Provides
        @IntoMap
        @StringKey(WORK_MODE_TILE_SPEC)
        fun provideWorkModeTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            QSTileConfig(
                tileSpec = TileSpec.create(WORK_MODE_TILE_SPEC),
                uiConfig =
                    QSTileUIConfig.Resource(
                        iconRes = com.android.internal.R.drawable.stat_sys_managed_profile_status,
                        labelRes = R.string.quick_settings_work_mode_label,
                    ),
                instanceId = uiEventLogger.getNewInstanceId(),
                autoRemoveOnUnavailable = false,
                category = TileCategory.PRIVACY,
            )

        /** Inject work mode into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(WORK_MODE_TILE_SPEC)
        fun provideWorkModeTileViewModel(
            factory: QSTileViewModelFactory.Static<WorkModeTileModel>,
            mapper: WorkModeTileMapper,
            stateInteractor: WorkModeTileDataInteractor,
            userActionInteractor: WorkModeTileUserActionInteractor,
        ): QSTileViewModel =
            factory.create(
                TileSpec.create(WORK_MODE_TILE_SPEC),
                userActionInteractor,
                stateInteractor,
                mapper,
            )

        /** Inject camera toggle config */
        @Provides
        @IntoMap
        @StringKey(CAMERA_TOGGLE_TILE_SPEC)
        fun provideCameraToggleTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            QSTileConfig(
                tileSpec = TileSpec.create(CAMERA_TOGGLE_TILE_SPEC),
                uiConfig =
                    QSTileUIConfig.Resource(
                        iconRes = R.drawable.qs_camera_access_icon_off,
                        labelRes = R.string.quick_settings_camera_label,
                    ),
                instanceId = uiEventLogger.getNewInstanceId(),
                policy = QSTilePolicy.Restricted(listOf(DISALLOW_CAMERA_TOGGLE)),
                category = TileCategory.PRIVACY,
            )

        /** Inject camera toggle tile into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(CAMERA_TOGGLE_TILE_SPEC)
        fun provideCameraToggleTileViewModel(
            factory: QSTileViewModelFactory.Static<SensorPrivacyToggleTileModel>,
            mapper: SensorPrivacyToggleTileMapper.Factory,
            stateInteractor: SensorPrivacyToggleTileDataInteractor.Factory,
            userActionInteractor: SensorPrivacyToggleTileUserActionInteractor.Factory,
        ): QSTileViewModel =
            factory.create(
                TileSpec.create(CAMERA_TOGGLE_TILE_SPEC),
                userActionInteractor.create(CAMERA),
                stateInteractor.create(CAMERA),
                mapper.create(SensorPrivacyTileResources.CameraPrivacyTileResources),
            )

        @Provides
        @IntoMap
        @StringKey(CAMERA_TOGGLE_TILE_SPEC)
        fun provideCameraToggleAvailabilityInteractor(
            factory: SensorPrivacyToggleTileDataInteractor.Factory
        ): QSTileAvailabilityInteractor {
            return factory.create(CAMERA)
        }

        /** Inject microphone toggle config */
        @Provides
        @IntoMap
        @StringKey(MIC_TOGGLE_TILE_SPEC)
        fun provideMicrophoneToggleTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            QSTileConfig(
                tileSpec = TileSpec.create(MIC_TOGGLE_TILE_SPEC),
                uiConfig =
                    QSTileUIConfig.Resource(
                        iconRes = R.drawable.qs_mic_access_off,
                        labelRes = R.string.quick_settings_mic_label,
                    ),
                instanceId = uiEventLogger.getNewInstanceId(),
                policy = QSTilePolicy.Restricted(listOf(DISALLOW_MICROPHONE_TOGGLE)),
                category = TileCategory.PRIVACY,
            )

        /** Inject microphone toggle tile into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(MIC_TOGGLE_TILE_SPEC)
        fun provideMicrophoneToggleTileViewModel(
            factory: QSTileViewModelFactory.Static<SensorPrivacyToggleTileModel>,
            mapper: SensorPrivacyToggleTileMapper.Factory,
            stateInteractor: SensorPrivacyToggleTileDataInteractor.Factory,
            userActionInteractor: SensorPrivacyToggleTileUserActionInteractor.Factory,
        ): QSTileViewModel =
            factory.create(
                TileSpec.create(MIC_TOGGLE_TILE_SPEC),
                userActionInteractor.create(MICROPHONE),
                stateInteractor.create(MICROPHONE),
                mapper.create(SensorPrivacyTileResources.MicrophonePrivacyTileResources),
            )

        @Provides
        @IntoMap
        @StringKey(MIC_TOGGLE_TILE_SPEC)
        fun provideMicToggleModeAvailabilityInteractor(
            factory: SensorPrivacyToggleTileDataInteractor.Factory
        ): QSTileAvailabilityInteractor {
            return factory.create(MICROPHONE)
        }

        /** Inject DND tile or Modes tile config based on feature flag */
        @Provides
        @IntoMap
        @StringKey(DND_TILE_SPEC)
        fun provideDndOrModesTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
            if (ModesUi.isEnabled) {
                QSTileConfig(
                    tileSpec = TileSpec.create(DND_TILE_SPEC),
                    uiConfig =
                        QSTileUIConfig.Resource(
                            iconRes = com.android.internal.R.drawable.ic_zen_priority_modes,
                            labelRes = R.string.quick_settings_modes_label,
                        ),
                    instanceId = uiEventLogger.getNewInstanceId(),
                    category = TileCategory.CONNECTIVITY,
                )
            } else {
                QSTileConfig(
                    tileSpec = TileSpec.create(DND_TILE_SPEC),
                    uiConfig =
                        QSTileUIConfig.Resource(
                            iconRes = R.drawable.qs_dnd_icon_off,
                            labelRes = R.string.quick_settings_dnd_label,
                        ),
                    instanceId = uiEventLogger.getNewInstanceId(),
                    category = TileCategory.CONNECTIVITY,
                )
            }

        /** Inject ModesTile into tileViewModelMap in QSModule */
        @Provides
        @IntoMap
        @StringKey(DND_TILE_SPEC)
        fun provideModesTileViewModel(
            factory: QSTileViewModelFactory.Static<ModesTileModel>,
            mapper: ModesTileMapper,
            stateInteractor: ModesTileDataInteractor,
            userActionInteractor: ModesTileUserActionInteractor,
        ): QSTileViewModel =
            if (ModesUi.isEnabled && Flags.qsNewTilesFuture())
                factory.create(
                    TileSpec.create(DND_TILE_SPEC),
                    userActionInteractor,
                    stateInteractor,
                    mapper,
                )
            else StubQSTileViewModel
    }

    /** Inject FlashlightTile into tileMap in QSModule */
    @Binds
    @IntoMap
    @StringKey(FlashlightTile.TILE_SPEC)
    fun bindFlashlightTile(flashlightTile: FlashlightTile): QSTileImpl<*>



    /** Inject ScreenShotTile into tileMap in QSModule */
    @Binds
    @IntoMap
    @StringKey(ScreenShotTile.TILE_SPEC)
    fun bindScreenShotTile(screenShot: ScreenShotTile): QSTileImpl<*>

    /** Inject LocationTile into tileMap in QSModule */
    @Binds
    @IntoMap
    @StringKey(LocationTile.TILE_SPEC)
    fun bindLocationTile(locationTile: LocationTile): QSTileImpl<*>

    /** Inject CameraToggleTile into tileMap in QSModule */
    @Binds
    @IntoMap
    @StringKey(CameraToggleTile.TILE_SPEC)
    fun bindCameraToggleTile(cameraToggleTile: CameraToggleTile): QSTileImpl<*>

    /** Inject MicrophoneToggleTile into tileMap in QSModule */
    @Binds
    @IntoMap
    @StringKey(MicrophoneToggleTile.TILE_SPEC)
    fun bindMicrophoneToggleTile(microphoneToggleTile: MicrophoneToggleTile): QSTileImpl<*>

    /** Inject AlarmTile into tileMap in QSModule */
    @Binds
    @IntoMap
    @StringKey(AlarmTile.TILE_SPEC)
    fun bindAlarmTile(alarmTile: AlarmTile): QSTileImpl<*>

    @Binds
    @IntoMap
    @StringKey(UiModeNightTile.TILE_SPEC)
    fun bindUiModeNightTile(uiModeNightTile: UiModeNightTile): QSTileImpl<*>
}

编译导入,然后杀掉systemui的进程即可

make SystemUI;adb push out/target/product/blueline/system_ext/priv-app/SystemUI/SystemUI.apk /system_ext/priv-app/SystemUI/SystemUI.apk

在这里插入图片描述

相关文章:

  • 使用AI一步一步实现若依前端(4)
  • 【JAVA】之路启航——初识Java篇
  • python绘图之瀑布图
  • MySQL中有哪几种锁?
  • 个人学习编程(3-10) 刷题
  • 【C++】C++入门基础
  • SpringAI介绍及本地模型使用方法
  • c++介绍锁四
  • vim 编写/etc/docker/daemon.json文件时,E212: 无法打开并写入文件
  • 红队思想:Live off the Land - 靠山吃山,靠水吃水
  • 算法 之 树形dp 树的中心、重心
  • 深入理解序列并行化:sp_size 与批量大小参数详解
  • git安装(windows)+vscode配置
  • 深入理解C语言链表:数据结构的基石
  • 注意力机制-学习
  • QML界面卡死分析--01 --Canvas与QRasterPaintEngine
  • Python:函数(一)
  • 【DDD的本质与核心思想】
  • 脚本学习(1)验证目录自动化生成脚本
  • 在rocklinux里面批量部署安装rocklinx9
  • 上海徐汇 “家 + 书屋”,创新服务广大家庭
  • 发射后失联,印度地球观测卫星发射任务宣告失败
  • 用贝多芬八首钢琴三重奏纪念风雨并肩20年
  • 泽连斯基:乌代表团已启程,谈判可能于今晚或明天举行
  • 诠释微末处的丰盈:“上海制造佳品汇”首届海外专场即将亮相日本大阪
  • 夜读丨读《汉书》一得