summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/TetherService.java
diff options
context:
space:
mode:
authorHyejin <hyejin.kim@lge.com>2015-09-10 23:26:53 -0700
committerVineeta Srivastava <vsrivastava@google.com>2015-09-14 16:04:52 -0700
commit5565b5cd7537e9360e6382507a45cf5e091a5108 (patch)
tree0be72d315a75d786000892de8c41218b7afadee3 /src/com/android/settings/TetherService.java
parentcda53c5dc2c6a2c01dfd5db278a7899dd868da7d (diff)
downloadpackages_apps_Settings-5565b5cd7537e9360e6382507a45cf5e091a5108.tar.gz
packages_apps_Settings-5565b5cd7537e9360e6382507a45cf5e091a5108.tar.bz2
packages_apps_Settings-5565b5cd7537e9360e6382507a45cf5e091a5108.zip
Fix IndexOutOfBoundsException while silent provisioning check
- If hostpot off, we receive result through HotspotOffReceiver. Sometimes, during provisioning, we're used to receive this. In this case, we don't care. After provisioning, we'll receive the intent again. - In stress test, index is sometimes invalid, equals to mCurrentTethers.size(). So, when provisioning, We check whether index is valid or not. BUG=23528220 Change-Id: I70f35e045042c6c81b1db03e2a44cd41d3e7437f
Diffstat (limited to 'src/com/android/settings/TetherService.java')
-rw-r--r--src/com/android/settings/TetherService.java55
1 files changed, 33 insertions, 22 deletions
diff --git a/src/com/android/settings/TetherService.java b/src/com/android/settings/TetherService.java
index b6effadd1..346a175d2 100644
--- a/src/com/android/settings/TetherService.java
+++ b/src/com/android/settings/TetherService.java
@@ -89,21 +89,28 @@ public class TetherService extends Service {
mCurrentTethers.add(type);
}
}
+
if (intent.hasExtra(TetherUtil.EXTRA_REM_TETHER_TYPE)) {
- int type = intent.getIntExtra(TetherUtil.EXTRA_REM_TETHER_TYPE,
- TetherUtil.TETHERING_INVALID);
- if (DEBUG) Log.d(TAG, "Removing tether " + type);
- int index = mCurrentTethers.indexOf(type);
- if (index >= 0) {
- mCurrentTethers.remove(index);
- // If we are currently in the middle of a check, we may need to adjust the
- // index accordingly.
- if (index <= mCurrentTypeIndex && mCurrentTypeIndex > 0) {
- mCurrentTypeIndex--;
+ if (!mInProvisionCheck) {
+ int type = intent.getIntExtra(TetherUtil.EXTRA_REM_TETHER_TYPE,
+ TetherUtil.TETHERING_INVALID);
+ int index = mCurrentTethers.indexOf(type);
+ if (DEBUG) Log.d(TAG, "Removing tether " + type + ", index " + index);
+ if (index >= 0) {
+ mCurrentTethers.remove(index);
+ // If we are currently in the middle of a check, we may need to adjust the
+ // index accordingly.
+ if (DEBUG) Log.d(TAG, "mCurrentTypeIndex: " + mCurrentTypeIndex);
+ if (index <= mCurrentTypeIndex && mCurrentTypeIndex > 0) {
+ mCurrentTypeIndex--;
+ }
}
+ cancelAlarmIfNecessary();
+ } else {
+ if (DEBUG) Log.d(TAG, "Don't cancel alarm during provisioning");
}
- cancelAlarmIfNecessary();
}
+
// Only set the alarm if we have one tether, meaning the one just added,
// to avoid setting it when it was already set previously for another
// type.
@@ -199,15 +206,17 @@ public class TetherService extends Service {
}
private void startProvisioning(int index) {
- String provisionAction = getResources().getString(
- com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui);
- if (DEBUG) Log.d(TAG, "Sending provisioning broadcast: " + provisionAction + " type: "
- + mCurrentTethers.get(index));
- Intent intent = new Intent(provisionAction);
- intent.putExtra(TETHER_CHOICE, mCurrentTethers.get(index));
- intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- sendBroadcast(intent);
- mInProvisionCheck = true;
+ if (index < mCurrentTethers.size()) {
+ String provisionAction = getResources().getString(
+ com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui);
+ if (DEBUG) Log.d(TAG, "Sending provisioning broadcast: " + provisionAction + " type: "
+ + mCurrentTethers.get(index));
+ Intent intent = new Intent(provisionAction);
+ intent.putExtra(TETHER_CHOICE, mCurrentTethers.get(index));
+ intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ sendBroadcast(intent);
+ mInProvisionCheck = true;
+ }
}
public static void scheduleRecheckAlarm(Context context, int type) {
@@ -261,13 +270,14 @@ public class TetherService extends Service {
if (DEBUG) Log.d(TAG, "Got provision result " + intent);
String provisionResponse = context.getResources().getString(
com.android.internal.R.string.config_mobile_hotspot_provision_response);
+
if (provisionResponse.equals(intent.getAction())) {
if (!mInProvisionCheck) {
Log.e(TAG, "Unexpected provision response " + intent);
return;
}
- mInProvisionCheck = false;
int checkType = mCurrentTethers.get(mCurrentTypeIndex);
+ mInProvisionCheck = false;
if (intent.getIntExtra(EXTRA_RESULT, RESULT_DEFAULT) == RESULT_OK) {
if (checkType == TetherUtil.TETHERING_WIFI && mEnableWifiAfterCheck) {
enableWifiTetheringIfNeeded();
@@ -286,7 +296,8 @@ public class TetherService extends Service {
break;
}
}
- if (++mCurrentTypeIndex == mCurrentTethers.size()) {
+
+ if (++mCurrentTypeIndex >= mCurrentTethers.size()) {
// We are done with all checks, time to die.
stopSelf();
} else {