Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2512ec9e authored by Ruchi Kandoi's avatar Ruchi Kandoi Committed by Android (Google) Code Review
Browse files

Merge "network: Adds the functionality to parse uid in netlink messages." into nyc-dev

parents 73522651 fa97fcf7
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ interface IBatteryStats {
    void noteWakeUp(String reason, int reasonUid);
    void noteWakeUp(String reason, int reasonUid);
    void noteInteractive(boolean interactive);
    void noteInteractive(boolean interactive);
    void noteConnectivityChanged(int type, String extra);
    void noteConnectivityChanged(int type, String extra);
    void noteMobileRadioPowerState(int powerState, long timestampNs);
    void noteMobileRadioPowerState(int powerState, long timestampNs, int uid);
    void notePhoneOn();
    void notePhoneOn();
    void notePhoneOff();
    void notePhoneOff();
    void notePhoneSignalStrength(in SignalStrength signalStrength);
    void notePhoneSignalStrength(in SignalStrength signalStrength);
+1 −1
Original line number Original line Diff line number Diff line
@@ -3538,7 +3538,7 @@ public class BatteryStatsImpl extends BatteryStats {
        mNumConnectivityChange++;
        mNumConnectivityChange++;
    }
    }


    public void noteMobileRadioPowerState(int powerState, long timestampNs) {
    public void noteMobileRadioPowerState(int powerState, long timestampNs, int uid) {
        final long elapsedRealtime = mClocks.elapsedRealtime();
        final long elapsedRealtime = mClocks.elapsedRealtime();
        final long uptime = mClocks.uptimeMillis();
        final long uptime = mClocks.uptimeMillis();
        if (mMobileRadioPowerState != powerState) {
        if (mMobileRadioPowerState != powerState) {
+11 −6
Original line number Original line Diff line number Diff line
@@ -468,7 +468,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
     * Notify our observers of a change in the data activity state of the interface
     * Notify our observers of a change in the data activity state of the interface
     */
     */
    private void notifyInterfaceClassActivity(int type, int powerState, long tsNanos,
    private void notifyInterfaceClassActivity(int type, int powerState, long tsNanos,
            boolean fromRadio) {
            int uid, boolean fromRadio) {
        final boolean isMobile = ConnectivityManager.isNetworkTypeMobile(type);
        final boolean isMobile = ConnectivityManager.isNetworkTypeMobile(type);
        if (isMobile) {
        if (isMobile) {
            if (!fromRadio) {
            if (!fromRadio) {
@@ -484,7 +484,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
            if (mLastPowerStateFromRadio != powerState) {
            if (mLastPowerStateFromRadio != powerState) {
                mLastPowerStateFromRadio = powerState;
                mLastPowerStateFromRadio = powerState;
                try {
                try {
                    getBatteryStats().noteMobileRadioPowerState(powerState, tsNanos);
                    getBatteryStats().noteMobileRadioPowerState(powerState, tsNanos, uid);
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                }
                }
            }
            }
@@ -845,9 +845,13 @@ public class NetworkManagementService extends INetworkManagementService.Stub
                        throw new IllegalStateException(errorMessage);
                        throw new IllegalStateException(errorMessage);
                    }
                    }
                    long timestampNanos = 0;
                    long timestampNanos = 0;
                    if (cooked.length == 5) {
                    int processUid = -1;
                    if (cooked.length >= 5) {
                        try {
                        try {
                            timestampNanos = Long.parseLong(cooked[4]);
                            timestampNanos = Long.parseLong(cooked[4]);
                            if (cooked.length == 6) {
                                processUid = Integer.parseInt(cooked[5]);
                            }
                        } catch(NumberFormatException ne) {}
                        } catch(NumberFormatException ne) {}
                    } else {
                    } else {
                        timestampNanos = SystemClock.elapsedRealtimeNanos();
                        timestampNanos = SystemClock.elapsedRealtimeNanos();
@@ -855,7 +859,8 @@ public class NetworkManagementService extends INetworkManagementService.Stub
                    boolean isActive = cooked[2].equals("active");
                    boolean isActive = cooked[2].equals("active");
                    notifyInterfaceClassActivity(Integer.parseInt(cooked[3]),
                    notifyInterfaceClassActivity(Integer.parseInt(cooked[3]),
                            isActive ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH
                            isActive ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH
                            : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW, timestampNanos, false);
                            : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW,
                            timestampNanos, processUid, false);
                    return true;
                    return true;
                    // break;
                    // break;
            case NetdResponseCode.InterfaceAddressChange:
            case NetdResponseCode.InterfaceAddressChange:
@@ -1599,7 +1604,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
                @Override public void run() {
                @Override public void run() {
                    notifyInterfaceClassActivity(type,
                    notifyInterfaceClassActivity(type,
                            DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH,
                            DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH,
                            SystemClock.elapsedRealtimeNanos(), false);
                            SystemClock.elapsedRealtimeNanos(), -1, false);
                }
                }
            });
            });
        }
        }
@@ -1628,7 +1633,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
                @Override public void run() {
                @Override public void run() {
                    notifyInterfaceClassActivity(params.type,
                    notifyInterfaceClassActivity(params.type,
                            DataConnectionRealTimeInfo.DC_POWER_STATE_LOW,
                            DataConnectionRealTimeInfo.DC_POWER_STATE_LOW,
                            SystemClock.elapsedRealtimeNanos(), false);
                            SystemClock.elapsedRealtimeNanos(), -1, false);
                }
                }
            });
            });
        }
        }
+2 −2
Original line number Original line Diff line number Diff line
@@ -565,10 +565,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
        }
        }
    }
    }


    public void noteMobileRadioPowerState(int powerState, long timestampNs) {
    public void noteMobileRadioPowerState(int powerState, long timestampNs, int uid) {
        enforceCallingPermission();
        enforceCallingPermission();
        synchronized (mStats) {
        synchronized (mStats) {
            mStats.noteMobileRadioPowerState(powerState, timestampNs);
            mStats.noteMobileRadioPowerState(powerState, timestampNs, uid);
        }
        }
    }
    }