# 6. Quest Classroom Voice and Pitfalls
Part of [[Voice Chat with Vivox]]. Back: [[5. Hooking Vivox to Lobby Sessions]].
> [!warning] Code not compiled in Unity
> `AndroidMicPermission` was type-checked against Unity 6000.5.8f1 (`UnityEngine.Android.Permission`, including `RequestUserPermissions`). It has not been run on a Quest headset. The teacher Command is a plain C# API — wiring it to the existing classroom NGO RPCs was not compiled. Vivox APIs as in the hub: docs-checked, not compiled.
## 6.1 Runtime permissions, officially
Official Vivox Android docs: before you **join a channel**, request `android.permission.RECORD_AUDIO` and, on **Android 12 and later**, `android.permission.BLUETOOTH_CONNECT`, using `UnityEngine.Android.Permission`.
Quest 2 / 3 run an Android OS. Treat the official Android path as required. The Unity 6000.5 `Permission` API (from that Editor's `UnityEngine.AndroidJNIModule` docs):
- `Permission.Microphone` — official summary: used when requesting or checking microphone permission.
- `Permission.HasUserAuthorizedPermission(string)`
- `Permission.RequestUserPermission(string)` and `RequestUserPermissions(string[])`
- There is **no** built-in constant for Bluetooth Connect; pass the official string `android.permission.BLUETOOTH_CONNECT`.
- Android 12 is API 31 (`Build.VERSION.SDK_INT >= 31`).
```csharp
using System.Collections.Generic;
using UnityEngine;
#if UNITY_ANDROID
using UnityEngine.Android;
#endif
/// <summary>
/// Requests the runtime permissions official Vivox Android docs require
/// before you join a channel: RECORD_AUDIO (Permission.Microphone) and,
/// on Android 12+, BLUETOOTH_CONNECT.
/// </summary>
public static class AndroidMicPermission
{
public const string BluetoothConnect = "android.permission.BLUETOOTH_CONNECT";
public static bool HasRequiredPermissions()
{
#if UNITY_ANDROID && !UNITY_EDITOR
if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
return false;
if (IsAndroid12OrNewer() && !Permission.HasUserAuthorizedPermission(BluetoothConnect))
return false;
#endif
return true;
}
public static void RequestRequiredPermissions()
{
#if UNITY_ANDROID && !UNITY_EDITOR
var needed = new List<string>();
if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
needed.Add(Permission.Microphone);
if (IsAndroid12OrNewer() && !Permission.HasUserAuthorizedPermission(BluetoothConnect))
needed.Add(BluetoothConnect);
if (needed.Count == 1)
Permission.RequestUserPermission(needed[0]);
else if (needed.Count > 1)
Permission.RequestUserPermissions(needed.ToArray());
#endif
}
static bool IsAndroid12OrNewer()
{
return GetAndroidSdkInt() >= 31;
}
static int GetAndroidSdkInt()
{
#if UNITY_ANDROID && !UNITY_EDITOR
using (var version = new AndroidJavaClass("android.os.Build$VERSION"))
return version.GetStatic<int>("SDK_INT");
#else
return 0;
#endif
}
}
```
On Quest, call `RequestRequiredPermissions()` after a short explanation in the UI, then **wait until** `HasRequiredPermissions()` is true before `JoinGroupAsync`. `RequestUserPermission` is not awaitable in this API; poll on a later frame or use the `PermissionCallbacks` overload if you want a callback. The Editor `#if` path returns true so you can still test voice on a PC.
16.9.0 already stopped Vivox from adding `READ_PHONE_STATE` to an XR manifest. Do not add that permission yourself. Confirm your final APK manifest on a build you actually install ([[6. Deploying to Five Headsets and Running a Class]]).
## 6.2 Pin 16.12.1 on every headset APK
Repeat from part 1 because this is the Quest-specific failure mode: **16.12.0 is unusable on Android**; **16.12.1** (2026-09-16) fixes that. A classroom image built from an unlocked manifest that resolved 16.12.0 will fail on every headset the same way. Lock 16.12.1, rebuild, sideload all five (or however many) headsets together.
For this lab, prefer the classroom series' Editor floor — **Unity 6.3 LTS (6000.3.27f2+)** — and confirm 16.12.1 on that Editor's official package page before you lock it there. The 16.12.1 package itself lists a minimum Editor of 6000.0 (from the 16.12.0 changelog). That is not a substitute for checking the 6000.3 list.
## 6.3 Teacher mute is a Command, not MutePlayerLocally
`MutePlayerLocally` only silences a student **for the teacher**. The rest of the class still hears them. A "mute students" beat in a seminar has to run on each student headset:
```csharp
using Unity.Services.Vivox;
using UnityEngine;
/// <summary>
/// Local voice Commands a classroom host can issue. Wire RequestStudentMicMuted
/// through the same NGO RPC (or session message) path you already use for
/// gather and pause in Multi-Headset Quest Classroom Sessions. This class
/// does not invent an RPC attribute.
/// </summary>
public sealed class ClassroomVoiceCommands : MonoBehaviour
{
[SerializeField] bool isTeacher;
public bool IsTeacher => isTeacher;
/// <summary>Teacher-only. Broadcast to every student headset.</summary>
public void RequestStudentMicMuted(bool muted)
{
if (!isTeacher)
{
Debug.LogWarning("ClassroomVoiceCommands: only the teacher may request a class mute.");
return;
}
// Host applies the same local policy, then send `muted` to clients.
ApplyStudentMicMuted(muted);
// TODO: raise your existing classroom Command / RPC here with `muted`.
}
/// <summary>Runs on the headset that should actually mute or unmute.</summary>
public void ApplyStudentMicMuted(bool muted)
{
if (isTeacher)
return; // Teacher stays unmuted unless they toggle their own mute.
var v = VivoxService.Instance;
if (v == null || !v.IsLoggedIn)
return;
if (muted && !v.IsInputDeviceMuted)
v.MuteInputDevice();
else if (!muted && v.IsInputDeviceMuted)
v.UnmuteInputDevice();
}
}
```
That is the same **Command** pattern the classroom series already uses for gather and pause ([[Game Programming Patterns (Review)]]). Students can still mute *themselves* with the part 4 input-device toggle; a teacher unmute should not fight a student who has muted on purpose — if you need that policy, keep a separate "class muted by teacher" flag and only unmute when both the teacher and the student want audio. That policy is yours; Vivox will not enforce it.
## 6.4 Headset test order
Run this on two headsets before you scale to a full class ([[6. Deploying to Five Headsets and Running a Class]]):
1. Confirm the APK resolved **Vivox 16.12.1**.
2. Grant microphone (and Bluetooth Connect, if requested) **before** the join.
3. Echo channel on a single headset — you hear yourself (part 3). Leave the echo channel.
4. Two headsets in the same Session — both join `session-{Id}`, both appear on the roster, speech indicators move.
5. Local mute: A mutes B locally; C still hears B.
6. Teacher Command: students' `IsInputDeviceMuted` becomes true; teacher still speaks.
7. Leave the Session — voice leaves too (part 5).
8. Only then run five headsets. If something fails at five but not at two, look at [[7. Classroom Session Pitfalls]] (capacity, attention, leftover processes) before blaming Vivox.
## 6.5 Symptom table
| Symptom | Check first |
|---|---|
| Package Manager shows 16.12.0 | Lock 16.12.1. 16.12.0 is officially unusable on Android |
| Join fails on Quest, works in Editor | Runtime `RECORD_AUDIO` (and Bluetooth Connect on Android 12+) not granted before join |
| Nobody hears anyone, credentials look fine | Vivox enabled on a *different* UGS project than Sessions; or still in an echo channel under a sample name |
| Roster row stuck on "connecting" | `IsInAudio` is officially false until the first participant update — wait for `ParticipantAudioStateChanged` |
| Teacher "mute" does nothing for the class | You called `MutePlayerLocally` (local only). Send a Command to `MuteInputDevice` on each student |
| `VivoxApiException` on mute after leaving | Official 16.12.0 fix is in 16.12.1; still, do not mute after `LogoutAsync` |
| Duplicate participant events after re-login | 16.12.0/16.12.1 fixed stale subscriptions; also check you unsubscribed in `OnDisable` |
| Can't hear the teacher at the back of the real room | You joined a **positional** channel. Use a group channel for a seminar (part 3) |
| `InAudio` does not compile | The 16.12.1 property is `IsInAudio` |
| `Transmission.None` does not compile | The 16.12.1 enum is `TransmissionMode` |
| XR APK asks for phone state | Should already be fixed in 16.9.0+; inspect the merged manifest and remove any leftover you added by hand |
| UI Toolkit roster is empty but you have audio | Events subscribed after join; rebuild from `VivoxService.Instance.ActiveChannels` once, then keep listening |
Back to the hub: [[Voice Chat with Vivox]].