Merge "Start of tethering OffloadController"
This commit is contained in:
@@ -76,6 +76,7 @@ import com.android.internal.util.StateMachine;
|
||||
import com.android.server.connectivity.tethering.IControlsTethering;
|
||||
import com.android.server.connectivity.tethering.IPv6TetheringCoordinator;
|
||||
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.TetherInterfaceStateMachine;
|
||||
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));
|
||||
|
||||
private final StateMachine mTetherMasterSM;
|
||||
private final OffloadController mOffloadController;
|
||||
private final UpstreamNetworkMonitor mUpstreamNetworkMonitor;
|
||||
private String mCurrentUpstreamIface;
|
||||
|
||||
@@ -175,6 +177,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
|
||||
mTetherMasterSM = new TetherMasterSM("TetherMaster", mLooper);
|
||||
mTetherMasterSM.start();
|
||||
|
||||
mOffloadController = new OffloadController(mTetherMasterSM.getHandler());
|
||||
mUpstreamNetworkMonitor = new UpstreamNetworkMonitor(
|
||||
mContext, mTetherMasterSM, TetherMasterSM.EVENT_UPSTREAM_CALLBACK);
|
||||
|
||||
@@ -1203,6 +1206,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
|
||||
|
||||
protected void handleNewUpstreamNetworkState(NetworkState ns) {
|
||||
mIPv6TetheringCoordinator.updateUpstreamNetworkState(ns);
|
||||
mOffloadController.setUpstreamLinkProperties(ns.linkProperties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1364,12 +1368,14 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
|
||||
class TetherModeAliveState extends TetherMasterUtilState {
|
||||
final SimChangeListener simChange = new SimChangeListener(mContext);
|
||||
boolean mTryCell = true;
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
// TODO: examine if we should check the return value.
|
||||
turnOnMasterTetherSettings(); // may transition us out
|
||||
simChange.startListening();
|
||||
mUpstreamNetworkMonitor.start();
|
||||
mOffloadController.start();
|
||||
|
||||
// Better try something first pass or crazy tests cases will fail.
|
||||
chooseUpstreamType(true);
|
||||
@@ -1378,6 +1384,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
mOffloadController.stop();
|
||||
unrequestUpstreamMobileConnection();
|
||||
mUpstreamNetworkMonitor.stop();
|
||||
simChange.stopListening();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user