Skip to content

Commit

Permalink
Merge pull request #731 from gree/fix/android_audio_recording_permiss…
Browse files Browse the repository at this point in the history
…ions

fixed to add android MODIFY_AUDIO_SETTINGS and RECORD_AUDIO permissions.
  • Loading branch information
KojiNakamaru authored Aug 26, 2021
2 parents 7ce5342 + 92ffc5c commit 2300735
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ For allowing microphone access (`navigator.mediaDevices.getUserMedia({ audio:tru
```xml
<uses-permission android:name="android.permission.MICROPHONE" />
<uses-feature android:name="android.hardware.microphone" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
```

and call the following on runtime.
Expand Down
16 changes: 16 additions & 0 deletions plugins/Editor/UnityWebViewPostprocessBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ internal bool AddMicrophone() {
ManifestElement.AppendChild(elem);
changed = true;
}
// cf. https://github.com/gree/unity-webview/issues/679
// cf. https://github.com/fluttercommunity/flutter_webview_plugin/issues/138#issuecomment-559307558
// cf. https://stackoverflow.com/questions/38917751/webview-webrtc-not-working/68024032#68024032
// cf. https://stackoverflow.com/questions/40236925/allowing-microphone-accesspermission-in-webview-android-studio-java/47410311#47410311
if (SelectNodes("/manifest/uses-permission[@android:name='android.permission.MODIFY_AUDIO_SETTINGS']", nsMgr).Count == 0) {
var elem = CreateElement("uses-permission");
elem.Attributes.Append(CreateAndroidAttribute("name", "android.permission.MODIFY_AUDIO_SETTINGS"));
ManifestElement.AppendChild(elem);
changed = true;
}
if (SelectNodes("/manifest/uses-permission[@android:name='android.permission.RECORD_AUDIO']", nsMgr).Count == 0) {
var elem = CreateElement("uses-permission");
elem.Attributes.Append(CreateAndroidAttribute("name", "android.permission.RECORD_AUDIO"));
ManifestElement.AppendChild(elem);
changed = true;
}
return changed;
}
}
Expand Down

0 comments on commit 2300735

Please sign in to comment.