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

Commit a705a150 authored by Helen Cheuk's avatar Helen Cheuk Committed by Android (Google) Code Review
Browse files

Merge "[Action Corner] Add action corner module and interactor" into main

parents c723ea80 0bdbab39
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.actioncorner

import com.android.app.displaylib.PerDisplayInstanceRepositoryImpl
import com.android.app.displaylib.PerDisplayRepository
import com.android.systemui.CoreStartable
import com.android.systemui.actioncorner.data.repository.ActionCornerRepository
import com.android.systemui.actioncorner.data.repository.ActionCornerRepositoryImpl
import com.android.systemui.cursorposition.data.repository.MultiDisplayCursorPositionRepository
import com.android.systemui.cursorposition.data.repository.MultiDisplayCursorPositionRepositoryImpl
import com.android.systemui.cursorposition.data.repository.SingleDisplayCursorPositionRepository
import com.android.systemui.cursorposition.data.repository.SingleDisplayCursorPositionRepositoryFactory
import com.android.systemui.dagger.SysUISingleton
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.multibindings.ClassKey
import dagger.multibindings.IntoMap

@Module
abstract class ActionCornerModule {
    @Binds
    @IntoMap
    @ClassKey(ActionCornerStartable::class)
    abstract fun bindActionCornerStartable(updater: ActionCornerStartable): CoreStartable

    @Binds
    abstract fun bindActionCornerRepository(
        impl: ActionCornerRepositoryImpl
    ): ActionCornerRepository

    @Binds
    abstract fun bindMultiDisplayCursorPositionRepository(
        impl: MultiDisplayCursorPositionRepositoryImpl
    ): MultiDisplayCursorPositionRepository

    companion object {

        @SysUISingleton
        @Provides
        fun provideCursorPositionRepository(
            repositoryFactory:
                PerDisplayInstanceRepositoryImpl.Factory<SingleDisplayCursorPositionRepository>,
            instanceProvider: SingleDisplayCursorPositionRepositoryFactory,
        ): PerDisplayRepository<SingleDisplayCursorPositionRepository> {
            val debugName = "CursorPositionRepositoryPerDisplayRepo"
            return repositoryFactory.create(debugName, instanceProvider)
        }
    }
}
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.actioncorner

import com.android.systemui.CoreStartable
import com.android.systemui.actioncorner.domain.interactor.ActionCornerInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.shared.Flags.cursorHotCorner
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

@SysUISingleton
class ActionCornerStartable
@Inject
constructor(
    private val interactor: Lazy<ActionCornerInteractor>,
    @Background private val scope: CoroutineScope,
) : CoreStartable {

    override fun start() {
        if (!cursorHotCorner()) {
            return
        }

        scope.launch { interactor.get().activate() }
    }
}
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.actioncorner.domain.interactor

import com.android.systemui.actioncorner.data.repository.ActionCornerRepository
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.recents.LauncherProxyService
import javax.inject.Inject

@SysUISingleton
class ActionCornerInteractor
@Inject
constructor(
    private val repository: ActionCornerRepository,
    private val launcherProxyService: LauncherProxyService,
) : ExclusiveActivatable() {

    override suspend fun onActivated(): Nothing {
        repository.actionCornerState.collect {
            // TODO: call methods in LauncherProxyService to send action to launcher when the APIs
            // are ready
        }
    }
}