mirror of
				https://github.com/mik3y/usb-serial-for-android
				synced 2025-10-31 10:27:27 +00:00 
			
		
		
		
	have to use MUTABLE to get GRANTED flag at intent extras
This commit is contained in:
		
							parent
							
								
									dd1b95b852
								
							
						
					
					
						commit
						6c648e9f56
					
				| @ -212,7 +212,7 @@ public class TerminalFragment extends Fragment implements SerialInputOutputManag | ||||
|         UsbDeviceConnection usbConnection = usbManager.openDevice(driver.getDevice()); | ||||
|         if(usbConnection == null && usbPermission == UsbPermission.Unknown && !usbManager.hasPermission(driver.getDevice())) { | ||||
|             usbPermission = UsbPermission.Requested; | ||||
|             int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0; | ||||
|             int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_MUTABLE : 0; | ||||
|             PendingIntent usbPermissionIntent = PendingIntent.getBroadcast(getActivity(), 0, new Intent(INTENT_ACTION_GRANT_USB), flags); | ||||
|             usbManager.requestPermission(driver.getDevice(), usbPermissionIntent); | ||||
|             return; | ||||
|  | ||||
| @ -84,7 +84,7 @@ public class UsbWrapper implements SerialInputOutputManager.Listener { | ||||
|                     granted[0] = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false); | ||||
|                 } | ||||
|             }; | ||||
|             int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0; | ||||
|             int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_MUTABLE : 0; | ||||
|             PendingIntent permissionIntent = PendingIntent.getBroadcast(context, 0, new Intent("com.android.example.USB_PERMISSION"), flags); | ||||
|             IntentFilter filter = new IntentFilter("com.android.example.USB_PERMISSION"); | ||||
|             context.registerReceiver(usbReceiver, filter); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user