Merge "Start of tethering OffloadController"

am: 121006f428

Change-Id: I590569818c7d7ac50dcc61bd7058bd7c5cad4e77
This commit is contained in:
Erik Kline
2017-03-07 02:45:51 +00:00
committed by android-build-merger
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.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);
}
}
@@ -1359,12 +1363,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);
@@ -1373,6 +1379,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
@Override
public void exit() {
mOffloadController.stop();
unrequestUpstreamMobileConnection();
mUpstreamNetworkMonitor.stop();
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;
}
}