Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e69e5f87 authored by Jason Monk's avatar Jason Monk
Browse files

Add config to handle periodic check of tether provision

While here also update QS to handle the changes made for this
new check.

Bug: 18453076
Change-Id: I1f6e2d954562c5a16a0de60dac625005ec3e5c50
parent c5c93edd
Loading
Loading
Loading
Loading
+36 −1
Original line number Original line Diff line number Diff line
@@ -293,6 +293,7 @@
            }
            }


        See src/com/android/settings/TetherSettings.java for more details.
        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
    <!-- The first element is the package name and the second element is the class name
         of the provisioning app -->
         of the provisioning app -->
@@ -303,8 +304,42 @@
    -->
    -->
    </string-array>
    </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 -->
    <!-- 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 -->
    <!-- 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
+3 −0
Original line number Original line Diff line number Diff line
@@ -1877,6 +1877,9 @@


  <!-- 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_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="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" />
+1 −3
Original line number Original line Diff line number Diff line
@@ -88,9 +88,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() && 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();
+13 −1
Original line number Original line Diff line number Diff line
@@ -36,6 +36,14 @@ 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);
    // 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 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;
@@ -97,9 +105,13 @@ public class HotspotControllerImpl implements HotspotController {
                String tetherEnable = mContext.getResources().getString(
                String tetherEnable = mContext.getResources().getString(
                        com.android.internal.R.string.config_wifi_tether_enable);
                        com.android.internal.R.string.config_wifi_tether_enable);
                Intent intent = new Intent();
                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.setComponent(ComponentName.unflattenFromString(tetherEnable));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                mContext.startActivityAsUser(intent, UserHandle.CURRENT);
                mContext.startServiceAsUser(intent, UserHandle.CURRENT);
            } else {
            } else {
                int wifiState = mWifiManager.getWifiState();
                int wifiState = mWifiManager.getWifiState();
                if ((wifiState == WifiManager.WIFI_STATE_ENABLING) ||
                if ((wifiState == WifiManager.WIFI_STATE_ENABLING) ||