public BatteryService(Context context, LightsService lights) {
    mContext = context;
    mHandler = new Handler(true /*async*/);
    mLed = new Led(context, lights);
    mBatteryStats = BatteryStatsService.getService();

    mCriticalBatteryLevel =
        mContext
            .getResources()
            .getInteger(com.android.internal.R.integer.config_criticalBatteryWarningLevel);
    mLowBatteryWarningLevel =
        mContext
            .getResources()
            .getInteger(com.android.internal.R.integer.config_lowBatteryWarningLevel);
    mLowBatteryCloseWarningLevel =
        mContext
            .getResources()
            .getInteger(com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);
    mShutdownBatteryTemperature =
        mContext
            .getResources()
            .getInteger(com.android.internal.R.integer.config_shutdownBatteryTemperature);

    // watch for invalid charger messages if the invalid_charger switch exists
    if (new File("/sys/devices/virtual/switch/invalid_charger/state").exists()) {
      mInvalidChargerObserver.startObserving("DEVPATH=/devices/virtual/switch/invalid_charger");
    }

    mBatteryPropertiesListener = new BatteryListener();

    IBinder b = ServiceManager.getService("batterypropreg");
    mBatteryPropertiesRegistrar = IBatteryPropertiesRegistrar.Stub.asInterface(b);

    try {
      mBatteryPropertiesRegistrar.registerListener(mBatteryPropertiesListener);
    } catch (RemoteException e) {
      // Should never happen.
    }
    if (FeatureOption.MTK_IPO_SUPPORT == true) {
      IntentFilter filter = new IntentFilter();
      filter.addAction(IPO_POWER_ON);
      filter.addAction(IPO_POWER_OFF);
      mContext.registerReceiver(
          new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
              if (IPO_POWER_ON.equals(intent.getAction())) {
                mIPOShutdown = false;
                mIPOBoot = true;
                // Let BatteryService to handle low battery warning.
                mLastBatteryLevel = mLowBatteryWarningLevel + 1;
                update(mBatteryProps);
              } else if (IPO_POWER_OFF.equals(intent.getAction())) {
                mIPOShutdown = true;
              }
            }
          },
          filter);
    }
  }
  public BatteryService(Context context, LightsService lights) {
    mContext = context;
    mLed = new Led(context, lights);
    mBatteryStats = BatteryStatsService.getService();

    mCriticalBatteryLevel =
        mContext
            .getResources()
            .getInteger(com.android.internal.R.integer.config_criticalBatteryWarningLevel);
    mLowBatteryWarningLevel =
        mContext
            .getResources()
            .getInteger(com.android.internal.R.integer.config_lowBatteryWarningLevel);
    mLowBatteryCloseWarningLevel =
        mContext
            .getResources()
            .getInteger(com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);

    mPowerSupplyObserver.startObserving("SUBSYSTEM=power_supply");

    // watch for invalid charger messages if the invalid_charger switch exists
    if (new File("/sys/devices/virtual/switch/invalid_charger/state").exists()) {
      mInvalidChargerObserver.startObserving("DEVPATH=/devices/virtual/switch/invalid_charger");
    }

    // set initial status
    update();
  }