I need to write/read special files in order to send AT commands to the SIM controller on Android. My device is rooted, and the app has been granted with root privileges, but I still don't have access to the file (Permission denied)
The code :
bool rootStatus = await RootAccess.requestRootAccess;
File file = File('/dev/smd7');
String text = await file.readAsString();
the log :
W/DartWorker( 3970): type=1400 audit(0.0:257920): avc: denied { getattr } for path="/dev/smd7" dev="tmpfs" ino=12484 scontext=u:r:untrusted_app:s0:c57,c257,c512,c768 tcontext=u:object_r:vendor_smd7_device:s0 tclass=chr_file permissive=0 app=app.ussd.ussd
E/flutter ( 3970): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: FileSystemException: Cannot open file, path = '/dev/smd7' (OS Error: Permission denied, errno = 13)
E/flutter ( 3970): #0 _File.open.<anonymous closure> (dart:io/file_impl.dart:356:9)
E/flutter ( 3970): #1 _rootRunUnary (dart:async/zone.dart:1434:47)
E/flutter ( 3970): #2 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter ( 3970): <asynchronous suspension>
E/flutter ( 3970): #3 _MyAppState.build.<anonymous closure> (package:ussd/main.dart:71:35)
E/flutter ( 3970): <asynchronous suspension>
E/flutter ( 3970):
any thought ?
PS: I am able to cat and echo the file through a terminal with root privileges
PS2 : I get the same result with native Java Code
public void onClick(View view) {
File file = new File("/dev/smd7");
try {
mSerR = new FileInputStream(file);
mSerW = new FileOutputStream(file);
} catch (FileNotFoundException e) {
Log.d("Error", "onClick: " + e.getLocalizedMessage());
}
}
W/mple.myussdtest: type=1400 audit(0.0:272431): avc: denied { read } for name="smd7" dev="tmpfs" ino=12484 scontext=u:r:untrusted_app:s0:c61,c257,c512,c768 tcontext=u:object_r:vendor_smd7_device:s0 tclass=chr_file permissive=0 app=com.example.myussdtest
D/Error: onClick: /dev/smd7: open failed: EACCES (Permission denied)