use of com.android.server.connectivity.tethering.TetheringConfiguration in project platform_frameworks_base by android.
the class Tethering method dump.
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
// Binder.java closes the resource for us.
@SuppressWarnings("resource") final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump ConnectivityService.Tether " + "from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
return;
}
pw.println("Tethering:");
pw.increaseIndent();
final TetheringConfiguration cfg = mConfig;
pw.print("preferredUpstreamIfaceTypes:");
synchronized (mPublicSync) {
for (Integer netType : cfg.preferredUpstreamIfaceTypes) {
pw.print(" " + ConnectivityManager.getNetworkTypeName(netType));
}
pw.println();
pw.println("Tether state:");
pw.increaseIndent();
for (int i = 0; i < mTetherStates.size(); i++) {
final String iface = mTetherStates.keyAt(i);
final TetherState tetherState = mTetherStates.valueAt(i);
pw.print(iface + " - ");
switch(tetherState.lastState) {
case IControlsTethering.STATE_UNAVAILABLE:
pw.print("UnavailableState");
break;
case IControlsTethering.STATE_AVAILABLE:
pw.print("AvailableState");
break;
case IControlsTethering.STATE_TETHERED:
pw.print("TetheredState");
break;
default:
pw.print("UnknownState");
break;
}
pw.println(" - lastError = " + tetherState.lastError);
}
pw.decreaseIndent();
}
pw.decreaseIndent();
}
use of com.android.server.connectivity.tethering.TetheringConfiguration in project platform_frameworks_base by android.
the class Tethering method sendTetherStateChangedBroadcast.
private void sendTetherStateChangedBroadcast() {
if (!getConnectivityManager().isTetheringSupported())
return;
ArrayList<String> availableList = new ArrayList<String>();
ArrayList<String> activeList = new ArrayList<String>();
ArrayList<String> erroredList = new ArrayList<String>();
boolean wifiTethered = false;
boolean usbTethered = false;
boolean bluetoothTethered = false;
final TetheringConfiguration cfg = mConfig;
synchronized (mPublicSync) {
for (int i = 0; i < mTetherStates.size(); i++) {
TetherState tetherState = mTetherStates.valueAt(i);
String iface = mTetherStates.keyAt(i);
if (tetherState.lastError != ConnectivityManager.TETHER_ERROR_NO_ERROR) {
erroredList.add(iface);
} else if (tetherState.lastState == IControlsTethering.STATE_AVAILABLE) {
availableList.add(iface);
} else if (tetherState.lastState == IControlsTethering.STATE_TETHERED) {
if (cfg.isUsb(iface)) {
usbTethered = true;
} else if (cfg.isWifi(iface)) {
wifiTethered = true;
} else if (cfg.isBluetooth(iface)) {
bluetoothTethered = true;
}
activeList.add(iface);
}
}
}
Intent broadcast = new Intent(ConnectivityManager.ACTION_TETHER_STATE_CHANGED);
broadcast.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
broadcast.putStringArrayListExtra(ConnectivityManager.EXTRA_AVAILABLE_TETHER, availableList);
broadcast.putStringArrayListExtra(ConnectivityManager.EXTRA_ACTIVE_TETHER, activeList);
broadcast.putStringArrayListExtra(ConnectivityManager.EXTRA_ERRORED_TETHER, erroredList);
mContext.sendStickyBroadcastAsUser(broadcast, UserHandle.ALL);
if (DBG) {
Log.d(TAG, String.format("sendTetherStateChangedBroadcast avail=[%s] active=[%s] error=[%s]", TextUtils.join(",", availableList), TextUtils.join(",", activeList), TextUtils.join(",", erroredList)));
}
if (usbTethered) {
if (wifiTethered || bluetoothTethered) {
showTetheredNotification(com.android.internal.R.drawable.stat_sys_tether_general);
} else {
showTetheredNotification(com.android.internal.R.drawable.stat_sys_tether_usb);
}
} else if (wifiTethered) {
if (bluetoothTethered) {
showTetheredNotification(com.android.internal.R.drawable.stat_sys_tether_general);
} else {
/* We now have a status bar icon for WifiTethering, so drop the notification */
clearTetheredNotification();
}
} else if (bluetoothTethered) {
showTetheredNotification(com.android.internal.R.drawable.stat_sys_tether_bluetooth);
} else {
clearTetheredNotification();
}
}
use of com.android.server.connectivity.tethering.TetheringConfiguration in project platform_frameworks_base by android.
the class Tethering method hasTetherableConfiguration.
public boolean hasTetherableConfiguration() {
final TetheringConfiguration cfg = mConfig;
final boolean hasDownstreamConfiguration = (cfg.tetherableUsbRegexs.length != 0) || (cfg.tetherableWifiRegexs.length != 0) || (cfg.tetherableBluetoothRegexs.length != 0);
final boolean hasUpstreamConfiguration = !cfg.preferredUpstreamIfaceTypes.isEmpty();
return hasDownstreamConfiguration && hasUpstreamConfiguration;
}
Aggregations