Merge "Import translations. DO NOT MERGE"
diff --git a/src/com/android/settings/HotspotOffReceiver.java b/src/com/android/settings/HotspotOffReceiver.java
index 06ced1f..f3c3fee 100644
--- a/src/com/android/settings/HotspotOffReceiver.java
+++ b/src/com/android/settings/HotspotOffReceiver.java
@@ -5,6 +5,7 @@
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;
+import android.util.Log;
import com.android.settingslib.TetherUtil;
@@ -14,11 +15,15 @@
*/
public class HotspotOffReceiver extends BroadcastReceiver {
+ private static final String TAG = "HotspotOffReceiver";
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+
@Override
public void onReceive(Context context, Intent intent) {
if (WifiManager.WIFI_AP_STATE_CHANGED_ACTION.equals(intent.getAction())) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (wifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED) {
+ if (DEBUG) Log.d(TAG, "TetherService.cancelRecheckAlarmIfNecessary called");
// The hotspot has been turned off, we don't need to recheck tethering.
TetherService.cancelRecheckAlarmIfNecessary(context, TetherUtil.TETHERING_WIFI);
}
diff --git a/src/com/android/settings/TetherService.java b/src/com/android/settings/TetherService.java
index b6effad..346a175 100644
--- a/src/com/android/settings/TetherService.java
+++ b/src/com/android/settings/TetherService.java
@@ -89,21 +89,28 @@
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 @@
}
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 @@
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 @@
break;
}
}
- if (++mCurrentTypeIndex == mCurrentTethers.size()) {
+
+ if (++mCurrentTypeIndex >= mCurrentTethers.size()) {
// We are done with all checks, time to die.
stopSelf();
} else {
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index 45aafdf..52cb509 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -18,7 +18,6 @@
import android.app.Dialog;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.res.Resources;
import android.net.wifi.WifiManager;
import android.os.Bundle;
@@ -45,7 +44,7 @@
* UI to manage saved networks/access points.
*/
public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
- implements DialogInterface.OnClickListener, Indexable {
+ implements Indexable, WifiDialog.WifiDialogListener {
private static final String TAG = "SavedAccessPointsWifiSettings";
private WifiDialog mDialog;
@@ -170,8 +169,8 @@
}
@Override
- public void onClick(DialogInterface dialogInterface, int button) {
- if (button == WifiDialog.BUTTON_FORGET && mSelectedAccessPoint != null) {
+ public void onForget(WifiDialog dialog) {
+ if (mSelectedAccessPoint != null) {
mWifiManager.forget(mSelectedAccessPoint.getConfig().networkId, null);
getPreferenceScreen().removePreference((Preference) mSelectedAccessPoint.getTag());
mSelectedAccessPoint = null;
@@ -179,6 +178,11 @@
}
@Override
+ public void onSubmit(WifiDialog dialog) {
+ // Ignored
+ }
+
+ @Override
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
if (preference instanceof AccessPointPreference) {
showDialog((AccessPointPreference) preference, false);
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 1090758..4497a37 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -42,8 +42,10 @@
import android.text.TextWatcher;
import android.text.TextUtils;
import android.util.Log;
+import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
@@ -68,7 +70,8 @@
* share the logic for controlling buttons, text fields, etc.
*/
public class WifiConfigController implements TextWatcher,
- AdapterView.OnItemSelectedListener, OnCheckedChangeListener {
+ AdapterView.OnItemSelectedListener, OnCheckedChangeListener,
+ TextView.OnEditorActionListener, View.OnKeyListener{
private static final String TAG = "WifiConfigController";
private final WifiConfigUiBase mConfigUi;
@@ -344,32 +347,32 @@
Button submit = mConfigUi.getSubmitButton();
if (submit == null) return;
+ submit.setEnabled(isSubmittable());
+ }
+
+ boolean isSubmittable() {
boolean enabled = false;
boolean passwordInvalid = false;
if (mPasswordView != null &&
- ((mAccessPointSecurity == AccessPoint.SECURITY_WEP && mPasswordView.length() == 0) ||
- (mAccessPointSecurity == AccessPoint.SECURITY_PSK && mPasswordView.length() < 8))) {
+ ((mAccessPointSecurity == AccessPoint.SECURITY_WEP && mPasswordView.length() == 0) ||
+ (mAccessPointSecurity == AccessPoint.SECURITY_PSK && mPasswordView.length() < 8))) {
passwordInvalid = true;
}
if ((mSsidView != null && mSsidView.length() == 0) ||
- ((mAccessPoint == null || !mAccessPoint.isSaved()) &&
- passwordInvalid)) {
+ ((mAccessPoint == null || !mAccessPoint.isSaved()) &&
+ passwordInvalid)) {
enabled = false;
} else {
- if (ipAndProxyFieldsAreValid()) {
- enabled = true;
- } else {
- enabled = false;
- }
+ enabled = ipAndProxyFieldsAreValid();
}
if (mEapCaCertSpinner != null &&
mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE &&
((String)mEapCaCertSpinner.getSelectedItem()).equals(unspecifiedCert)) {
enabled = false;
}
- submit.setEnabled(enabled);
+ return enabled;
}
/* package */ WifiConfiguration getConfig() {
@@ -632,6 +635,8 @@
if (mPasswordView == null) {
mPasswordView = (TextView) mView.findViewById(R.id.password);
mPasswordView.addTextChangedListener(this);
+ mPasswordView.setOnEditorActionListener(this);
+ mPasswordView.setOnKeyListener(this);
((CheckBox) mView.findViewById(R.id.show_password))
.setOnCheckedChangeListener(this);
@@ -989,6 +994,28 @@
}
@Override
+ public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
+ if (textView == mPasswordView) {
+ if (id == EditorInfo.IME_ACTION_DONE && isSubmittable()) {
+ mConfigUi.dispatchSubmit();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
+ if (view == mPasswordView) {
+ if (keyCode == KeyEvent.KEYCODE_ENTER && isSubmittable()) {
+ mConfigUi.dispatchSubmit();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
if (view.getId() == R.id.show_password) {
int pos = mPasswordView.getSelectionEnd();
diff --git a/src/com/android/settings/wifi/WifiConfigUiBase.java b/src/com/android/settings/wifi/WifiConfigUiBase.java
index a0f67ab..d6ecf02 100644
--- a/src/com/android/settings/wifi/WifiConfigUiBase.java
+++ b/src/com/android/settings/wifi/WifiConfigUiBase.java
@@ -29,6 +29,8 @@
public LayoutInflater getLayoutInflater();
public boolean isEdit();
+ public void dispatchSubmit();
+
public void setTitle(int id);
public void setTitle(CharSequence title);
diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java
index d052c95..42f93bd 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -26,13 +26,19 @@
import android.view.View;
import android.widget.Button;
-class WifiDialog extends AlertDialog implements WifiConfigUiBase {
- static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE;
- static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;
+class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterface.OnClickListener {
+
+ public interface WifiDialogListener {
+ void onForget(WifiDialog dialog);
+ void onSubmit(WifiDialog dialog);
+ }
+
+ private static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE;
+ private static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;
private final boolean mEdit;
private final boolean mModify;
- private final DialogInterface.OnClickListener mListener;
+ private final WifiDialogListener mListener;
private final AccessPoint mAccessPoint;
private View mView;
@@ -40,7 +46,7 @@
private boolean mHideSubmitButton;
private boolean mHideForgetButton;
- public WifiDialog(Context context, DialogInterface.OnClickListener listener,
+ public WifiDialog(Context context, WifiDialogListener listener,
AccessPoint accessPoint, boolean edit, boolean modify,
boolean hideSubmitButton, boolean hideForgetButton) {
this(context, listener, accessPoint, edit, modify);
@@ -48,7 +54,7 @@
mHideForgetButton = hideForgetButton;
}
- public WifiDialog(Context context, DialogInterface.OnClickListener listener,
+ public WifiDialog(Context context, WifiDialogListener listener,
AccessPoint accessPoint, boolean edit, boolean modify) {
super(context);
mEdit = edit;
@@ -91,6 +97,28 @@
}
@Override
+ public void dispatchSubmit() {
+ if (mListener != null) {
+ mListener.onSubmit(this);
+ }
+ dismiss();
+ }
+
+ @Override
+ public void onClick(DialogInterface dialogInterface, int id) {
+ if (mListener != null) {
+ switch (id) {
+ case BUTTON_SUBMIT:
+ mListener.onSubmit(this);
+ break;
+ case BUTTON_FORGET:
+ mListener.onForget(this);
+ break;
+ }
+ }
+ }
+
+ @Override
public boolean isEdit() {
return mEdit;
}
@@ -112,16 +140,16 @@
@Override
public void setSubmitButton(CharSequence text) {
- setButton(BUTTON_SUBMIT, text, mListener);
+ setButton(BUTTON_SUBMIT, text, this);
}
@Override
public void setForgetButton(CharSequence text) {
- setButton(BUTTON_FORGET, text, mListener);
+ setButton(BUTTON_FORGET, text, this);
}
@Override
public void setCancelButton(CharSequence text) {
- setButton(BUTTON_NEGATIVE, text, mListener);
+ setButton(BUTTON_NEGATIVE, text, this);
}
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 92776c3..995e4a4 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -16,19 +16,15 @@
package com.android.settings.wifi;
-import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.Dialog;
-import android.app.admin.DeviceAdminInfo;
import android.app.admin.DevicePolicyManager;
-import android.app.admin.DevicePolicyManagerInternal;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
@@ -48,7 +44,6 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.os.UserManager;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.provider.Settings;
@@ -69,7 +64,6 @@
import android.widget.Toast;
import com.android.internal.logging.MetricsLogger;
-import com.android.server.LocalServices;
import com.android.settings.LinkifyUtils;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
@@ -96,8 +90,8 @@
* and menus.
*/
public class WifiSettings extends RestrictedSettingsFragment
- implements DialogInterface.OnClickListener, Indexable, WifiTracker.WifiListener,
- AccessPointListener {
+ implements Indexable, WifiTracker.WifiListener, AccessPointListener,
+ WifiDialog.WifiDialogListener {
private static final String TAG = "WifiSettings";
@@ -816,13 +810,14 @@
}
@Override
- public void onClick(DialogInterface dialogInterface, int button) {
- if (button == WifiDialog.BUTTON_FORGET && mSelectedAccessPoint != null) {
- forget();
- } else if (button == WifiDialog.BUTTON_SUBMIT) {
- if (mDialog != null) {
- submit(mDialog.getController());
- }
+ public void onForget(WifiDialog dialog) {
+ forget();
+ }
+
+ @Override
+ public void onSubmit(WifiDialog dialog) {
+ if (mDialog != null) {
+ submit(mDialog.getController());
}
}
@@ -1020,5 +1015,4 @@
Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, 0) != 0;
return !isLockdownFeatureEnabled;
}
-
}