CAPTURE_AUDIO_OUTPUT did not request permission at runtime
I’m trying to record sound from Audio Recorder but I get permission error on Android 6+.
I added the code to request permissions (there are 3 request permissions)2 works but
CAPTURE_AUDIO_OUTPUT displays an error. It just doesn’t ask me for permission. In the log it is simply “not granted”
Does anyone know what the problem is?
public static boolean PermissionCheck(Activity context, String permission, int code) {
boolean state = false;
int permissionCheck = ContextCompat.checkSelfPermission(context,
permission);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(context, new String[]{permission}, code); define this constant yourself
} else {
you have the permission
return true;
}
return state;
}
case CAPTURE_AUDIO_OUTPUT_CONSTANT: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Logger.e("CAPTURE PERMISSION GRANTED");
INIT();
} else {
Logger.e("CAPTURE PERMISSION NOT GRANTED");
finish();
}
return;
}
Error
W/PackageManager: Not granting permission android.permission.CAPTURE_AUDIO_OUTPUT to package blabla_package (protectionLevel=18 flags=0x3848be46)
in the list
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT"/>
[UPD] After a lot of trial and research, I can now answer:
Thanks to Google, now we can’t record calls.
This is only possible using C code and the NDK.
Solution
CAPTURE_AUDIO_OUTPUT
is not a dangerous
permission, so it does not apply to the runtime permission system. CAPTURE_AUDIO_OUTPUT
has android:protectionLevel="signature|privileged"
, so it can only be installed on the privilege (aka system) partition or signed by the platform key.