|
43 | 43 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
44 | 44 | import com.android.systemui.Dependency; |
45 | 45 | import com.android.systemui.R; |
| 46 | +import com.android.systemui.statusbar.policy.ConfigurationController; |
| 47 | +import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; |
46 | 48 |
|
47 | 49 | import vendor.lineage.biometrics.fingerprint.inscreen.V1_0.IFingerprintInscreen; |
48 | 50 | import vendor.lineage.biometrics.fingerprint.inscreen.V1_0.IFingerprintInscreenCallback; |
|
51 | 53 | import java.util.Timer; |
52 | 54 | import java.util.TimerTask; |
53 | 55 |
|
54 | | -public class FODCircleView extends ImageView { |
| 56 | +public class FODCircleView extends ImageView implements ConfigurationListener { |
55 | 57 | private final int mPositionX; |
56 | 58 | private final int mPositionY; |
57 | 59 | private final int mSize; |
@@ -137,6 +139,9 @@ public void onScreenTurnedOn() { |
137 | 139 | } |
138 | 140 | }; |
139 | 141 |
|
| 142 | + private boolean mCutoutMasked; |
| 143 | + private int mStatusbarHeight; |
| 144 | + |
140 | 145 | public FODCircleView(Context context) { |
141 | 146 | super(context); |
142 | 147 |
|
@@ -208,6 +213,9 @@ protected void onDraw(Canvas canvas) { |
208 | 213 |
|
209 | 214 | mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class); |
210 | 215 | mUpdateMonitor.registerCallback(mMonitorCallback); |
| 216 | + |
| 217 | + updateCutoutFlags(); |
| 218 | + Dependency.get(ConfigurationController.class).addCallback(this); |
211 | 219 | } |
212 | 220 |
|
213 | 221 | @Override |
@@ -354,22 +362,23 @@ private void updatePosition() { |
354 | 362 | defaultDisplay.getRealSize(size); |
355 | 363 |
|
356 | 364 | int rotation = defaultDisplay.getRotation(); |
| 365 | + int cutoutMaskedExtra = mCutoutMasked ? mStatusbarHeight : 0; |
357 | 366 | int x, y; |
358 | 367 | switch (rotation) { |
359 | 368 | case Surface.ROTATION_0: |
360 | 369 | x = mPositionX; |
361 | | - y = mPositionY; |
| 370 | + y = mPositionY - cutoutMaskedExtra; |
362 | 371 | break; |
363 | 372 | case Surface.ROTATION_90: |
364 | 373 | x = mPositionY; |
365 | | - y = mPositionX; |
| 374 | + y = mPositionX - cutoutMaskedExtra; |
366 | 375 | break; |
367 | 376 | case Surface.ROTATION_180: |
368 | 377 | x = mPositionX; |
369 | | - y = size.y - mPositionY - mSize; |
| 378 | + y = size.y - mPositionY - mSize - cutoutMaskedExtra; |
370 | 379 | break; |
371 | 380 | case Surface.ROTATION_270: |
372 | | - x = size.x - mPositionY - mSize - mNavigationBarSize; |
| 381 | + x = size.x - mPositionY - mSize - mNavigationBarSize - cutoutMaskedExtra; |
373 | 382 | y = mPositionX; |
374 | 383 | break; |
375 | 384 | default: |
@@ -461,4 +470,20 @@ public void run() { |
461 | 470 | mHandler.post(() -> updatePosition()); |
462 | 471 | } |
463 | 472 | }; |
| 473 | + |
| 474 | + @Override |
| 475 | + public void onOverlayChanged() { |
| 476 | + updateCutoutFlags(); |
| 477 | + } |
| 478 | + |
| 479 | + private void updateCutoutFlags() { |
| 480 | + mStatusbarHeight = getContext().getResources().getDimensionPixelSize( |
| 481 | + com.android.internal.R.dimen.status_bar_height_portrait); |
| 482 | + boolean cutoutMasked = getContext().getResources().getBoolean( |
| 483 | + com.android.internal.R.bool.config_maskMainBuiltInDisplayCutout); |
| 484 | + if (mCutoutMasked != cutoutMasked){ |
| 485 | + mCutoutMasked = cutoutMasked; |
| 486 | + updatePosition(); |
| 487 | + } |
| 488 | + } |
464 | 489 | } |
0 commit comments