am 0c1a5bea: Merge "Doing provisioning check for wifi tethering from SystemUI" into lmp-mr1-dev
* commit '0c1a5bea2eb897b3f1d34b9c25ea6ed0bd5ca6eb': Doing provisioning check for wifi tethering from SystemUI
This commit is contained in:
@@ -303,6 +303,9 @@
|
|||||||
-->
|
-->
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Activity name to enable wifi tethering after provisioning app succeeds -->
|
||||||
|
<string translatable="false" name="config_wifi_tether_enable">com.android.settings/.EnableWifiTether</string>
|
||||||
|
|
||||||
<!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->
|
<!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->
|
||||||
<!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or
|
<!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or
|
||||||
<!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->
|
<!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->
|
||||||
|
|||||||
@@ -1877,6 +1877,7 @@
|
|||||||
|
|
||||||
<!-- From Settings -->
|
<!-- From Settings -->
|
||||||
<java-symbol type="array" name="config_mobile_hotspot_provision_app" />
|
<java-symbol type="array" name="config_mobile_hotspot_provision_app" />
|
||||||
|
<java-symbol type="string" name="config_wifi_tether_enable" />
|
||||||
<java-symbol type="bool" name="config_intrusiveNotificationLed" />
|
<java-symbol type="bool" name="config_intrusiveNotificationLed" />
|
||||||
<java-symbol type="dimen" name="preference_fragment_padding_bottom" />
|
<java-symbol type="dimen" name="preference_fragment_padding_bottom" />
|
||||||
<java-symbol type="dimen" name="preference_fragment_padding_side" />
|
<java-symbol type="dimen" name="preference_fragment_padding_side" />
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.android.systemui.R;
|
|||||||
import com.android.systemui.qs.UsageTracker;
|
import com.android.systemui.qs.UsageTracker;
|
||||||
import com.android.systemui.qs.QSTile;
|
import com.android.systemui.qs.QSTile;
|
||||||
import com.android.systemui.statusbar.policy.HotspotController;
|
import com.android.systemui.statusbar.policy.HotspotController;
|
||||||
|
import com.android.systemui.statusbar.policy.KeyguardMonitor;
|
||||||
|
|
||||||
/** Quick settings tile: Hotspot **/
|
/** Quick settings tile: Hotspot **/
|
||||||
public class HotspotTile extends QSTile<QSTile.BooleanState> {
|
public class HotspotTile extends QSTile<QSTile.BooleanState> {
|
||||||
@@ -34,12 +35,14 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
|
|||||||
private final HotspotController mController;
|
private final HotspotController mController;
|
||||||
private final Callback mCallback = new Callback();
|
private final Callback mCallback = new Callback();
|
||||||
private final UsageTracker mUsageTracker;
|
private final UsageTracker mUsageTracker;
|
||||||
|
private final KeyguardMonitor mKeyguard;
|
||||||
|
|
||||||
public HotspotTile(Host host) {
|
public HotspotTile(Host host) {
|
||||||
super(host);
|
super(host);
|
||||||
mController = host.getHotspotController();
|
mController = host.getHotspotController();
|
||||||
mUsageTracker = newUsageTracker(host.getContext());
|
mUsageTracker = newUsageTracker(host.getContext());
|
||||||
mUsageTracker.setListening(true);
|
mUsageTracker.setListening(true);
|
||||||
|
mKeyguard = host.getKeyguardMonitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,7 +88,9 @@ 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() && mKeyguard.isSecure()
|
||||||
|
&& mKeyguard.isShowing());
|
||||||
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();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.policy;
|
|||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -35,9 +36,6 @@ 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();
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -95,10 +93,22 @@ public class HotspotControllerImpl implements HotspotController {
|
|||||||
final ContentResolver cr = mContext.getContentResolver();
|
final ContentResolver cr = mContext.getContentResolver();
|
||||||
// Call provisioning app which is called when enabling Tethering from Settings
|
// Call provisioning app which is called when enabling Tethering from Settings
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
Intent intent = new Intent();
|
if (isProvisioningNeeded()) {
|
||||||
intent.setClassName(TETHER_ENABLE_PACKAGE, TETHER_ENABLE_CLASS);
|
String tetherEnable = mContext.getResources().getString(
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
com.android.internal.R.string.config_wifi_tether_enable);
|
||||||
mContext.startActivity(intent);
|
Intent intent = new Intent();
|
||||||
|
intent.setComponent(ComponentName.unflattenFromString(tetherEnable));
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
|
||||||
|
} else {
|
||||||
|
int wifiState = mWifiManager.getWifiState();
|
||||||
|
if ((wifiState == WifiManager.WIFI_STATE_ENABLING) ||
|
||||||
|
(wifiState == WifiManager.WIFI_STATE_ENABLED)) {
|
||||||
|
mWifiManager.setWifiEnabled(false);
|
||||||
|
Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 1);
|
||||||
|
}
|
||||||
|
mWifiManager.setWifiApEnabled(null, true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mWifiManager.setWifiApEnabled(null, false);
|
mWifiManager.setWifiApEnabled(null, false);
|
||||||
if (Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE, 0) == 1) {
|
if (Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE, 0) == 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user