Merge "network: Adds the functionality to parse uid in netlink messages." into nyc-dev
am: 2512ec9e37
* commit '2512ec9e376b0fce213f6d635dfb991c79041031':
network: Adds the functionality to parse uid in netlink messages.
Change-Id: I2bb83824d97d426d114f71fdb0b590ce9fd8a12a
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index 44e072d..216a4f1 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -90,7 +90,7 @@
void noteWakeUp(String reason, int reasonUid);
void noteInteractive(boolean interactive);
void noteConnectivityChanged(int type, String extra);
- void noteMobileRadioPowerState(int powerState, long timestampNs);
+ void noteMobileRadioPowerState(int powerState, long timestampNs, int uid);
void notePhoneOn();
void notePhoneOff();
void notePhoneSignalStrength(in SignalStrength signalStrength);
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 9fdc9c4..937fc75 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -3538,7 +3538,7 @@
mNumConnectivityChange++;
}
- public void noteMobileRadioPowerState(int powerState, long timestampNs) {
+ public void noteMobileRadioPowerState(int powerState, long timestampNs, int uid) {
final long elapsedRealtime = mClocks.elapsedRealtime();
final long uptime = mClocks.uptimeMillis();
if (mMobileRadioPowerState != powerState) {
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index e5b301e..22f01ab 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -468,7 +468,7 @@
* Notify our observers of a change in the data activity state of the interface
*/
private void notifyInterfaceClassActivity(int type, int powerState, long tsNanos,
- boolean fromRadio) {
+ int uid, boolean fromRadio) {
final boolean isMobile = ConnectivityManager.isNetworkTypeMobile(type);
if (isMobile) {
if (!fromRadio) {
@@ -484,7 +484,7 @@
if (mLastPowerStateFromRadio != powerState) {
mLastPowerStateFromRadio = powerState;
try {
- getBatteryStats().noteMobileRadioPowerState(powerState, tsNanos);
+ getBatteryStats().noteMobileRadioPowerState(powerState, tsNanos, uid);
} catch (RemoteException e) {
}
}
@@ -845,9 +845,13 @@
throw new IllegalStateException(errorMessage);
}
long timestampNanos = 0;
- if (cooked.length == 5) {
+ int processUid = -1;
+ if (cooked.length >= 5) {
try {
timestampNanos = Long.parseLong(cooked[4]);
+ if (cooked.length == 6) {
+ processUid = Integer.parseInt(cooked[5]);
+ }
} catch(NumberFormatException ne) {}
} else {
timestampNanos = SystemClock.elapsedRealtimeNanos();
@@ -855,7 +859,8 @@
boolean isActive = cooked[2].equals("active");
notifyInterfaceClassActivity(Integer.parseInt(cooked[3]),
isActive ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH
- : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW, timestampNanos, false);
+ : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW,
+ timestampNanos, processUid, false);
return true;
// break;
case NetdResponseCode.InterfaceAddressChange:
@@ -1599,7 +1604,7 @@
@Override public void run() {
notifyInterfaceClassActivity(type,
DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH,
- SystemClock.elapsedRealtimeNanos(), false);
+ SystemClock.elapsedRealtimeNanos(), -1, false);
}
});
}
@@ -1628,7 +1633,7 @@
@Override public void run() {
notifyInterfaceClassActivity(params.type,
DataConnectionRealTimeInfo.DC_POWER_STATE_LOW,
- SystemClock.elapsedRealtimeNanos(), false);
+ SystemClock.elapsedRealtimeNanos(), -1, false);
}
});
}
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index af5c577..96934f0 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -565,10 +565,10 @@
}
}
- public void noteMobileRadioPowerState(int powerState, long timestampNs) {
+ public void noteMobileRadioPowerState(int powerState, long timestampNs, int uid) {
enforceCallingPermission();
synchronized (mStats) {
- mStats.noteMobileRadioPowerState(powerState, timestampNs);
+ mStats.noteMobileRadioPowerState(powerState, timestampNs, uid);
}
}