am b13c12f5: Merge "Call entitlement on clicking tethering tile in quick settings." into lmp-mr1-dev

* commit 'b13c12f58db3026ad30849873b3b6fc664f5ce7b':
  Call entitlement on clicking tethering tile in quick settings.
This commit is contained in:
Sanket Padawe
2014-12-03 02:19:06 +00:00
committed by Android Git Automerger
2 changed files with 11 additions and 16 deletions

View File

@@ -85,8 +85,7 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
@Override @Override
protected void handleUpdateState(BooleanState state, Object arg) { protected void handleUpdateState(BooleanState state, Object arg) {
state.visible = mController.isHotspotSupported() && mUsageTracker.isRecentlyUsed() state.visible = mController.isHotspotSupported() && mUsageTracker.isRecentlyUsed();
&& !mController.isProvisioningNeeded();
state.label = mContext.getString(R.string.quick_settings_hotspot_label); state.label = mContext.getString(R.string.quick_settings_hotspot_label);
state.value = mController.isHotspotEnabled(); state.value = mController.isHotspotEnabled();

View File

@@ -35,6 +35,8 @@ public class HotspotControllerImpl implements HotspotController {
private static final String TAG = "HotspotController"; private static final String TAG = "HotspotController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final String TETHER_ENABLE_PACKAGE = "com.android.settings";
private static final String TETHER_ENABLE_CLASS = "com.android.settings.EnableWifiTether";
private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>(); private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>();
private final Receiver mReceiver = new Receiver(); private final Receiver mReceiver = new Receiver();
@@ -91,20 +93,14 @@ public class HotspotControllerImpl implements HotspotController {
@Override @Override
public void setHotspotEnabled(boolean enabled) { public void setHotspotEnabled(boolean enabled) {
final ContentResolver cr = mContext.getContentResolver(); final ContentResolver cr = mContext.getContentResolver();
// This needs to be kept up to date with Settings (WifiApEnabler.setSoftapEnabled) // Call provisioning app which is called when enabling Tethering from Settings
// in case it is turned on in settings and off in qs (or vice versa). if (enabled) {
// Disable Wifi if enabling tethering. Intent intent = new Intent();
int wifiState = mWifiManager.getWifiState(); intent.setClassName(TETHER_ENABLE_PACKAGE, TETHER_ENABLE_CLASS);
if (enabled && ((wifiState == WifiManager.WIFI_STATE_ENABLING) || intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
(wifiState == WifiManager.WIFI_STATE_ENABLED))) { mContext.startActivity(intent);
mWifiManager.setWifiEnabled(false); } else {
Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 1); mWifiManager.setWifiApEnabled(null, false);
}
mWifiManager.setWifiApEnabled(null, enabled);
// If needed, restore Wifi on tether disable.
if (!enabled) {
if (Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE, 0) == 1) { if (Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE, 0) == 1) {
mWifiManager.setWifiEnabled(true); mWifiManager.setWifiEnabled(true);
Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 0); Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 0);