Support set test network to tethering upstream

Test: atest EthernetTetheringTest

Change-Id: Ief2a92bc6c573a6bb75c72b7a0630e5c0accfa73
This commit is contained in:
markchien
2021-08-17 23:59:09 +08:00
committed by Mark Chien
parent c80a5d56db
commit 2fbd3e72d3
11 changed files with 191 additions and 21 deletions

View File

@@ -49,4 +49,6 @@ oneway interface ITetheringConnector {
void stopAllTethering(String callerPkg, String callingAttributionTag,
IIntResultListener receiver);
void setPreferTestNetworks(boolean prefer, IIntResultListener listener);
}

View File

@@ -1538,4 +1538,25 @@ public class TetheringManager {
}
}));
}
/**
* Whether to treat networks that have TRANSPORT_TEST as Tethering upstreams. The effects of
* this method apply to any test networks that are already present on the system.
*
* @throws SecurityException If the caller doesn't have the NETWORK_SETTINGS permission.
* @hide
*/
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
public void setPreferTestNetworks(final boolean prefer) {
Log.i(TAG, "setPreferTestNetworks caller: " + mContext.getOpPackageName());
final RequestDispatcher dispatcher = new RequestDispatcher();
final int ret = dispatcher.waitForResult((connector, listener) -> {
try {
connector.setPreferTestNetworks(prefer, listener);
} catch (RemoteException e) {
throw new IllegalStateException(e);
}
});
}
}