Fix call chip lifecycle tracking
This commit is contained in:
+32
-4
@@ -10,6 +10,7 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
|
import android.telecom.TelecomManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@@ -2454,8 +2455,7 @@ final class StockLayoutCanvasController {
|
|||||||
}
|
}
|
||||||
if (!isTrackableStatusChipSurface(view)
|
if (!isTrackableStatusChipSurface(view)
|
||||||
&& !isTrackedHiddenStatusChipSource(root, view)) {
|
&& !isTrackedHiddenStatusChipSource(root, view)) {
|
||||||
hiddenViewStates.remove(view);
|
forgetTrackedStatusChipState(view);
|
||||||
trackedUnlockedStockSurfaces.remove(view);
|
|
||||||
staleViews.add(view);
|
staleViews.add(view);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -3457,6 +3457,9 @@ final class StockLayoutCanvasController {
|
|||||||
if (view == null || ownedIconHostManager.isOwnedHost(view)) {
|
if (view == null || ownedIconHostManager.isOwnedHost(view)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (view.getVisibility() != View.VISIBLE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String idName = ViewIdNames.idName(view);
|
String idName = ViewIdNames.idName(view);
|
||||||
if (!"ongoing_activity_capsule".equals(idName)) {
|
if (!"ongoing_activity_capsule".equals(idName)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -3485,9 +3488,26 @@ final class StockLayoutCanvasController {
|
|||||||
|| !isStatusChipCandidate(view)) {
|
|| !isStatusChipCandidate(view)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (isCallStatusChip(view)
|
||||||
|
&& view.getVisibility() != View.VISIBLE
|
||||||
|
&& !isPhoneCallActive(view)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return hasVisibleStatusChipContent(view);
|
return hasVisibleStatusChipContent(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPhoneCallActive(View view) {
|
||||||
|
if (view == null || view.getContext() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
TelecomManager telecomManager = view.getContext().getSystemService(TelecomManager.class);
|
||||||
|
return telecomManager != null && telecomManager.isInCall();
|
||||||
|
} catch (RuntimeException ignored) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasVisibleStatusChipContent(View source) {
|
private boolean hasVisibleStatusChipContent(View source) {
|
||||||
if (!(source instanceof ViewGroup group)) {
|
if (!(source instanceof ViewGroup group)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -4303,11 +4323,19 @@ final class StockLayoutCanvasController {
|
|||||||
|| isStatusChipShell(view)) {
|
|| isStatusChipShell(view)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hiddenViewStates.remove(view);
|
forgetTrackedStatusChip(view);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forgetTrackedStatusChip(View view) {
|
||||||
|
forgetTrackedStatusChipState(view);
|
||||||
trackedStatusChipSources.remove(view);
|
trackedStatusChipSources.remove(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forgetTrackedStatusChipState(View view) {
|
||||||
|
hiddenViewStates.remove(view);
|
||||||
trackedUnlockedStockSurfaces.remove(view);
|
trackedUnlockedStockSurfaces.remove(view);
|
||||||
statusChipLifecycleLayoutSignatureByView.remove(view);
|
statusChipLifecycleLayoutSignatureByView.remove(view);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupLayoutOffRoot(View root, SceneKey activeScene) {
|
private void cleanupLayoutOffRoot(View root, SceneKey activeScene) {
|
||||||
|
|||||||
+2
-1
@@ -1188,6 +1188,7 @@ final class UnlockedStockSourceCollector {
|
|||||||
View view = source.view();
|
View view = source.view();
|
||||||
if (view == null
|
if (view == null
|
||||||
|| view == root
|
|| view == root
|
||||||
|
|| view.getVisibility() != View.VISIBLE
|
||||||
|| !view.isAttachedToWindow()
|
|| !view.isAttachedToWindow()
|
||||||
|| !ViewGeometry.isDescendantOf(view, root)
|
|| !ViewGeometry.isDescendantOf(view, root)
|
||||||
|| ReflectionSupport.getBooleanField(view, "sbtStatusChipForcedHidden", false)
|
|| ReflectionSupport.getBooleanField(view, "sbtStatusChipForcedHidden", false)
|
||||||
@@ -1301,7 +1302,7 @@ final class UnlockedStockSourceCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStatusChipMetricCandidate(View root, View view, boolean allowHidden) {
|
private boolean isStatusChipMetricCandidate(View root, View view, boolean allowHidden) {
|
||||||
if (view == null || view == root || root == null) {
|
if (view == null || view == root || root == null || view.getVisibility() != View.VISIBLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!allowHidden && view.getAlpha() <= 0f && !hasRenderableStatusChipContent(view)) {
|
if (!allowHidden && view.getAlpha() <= 0f && !hasRenderableStatusChipContent(view)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user