From 20ef4024edb5c7ed08a660cea731d47bcf90add5 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Tue, 7 Oct 2014 14:22:59 -0400 Subject: [PATCH] Hide hotspot tile if 'provisioning' is needed If we need carrier entitlement checks don't show the hotspot tile which could bypass them, instead make the user go to settings. Bug: 17879554 Change-Id: I30a5b51b26a2d4e977579b71a16c3c7a8d004eea --- .../android/systemui/qs/tiles/HotspotTile.java | 3 ++- .../statusbar/policy/HotspotController.java | 1 + .../statusbar/policy/HotspotControllerImpl.java | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java index 9984fcac8653b..ce99cc33221ad 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java @@ -66,7 +66,8 @@ public class HotspotTile extends QSTile { @Override 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.value = mController.isHotspotEnabled(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java index 7ca91a5590ae2..0863c86d254ec 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java @@ -22,6 +22,7 @@ public interface HotspotController { boolean isHotspotEnabled(); boolean isHotspotSupported(); void setHotspotEnabled(boolean enabled); + boolean isProvisioningNeeded(); public interface Callback { void onHotspotChanged(boolean enabled); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java index dd706bb949f63..63c11007c19d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java @@ -24,6 +24,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; +import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; @@ -73,6 +74,20 @@ public class HotspotControllerImpl implements HotspotController { return !isSecondaryUser && mConnectivityManager.isTetheringSupported(); } + @Override + public boolean isProvisioningNeeded() { + // Keep in sync with other usage of config_mobile_hotspot_provision_app. + // TetherSettings#isProvisioningNeeded and + // ConnectivityManager#enforceTetherChangePermission + String[] provisionApp = mContext.getResources().getStringArray( + com.android.internal.R.array.config_mobile_hotspot_provision_app); + if (SystemProperties.getBoolean("net.tethering.noprovisioning", false) + || provisionApp == null) { + return false; + } + return (provisionApp.length == 2); + } + @Override public void setHotspotEnabled(boolean enabled) { final ContentResolver cr = mContext.getContentResolver();