Merge "Integrate testNetworkService and Manager with Connectivity stack"
This commit is contained in:
@@ -220,4 +220,6 @@ interface IConnectivityManager
|
|||||||
|
|
||||||
void registerTetheringEventCallback(ITetheringEventCallback callback, String callerPkg);
|
void registerTetheringEventCallback(ITetheringEventCallback callback, String callerPkg);
|
||||||
void unregisterTetheringEventCallback(ITetheringEventCallback callback, String callerPkg);
|
void unregisterTetheringEventCallback(ITetheringEventCallback callback, String callerPkg);
|
||||||
|
|
||||||
|
IBinder startOrGetTestNetworkService();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,6 +300,15 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private INetworkPolicyManager mPolicyManager;
|
private INetworkPolicyManager mPolicyManager;
|
||||||
private NetworkPolicyManagerInternal mPolicyManagerInternal;
|
private NetworkPolicyManagerInternal mPolicyManagerInternal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TestNetworkService (lazily) created upon first usage. Locked to prevent creation of multiple
|
||||||
|
* instances.
|
||||||
|
*/
|
||||||
|
@GuardedBy("mTNSLock")
|
||||||
|
private TestNetworkService mTNS;
|
||||||
|
|
||||||
|
private final Object mTNSLock = new Object();
|
||||||
|
|
||||||
private String mCurrentTcpBufferSizes;
|
private String mCurrentTcpBufferSizes;
|
||||||
|
|
||||||
private static final SparseArray<String> sMagicDecoderRing = MessageUtils.findMessageNames(
|
private static final SparseArray<String> sMagicDecoderRing = MessageUtils.findMessageNames(
|
||||||
@@ -6959,4 +6968,22 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
return vpn != null && vpn.getLockdown();
|
return vpn != null && vpn.getLockdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a IBinder to a TestNetworkService. Will be lazily created as needed.
|
||||||
|
*
|
||||||
|
* <p>The TestNetworkService must be run in the system server due to TUN creation.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IBinder startOrGetTestNetworkService() {
|
||||||
|
synchronized (mTNSLock) {
|
||||||
|
TestNetworkService.enforceTestNetworkPermissions(mContext);
|
||||||
|
|
||||||
|
if (mTNS == null) {
|
||||||
|
mTNS = new TestNetworkService(mContext, mNMS);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mTNS;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user