• RK:android5.1、android7.1便携式WLAN热点 记住State


    Platform: RK3288
    OS: Android 5.1

    diff --git a/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java b/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
    old mode 100644
    new mode 100755
    index cc5824e..49d371a
    --- a/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
    +++ b/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
    @@ -353,6 +353,13 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
     
             mWifiController.start();
     
    +		int wifiap_on = SystemProperties.getInt("persist.sys.wifiapenable",0);
    +		if(wifiap_on == 1) {
    +		   setWifiApEnabled(getWifiApConfiguration(),true);
    +		} else if (wifiEnabled){
    +		   setWifiEnabled(wifiEnabled); 
    +		}
    +		   
             // If we are already disabled (could be due to airplane mode), avoid changing persist
             // state here
             if (wifiEnabled) setWifiEnabled(wifiEnabled);
    @@ -725,6 +732,12 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
             }
             // null wifiConfig is a meaningful input for CMD_SET_AP
             if (wifiConfig == null || wifiConfig.isValid()) {
    +			if(enabled){
    +			  SystemProperties.set("persist.sys.wifiapenable","1");
    +			}else {
    +			  SystemProperties.set("persist.sys.wifiapenable","0");
    +			}
    +			
                 mWifiController.obtainMessage(CMD_SET_AP, enabled ? 1 : 0, 0, wifiConfig).sendToTarget();
             } else {
                 Slog.e(TAG, "Invalid WifiConfiguration");
    diff --git a/packages/apps/Settings/src/com/android/settings/TetherSettings.java b/packages/apps/Settings/src/com/android/settings/TetherSettings.java
    old mode 100644
    new mode 100755
    index e33ddb0..5a34a4a
    --- a/packages/apps/Settings/src/com/android/settings/TetherSettings.java
    +++ b/packages/apps/Settings/src/com/android/settings/TetherSettings.java
    @@ -40,6 +40,7 @@ import android.preference.Preference;
     import android.preference.PreferenceScreen;
     import android.preference.SwitchPreference;
     import android.widget.TextView;
    +import android.util.Log;
     
     import com.android.settings.wifi.WifiApDialog;
     import com.android.settings.wifi.WifiApEnabler;
    @@ -308,6 +309,15 @@ public class TetherSettings extends SettingsPreferenceFragment
             activity.registerReceiver(mTetherChangeReceiver, filter);
     
             if (intent != null) mTetherChangeReceiver.onReceive(activity, intent);
    +		if(mEnableWifiAp != null) 
    +		{
    +	       if(SystemProperties.getInt("persist.sys.wifiapenable",0) == 1)
    +	       {	
    +		      mEnableWifiAp.setChecked(true);
    +	       }else{
    +	          mEnableWifiAp.setChecked(false);
    +	       }						
    +		}	  		    		
             if (mWifiApEnabler != null) {
                 mEnableWifiAp.setOnPreferenceChangeListener(this);
                 mWifiApEnabler.resume();
    @@ -454,8 +464,10 @@ public class TetherSettings extends SettingsPreferenceFragment
             boolean enable = (Boolean) value;
     
             if (enable) {
    +			SystemProperties.set("persist.sys.wifiapenable","1");
                 startProvisioningIfNecessary(WIFI_TETHERING);
             } else {
    +			SystemProperties.set("persist.sys.wifiapenable","0");
                 if (isProvisioningNeeded(mProvisionApp)) {
                     TetherService.cancelRecheckAlarmIfNecessary(getActivity(), WIFI_TETHERING);
                 }
    

     https://blog.csdn.net/weixin_39966398/article/details/103661656

    Platform: RK3399
    OS: Android 7.1.1

    需求:开机默认打开wifi热点

    diff --git a/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java b/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
    index 0f3e901..060563c 100644
    --- a/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
    +++ b/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
    @@ -408,14 +408,21 @@ public class WifiServiceImpl extends IWifiManager.Stub {
     
        public void checkAndStartWifi() {
             /* Check if wi-fi needs to be enabled */
             .....
             .....
             .....
             // Adding optimizations of only receiving broadcasts when wifi is enabled
             // can result in race conditions when apps toggle wifi in the background
             // without active user involvement. Always receive broadcasts.
             registerForBroadcasts();
             registerForPackageOrUserRemoval();
             mInIdleMode = mPowerManager.isDeviceIdleMode();
    
             mWifiController.start();
            
    +        int wifiap_on = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.WIFIAP_ON, 0);
    +        if(wifiap_on == 1) {
    +            setWifiApEnabled(getWifiApConfiguration(),true);
    +        } else if (wifiEnabled){
    +            setWifiEnabled(wifiEnabled); 
    +        } 
         }
    
        public void setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
            enforceChangePermission();
            ConnectivityManager.enforceTetherChangePermission(mContext);
            if (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) {
                throw new SecurityException("DISALLOW_CONFIG_TETHERING is enabled for this user.");
            }
            // null wifiConfig is a meaningful input for CMD_SET_AP
            if (wifiConfig == null || isValid(wifiConfig)) {
    +	  		Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.WIFIAP_ON, enabled ? 1 : 0);
                mWifiController.obtainMessage(CMD_SET_AP, enabled ? 1 : 0, 0, wifiConfig).sendToTarget();
            } else {
                Slog.e(TAG, "Invalid WifiConfiguration");
            }
        }
    
    diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
    index 20b95b9..545af52 100644
    --- a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
    +++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
    @@ -2581,6 +2581,9 @@ class DatabaseHelper extends SQLiteOpenHelper {
    		private void loadGlobalSettings(SQLiteDatabase db) {
    		     ......
    		     ......
                 loadBooleanSetting(stmt, Settings.Global.AIRPLANE_MODE_ON,
                         R.bool.def_airplane_mode_on);
     
    +            loadBooleanSetting(stmt, Settings.Global.WIFIAP_ON,
    +                    R.bool.def_wifiap_on);
    +
                 loadBooleanSetting(stmt, Settings.Global.THEATER_MODE_ON,
                         R.bool.def_theater_mode_on);
    
    diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
    index a2e0012..3cc42eb 100644
    --- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
    +++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
    @@ -7,4 +7,7 @@
    +    <!--if true while boot_completed will start wifiap on  -->
    +    <bool name="def_wifiap_on">true</bool>
    
    
    
    diff --git a/frameworks/base/core/java/android/provider/Settings.java b/frameworks/base/core/java/android/provider/Settings.java
    index d8e8e45..82a50f3 100755
    --- a/frameworks/base/core/java/android/provider/Settings.java
    +++ b/frameworks/base/core/java/android/provider/Settings.java
    @@ -4249,7 +4249,7 @@ public final class Settings {
                 MOVED_TO_GLOBAL.add(Settings.Global.WIFI_ON);
                 MOVED_TO_GLOBAL.add(Settings.Global.WIFI_P2P_DEVICE_NAME);
                 MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SAVED_STATE);
    +            MOVED_TO_GLOBAL.add(Settings.Global.WIFIAP_ON);
                 MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS);
                 MOVED_TO_GLOBAL.add(Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED);
                 MOVED_TO_GLOBAL.add(Settings.Global.WIFI_VERBOSE_LOGGING_ENABLED);
    @@ -7764,7 +7764,7 @@ public final class Settings {
           /**
            * Settings to allow BLE scans to be enabled even when Bluetooth is turned off for
            * connectivity.
            * @hide
            */
           public static final String BLE_SCAN_ALWAYS_AVAILABLE =
                   "ble_scan_always_enabled";
    
    +        /**
    +         * Used to save the WifiAP_ON State
    +         * @hide
    +        */
    +       public static final String WIFIAP_ON = "wifiap_on";
    
  • 相关阅读:
    JSP
    Tomcat根据JSP生成Servlet机制解析
    JSON基础
    ATouch 吃鸡开发板原理及功能介绍
    Android触摸touchevent的AB两种方式(TYPE_A,TYPE_B)识别方法
    ubuntu诸软件安装
    linux kernel mini2440 start.S head-common.S 部分注释
    Android USB ADB ATUH 验证包验证流程
    USB协议学习
    Android memory dump
  • 原文地址:https://www.cnblogs.com/crushgirl/p/13955261.html
Copyright © 2020-2023  润新知