Created
December 2, 2020 15:00
-
-
Save Dil3mm4/76e1ab2b7bd6eeac88f76718fa3623f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 961d3814e2df872f8f16271477065341b329c1a9 Mon Sep 17 00:00:00 2001 | |
From: Dil3mm4 <[email protected]> | |
Date: Wed, 2 Dec 2020 00:28:32 +0000 | |
Subject: [PATCH] SystemUI - FODCircleViewImpl: handle cases that we can't | |
address within FODCircleView | |
So, briefly, what went on in this pow-wow is: | |
- created a callback to efficiently monitor calls to FODCircleView impl (LuK1377 had a lot of patience) | |
- addressed FOD visibility on statusbar expansion/collapse checking top activity package name and class within StatusBar.java | |
- addressed FOD visibility if an app gets launched after statusbar expansion from a notif | |
- addressed FOD visibility over every launcher animation, where every stands for: | |
back to home, open recents, back gesture, assistant gesture (tested against any navigation type available) | |
- reduced animation time to 175ms | |
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java | |
index dc41fcee9ca7..919cd622dea2 100644 | |
--- a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java | |
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java | |
@@ -22,12 +22,20 @@ import android.util.Slog; | |
import android.view.View; | |
import com.android.systemui.SystemUI; | |
+import com.android.systemui.biometrics.FODCircleViewImplCallback; | |
import com.android.systemui.statusbar.CommandQueue; | |
import com.android.systemui.statusbar.CommandQueue.Callbacks; | |
+import com.android.systemui.util.Assert; | |
+ | |
+import com.google.android.collect.Lists; | |
+ | |
+import java.lang.ref.WeakReference; | |
+import java.util.ArrayList; | |
import javax.inject.Inject; | |
import javax.inject.Singleton; | |
+ | |
import com.android.internal.util.custom.FodUtils; | |
@Singleton | |
@@ -35,8 +43,13 @@ public class FODCircleViewImpl extends SystemUI implements CommandQueue.Callback | |
private static final String TAG = "FODCircleViewImpl"; | |
private FODCircleView mFodCircleView; | |
+ | |
+ private final ArrayList<WeakReference<FODCircleViewImplCallback>> | |
+ mCallbacks = Lists.newArrayList(); | |
private final CommandQueue mCommandQueue; | |
+ private boolean mIsFODVisible; | |
+ | |
@Inject | |
public FODCircleViewImpl(Context context, CommandQueue commandQueue) { | |
super(context); | |
@@ -53,6 +66,12 @@ public class FODCircleViewImpl extends SystemUI implements CommandQueue.Callback | |
mCommandQueue.addCallback(this); | |
try { | |
mFodCircleView = new FODCircleView(mContext); | |
+ for (int i = 0; i < mCallbacks.size(); i++) { | |
+ FODCircleViewImplCallback cb = mCallbacks.get(i).get(); | |
+ if (cb != null) { | |
+ cb.onFODStart(); | |
+ } | |
+ } | |
} catch (RuntimeException e) { | |
Slog.e(TAG, "Failed to initialize FODCircleView", e); | |
} | |
@@ -61,6 +80,13 @@ public class FODCircleViewImpl extends SystemUI implements CommandQueue.Callback | |
@Override | |
public void showInDisplayFingerprintView() { | |
if (mFodCircleView != null) { | |
+ for (int i = 0; i < mCallbacks.size(); i++) { | |
+ FODCircleViewImplCallback cb = mCallbacks.get(i).get(); | |
+ if (cb != null) { | |
+ cb.onFODStatusChange(true); | |
+ } | |
+ } | |
+ mIsFODVisible = true; | |
mFodCircleView.show(); | |
} | |
} | |
@@ -68,7 +94,40 @@ public class FODCircleViewImpl extends SystemUI implements CommandQueue.Callback | |
@Override | |
public void hideInDisplayFingerprintView() { | |
if (mFodCircleView != null) { | |
+ for (int i = 0; i < mCallbacks.size(); i++) { | |
+ FODCircleViewImplCallback cb = mCallbacks.get(i).get(); | |
+ if (cb != null) { | |
+ cb.onFODStatusChange(false); | |
+ } | |
+ } | |
+ mIsFODVisible = false; | |
mFodCircleView.hide(); | |
} | |
} | |
+ | |
+ public void registerCallback(FODCircleViewImplCallback callback) { | |
+ Assert.isMainThread(); | |
+ Slog.v(TAG, "*** register callback for " + callback); | |
+ for (int i = 0; i < mCallbacks.size(); i++) { | |
+ if (mCallbacks.get(i).get() == callback) { | |
+ Slog.e(TAG, "Object tried to add another callback", | |
+ new Exception("Called by")); | |
+ return; | |
+ } | |
+ } | |
+ mCallbacks.add(new WeakReference<>(callback)); | |
+ removeCallback(null); | |
+ sendUpdates(callback); | |
+ } | |
+ | |
+ public void removeCallback(FODCircleViewImplCallback callback) { | |
+ Assert.isMainThread(); | |
+ Slog.v(TAG, "*** unregister callback for " + callback); | |
+ mCallbacks.removeIf(el -> el.get() == callback); | |
+ } | |
+ | |
+ private void sendUpdates(FODCircleViewImplCallback callback) { | |
+ callback.onFODStart(); | |
+ callback.onFODStatusChange(mIsFODVisible); | |
+ } | |
} | |
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImplCallback.java b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImplCallback.java | |
new file mode 100644 | |
index 000000000000..3a776b3ee2f6 | |
--- /dev/null | |
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImplCallback.java | |
@@ -0,0 +1,25 @@ | |
+/** | |
+ * Copyright (C) 2019 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.biometrics; | |
+ | |
+public class FODCircleViewImplCallback { | |
+ | |
+ public void onFODStart() {} | |
+ | |
+ public void onFODStatusChange(boolean isVisible){} | |
+ | |
+} | |
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java | |
index 382715a3fb77..de849ee0f3b3 100644 | |
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java | |
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java | |
@@ -33,6 +33,7 @@ import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams; | |
import android.view.View; | |
import com.android.internal.policy.ScreenDecorationsUtils; | |
+import com.android.systemui.biometrics.FODCircleViewImpl; | |
import com.android.systemui.Interpolators; | |
import com.android.systemui.statusbar.NotificationShadeDepthController; | |
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; | |
@@ -42,6 +43,7 @@ import com.android.systemui.statusbar.phone.NotificationPanelViewController; | |
import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; | |
import java.util.concurrent.Executor; | |
+import javax.inject.Inject; | |
/** | |
* A class that allows activities to be launched in a seamless way where the notification | |
@@ -71,13 +73,16 @@ public class ActivityLaunchAnimator { | |
private boolean mAnimationRunning; | |
private boolean mIsLaunchForActivity; | |
+ private FODCircleViewImpl mFODCircleViewImpl; | |
+ | |
public ActivityLaunchAnimator( | |
NotificationShadeWindowViewController notificationShadeWindowViewController, | |
Callback callback, | |
NotificationPanelViewController notificationPanel, | |
NotificationShadeDepthController depthController, | |
NotificationListContainer container, | |
- Executor mainExecutor) { | |
+ Executor mainExecutor, | |
+ FODCircleViewImpl fodCircleViewImpl) { | |
mNotificationPanel = notificationPanel; | |
mNotificationContainer = container; | |
mDepthController = depthController; | |
@@ -87,6 +92,7 @@ public class ActivityLaunchAnimator { | |
mWindowCornerRadius = ScreenDecorationsUtils | |
.getWindowCornerRadius(mNotificationShadeWindowViewController.getView() | |
.getResources()); | |
+ mFODCircleViewImpl = fodCircleViewImpl; | |
} | |
public RemoteAnimationAdapter getLaunchAnimation( | |
@@ -263,12 +269,12 @@ public class ActivityLaunchAnimator { | |
mNotificationShadeWindowViewController.setExpandAnimationRunning(running); | |
mNotificationContainer.setExpandingNotification(running ? mSourceNotification : null); | |
mAnimationRunning = running; | |
+ mFODCircleViewImpl.hideInDisplayFingerprintView(); | |
if (!running) { | |
mCallback.onExpandAnimationFinished(mIsFullScreenLaunch); | |
applyParamsToNotification(null); | |
applyParamsToNotificationShade(null); | |
} | |
- | |
} | |
private void applyParamsToNotificationShade(ExpandAnimationParameters params) { | |
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java | |
index cd69505b2092..f45385783ccd 100644 | |
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java | |
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java | |
@@ -159,6 +159,8 @@ import com.android.systemui.SystemUIFactory; | |
import com.android.systemui.ThumbUIManager; | |
import com.android.systemui.assist.AssistManager; | |
import com.android.systemui.broadcast.BroadcastDispatcher; | |
+import com.android.systemui.biometrics.FODCircleViewImpl; | |
+import com.android.systemui.biometrics.FODCircleViewImplCallback; | |
import com.android.systemui.bubbles.BubbleController; | |
import com.android.systemui.charging.WirelessChargingAnimation; | |
import com.android.systemui.classifier.FalsingLog; | |
@@ -245,6 +247,7 @@ import java.io.FileDescriptor; | |
import java.io.PrintWriter; | |
import java.io.StringWriter; | |
import java.util.Calendar; | |
+import java.util.List; | |
import java.util.Map; | |
import java.util.Optional; | |
import java.util.concurrent.Executor; | |
@@ -635,6 +638,21 @@ public class StatusBar extends SystemUI implements DemoMode, | |
} | |
}; | |
+ private ActivityManager mActivityManager; | |
+ private boolean mFodVisibility; | |
+ private boolean mIsDreaming; | |
+ private FODCircleViewImpl mFODCircleViewImpl; | |
+ private String mTopPkgClass; | |
+ private FODCircleViewImplCallback mFODCircleViewImplCallback = new FODCircleViewImplCallback() { | |
+ @Override | |
+ public void onFODStatusChange(boolean isVisible) { | |
+ mFodVisibility = isVisible; | |
+ if (isVisible && !mIsKeyguard && !mIsDreaming) { | |
+ mTopPkgClass = getTopActivityPkgClass(); | |
+ } | |
+ } | |
+ }; | |
+ | |
private FlashlightController mFlashlightController; | |
private KeyguardUserSwitcher mKeyguardUserSwitcher; | |
private final UserSwitcherController mUserSwitcherController; | |
@@ -664,6 +682,7 @@ public class StatusBar extends SystemUI implements DemoMode, | |
new KeyguardUpdateMonitorCallback() { | |
@Override | |
public void onDreamingStateChanged(boolean dreaming) { | |
+ mIsDreaming = dreaming; | |
if (dreaming) { | |
maybeEscalateHeadsUp(); | |
} | |
@@ -777,7 +796,8 @@ public class StatusBar extends SystemUI implements DemoMode, | |
DismissCallbackRegistry dismissCallbackRegistry, | |
Lazy<NotificationShadeDepthController> notificationShadeDepthControllerLazy, | |
StatusBarTouchableRegionManager statusBarTouchableRegionManager, | |
- FlashlightController flashlightController) { | |
+ FlashlightController flashlightController, | |
+ FODCircleViewImpl fodCircleViewImpl) { | |
super(context); | |
mNotificationsController = notificationsController; | |
mLightBarController = lightBarController; | |
@@ -855,7 +875,7 @@ public class StatusBar extends SystemUI implements DemoMode, | |
mIconPolicy = phoneStatusBarPolicy; | |
mDismissCallbackRegistry = dismissCallbackRegistry; | |
mFlashlightController = flashlightController; | |
- | |
+ mFODCircleViewImpl = fodCircleViewImpl; | |
mBubbleExpandListener = | |
(isExpanding, key) -> { | |
mNotificationsController.requestNotificationUpdate("onBubbleExpandChanged"); | |
@@ -1051,6 +1071,8 @@ public class StatusBar extends SystemUI implements DemoMode, | |
} | |
} | |
}, OverlayPlugin.class, true /* Allow multiple plugins */); | |
+ mFODCircleViewImpl.registerCallback(mFODCircleViewImplCallback); | |
+ mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); | |
} | |
// ================================================================================ | |
@@ -1353,7 +1375,7 @@ public class StatusBar extends SystemUI implements DemoMode, | |
mActivityLaunchAnimator = new ActivityLaunchAnimator( | |
mNotificationShadeWindowViewController, this, mNotificationPanelViewController, | |
mNotificationShadeDepthControllerLazy.get(), | |
- (NotificationListContainer) mStackScroller, mContext.getMainExecutor()); | |
+ (NotificationListContainer) mStackScroller, mContext.getMainExecutor(), mFODCircleViewImpl); | |
// TODO: inject this. | |
mPresenter = new StatusBarNotificationPresenter(mContext, mNotificationPanelViewController, | |
@@ -1891,6 +1913,12 @@ public class StatusBar extends SystemUI implements DemoMode, | |
clearNotificationEffects(); | |
} | |
+ if (isExpanded && mFodVisibility) { | |
+ mFODCircleViewImpl.hideInDisplayFingerprintView(); | |
+ } else if (!isExpanded && getTopActivityPkgClass().equals(mTopPkgClass)) { | |
+ mFODCircleViewImpl.showInDisplayFingerprintView(); | |
+ } | |
+ | |
if (!isExpanded) { | |
mRemoteInputManager.onPanelCollapsed(); | |
} | |
@@ -2620,6 +2648,15 @@ public class StatusBar extends SystemUI implements DemoMode, | |
@Override | |
public void onRecentsAnimationStateChanged(boolean running) { | |
setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, running); | |
+ if (running) { | |
+ mFODCircleViewImpl.hideInDisplayFingerprintView(); | |
+ } else { | |
+ if (getTopActivityPkgClass().equals(mTopPkgClass)) { | |
+ mFODCircleViewImpl.showInDisplayFingerprintView(); | |
+ } else { | |
+ mFODCircleViewImpl.hideInDisplayFingerprintView(); | |
+ } | |
+ } | |
} | |
protected BarTransitions getStatusBarTransitions() { | |
@@ -4682,4 +4719,17 @@ public class StatusBar extends SystemUI implements DemoMode, | |
} | |
DescendantSystemUIUtils.setSystemSetting("feature_copy", mContext, 1); | |
} | |
+ | |
+ private String getTopActivityPkgClass() { | |
+ List<ActivityManager.RunningTaskInfo> tasks = | |
+ mActivityManager.getRunningTasks(1); | |
+ ActivityManager.RunningTaskInfo currentTask = tasks.get(0); | |
+ ComponentName currentActivity = currentTask.topActivity; | |
+ if (currentActivity.getPackageName() != null) { | |
+ return currentActivity.getPackageName().trim() + currentActivity.getShortClassName().trim(); | |
+ } else { | |
+ return null; | |
+ } | |
+ } | |
+ | |
} | |
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java | |
index 4abca289c90e..00b3524c1f95 100644 | |
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java | |
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java | |
@@ -30,6 +30,7 @@ import com.android.keyguard.KeyguardUpdateMonitor; | |
import com.android.keyguard.ViewMediatorCallback; | |
import com.android.systemui.InitController; | |
import com.android.systemui.assist.AssistManager; | |
+import com.android.systemui.biometrics.FODCircleViewImpl; | |
import com.android.systemui.broadcast.BroadcastDispatcher; | |
import com.android.systemui.bubbles.BubbleController; | |
import com.android.systemui.colorextraction.SysuiColorExtractor; | |
@@ -200,7 +201,8 @@ public interface StatusBarPhoneModule { | |
Lazy<NotificationShadeDepthController> notificationShadeDepthController, | |
DismissCallbackRegistry dismissCallbackRegistry, | |
StatusBarTouchableRegionManager statusBarTouchableRegionManager, | |
- FlashlightController flashlightController) { | |
+ FlashlightController flashlightController, | |
+ FODCircleViewImpl fodCircleViewImpl) { | |
return new StatusBar( | |
context, | |
notificationsController, | |
@@ -279,6 +281,7 @@ public interface StatusBarPhoneModule { | |
dismissCallbackRegistry, | |
notificationShadeDepthController, | |
statusBarTouchableRegionManager, | |
- flashlightController); | |
+ flashlightController, | |
+ fodCircleViewImpl); | |
} | |
} | |
-- | |
2.20.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment