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

Commit f221f816 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "When the DeviceEntryUdfpsRefactor is enabled, use an empty lock icon...

Merge "When the DeviceEntryUdfpsRefactor is enabled, use an empty lock icon view controller" into main
parents d79e1dc2 5ceed31b
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.LockIconViewController;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.biometrics.AuthController;
@@ -93,7 +92,6 @@ public class DozeServiceHostTest extends SysuiTestCase {
    @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController;
    @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
    @Mock private ShadeLockscreenInteractor mShadeLockscreenInteractor;
    @Mock private LockIconViewController mLockIconViewController;
    @Mock private View mAmbientIndicationContainer;
    @Mock private BiometricUnlockController mBiometricUnlockController;
    @Mock private AuthController mAuthController;
+64 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.keyguard

import android.view.MotionEvent
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.ui.view.KeyguardRootView
import com.android.systemui.res.R
import dagger.Lazy
import javax.inject.Inject

/**
 * Lock icon view logic now lives in DeviceEntryIconViewBinder and ViewModels. Icon is positioned in
 * [com.android.systemui.keyguard.ui.view.layout.sections.DefaultDeviceEntrySection].
 *
 * This class is to bridge the gap between the logic when the DeviceEntryUdfpsRefactor is enabled
 * and the KeyguardBottomAreaRefactor is NOT enabled. This class can and should be removed when both
 * flags are enabled.
 */
@SysUISingleton
class EmptyLockIconViewController
@Inject
constructor(
    private val keyguardRootView: Lazy<KeyguardRootView>,
) : LockIconViewController {
    private val deviceEntryIconViewId = R.id.device_entry_icon_view
    override fun setLockIconView(lockIconView: LockIconView) {
        // no-op
    }

    override fun getTop(): Float {
        return keyguardRootView.get().getViewById(deviceEntryIconViewId)?.top?.toFloat() ?: 0f
    }

    override fun getBottom(): Float {
        return keyguardRootView.get().getViewById(deviceEntryIconViewId)?.bottom?.toFloat() ?: 0f
    }

    override fun dozeTimeTick() {
        // no-op
    }

    override fun setAlpha(alpha: Float) {
        // no-op
    }

    override fun willHandleTouchWhileDozing(event: MotionEvent): Boolean {
        return false
    }
}
+8 −2
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi;
 * icon will show a set distance from the bottom of the device.
 */
@SysUISingleton
public class LockIconViewController implements Dumpable {
public class LegacyLockIconViewController implements Dumpable, LockIconViewController {
    private static final String TAG = "LockIconViewController";
    private static final float sDefaultDensity =
            (float) DisplayMetrics.DENSITY_DEVICE_STABLE / (float) DisplayMetrics.DENSITY_DEFAULT;
@@ -189,7 +189,7 @@ public class LockIconViewController implements Dumpable {
            };

    @Inject
    public LockIconViewController(
    public LegacyLockIconViewController(
            @NonNull StatusBarStateController statusBarStateController,
            @NonNull KeyguardUpdateMonitor keyguardUpdateMonitor,
            @NonNull KeyguardViewController keyguardViewController,
@@ -262,6 +262,7 @@ public class LockIconViewController implements Dumpable {

    /** Sets the LockIconView to the controller and rebinds any that depend on it. */
    @SuppressLint("ClickableViewAccessibility")
    @Override
    public void setLockIconView(LockIconView lockIconView) {
        mView = lockIconView;
        mView.setAccessibilityDelegate(mAccessibilityDelegate);
@@ -344,10 +345,12 @@ public class LockIconViewController implements Dumpable {
        }
    }

    @Override
    public float getTop() {
        return mView.getLocationTop();
    }

    @Override
    public float getBottom() {
        return mView.getLocationBottom();
    }
@@ -499,6 +502,7 @@ public class LockIconViewController implements Dumpable {
    }

    /** Every minute, update the aod icon's burn in offset */
    @Override
    public void dozeTimeTick() {
        updateBurnInOffsets();
    }
@@ -774,6 +778,7 @@ public class LockIconViewController implements Dumpable {
    /**
     * Set the alpha of this view.
     */
    @Override
    public void setAlpha(float alpha) {
        mView.setAlpha(alpha);
    }
@@ -823,6 +828,7 @@ public class LockIconViewController implements Dumpable {
    /**
     * Whether the lock icon will handle a touch while dozing.
     */
    @Override
    public boolean willHandleTouchWhileDozing(MotionEvent event) {
        // is in lock icon area
        mView.getHitRect(mSensorTouchLocation);
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.keyguard

import android.view.MotionEvent

/** Controls the [LockIconView]. */
interface LockIconViewController {
    fun setLockIconView(lockIconView: LockIconView)
    fun getTop(): Float
    fun getBottom(): Float
    fun dozeTimeTick()
    fun setAlpha(alpha: Float)
    fun willHandleTouchWhileDozing(event: MotionEvent): Boolean
}
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.deviceentry

import com.android.keyguard.EmptyLockIconViewController
import com.android.keyguard.LegacyLockIconViewController
import com.android.keyguard.LockIconViewController
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.deviceentry.data.repository.DeviceEntryRepositoryModule
import com.android.systemui.deviceentry.data.repository.FaceWakeUpTriggersConfigModule
import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.keyguard.ui.transitions.DeviceEntryIconTransition
import dagger.Lazy
import dagger.Module
import dagger.Provides
import dagger.multibindings.Multibinds

@Module(
@@ -18,4 +41,19 @@ abstract class DeviceEntryModule {
     * A set of DeviceEntryIconTransitions. Ensures that this can be injected even if it's empty.
     */
    @Multibinds abstract fun deviceEntryIconTransitionSet(): Set<DeviceEntryIconTransition>

    companion object {
        @Provides
        @SysUISingleton
        fun provideLockIconViewController(
            legacyLockIconViewController: Lazy<LegacyLockIconViewController>,
            emptyLockIconViewController: Lazy<EmptyLockIconViewController>,
        ): LockIconViewController {
            return if (DeviceEntryUdfpsRefactor.isEnabled) {
                emptyLockIconViewController.get()
            } else {
                legacyLockIconViewController.get()
            }
        }
    }
}
Loading