First pass at USB Tethering.

bug:2281900
This commit is contained in:
Robert Greenwalt
2010-01-26 11:40:34 -08:00
parent fe630655d2
commit 0c4828c25d
3 changed files with 108 additions and 0 deletions

View File

@@ -43,6 +43,8 @@ import android.util.Log;
import com.android.internal.telephony.Phone;
import com.android.server.connectivity.Tethering;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -62,6 +64,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private static final String NETWORK_RESTORE_DELAY_PROP_NAME =
"android.telephony.apn-restore";
private Tethering mTethering;
/**
* Sometimes we want to refer to the individual network state
* trackers separately, and sometimes we just want to treat them
@@ -308,6 +313,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
continue;
}
}
mTethering = new Tethering(mContext);
}
@@ -784,6 +791,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
"ConnectivityService");
}
// TODO Make this a special check when it goes public
private void enforceTetherChangePermission() {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.CHANGE_NETWORK_STATE,
"ConnectivityService");
}
/**
* Handle a {@code DISCONNECTED} event. If this pertains to the non-active
* network, we ignore it. If it is for the active network, we send out a
@@ -1368,4 +1382,28 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
}
// javadoc from interface
public boolean tether(String iface) {
enforceTetherChangePermission();
return mTethering.tether(iface);
}
// javadoc from interface
public boolean untether(String iface) {
enforceTetherChangePermission();
return mTethering.untether(iface);
}
// TODO - move iface listing, queries, etc to new module
// javadoc from interface
public String[] getTetherableIfaces() {
enforceAccessPermission();
return mTethering.getTetherableIfaces();
}
public String[] getTetheredIfaces() {
enforceAccessPermission();
return mTethering.getTetheredIfaces();
}
}