diff options
Diffstat (limited to 'services/java/com/android/server/TelephonyRegistry.java')
-rw-r--r-- | services/java/com/android/server/TelephonyRegistry.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java index b5cf1aabd702..5e5fb935a1e8 100644 --- a/services/java/com/android/server/TelephonyRegistry.java +++ b/services/java/com/android/server/TelephonyRegistry.java @@ -33,12 +33,14 @@ import java.util.ArrayList; import java.io.FileDescriptor; import java.io.PrintWriter; +import com.android.internal.app.IBatteryStats; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.DefaultPhoneNotifier; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneStateIntentReceiver; import com.android.internal.telephony.TelephonyIntents; +import com.android.server.am.BatteryStatsService; /** @@ -55,8 +57,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { int events; } - private Context mContext; - private ArrayList<Record> mRecords = new ArrayList(); + private final Context mContext; + private final ArrayList<Record> mRecords = new ArrayList(); + private final IBatteryStats mBatteryStats; private int mCallState = TelephonyManager.CALL_STATE_IDLE; private String mCallIncomingNumber = ""; @@ -81,6 +84,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { TelephonyRegistry(Context context) { CellLocation.getEmpty().fillInNotifierBundle(mCellLocation); mContext = context; + mBatteryStats = BatteryStatsService.getService(); } public void listen(String pkgForDebug, IPhoneStateListener callback, int events, @@ -414,6 +418,18 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } private void broadcastCallStateChanged(int state, String incomingNumber) { + long ident = Binder.clearCallingIdentity(); + try { + if (state == TelephonyManager.CALL_STATE_IDLE) { + mBatteryStats.notePhoneOff(); + } else { + mBatteryStats.notePhoneOn(); + } + } catch (RemoteException e) { + } finally { + Binder.restoreCallingIdentity(ident); + } + Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertCallState(state).toString()); |