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

Commit be4aa4cd authored by Bharat Singh's avatar Bharat Singh
Browse files

[SysUI][Floaty] Add mechanism to decide when to draw squeeze effect

* Adds a flow to detect changes in global security settings of LPP
* Combines above flow with flow which detects LPP
* Combined flow is used to determine when to draw the squeeze effect

Bug: 399263897
Flag: com.android.systemui.shared.enable_lpp_squeeze_effect
Change-Id: I338a4097163989f95e5bd22b9f60fea9f7209f19
parent 7db46f58
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManagerImpl;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.education.dagger.ContextualEducationModule;
import com.android.systemui.effects.dagger.TopLevelWindowEffectsModule;
import com.android.systemui.topwindoweffects.dagger.SqueezeEffectRepositoryModule;
import com.android.systemui.topwindoweffects.dagger.TopLevelWindowEffectsModule;
import com.android.systemui.emergency.EmergencyGestureModule;
import com.android.systemui.inputdevice.tutorial.KeyboardTouchpadTutorialModule;
import com.android.systemui.keyboard.shortcut.ShortcutHelperModule;
@@ -161,6 +162,7 @@ import javax.inject.Named;
        StatusBarPhoneModule.class,
        SystemActionsModule.class,
        ShadeModule.class,
        SqueezeEffectRepositoryModule.class,
        StartCentralSurfacesModule.class,
        SceneContainerFrameworkModule.class,
        SysUICoroutinesModule.class,
+25 −3
Original line number Diff line number Diff line
@@ -14,24 +14,46 @@
 * limitations under the License.
 */

package com.android.systemui.effects;
package com.android.systemui.topwindoweffects;

import android.content.Context
import android.graphics.PixelFormat
import android.view.Gravity
import android.view.WindowInsets
import android.view.WindowManager
import com.android.app.viewcapture.ViewCaptureAwareWindowManager
import com.android.systemui.CoreStartable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor
import com.android.systemui.topwindoweffects.ui.compose.EffectsWindowRoot
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import javax.inject.Inject

@SysUISingleton
class TopLevelWindowEffects @Inject constructor(
    @Application private val context: Context
    @Application private val context: Context,
    @Application private val applicationScope: CoroutineScope,
    private val windowManager: ViewCaptureAwareWindowManager,
    private val squeezeEffectInteractor: SqueezeEffectInteractor
) : CoreStartable {
    override fun start() {

    override fun start() {
        applicationScope.launch {
            var root: EffectsWindowRoot? = null
            squeezeEffectInteractor.isSqueezeEffectEnabled.collectLatest { enabled ->
                // TODO: move window ops to a separate UI thread
                if (enabled && root == null) {
                    root = EffectsWindowRoot(context)
                    root?.let { windowManager.addView(it, getWindowManagerLayoutParams()) }
                } else if (root?.isAttachedToWindow == true) {
                    windowManager.removeView(root)
                    root = null
                }
            }
        }
    }

    private fun getWindowManagerLayoutParams(): WindowManager.LayoutParams {
+31 −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.topwindoweffects.dagger

import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepository
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl
import dagger.Binds
import dagger.Module

@Module
interface SqueezeEffectRepositoryModule {

    @Binds
    fun squeezeEffectRepository(
        squeezeEffectRepositoryImpl: SqueezeEffectRepositoryImpl
    ) : SqueezeEffectRepository
}
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -14,10 +14,10 @@
 * limitations under the License.
 */

package com.android.systemui.effects.dagger
package com.android.systemui.topwindoweffects.dagger

import com.android.systemui.CoreStartable
import com.android.systemui.effects.TopLevelWindowEffects
import com.android.systemui.topwindoweffects.TopLevelWindowEffects
import dagger.Binds
import dagger.Module
import dagger.multibindings.ClassKey
+23 −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.topwindoweffects.data.repository

import kotlinx.coroutines.flow.Flow

interface SqueezeEffectRepository {
    val isSqueezeEffectEnabled: Flow<Boolean>
}
 No newline at end of file
Loading