Merge "No QS hotspot unless supported" into nyc-dev

This commit is contained in:
Jason Monk
2016-04-19 15:19:45 +00:00
committed by Android (Google) Code Review
3 changed files with 12 additions and 0 deletions

View File

@@ -42,6 +42,11 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
mController = host.getHotspotController();
}
@Override
public boolean isAvailable() {
return mController.isHotspotSupported();
}
@Override
protected void handleDestroy() {
super.handleDestroy();

View File

@@ -21,6 +21,7 @@ public interface HotspotController {
void removeCallback(Callback callback);
boolean isHotspotEnabled();
void setHotspotEnabled(boolean enabled);
boolean isHotspotSupported();
public interface Callback {
void onHotspotChanged(boolean enabled);

View File

@@ -46,6 +46,12 @@ public class HotspotControllerImpl implements HotspotController {
Context.CONNECTIVITY_SERVICE);
}
@Override
public boolean isHotspotSupported() {
return mConnectivityManager.isTetheringSupported()
&& mConnectivityManager.getTetherableWifiRegexs().length != 0;
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("HotspotController state:");
pw.print(" mHotspotEnabled="); pw.println(stateToString(mHotspotState));