Merge "[IT04] Add uid as parameter of interfaceClassDataActivityChanged" am: baef452e38 am: 04aa5eac85 am: a817ecd4b5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1523339 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ieafdf569c13b1421c18fa3086827e6e432b498d7
This commit is contained in:
@@ -85,11 +85,14 @@ oneway interface INetworkManagementEventObserver {
|
||||
/**
|
||||
* Interface data activity status is changed.
|
||||
*
|
||||
* @param iface The interface.
|
||||
* @param label Unique identifier indicates the network type of the data activity change.
|
||||
* @param active True if the interface is actively transmitting data, false if it is idle.
|
||||
* @param tsNanos Elapsed realtime in nanos when the state of the network interface changed.
|
||||
* @param uid Uid of this event. It represents the uid that was responsible for waking the
|
||||
* radio. For those events that are reported by system itself, not from specific uid,
|
||||
* use -1 for the events which means no uid.
|
||||
*/
|
||||
void interfaceClassDataActivityChanged(String label, boolean active, long tsNanos);
|
||||
void interfaceClassDataActivityChanged(String label, boolean active, long tsNanos, int uid);
|
||||
|
||||
/**
|
||||
* Information about available DNS servers has been received.
|
||||
|
||||
@@ -64,7 +64,8 @@ public class BaseNetworkObserver extends INetworkManagementEventObserver.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interfaceClassDataActivityChanged(String label, boolean active, long tsNanos) {
|
||||
public void interfaceClassDataActivityChanged(String label, boolean active, long tsNanos,
|
||||
int uid) {
|
||||
// default no-op
|
||||
}
|
||||
|
||||
|
||||
@@ -1803,7 +1803,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
private INetworkManagementEventObserver mDataActivityObserver = new BaseNetworkObserver() {
|
||||
@Override
|
||||
public void interfaceClassDataActivityChanged(String label, boolean active, long tsNanos) {
|
||||
public void interfaceClassDataActivityChanged(String label, boolean active, long tsNanos,
|
||||
int uid) {
|
||||
int deviceType = Integer.parseInt(label);
|
||||
sendDataActivityBroadcast(deviceType, active, tsNanos);
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
|
||||
// the radio is the authority for the current state.
|
||||
final boolean active = isActive;
|
||||
invokeForAllObservers(o -> o.interfaceClassDataActivityChanged(
|
||||
Integer.toString(type), active, tsNanos));
|
||||
Integer.toString(type), active, tsNanos, uid));
|
||||
}
|
||||
|
||||
boolean report = false;
|
||||
|
||||
@@ -68,11 +68,12 @@ import java.util.function.BiFunction;
|
||||
@SmallTest
|
||||
public class NetworkManagementServiceTest {
|
||||
private NetworkManagementService mNMService;
|
||||
|
||||
@Mock private Context mContext;
|
||||
@Mock private IBatteryStats.Stub mBatteryStatsService;
|
||||
@Mock private INetd.Stub mNetdService;
|
||||
|
||||
private static final int TEST_UID = 111;
|
||||
|
||||
@NonNull
|
||||
@Captor
|
||||
private ArgumentCaptor<INetdUnsolicitedEventListener> mUnsolListenerCaptor;
|
||||
@@ -165,14 +166,14 @@ public class NetworkManagementServiceTest {
|
||||
/**
|
||||
* Interface class activity.
|
||||
*/
|
||||
unsolListener.onInterfaceClassActivityChanged(true, 1, 1234, 0);
|
||||
expectSoon(observer).interfaceClassDataActivityChanged("1", true, 1234);
|
||||
unsolListener.onInterfaceClassActivityChanged(true, 1, 1234, TEST_UID);
|
||||
expectSoon(observer).interfaceClassDataActivityChanged("1", true, 1234, TEST_UID);
|
||||
|
||||
unsolListener.onInterfaceClassActivityChanged(false, 9, 5678, 0);
|
||||
expectSoon(observer).interfaceClassDataActivityChanged("9", false, 5678);
|
||||
unsolListener.onInterfaceClassActivityChanged(false, 9, 5678, TEST_UID);
|
||||
expectSoon(observer).interfaceClassDataActivityChanged("9", false, 5678, TEST_UID);
|
||||
|
||||
unsolListener.onInterfaceClassActivityChanged(false, 9, 4321, 0);
|
||||
expectSoon(observer).interfaceClassDataActivityChanged("9", false, 4321);
|
||||
unsolListener.onInterfaceClassActivityChanged(false, 9, 4321, TEST_UID);
|
||||
expectSoon(observer).interfaceClassDataActivityChanged("9", false, 4321, TEST_UID);
|
||||
|
||||
/**
|
||||
* IP address changes.
|
||||
@@ -222,8 +223,6 @@ public class NetworkManagementServiceTest {
|
||||
assertFalse(mNMService.isFirewallEnabled());
|
||||
}
|
||||
|
||||
private static final int TEST_UID = 111;
|
||||
|
||||
@Test
|
||||
public void testNetworkRestrictedDefault() {
|
||||
assertFalse(mNMService.isNetworkRestricted(TEST_UID));
|
||||
|
||||
Reference in New Issue
Block a user