package com.kwad.components.core.n; import android.app.Activity; import android.os.Build; import android.view.View; import android.view.Window; import android.view.WindowManager; import com.kwad.sdk.utils.r; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public final class m { private static Method LS; private static Method LT; private static Field LU; private static int SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; static { try { LS = Activity.class.getMethod("setStatusBarDarkIcon", Integer.TYPE); } catch (NoSuchMethodException e) { e.printStackTrace(); } try { LT = Activity.class.getMethod("setStatusBarDarkIcon", Boolean.TYPE); } catch (NoSuchMethodException e2) { e2.printStackTrace(); } try { LU = WindowManager.LayoutParams.class.getField("statusBarColor"); } catch (NoSuchFieldException e3) { e3.printStackTrace(); } try { SYSTEM_UI_FLAG_LIGHT_STATUS_BAR = ((Integer) r.c((Class<?>) View.class, "SYSTEM_UI_FLAG_LIGHT_STATUS_BAR")).intValue(); } catch (Exception e4) { e4.printStackTrace(); } } private static void a(Activity activity, boolean z, boolean z2) { Method method = LT; if (method != null) { try { method.invoke(activity, Boolean.valueOf(z)); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e2) { e2.printStackTrace(); } } else { a(activity.getWindow(), z); } } private static void a(Window window, boolean z) { if (Build.VERSION.SDK_INT < 23) { a(window.getAttributes(), "MEIZU_FLAG_DARK_STATUS_BAR_ICON", z); return; } View decorView = window.getDecorView(); if (decorView != null) { g(decorView, z); setStatusBarColor(window, 0); } } private static boolean a(WindowManager.LayoutParams layoutParams, String str, boolean z) { try { int intValue = ((Integer) r.c(layoutParams, str)).intValue(); int intValue2 = ((Integer) r.c(layoutParams, "meizuFlags")).intValue(); int i = z ? intValue | intValue2 : (~intValue) & intValue2; if (intValue2 == i) { return false; } r.a(layoutParams, "meizuFlags", Integer.valueOf(i)); return true; } catch (Throwable th) { th.printStackTrace(); return false; } } public static void b(Activity activity, boolean z) { a(activity, true, true); } private static void g(View view, boolean z) { int systemUiVisibility = view.getSystemUiVisibility(); int i = z ? SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | systemUiVisibility : (~SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) & systemUiVisibility; if (i != systemUiVisibility) { view.setSystemUiVisibility(i); } } private static void setStatusBarColor(Window window, int i) { WindowManager.LayoutParams attributes = window.getAttributes(); Field field = LU; if (field != null) { try { if (field.getInt(attributes) != 0) { LU.set(attributes, 0); window.setAttributes(attributes); } } catch (IllegalAccessException e) { e.printStackTrace(); } } } }