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.PowerManager;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
@@ -2454,8 +2455,7 @@ final class StockLayoutCanvasController {
|
||||
}
|
||||
if (!isTrackableStatusChipSurface(view)
|
||||
&& !isTrackedHiddenStatusChipSource(root, view)) {
|
||||
hiddenViewStates.remove(view);
|
||||
trackedUnlockedStockSurfaces.remove(view);
|
||||
forgetTrackedStatusChipState(view);
|
||||
staleViews.add(view);
|
||||
continue;
|
||||
}
|
||||
@@ -3457,6 +3457,9 @@ final class StockLayoutCanvasController {
|
||||
if (view == null || ownedIconHostManager.isOwnedHost(view)) {
|
||||
return false;
|
||||
}
|
||||
if (view.getVisibility() != View.VISIBLE) {
|
||||
return false;
|
||||
}
|
||||
String idName = ViewIdNames.idName(view);
|
||||
if (!"ongoing_activity_capsule".equals(idName)) {
|
||||
return false;
|
||||
@@ -3485,9 +3488,26 @@ final class StockLayoutCanvasController {
|
||||
|| !isStatusChipCandidate(view)) {
|
||||
return false;
|
||||
}
|
||||
if (isCallStatusChip(view)
|
||||
&& view.getVisibility() != View.VISIBLE
|
||||
&& !isPhoneCallActive(view)) {
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
if (!(source instanceof ViewGroup group)) {
|
||||
return false;
|
||||
@@ -4303,11 +4323,19 @@ final class StockLayoutCanvasController {
|
||||
|| isStatusChipShell(view)) {
|
||||
return false;
|
||||
}
|
||||
hiddenViewStates.remove(view);
|
||||
forgetTrackedStatusChip(view);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void forgetTrackedStatusChip(View view) {
|
||||
forgetTrackedStatusChipState(view);
|
||||
trackedStatusChipSources.remove(view);
|
||||
}
|
||||
|
||||
private void forgetTrackedStatusChipState(View view) {
|
||||
hiddenViewStates.remove(view);
|
||||
trackedUnlockedStockSurfaces.remove(view);
|
||||
statusChipLifecycleLayoutSignatureByView.remove(view);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cleanupLayoutOffRoot(View root, SceneKey activeScene) {
|
||||
|
||||
+2
-1
@@ -1188,6 +1188,7 @@ final class UnlockedStockSourceCollector {
|
||||
View view = source.view();
|
||||
if (view == null
|
||||
|| view == root
|
||||
|| view.getVisibility() != View.VISIBLE
|
||||
|| !view.isAttachedToWindow()
|
||||
|| !ViewGeometry.isDescendantOf(view, root)
|
||||
|| ReflectionSupport.getBooleanField(view, "sbtStatusChipForcedHidden", false)
|
||||
@@ -1301,7 +1302,7 @@ final class UnlockedStockSourceCollector {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (!allowHidden && view.getAlpha() <= 0f && !hasRenderableStatusChipContent(view)) {
|
||||
|
||||
Reference in New Issue
Block a user