Merge "Start of tethering OffloadController"

This commit is contained in:
Treehugger Robot
2017-03-07 01:00:55 +00:00
committed by Gerrit Code Review
2 changed files with 60 additions and 0 deletions

View File

@@ -76,6 +76,7 @@ import com.android.internal.util.StateMachine;
import com.android.server.connectivity.tethering.IControlsTethering; import com.android.server.connectivity.tethering.IControlsTethering;
import com.android.server.connectivity.tethering.IPv6TetheringCoordinator; import com.android.server.connectivity.tethering.IPv6TetheringCoordinator;
import com.android.server.connectivity.tethering.IPv6TetheringInterfaceServices; import com.android.server.connectivity.tethering.IPv6TetheringInterfaceServices;
import com.android.server.connectivity.tethering.OffloadController;
import com.android.server.connectivity.tethering.TetheringConfiguration; import com.android.server.connectivity.tethering.TetheringConfiguration;
import com.android.server.connectivity.tethering.TetherInterfaceStateMachine; import com.android.server.connectivity.tethering.TetherInterfaceStateMachine;
import com.android.server.connectivity.tethering.UpstreamNetworkMonitor; import com.android.server.connectivity.tethering.UpstreamNetworkMonitor;
@@ -145,6 +146,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
.getSystem().getString(com.android.internal.R.string.config_wifi_tether_enable)); .getSystem().getString(com.android.internal.R.string.config_wifi_tether_enable));
private final StateMachine mTetherMasterSM; private final StateMachine mTetherMasterSM;
private final OffloadController mOffloadController;
private final UpstreamNetworkMonitor mUpstreamNetworkMonitor; private final UpstreamNetworkMonitor mUpstreamNetworkMonitor;
private String mCurrentUpstreamIface; private String mCurrentUpstreamIface;
@@ -175,6 +177,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
mTetherMasterSM = new TetherMasterSM("TetherMaster", mLooper); mTetherMasterSM = new TetherMasterSM("TetherMaster", mLooper);
mTetherMasterSM.start(); mTetherMasterSM.start();
mOffloadController = new OffloadController(mTetherMasterSM.getHandler());
mUpstreamNetworkMonitor = new UpstreamNetworkMonitor( mUpstreamNetworkMonitor = new UpstreamNetworkMonitor(
mContext, mTetherMasterSM, TetherMasterSM.EVENT_UPSTREAM_CALLBACK); mContext, mTetherMasterSM, TetherMasterSM.EVENT_UPSTREAM_CALLBACK);
@@ -1203,6 +1206,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
protected void handleNewUpstreamNetworkState(NetworkState ns) { protected void handleNewUpstreamNetworkState(NetworkState ns) {
mIPv6TetheringCoordinator.updateUpstreamNetworkState(ns); mIPv6TetheringCoordinator.updateUpstreamNetworkState(ns);
mOffloadController.setUpstreamLinkProperties(ns.linkProperties);
} }
} }
@@ -1364,12 +1368,14 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
class TetherModeAliveState extends TetherMasterUtilState { class TetherModeAliveState extends TetherMasterUtilState {
final SimChangeListener simChange = new SimChangeListener(mContext); final SimChangeListener simChange = new SimChangeListener(mContext);
boolean mTryCell = true; boolean mTryCell = true;
@Override @Override
public void enter() { public void enter() {
// TODO: examine if we should check the return value. // TODO: examine if we should check the return value.
turnOnMasterTetherSettings(); // may transition us out turnOnMasterTetherSettings(); // may transition us out
simChange.startListening(); simChange.startListening();
mUpstreamNetworkMonitor.start(); mUpstreamNetworkMonitor.start();
mOffloadController.start();
// Better try something first pass or crazy tests cases will fail. // Better try something first pass or crazy tests cases will fail.
chooseUpstreamType(true); chooseUpstreamType(true);
@@ -1378,6 +1384,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
@Override @Override
public void exit() { public void exit() {
mOffloadController.stop();
unrequestUpstreamMobileConnection(); unrequestUpstreamMobileConnection();
mUpstreamNetworkMonitor.stop(); mUpstreamNetworkMonitor.stop();
simChange.stopListening(); simChange.stopListening();

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.connectivity.tethering;
import android.net.LinkProperties;
import android.os.Handler;
import android.util.Log;
/**
* A wrapper around hardware offload interface.
*
* @hide
*/
public class OffloadController {
private static final String TAG = OffloadController.class.getSimpleName();
private final Handler mHandler;
private LinkProperties mUpstreamLinkProperties;
public OffloadController(Handler h) {
mHandler = h;
}
public void start() {
// TODO: initOffload() and configure callbacks to be handled on our
// preferred Handler.
Log.d(TAG, "tethering offload not supported");
}
public void stop() {
// TODO: stopOffload().
mUpstreamLinkProperties = null;
}
public void setUpstreamLinkProperties(LinkProperties lp) {
// TODO: setUpstreamParameters().
mUpstreamLinkProperties = lp;
}
}