MuntashirAkon/AppManager · error · IOException
Could not reset sensor.
Error message
Could not reset sensor.
What it means
Thrown by SensorServiceCompat.resetSensor when the 'reset-uid-state' binder shell command to the 'sensorservice' service exits non-zero, i.e. the sensor privacy state for the package could not be reset to default.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/compat/SensorServiceCompat.java:56
String[] command;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
command = new String[]{"set-uid-state", packageName, state, "--user", String.valueOf(userId)};
} else command = new String[]{"set-uid-state", packageName, state};
BinderShellExecutor.ShellResult result = BinderShellExecutor.execute(getSensorService(), command);
if (result.getResultCode() != 0) {
throw new IOException("Could not " + (enable ? "enable" : "disable") + " sensor.");
}
}
@RequiresPermission(ManifestCompat.permission.MANAGE_SENSORS)
public static void resetSensor(@NonNull String packageName, @UserIdInt int userId) throws IOException {
String[] command;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
command = new String[]{"reset-uid-state", packageName, "--user", String.valueOf(userId)};
} else command = new String[]{"reset-uid-state", packageName};
BinderShellExecutor.ShellResult result = BinderShellExecutor.execute(getSensorService(), command);
if (result.getResultCode() != 0) {
throw new IOException("Could not reset sensor.");
}
}
@NonNull
private static IBinder getSensorService() {
return ProxyBinder.getService("sensorservice");
}
}
View on GitHub (pinned to 0152f468fc)
Solutions
- Ensure the process runs as root/shell or a privileged system app with MANAGE_SENSORS
- Validate the userId exists before resetting; iterate only over returned user handles
- Capture shell stderr from the ShellResult for the true failure reason
- Fall back to per-user handling: retry without the --user argument on Android <= Q paths if applicable
Example fix
// before
BinderShellExecutor.execute(getSensorService(), command);
// after
BinderShellExecutor.ShellResult result = BinderShellExecutor.execute(getSensorService(), command);
if (result.getResultCode() != 0) {
Log.e(TAG, "reset-uid-state failed: " + result.getOutput());
throw new IOException("Could not reset sensor.");
} Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the uid state was actually modified before reset if (!userExists(userId)) return; // nothing to reset
Try / catch
try {
SensorServiceCompat.resetSensor(pkg, userId);
} catch (IOException e) {
Log.w(TAG, "Sensor reset failed for " + pkg, e);
} Prevention
- Check privileges first
- Validate userId exists
- Capture shell stderr
- Skip reset when no state was changed
When it happens
Trigger: Calling SensorServiceCompat.resetSensor(packageName, userId) on a device/ROM where sensorservice rejects reset-uid-state, with an invalid userId, or without the privileged identity required to manage sensors.
Common situations: Same privilege gaps as enable/disable: non-rooted device, unsupported vendor ROM, stale userId after user removal, or the package never having had its UID state modified.
Understand the failure class
Background: "You do not have permission" / 403 Forbidden errors: authenticated but not allowed — causes and fixes across open-source libraries — this error's family across 31 libraries.
Related errors
- Could not ${enable ? "enable" : "disable"} sensor.
- Failed to restore ADB data
- Could not cache splits
- IOException(REMOTE_ERR_MSG, throwable)
- The IBinder provided is invalid
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/f2cccfb0b908b29d.
Report an issue: GitHub.