diff options
author | Dianne Hackborn <> | 2009-03-24 22:32:56 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-24 22:32:56 -0700 |
commit | 627bba736d022c39696b7c582a6af5592d2b8c33 (patch) | |
tree | 42c0b064b345aa053ca63ff09e928f24705f9101 /services | |
parent | 1d4613c1ec6ddf8aec3f723a7cab4253d19f9e66 (diff) | |
download | frameworks_base-627bba736d022c39696b7c582a6af5592d2b8c33.zip frameworks_base-627bba736d022c39696b7c582a6af5592d2b8c33.tar.gz frameworks_base-627bba736d022c39696b7c582a6af5592d2b8c33.tar.bz2 |
Automated import from //branches/donutburger/...@142347,142347
Diffstat (limited to 'services')
3 files changed, 45 insertions, 5 deletions
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java index a74915c..fa54421 100644 --- a/services/java/com/android/server/TelephonyRegistry.java +++ b/services/java/com/android/server/TelephonyRegistry.java @@ -440,6 +440,14 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } private void broadcastSignalStrengthChanged(int asu) { + long ident = Binder.clearCallingIdentity(); + try { + mBatteryStats.notePhoneSignalStrength(asu); + } catch (RemoteException e) { + } finally { + Binder.restoreCallingIdentity(ident); + } + Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED); intent.putExtra(PhoneStateIntentReceiver.INTENT_KEY_ASU, asu); mContext.sendStickyBroadcast(intent); @@ -469,6 +477,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private void broadcastDataConnectionStateChanged(int state, boolean isDataConnectivityPossible, String reason, String apn, String interfaceName) { + // Note: not reporting to the battery stats service here, because the + // status bar takes care of that after taking into account all of the + // required info. Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertDataState(state).toString()); if (!isDataConnectivityPossible) { diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java index ee89c09..2192e06 100644 --- a/services/java/com/android/server/am/BatteryStatsService.java +++ b/services/java/com/android/server/am/BatteryStatsService.java @@ -25,6 +25,7 @@ import android.os.IBinder; import android.os.Parcel; import android.os.Process; import android.os.ServiceManager; +import android.telephony.TelephonyManager; import android.util.PrintWriterPrinter; import java.io.FileDescriptor; @@ -149,6 +150,20 @@ public final class BatteryStatsService extends IBatteryStats.Stub { } } + public void notePhoneSignalStrength(int asu) { + enforceCallingPermission(); + synchronized (mStats) { + mStats.notePhoneSignalStrengthLocked(asu); + } + } + + public void notePhoneDataConnectionState(int dataType, boolean hasData) { + enforceCallingPermission(); + synchronized (mStats) { + mStats.notePhoneDataConnectionStateLocked(dataType, hasData); + } + } + public void noteWifiOn() { enforceCallingPermission(); synchronized (mStats) { diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java index 36d1465..713cd13 100644 --- a/services/java/com/android/server/status/StatusBarPolicy.java +++ b/services/java/com/android/server/status/StatusBarPolicy.java @@ -17,9 +17,11 @@ package com.android.server.status; import com.android.internal.R; +import com.android.internal.app.IBatteryStats; import com.android.internal.location.GpsLocationProvider; import com.android.internal.telephony.SimCard; import com.android.internal.telephony.TelephonyIntents; +import com.android.server.am.BatteryStatsService; import android.app.AlertDialog; import android.bluetooth.BluetoothA2dp; @@ -38,9 +40,11 @@ import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.net.NetworkInfo; import android.net.wifi.WifiManager; +import android.os.Binder; import android.os.Handler; import android.os.IBinder; import android.os.Message; +import android.os.RemoteException; import android.provider.Settings; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; @@ -78,9 +82,10 @@ public class StatusBarPolicy { private static final int BATTERY_THRESHOLD_WARNING = 1; private static final int BATTERY_THRESHOLD_EMPTY = 2; - private Context mContext; - private StatusBarService mService; - private Handler mHandler = new StatusBarHandler(); + private final Context mContext; + private final StatusBarService mService; + private final Handler mHandler = new StatusBarHandler(); + private final IBatteryStats mBatteryStats; // clock private Calendar mCalendar; @@ -144,6 +149,7 @@ public class StatusBarPolicy { SimCard.State mSimState = SimCard.State.READY; int mPhoneState = TelephonyManager.CALL_STATE_IDLE; int mDataState = TelephonyManager.DATA_DISCONNECTED; + int mDataNetType = TelephonyManager.NETWORK_TYPE_UNKNOWN; int mDataActivity = TelephonyManager.DATA_ACTIVITY_NONE; ServiceState mServiceState; int mSignalAsu = -1; @@ -250,6 +256,7 @@ public class StatusBarPolicy { private StatusBarPolicy(Context context, StatusBarService service) { mContext = context; mService = service; + mBatteryStats = BatteryStatsService.getService(); // clock mCalendar = Calendar.getInstance(TimeZone.getDefault()); @@ -711,8 +718,8 @@ public class StatusBarPolicy { } private final void updateDataNetType() { - int net = mPhone.getNetworkType(); - switch (net) { + mDataNetType = mPhone.getNetworkType(); + switch (mDataNetType) { case TelephonyManager.NETWORK_TYPE_EDGE: mDataIconList = sDataNetType_e; break; @@ -766,6 +773,13 @@ public class StatusBarPolicy { mDataData.iconId = com.android.internal.R.drawable.stat_sys_no_sim; mService.updateIcon(mDataIcon, mDataData, null); } + long ident = Binder.clearCallingIdentity(); + try { + mBatteryStats.notePhoneDataConnectionState(mDataNetType, visible); + } catch (RemoteException e) { + } finally { + Binder.restoreCallingIdentity(ident); + } if (mDataIconVisible != visible) { mService.setIconVisibility(mDataIcon, visible); mDataIconVisible = visible; |