Use AsyncChannel in settings
Change-Id: I440f08dec986e4dad4b578ee4065d6063b8ef989
This commit is contained in:
@@ -26,6 +26,7 @@ import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -41,6 +42,8 @@ import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.util.AsyncChannel;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
@@ -143,6 +146,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
||||
// There's no button here enabling wifi network, so we need to enable it without
|
||||
// users' request.
|
||||
mWifiManager.setWifiEnabled(true);
|
||||
mWifiManager.asyncConnect(this, new WifiServiceHandler());
|
||||
|
||||
mWifiSettings =
|
||||
(WifiSettings)getFragmentManager().findFragmentById(R.id.wifi_setup_fragment);
|
||||
@@ -189,6 +193,25 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
||||
showScanningStatus();
|
||||
}
|
||||
|
||||
private class WifiServiceHandler extends Handler {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
|
||||
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
|
||||
//AsyncChannel in msg.obj
|
||||
} else {
|
||||
//AsyncChannel set up failure, ignore
|
||||
Log.e(TAG, "Failed to establish AsyncChannel connection");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//Ignore
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreFirstButtonVisibilityState() {
|
||||
showDefaultTitle();
|
||||
mAddNetworkButton.setVisibility(View.VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user