am b1a280a3: am 052e9b12: Merge "Add config to handle periodic check of tether provision" into lmp-mr1-dev

* commit 'b1a280a3ee38af72c6eed10ec9763f1202e63dd8':
  Add config to handle periodic check of tether provision
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index eb2e1ed..7088cc4 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -293,6 +293,7 @@
             }
 
         See src/com/android/settings/TetherSettings.java for more details.
+        For ui-less/periodic recheck support see config_mobile_hotspot_provision_app_no_ui
         -->
     <!-- The first element is the package name and the second element is the class name
          of the provisioning app -->
@@ -303,8 +304,42 @@
     -->
     </string-array>
 
+    <!-- If the mobile hotspot feature requires provisioning, an action can be provided
+         that will be broadcast in non-ui cases for checking the provisioning status.
+
+         A second broadcast, action defined by config_mobile_hotspot_provision_response,
+         will be sent back to notify if provisioning succeeded or not.  The response will
+         match that of the activity in config_mobile_hotspot_provision_app, but instead
+         contained within the int extra "EntitlementResult".
+
+         Example Usage:
+         String provisionAction = getString(R.string.config_mobile_hotspot_provision_check);
+         sendBroadcast(new Intent(provisionAction));
+
+         public void onReceive(Context context, Intent intent) {
+             String provisionResponse =
+                    getString(R.string.config_mobile_hotspot_provision_response);
+             if (provisionResponse.equals(intent.getAction())
+                    && intent.getIntExtra("EntitlementResult") == Activity.RESULT_OK) {
+                 //Mobile hotspot provisioning successful
+             } else {
+                 //Mobile hotspot provisioning failed
+             }
+         }
+        -->
+    <string translatable="false" name="config_mobile_hotspot_provision_app_no_ui"></string>
+    <!-- Sent in response to a provisioning check. The caller must hold the
+         permission android.permission.CONNECTIVITY_INTERNAL for Settings to
+         receive this response.
+
+         See config_mobile_hotspot_provision_response
+         -->
+    <string translatable="false" name="config_mobile_hotspot_provision_response"></string>
+    <!-- Number of hours between each background provisioning call -->
+    <integer translatable="false" name="config_mobile_hotspot_provision_check_period">24</integer>
+
     <!-- Activity name to enable wifi tethering after provisioning app succeeds -->
-    <string translatable="false" name="config_wifi_tether_enable">com.android.settings/.EnableWifiTether</string>
+    <string translatable="false" name="config_wifi_tether_enable">com.android.settings/.TetherService</string>
 
     <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->
     <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 3dd783f..6661290 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1880,6 +1880,9 @@
 
   <!-- From Settings -->
   <java-symbol type="array" name="config_mobile_hotspot_provision_app" />
+  <java-symbol type="string" name="config_mobile_hotspot_provision_app_no_ui" />
+  <java-symbol type="string" name="config_mobile_hotspot_provision_response" />
+  <java-symbol type="integer" name="config_mobile_hotspot_provision_check_period" />
   <java-symbol type="string" name="config_wifi_tether_enable" />
   <java-symbol type="bool" name="config_intrusiveNotificationLed" />
   <java-symbol type="dimen" name="preference_fragment_padding_bottom" />
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 6e710ef..fcc517f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
@@ -88,9 +88,7 @@
 
     @Override
     protected void handleUpdateState(BooleanState state, Object arg) {
-        state.visible = mController.isHotspotSupported() && mUsageTracker.isRecentlyUsed()
-                && !(mController.isProvisioningNeeded() && mKeyguard.isSecure()
-                && mKeyguard.isShowing());
+        state.visible = mController.isHotspotSupported() && mUsageTracker.isRecentlyUsed();
         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/HotspotControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
index b05cb31..5f7d452 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
@@ -36,6 +36,14 @@
 
     private static final String TAG = "HotspotController";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+    // Keep these in sync with Settings TetherService.java
+    public static final String EXTRA_ADD_TETHER_TYPE = "extraAddTetherType";
+    public static final String EXTRA_SET_ALARM = "extraSetAlarm";
+    public static final String EXTRA_RUN_PROVISION = "extraRunProvision";
+    public static final String EXTRA_ENABLE_WIFI_TETHER = "extraEnableWifiTether";
+    // Keep this in sync with Settings TetherSettings.java
+    public static final int WIFI_TETHERING = 0;
+
     private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>();
     private final Receiver mReceiver = new Receiver();
     private final Context mContext;
@@ -97,9 +105,13 @@
                 String tetherEnable = mContext.getResources().getString(
                         com.android.internal.R.string.config_wifi_tether_enable);
                 Intent intent = new Intent();
+                intent.putExtra(EXTRA_ADD_TETHER_TYPE, WIFI_TETHERING);
+                intent.putExtra(EXTRA_SET_ALARM, true);
+                intent.putExtra(EXTRA_RUN_PROVISION, true);
+                intent.putExtra(EXTRA_ENABLE_WIFI_TETHER, true);
                 intent.setComponent(ComponentName.unflattenFromString(tetherEnable));
                 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-                mContext.startActivityAsUser(intent, UserHandle.CURRENT);
+                mContext.startServiceAsUser(intent, UserHandle.CURRENT);
             } else {
                 int wifiState = mWifiManager.getWifiState();
                 if ((wifiState == WifiManager.WIFI_STATE_ENABLING) ||