Merge "Change to public POWER_SAVE_MODE_CHANGED broadcast." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1a84719041
@@ -39,7 +39,7 @@ public class BatterySaverReceiver extends BroadcastReceiver {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (DEBUG) Log.d(TAG, "Received " + intent.getAction());
|
if (DEBUG) Log.d(TAG, "Received " + intent.getAction());
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGING.equals(action)) {
|
if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGED.equals(action)) {
|
||||||
if (mBatterySaverListener != null) {
|
if (mBatterySaverListener != null) {
|
||||||
mBatterySaverListener.onPowerSaveModeChanged();
|
mBatterySaverListener.onPowerSaveModeChanged();
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ public class BatterySaverReceiver extends BroadcastReceiver {
|
|||||||
public void setListening(boolean listening) {
|
public void setListening(boolean listening) {
|
||||||
if (listening && !mRegistered) {
|
if (listening && !mRegistered) {
|
||||||
final IntentFilter ifilter = new IntentFilter();
|
final IntentFilter ifilter = new IntentFilter();
|
||||||
ifilter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGING);
|
ifilter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
|
||||||
ifilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
ifilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
mContext.registerReceiver(this, ifilter);
|
mContext.registerReceiver(this, ifilter);
|
||||||
mRegistered = true;
|
mRegistered = true;
|
||||||
|
@@ -68,7 +68,7 @@ public class BatterySaverReceiverTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOnReceive_powerSaveModeChanged_invokeCallback() {
|
public void testOnReceive_powerSaveModeChanged_invokeCallback() {
|
||||||
Intent intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGING);
|
Intent intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
|
||||||
|
|
||||||
mBatterySaverReceiver.onReceive(mContext, intent);
|
mBatterySaverReceiver.onReceive(mContext, intent);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user