@Test @SmallTest public void testGetInitialState_chargingIntent() { mockContextReturns(createBatteryChangedIntent(true)); assertThat(mTracker.getInitialState(), is(true)); }
@Override public Boolean getInitialState() { IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); Intent intent = mAppContext.registerReceiver(null, intentFilter); if (intent == null) { Log.e(TAG, "getInitialState - null intent received"); return null; } return isBatteryChangedIntentCharging(intent); }
BatteryChargingTracker extends BroadcastReceiverConstraintTracker<Boolean> { @Override public Boolean getInitialState() { IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); Intent intent = mAppContext.registerReceiver(null, intentFilter); if (intent == null) { Log.e(TAG, "getInitialState - null intent received"); return null; } return isBatteryChangedIntentCharging(intent); } }
BatteryChargingTracker extends BroadcastReceiverConstraintTracker<Boolean> { @Override public Boolean getInitialState() { IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); Intent intent = mAppContext.registerReceiver(null, intentFilter); if (intent == null) { Log.e(TAG, "getInitialState - null intent received"); return null; } return isBatteryChangedIntentCharging(intent); } BatteryChargingTracker(Context context); }
BatteryChargingTracker extends BroadcastReceiverConstraintTracker<Boolean> { @Override public Boolean getInitialState() { IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); Intent intent = mAppContext.registerReceiver(null, intentFilter); if (intent == null) { Log.e(TAG, "getInitialState - null intent received"); return null; } return isBatteryChangedIntentCharging(intent); } BatteryChargingTracker(Context context); @Override Boolean getInitialState(); @Override IntentFilter getIntentFilter(); @Override void onBroadcastReceive(Context context, @NonNull Intent intent); }
BatteryChargingTracker extends BroadcastReceiverConstraintTracker<Boolean> { @Override public Boolean getInitialState() { IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); Intent intent = mAppContext.registerReceiver(null, intentFilter); if (intent == null) { Log.e(TAG, "getInitialState - null intent received"); return null; } return isBatteryChangedIntentCharging(intent); } BatteryChargingTracker(Context context); @Override Boolean getInitialState(); @Override IntentFilter getIntentFilter(); @Override void onBroadcastReceive(Context context, @NonNull Intent intent);  }