Android rom开发:framework中wifi热点打开/关闭的源码实现

--- a/frameworks/base/core/java/android/net/ConnectivityManager.java
+++ b/frameworks/base/core/java/android/net/ConnectivityManager.java
@@ -42,6 +42,7 @@ import android.os.RemoteException;
 import android.os.ResultReceiver;
 import android.os.ServiceManager;
 import android.os.ServiceSpecificException;
+import android.os.SystemProperties;
 import android.provider.Settings;
 import android.telephony.SubscriptionManager;
 import android.util.ArrayMap;
@@ -2285,6 +2286,11 @@ public class ConnectivityManager {
     @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
     public void startTethering(int type, boolean showProvisioningUi,
             final OnStartTetheringCallback callback, Handler handler) {
+        //wifi热点开启源码
+        if (SystemProperties.getInt("persist.cyg.always.close.wifiap", 0) == 1) {
+            Log.d(TAG, "can't open, always close wifi ap!");
+            return;
+        }
         Preconditions.checkNotNull(callback, "OnStartTetheringCallback cannot be null.");
 
         ResultReceiver wrappedCallback = new ResultReceiver(handler) {
@@ -2321,6 +2327,11 @@ public class ConnectivityManager {
     @SystemApi
     @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
     public void stopTethering(int type) {
+        //wifi热点关闭源码
+        if (SystemProperties.getInt("persist.cyg.always.open.wifiap", 0) == 1) {
+            Log.d(TAG, "can't close, always open wifi ap!");
+            return;
+        }
         try {
             String pkgName = mContext.getOpPackageName();
             Log.i(TAG, "stopTethering caller:" + pkgName);

你可能感兴趣的:(android,rom开发,android源码,android)