Rename getXXX to makeXXX in TetheringDependencies
This fix the code review comment from aosp/2319853 that getXXX functions
should be renamed to makeXXX because it's actually creating the object.
Test: TH
Change-Id: Ife8e1cc3a90b835764a2dd9731388b05d8a5c964
diff --git a/Tethering/src/com/android/networkstack/tethering/Tethering.java b/Tethering/src/com/android/networkstack/tethering/Tethering.java
index da3b584..5022b40 100644
--- a/Tethering/src/com/android/networkstack/tethering/Tethering.java
+++ b/Tethering/src/com/android/networkstack/tethering/Tethering.java
@@ -303,9 +303,9 @@
mContext = mDeps.getContext();
mNetd = mDeps.getINetd(mContext);
mRoutingCoordinator = mDeps.getRoutingCoordinator(mContext);
- mLooper = mDeps.getTetheringLooper();
- mNotificationUpdater = mDeps.getNotificationUpdater(mContext, mLooper);
- mTetheringMetrics = mDeps.getTetheringMetrics();
+ mLooper = mDeps.makeTetheringLooper();
+ mNotificationUpdater = mDeps.makeNotificationUpdater(mContext, mLooper);
+ mTetheringMetrics = mDeps.makeTetheringMetrics();
// This is intended to ensrure that if something calls startTethering(bluetooth) just after
// bluetooth is enabled. Before onServiceConnected is called, store the calls into this
@@ -319,7 +319,7 @@
mTetherMainSM.start();
mHandler = mTetherMainSM.getHandler();
- mOffloadController = mDeps.getOffloadController(mHandler, mLog,
+ mOffloadController = mDeps.makeOffloadController(mHandler, mLog,
new OffloadController.Dependencies() {
@Override
@@ -327,7 +327,7 @@
return mConfig;
}
});
- mUpstreamNetworkMonitor = mDeps.getUpstreamNetworkMonitor(mContext, mHandler, mLog,
+ mUpstreamNetworkMonitor = mDeps.makeUpstreamNetworkMonitor(mContext, mHandler, mLog,
(what, obj) -> {
mTetherMainSM.sendMessage(TetherMainSM.EVENT_UPSTREAM_CALLBACK, what, 0, obj);
});
@@ -337,7 +337,7 @@
filter.addAction(ACTION_CARRIER_CONFIG_CHANGED);
// EntitlementManager will send EVENT_UPSTREAM_PERMISSION_CHANGED when cellular upstream
// permission is changed according to entitlement check result.
- mEntitlementMgr = mDeps.getEntitlementManager(mContext, mHandler, mLog,
+ mEntitlementMgr = mDeps.makeEntitlementManager(mContext, mHandler, mLog,
() -> mTetherMainSM.sendMessage(
TetherMainSM.EVENT_UPSTREAM_PERMISSION_CHANGED));
mEntitlementMgr.setOnTetherProvisioningFailedListener((downstream, reason) -> {
@@ -373,11 +373,11 @@
// It is OK for the configuration to be passed to the PrivateAddressCoordinator at
// construction time because the only part of the configuration it uses is
// shouldEnableWifiP2pDedicatedIp(), and currently do not support changing that.
- mPrivateAddressCoordinator = mDeps.getPrivateAddressCoordinator(mContext, mConfig);
+ mPrivateAddressCoordinator = mDeps.makePrivateAddressCoordinator(mContext, mConfig);
// Must be initialized after tethering configuration is loaded because BpfCoordinator
// constructor needs to use the configuration.
- mBpfCoordinator = mDeps.getBpfCoordinator(
+ mBpfCoordinator = mDeps.makeBpfCoordinator(
new BpfCoordinator.Dependencies() {
@NonNull
public Handler getHandler() {
@@ -406,7 +406,7 @@
});
if (SdkLevel.isAtLeastT() && mConfig.isWearTetheringEnabled()) {
- mWearableConnectionManager = mDeps.getWearableConnectionManager(mContext);
+ mWearableConnectionManager = mDeps.makeWearableConnectionManager(mContext);
} else {
mWearableConnectionManager = null;
}
@@ -875,7 +875,7 @@
private void changeBluetoothTetheringSettings(@NonNull final BluetoothPan bluetoothPan,
final boolean enable) {
- final BluetoothPanShim panShim = mDeps.getBluetoothPanShim(bluetoothPan);
+ final BluetoothPanShim panShim = mDeps.makeBluetoothPanShim(bluetoothPan);
if (enable) {
if (mBluetoothIfaceRequest != null) {
Log.d(TAG, "Bluetooth tethering settings already enabled");
@@ -1739,7 +1739,7 @@
addState(mSetDnsForwardersErrorState);
mNotifyList = new ArrayList<>();
- mIPv6TetheringCoordinator = deps.getIPv6TetheringCoordinator(mNotifyList, mLog);
+ mIPv6TetheringCoordinator = deps.makeIPv6TetheringCoordinator(mNotifyList, mLog);
mOffload = new OffloadWrapper();
setInitialState(mInitialState);
@@ -2844,7 +2844,7 @@
new IpServer(iface, mHandler, interfaceType, mLog, mNetd, mBpfCoordinator,
mRoutingCoordinator, new ControlCallback(), mConfig,
mPrivateAddressCoordinator, mTetheringMetrics,
- mDeps.getIpServerDependencies()), isNcm);
+ mDeps.makeIpServerDependencies()), isNcm);
mTetherStates.put(iface, tetherState);
tetherState.ipServer.start();
}
diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java b/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java
index d02e8e8..9dfd225 100644
--- a/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java
+++ b/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java
@@ -53,58 +53,58 @@
*/
public abstract class TetheringDependencies {
/**
- * Get a reference to the BpfCoordinator to be used by tethering.
+ * Make the BpfCoordinator to be used by tethering.
*/
- public @NonNull BpfCoordinator getBpfCoordinator(
+ public @NonNull BpfCoordinator makeBpfCoordinator(
@NonNull BpfCoordinator.Dependencies deps) {
return new BpfCoordinator(deps);
}
/**
- * Get a reference to the offload hardware interface to be used by tethering.
+ * Make the offload hardware interface to be used by tethering.
*/
- public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) {
+ public OffloadHardwareInterface makeOffloadHardwareInterface(Handler h, SharedLog log) {
return new OffloadHardwareInterface(h, log);
}
/**
- * Get a reference to the offload controller to be used by tethering.
+ * Make the offload controller to be used by tethering.
*/
@NonNull
- public OffloadController getOffloadController(@NonNull Handler h,
+ public OffloadController makeOffloadController(@NonNull Handler h,
@NonNull SharedLog log, @NonNull OffloadController.Dependencies deps) {
final NetworkStatsManager statsManager =
(NetworkStatsManager) getContext().getSystemService(Context.NETWORK_STATS_SERVICE);
- return new OffloadController(h, getOffloadHardwareInterface(h, log),
+ return new OffloadController(h, makeOffloadHardwareInterface(h, log),
getContext().getContentResolver(), statsManager, log, deps);
}
/**
- * Get a reference to the UpstreamNetworkMonitor to be used by tethering.
+ * Make the UpstreamNetworkMonitor to be used by tethering.
*/
- public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, Handler h,
+ public UpstreamNetworkMonitor makeUpstreamNetworkMonitor(Context ctx, Handler h,
SharedLog log, UpstreamNetworkMonitor.EventListener listener) {
return new UpstreamNetworkMonitor(ctx, h, log, listener);
}
/**
- * Get a reference to the IPv6TetheringCoordinator to be used by tethering.
+ * Make the IPv6TetheringCoordinator to be used by tethering.
*/
- public IPv6TetheringCoordinator getIPv6TetheringCoordinator(
+ public IPv6TetheringCoordinator makeIPv6TetheringCoordinator(
ArrayList<IpServer> notifyList, SharedLog log) {
return new IPv6TetheringCoordinator(notifyList, log);
}
/**
- * Get dependencies to be used by IpServer.
+ * Make dependencies to be used by IpServer.
*/
- public abstract IpServer.Dependencies getIpServerDependencies();
+ public abstract IpServer.Dependencies makeIpServerDependencies();
/**
- * Get a reference to the EntitlementManager to be used by tethering.
+ * Make the EntitlementManager to be used by tethering.
*/
- public EntitlementManager getEntitlementManager(Context ctx, Handler h, SharedLog log,
+ public EntitlementManager makeEntitlementManager(Context ctx, Handler h, SharedLog log,
Runnable callback) {
return new EntitlementManager(ctx, h, log, callback);
}
@@ -136,17 +136,17 @@
}
/**
- * Get a reference to the TetheringNotificationUpdater to be used by tethering.
+ * Make the TetheringNotificationUpdater to be used by tethering.
*/
- public TetheringNotificationUpdater getNotificationUpdater(@NonNull final Context ctx,
+ public TetheringNotificationUpdater makeNotificationUpdater(@NonNull final Context ctx,
@NonNull final Looper looper) {
return new TetheringNotificationUpdater(ctx, looper);
}
/**
- * Get tethering thread looper.
+ * Make tethering thread looper.
*/
- public abstract Looper getTetheringLooper();
+ public abstract Looper makeTetheringLooper();
/**
* Get Context of TetheringService.
@@ -166,26 +166,26 @@
}
/**
- * Get a reference to PrivateAddressCoordinator to be used by Tethering.
+ * Make PrivateAddressCoordinator to be used by Tethering.
*/
- public PrivateAddressCoordinator getPrivateAddressCoordinator(Context ctx,
+ public PrivateAddressCoordinator makePrivateAddressCoordinator(Context ctx,
TetheringConfiguration cfg) {
return new PrivateAddressCoordinator(ctx, cfg);
}
/**
- * Get BluetoothPanShim object to enable/disable bluetooth tethering.
+ * Make BluetoothPanShim object to enable/disable bluetooth tethering.
*
* TODO: use BluetoothPan directly when mainline module is built with API 32.
*/
- public BluetoothPanShim getBluetoothPanShim(BluetoothPan pan) {
+ public BluetoothPanShim makeBluetoothPanShim(BluetoothPan pan) {
return BluetoothPanShimImpl.newInstance(pan);
}
/**
- * Get a reference to the TetheringMetrics to be used by tethering.
+ * Make the TetheringMetrics to be used by tethering.
*/
- public TetheringMetrics getTetheringMetrics() {
+ public TetheringMetrics makeTetheringMetrics() {
return new TetheringMetrics();
}
@@ -193,7 +193,7 @@
* Returns the implementation of WearableConnectionManager.
*/
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
- public WearableConnectionManager getWearableConnectionManager(Context ctx) {
+ public WearableConnectionManager makeWearableConnectionManager(Context ctx) {
return new WearableConnectionManager(ctx);
}
}
diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringService.java b/Tethering/src/com/android/networkstack/tethering/TetheringService.java
index 96ddfa0..aa73819 100644
--- a/Tethering/src/com/android/networkstack/tethering/TetheringService.java
+++ b/Tethering/src/com/android/networkstack/tethering/TetheringService.java
@@ -322,7 +322,7 @@
public TetheringDependencies makeTetheringDependencies() {
return new TetheringDependencies() {
@Override
- public Looper getTetheringLooper() {
+ public Looper makeTetheringLooper() {
final HandlerThread tetherThread = new HandlerThread("android.tethering");
tetherThread.start();
return tetherThread.getLooper();
@@ -334,7 +334,7 @@
}
@Override
- public IpServer.Dependencies getIpServerDependencies() {
+ public IpServer.Dependencies makeIpServerDependencies() {
return new IpServer.Dependencies() {
@Override
public void makeDhcpServer(String ifName, DhcpServingParamsParcel params,
diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
index 5877fc5..82b8845 100644
--- a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
+++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
@@ -436,51 +436,51 @@
ArrayList<IpServer> mAllDownstreams;
@Override
- public BpfCoordinator getBpfCoordinator(
+ public BpfCoordinator makeBpfCoordinator(
BpfCoordinator.Dependencies deps) {
return mBpfCoordinator;
}
@Override
- public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) {
+ public OffloadHardwareInterface makeOffloadHardwareInterface(Handler h, SharedLog log) {
return mOffloadHardwareInterface;
}
@Override
- public OffloadController getOffloadController(Handler h, SharedLog log,
+ public OffloadController makeOffloadController(Handler h, SharedLog log,
OffloadController.Dependencies deps) {
- mOffloadCtrl = spy(super.getOffloadController(h, log, deps));
+ mOffloadCtrl = spy(super.makeOffloadController(h, log, deps));
// Return real object here instead of mock because
// testReportFailCallbackIfOffloadNotSupported depend on real OffloadController object.
return mOffloadCtrl;
}
@Override
- public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, Handler h,
+ public UpstreamNetworkMonitor makeUpstreamNetworkMonitor(Context ctx, Handler h,
SharedLog log, UpstreamNetworkMonitor.EventListener listener) {
// Use a real object instead of a mock so that some tests can use a real UNM and some
// can use a mock.
mEventListener = listener;
- mUpstreamNetworkMonitor = spy(super.getUpstreamNetworkMonitor(ctx, h, log, listener));
+ mUpstreamNetworkMonitor = spy(super.makeUpstreamNetworkMonitor(ctx, h, log, listener));
return mUpstreamNetworkMonitor;
}
@Override
- public IPv6TetheringCoordinator getIPv6TetheringCoordinator(
+ public IPv6TetheringCoordinator makeIPv6TetheringCoordinator(
ArrayList<IpServer> notifyList, SharedLog log) {
mAllDownstreams = notifyList;
return mIPv6TetheringCoordinator;
}
@Override
- public IpServer.Dependencies getIpServerDependencies() {
+ public IpServer.Dependencies makeIpServerDependencies() {
return mIpServerDependencies;
}
@Override
- public EntitlementManager getEntitlementManager(Context ctx, Handler h, SharedLog log,
+ public EntitlementManager makeEntitlementManager(Context ctx, Handler h, SharedLog log,
Runnable callback) {
- mEntitleMgr = spy(super.getEntitlementManager(ctx, h, log, callback));
+ mEntitleMgr = spy(super.makeEntitlementManager(ctx, h, log, callback));
return mEntitleMgr;
}
@@ -503,7 +503,7 @@
}
@Override
- public Looper getTetheringLooper() {
+ public Looper makeTetheringLooper() {
return mLooper.getLooper();
}
@@ -518,7 +518,7 @@
}
@Override
- public TetheringNotificationUpdater getNotificationUpdater(Context ctx, Looper looper) {
+ public TetheringNotificationUpdater makeNotificationUpdater(Context ctx, Looper looper) {
return mNotificationUpdater;
}
@@ -528,19 +528,19 @@
}
@Override
- public TetheringMetrics getTetheringMetrics() {
+ public TetheringMetrics makeTetheringMetrics() {
return mTetheringMetrics;
}
@Override
- public PrivateAddressCoordinator getPrivateAddressCoordinator(Context ctx,
+ public PrivateAddressCoordinator makePrivateAddressCoordinator(Context ctx,
TetheringConfiguration cfg) {
- mPrivateAddressCoordinator = super.getPrivateAddressCoordinator(ctx, cfg);
+ mPrivateAddressCoordinator = super.makePrivateAddressCoordinator(ctx, cfg);
return mPrivateAddressCoordinator;
}
@Override
- public BluetoothPanShim getBluetoothPanShim(BluetoothPan pan) {
+ public BluetoothPanShim makeBluetoothPanShim(BluetoothPan pan) {
try {
when(mBluetoothPanShim.requestTetheredInterface(
any(), any())).thenReturn(mTetheredInterfaceRequestShim);