title: get PatchStore::createDisableExceptionQarthFile method fail?
body: <p>hello dear programmers i am developing an android simple wifi direct chat application using android studio in the application i basically have a text view for the connection statuse which tells me if the device is the Host or client in the wifi Direct Group or if it is disconnected a button that opens the wifi settings and then you go to wifi direct and connect to another device manually.
  after that you can return to the app and use the edit text box to write the message and use the send button to send it.
  i am using three devices for testing:
  -an old samsung S4 with android version 5
  -a huawei mate 9 with android version 9
  -a samsung note 10 with android version 10</p>
  <p>i am facing two problems:
  the first problem is when i try to use the application with the note 10 (or any othe APi level 10 device ) after i connect it with another device and go back to the app the wifi direct does not work with my application IDK why also in the text view it doesn't show wheither it is the host or the client or even though it shows this info on the other device i am connected with</p>
  <p>the other problem is when i connect the huawei and the s4 the application works correctly on the s4 and it sends messages to the huawei and the text view in the huawei shows these messages but if i try the opposate the app crashes and gives me the following error</p>
  <pre><code>E/e.wifip2p_take: [qarth_debug:]  get PatchStore::createDisableExceptionQarthFile method fail.
  E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.wifip2p_take2, PID: 1388
  android.os.NetworkOnMainThreadException
      at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1523)
      at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:116)
      at java.net.SocketOutputStream.write(SocketOutputStream.java:149)
      at com.example.wifip2p_take2.MainActivity$sendReceive.write(MainActivity.java:229)
      at com.example.wifip2p_take2.MainActivity$4.onClick(MainActivity.java:114)
      at android.view.View.performClick(View.java:6659)
      at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
      at android.view.View.performClickInternal(View.java:6631)
      at android.view.View.access$3100(View.java:790)
      at android.view.View$PerformClick.run(View.java:26187)
      at android.os.Handler.handleCallback(Handler.java:907)
      at android.os.Handler.dispatchMessage(Handler.java:105)
      at android.os.Looper.loop(Looper.java:216)
      at android.app.ActivityThread.main(ActivityThread.java:7625)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
  </code></pre>
  <p>my manafist file</p>
  <pre><code>&lt;uses-sdk android:minSdkVersion=&quot;14&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.CHANGE_WIFI_STATE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.CHANGE_NETWORK_STATE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
  </code></pre>
  <p>my main activity code:</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private static final String TAG = &quot;MainActivity&quot;;
  TextView status,messageTV;
  Button send,connect;
  EditText messageET;
  boolean isHost;
  WifiP2pManager manager;
  WifiP2pManager.Channel channel;
  BroadcastReceiver receiver;
  IntentFilter intentFilter;
  
  server server;
  client client;
  sendReceive sendReceive;
  static final int MESSAGE_READ = 1;
  Handler handler = new Handler(new Handler.Callback() {
      @Override
      public boolean handleMessage(@NonNull Message msg) {
          switch (msg.what){
              case MESSAGE_READ:
                  byte [] readBuffer =(byte []) msg.obj;
                  String temp = new String(readBuffer,0,msg.arg1);
                  messageTV.setText(temp);
                  Log.d(TAG, &quot;handleMessage: The Other side Says:&quot;+temp);
                  break;
          }
          return true;
      }
  });
  
  private void initializework() {
      status = findViewById(R.id.statusTV);
      messageTV = findViewById(R.id.messageTV);
      send = findViewById(R.id.sendBtn);
      connect = findViewById(R.id.connectBtn);
      messageET= findViewById(R.id.messageEditText);
  
      manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
      channel = manager.initialize(this, getMainLooper(), null);
      receiver = new WiFiDirectBroadcastReceiver(manager, channel, this);
      intentFilter = new IntentFilter();
      intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
      intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
      intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
      intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
  
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      initializework();
      listeners();
  }
  
  private void listeners() {
      status.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              status.setText(&quot;Hello ?&quot;);
              status.setTextColor(Color.parseColor(&quot;#000000&quot;));
  
          }
      });
      connect.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              openWifiSettings();
          }
      });
      send.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              String message = messageET.getText().toString();
              sendReceive.write(message.getBytes());
  
          }
      });
  }
  
  private void openWifiSettings() {
      final Intent intent = new Intent(Intent.ACTION_MAIN, null);
      intent.addCategory(Intent.CATEGORY_LAUNCHER);
      final ComponentName cn = new ComponentName(&quot;com.android.settings&quot;, &quot;com.android.settings.wifi.WifiSettings&quot;);
      intent.setComponent(cn);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivity( intent);
  }
  
  WifiP2pManager.ConnectionInfoListener mConnectionInfoListener = new WifiP2pManager.ConnectionInfoListener() {
      @Override
      public void onConnectionInfoAvailable(WifiP2pInfo info) {
          final InetAddress groupOwnerAddress = info.groupOwnerAddress;
          if (info.groupFormed &amp;&amp; info.isGroupOwner) {
              isHost = true;
              status.setText(&quot;Host&quot;);
              status.setTextColor(Color.parseColor(&quot;#a4c639&quot;));
              Log.d(TAG, &quot;onConnectionInfoAvailable: this device is the HOST in the wifiDirect group&quot;);
              server = new server();
              server.start();
  
          } else if (info.groupFormed) {
              isHost = false;
              status.setText(&quot;Client&quot;);
              status.setTextColor(Color.parseColor(&quot;#a4c639&quot;));
              Log.d(TAG, &quot;onConnectionInfoAvailable: this device is the CLIENT in the wifiDirect 
  group&quot;);
              client = new client(groupOwnerAddress);
              client.start();
  
          }
      }
  };
  
  public class server extends Thread{
      Socket connectionSocket;
      ServerSocket serverSocket;
  
      @Override
      public void run() {
          try {
              serverSocket = new ServerSocket(6666);
              connectionSocket = new Socket();
              connectionSocket = serverSocket.accept();
              sendReceive=new sendReceive(connectionSocket);
              sendReceive.start();
          } catch (IOException e) {
              Log.d(TAG, &quot;Server run: failed to run server socket. exception: &quot;+e);
          }
  
      }
  }
  
  public class client extends Thread{
      Socket connectionSocket;
      InetAddress hostAddress;
      public client(InetAddress hostAddress) {
          this.hostAddress = hostAddress;
          connectionSocket = new Socket();
      }
  
      @Override
      public void run() {
          try {
              connectionSocket.connect(new InetSocketAddress(hostAddress,6666),500);
              sendReceive= new sendReceive(connectionSocket);
              sendReceive.start();
          } catch (IOException e) {
              Log.d(TAG, &quot;Client run: failed to run client socket. exception: &quot;+e);
          }
  
      }
  }
  
  public class sendReceive extends Thread{
      private Socket connectionSocket;
      private InputStream inputStream;
      private OutputStream outputStream;
  
      public sendReceive(Socket socket) {
          connectionSocket = socket;
          try {
              inputStream = connectionSocket.getInputStream();
              outputStream = connectionSocket.getOutputStream();
          }catch (IOException e){
              Log.d(TAG, &quot;sendReceive: failed to get input or output stream&quot;);
          }
      }
  
      @Override
      public void run() {
          byte[] buffer=new byte[2048];
          int bytes;
  
          while (connectionSocket!=null)
          {
              try {
                  bytes=inputStream.read(buffer);
                  if (bytes&gt;0)
                  {
                      handler.obtainMessage(MESSAGE_READ,bytes,-1,buffer).sendToTarget();
                  }
              } catch (IOException e) {
                  Log.d(TAG, &quot;Reading message run: something went wrong exception:&quot;+e);
              }
          }
      }
      public void write(byte[] bytes)
      {
          try {
              outputStream.write(bytes);
          } catch (IOException e) {
              Log.d(TAG, &quot;sendReceive write: failed to write output stream&quot;);
          }
      }
  }
  
  @Override
  protected void onResume() {
      super.onResume();
      registerReceiver(receiver, intentFilter);
  }
  @Override
  protected void onPause() {
      super.onPause();
      unregisterReceiver(receiver);
  }
  
  }
  </code></pre>
  <p>my WiFiDirectBroadcastReceiver activity code:</p>
  <pre><code>public class WiFiDirectBroadcastReceiver extends BroadcastReceiver{
      private static final String TAG =&quot;wifi direct app BroadCast Receiver&quot;;
      private WifiP2pManager manager;
      private WifiP2pManager.Channel channel;
      private MainActivity mainActivity;
  
      public WiFiDirectBroadcastReceiver(WifiP2pManager manager, WifiP2pManager.Channel channel, MainActivity mainActivity) {
          this.manager = manager;
          this.channel = channel;
          this.mainActivity = mainActivity;
      }
      @SuppressLint(&quot;LongLogTag&quot;)
      @Override
      public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
              // Determine if Wifi Direct mode is enabled or not, alert
              int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
              if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
                  // Wifi P2P is enabled
                  Toast.makeText(context, &quot;WifiDirect Enabled&quot;, Toast.LENGTH_SHORT).show();
              } else {
                  // Wi-Fi P2P is not enabled
                  Toast.makeText(context, &quot;WifiDirect Disabled&quot;, Toast.LENGTH_SHORT).show();
              }
          } else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
              // The peer list has changed!  We should probably do something about that
              
          } else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
              // Connection state changed!  We should probably do something about that
              if(manager != null){
                  NetworkInfo mNetworkInfo = intent.getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);
                  if (mNetworkInfo.isConnected()){
                      manager.requestConnectionInfo(channel,mainActivity.mConnectionInfoListener);
                  }else {
                      mainActivity.status.setText(&quot;Device Disconnected&quot;);
                      Log.d(TAG, &quot;onReceive: connection ended. device disconnected &quot;);
                  }
              }
          } else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
              
          }
      }
  }
  </code></pre>