Skip to content

Commit

Permalink
Revert D57878119: Multisect successfully blamed "D57878119: [RN] [And…
Browse files Browse the repository at this point in the history
…roid] Fix status bar height calculation for all cutout sizes" for one test failure

Summary:
This diff reverts D57878119
D57878119: [RN] [Android] Fix status bar height calculation for all cutout sizes by Abbondanzo causes the following test failure:

Tests affected:
- [xplat/endtoend/jest-e2e/apps/fb4a/__tests__/dating/onboarding/fb4aDatingOnboardingSessionImpressionLogging-e2e.js](https://www.internalfb.com/intern/test/562949977559606/)

Here's the Multisect link:
https://www.internalfb.com/multisect/5267005
Here are the tasks that are relevant to this breakage:
T189149205: 17 critical tests unhealthy for oncall dating_react_native_sop

The backout may land if someone accepts it.

If this diff has been generated in error, you can Commandeer and Abandon it.

Changelog: [Internal]

Reviewed By: Abbondanzo

Differential Revision: D58053899

fbshipit-source-id: c65a1094259f85c8e6084b2f191ca1e4cd149510
  • Loading branch information
generatedunixname89002005232357 authored and pull[bot] committed Aug 8, 2024
1 parent f3c0815 commit 4317172
Showing 1 changed file with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import android.animation.ValueAnimator
import android.animation.ValueAnimator.AnimatorUpdateListener
import android.os.Build
import android.view.View
import android.view.WindowInsets
import android.view.WindowInsetsController
import android.view.WindowManager
import android.view.WindowManager.LayoutParams
import androidx.core.view.ViewCompat
import com.facebook.common.logging.FLog
import com.facebook.fbreact.specs.NativeStatusBarManagerAndroidSpec
Expand All @@ -33,48 +33,39 @@ public class StatusBarModule(reactContext: ReactApplicationContext?) :

@Suppress("DEPRECATION")
override fun getTypedExportedConstants(): Map<String, Any> {
val context = getReactApplicationContext()
val heightResId = context.resources.getIdentifier("status_bar_height", "dimen", "android")
val height =
heightResId
.takeIf { it > 0 }
?.let {
PixelUtil.toDIPFromPixel(context.resources.getDimensionPixelSize(it).toFloat())
} ?: 0

var statusBarColorString = "black"
val statusBarColor = currentActivity?.window?.statusBarColor
val statusBarColor = getCurrentActivity()?.window?.statusBarColor
if (statusBarColor != null) {
statusBarColorString = String.format("#%06X", 0xFFFFFF and statusBarColor)
}

return mapOf(
HEIGHT_KEY to PixelUtil.toDIPFromPixel(getStatusBarHeightPx()),
HEIGHT_KEY to height,
DEFAULT_BACKGROUND_COLOR_KEY to statusBarColorString,
)
}

@Suppress("DEPRECATION")
private fun getStatusBarHeightPx(): Float {
val activity = currentActivity ?: return 0f
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val window = activity.window ?: return 0f
val insets =
window.decorView.rootWindowInsets.getInsets(
WindowInsets.Type.statusBars() or
WindowInsets.Type.navigationBars() or
WindowInsets.Type.displayCutout())
insets.top.toFloat()
} else {
val window = activity.window ?: return 0f
val insets = window.decorView.rootWindowInsets
insets.systemWindowInsetTop.toFloat()
}
}

@Suppress("DEPRECATION")
override fun setColor(colorDouble: Double, animated: Boolean) {
val color = colorDouble.toInt()
val activity = currentActivity
val activity = getCurrentActivity()
if (activity == null) {
FLog.w(
ReactConstants.TAG,
"StatusBarModule: Ignored status bar change, current activity is null.")
return
}
UiThreadUtil.runOnUiThread(
object : GuardedRunnable(reactApplicationContext) {
object : GuardedRunnable(getReactApplicationContext()) {
override fun runGuarded() {
val window = activity.window ?: return
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
Expand All @@ -98,15 +89,15 @@ public class StatusBarModule(reactContext: ReactApplicationContext?) :

@Suppress("DEPRECATION")
override fun setTranslucent(translucent: Boolean) {
val activity = currentActivity
val activity = getCurrentActivity()
if (activity == null) {
FLog.w(
ReactConstants.TAG,
"StatusBarModule: Ignored status bar change, current activity is null.")
return
}
UiThreadUtil.runOnUiThread(
object : GuardedRunnable(reactApplicationContext) {
object : GuardedRunnable(getReactApplicationContext()) {
override fun runGuarded() {
// If the status bar is translucent hook into the window insets calculations
// and consume all the top insets so no padding will be added under the status bar.
Expand All @@ -131,7 +122,7 @@ public class StatusBarModule(reactContext: ReactApplicationContext?) :

@Suppress("DEPRECATION")
override fun setHidden(hidden: Boolean) {
val activity = currentActivity
val activity = getCurrentActivity()
if (activity == null) {
FLog.w(
ReactConstants.TAG,
Expand All @@ -153,7 +144,7 @@ public class StatusBarModule(reactContext: ReactApplicationContext?) :

@Suppress("DEPRECATION")
override fun setStyle(style: String?) {
val activity = currentActivity
val activity = getCurrentActivity()
if (activity == null) {
FLog.w(
ReactConstants.TAG,
Expand Down

0 comments on commit 4317172

Please sign in to comment.