Remove ConnectivityServiceTest signature perms use
To allow unit tests to run without platform certificates, remove
signature permission usage in ConnectivityServiceTest.
This mocks permission checks done in ConnectivityService for which the
test assumed that the permission was held, and mocks calls to
BatteryStatsManager. Calls to ActivityManagerService (through
PendingIntent) are done with shell permissions as the test uses real
PendingIntent mechanics.
Bug: 187935317
Test: atest FrameworksNetTests
Merged-In: If309d653ac2e9bbcf1b94bcee6336367289df359
Change-Id: If309d653ac2e9bbcf1b94bcee6336367289df359
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1736615
(cherry picked from commit 595dda3604)
Change-Id: Idb19b0f7cb87bb4d9de7a0b1a0e4128c2d6b9c6d
This commit is contained in:
parent
e7d085e87d
commit
ff55aeb916
1 changed files with 112 additions and 19 deletions
|
|
@ -1276,6 +1276,20 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
public boolean getCellular464XlatEnabled() {
|
||||
return NetworkProperties.isCellular464XlatEnabled().orElse(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PendingIntent#intentFilterEquals
|
||||
*/
|
||||
public boolean intentFilterEquals(PendingIntent a, PendingIntent b) {
|
||||
return a.intentFilterEquals(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LocationPermissionChecker
|
||||
*/
|
||||
public LocationPermissionChecker makeLocationPermissionChecker(Context context) {
|
||||
return new LocationPermissionChecker(context);
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectivityService(Context context) {
|
||||
|
|
@ -1343,7 +1357,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
mNetd = netd;
|
||||
mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
|
||||
mLocationPermissionChecker = new LocationPermissionChecker(mContext);
|
||||
mLocationPermissionChecker = mDeps.makeLocationPermissionChecker(mContext);
|
||||
|
||||
// To ensure uid state is synchronized with Network Policy, register for
|
||||
// NetworkPolicyManagerService events must happen prior to NetworkPolicyManagerService
|
||||
|
|
@ -3934,7 +3948,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
for (Map.Entry<NetworkRequest, NetworkRequestInfo> entry : mNetworkRequests.entrySet()) {
|
||||
PendingIntent existingPendingIntent = entry.getValue().mPendingIntent;
|
||||
if (existingPendingIntent != null &&
|
||||
existingPendingIntent.intentFilterEquals(pendingIntent)) {
|
||||
mDeps.intentFilterEquals(existingPendingIntent, pendingIntent)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue