2015/09/21

Android - Wifi 設定為開啟(enable)之過程

1) 透過 WifiEnabler 開始enable wifi過程
android/packages/apps/Settings/src/com/android/settings/wifi/WifiSettings.java

    @Override    public void onActivityCreated(Bundle savedInstanceState) {        super.onActivityCreated(savedInstanceState);        mP2pSupported = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);        mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);        ....        // On/off switch is hidden for Setup Wizard        if (!mSetupWizardMode) {            Switch actionBarSwitch = new Switch(activity);            if (activity instanceof PreferenceActivity) {                PreferenceActivity preferenceActivity = (PreferenceActivity) activity;                if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {                    final int padding = activity.getResources().getDimensionPixelSize(                            R.dimen.action_bar_switch_padding);                    actionBarSwitch.setPaddingRelative(0, 0, padding, 0);                    activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,                            ActionBar.DISPLAY_SHOW_CUSTOM);                    activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(                            ActionBar.LayoutParams.WRAP_CONTENT,                            ActionBar.LayoutParams.WRAP_CONTENT,                            Gravity.CENTER_VERTICAL | Gravity.END));                }            }            mWifiEnabler = new WifiEnabler(activity, actionBarSwitch);        }        ...

2)
android/packages/apps/Settings/src/com/android/settings/wifi/WifiEnabler.java

沒有留言:

張貼留言