翰林优商.apk(点击下载) / PowerMonitor.java


package aegon.chrome.base;

import aegon.chrome.base.annotations.JNINamespace;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

@JNINamespace("base::android")
public class PowerMonitor {
    static final /* synthetic */ boolean $assertionsDisabled = false;
    private static PowerMonitor sInstance;
    private boolean mIsBatteryPower;

    private PowerMonitor() {
    }

    public static void create() {
        ThreadUtils.assertOnUiThread();
        if (sInstance == null) {
            Context applicationContext = ContextUtils.getApplicationContext();
            sInstance = new PowerMonitor();
            Intent registerReceiver = applicationContext.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
            if (registerReceiver != null) {
                onBatteryChargingChanged(registerReceiver);
            }
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction("android.intent.action.ACTION_POWER_CONNECTED");
            intentFilter.addAction("android.intent.action.ACTION_POWER_DISCONNECTED");
            applicationContext.registerReceiver(new BroadcastReceiver() {
                /* class aegon.chrome.base.PowerMonitor.AnonymousClass1 */

                public void onReceive(Context context, Intent intent) {
                    PowerMonitor.onBatteryChargingChanged(intent);
                }
            }, intentFilter);
        }
    }

    public static void createForTests() {
        sInstance = new PowerMonitor();
    }

    private static boolean isBatteryPower() {
        if (sInstance == null) {
            create();
        }
        return sInstance.mIsBatteryPower;
    }

    private static native void nativeOnBatteryChargingChanged();

    /* access modifiers changed from: private */
    public static void onBatteryChargingChanged(Intent intent) {
        int intExtra = intent.getIntExtra("plugged", -1);
        PowerMonitor powerMonitor = sInstance;
        boolean z = true;
        if (intExtra == 2 || intExtra == 1) {
            z = false;
        }
        powerMonitor.mIsBatteryPower = z;
        nativeOnBatteryChargingChanged();
    }
}