Skip to content

The "cras" Command

The cras command in ChromeOS provides control over the ChromeOS Audio Server (CRAS), allowing users to manage audio features and simulate telephony events.

Command Overview

The basic syntax for the command is:

cras [ enable <flag> | disable <flag> | telephony <event> [arg] ]

Understanding CRAS Features

Feature Flags

CRAS supports several feature flags that control audio behavior:

  1. Wideband Speech (wbs)
  2. Enables wideband speech mode in Bluetooth HFP
  3. Requires compatible Bluetooth controller and peripheral
  4. Improves audio quality for voice communications

  5. Noise Cancellation

  6. Enables noise cancellation processing
  7. Works with compatible input devices
  8. Reduces background noise in audio input

Telephony Events

The command supports various telephony events for Bluetooth HFP simulation: - Call management - Status indicators - System parameters - Connection states

Using the Command

Managing Feature Flags

  1. Enable a feature:

    cras enable wbs
    cras enable noise_cancellation
    
  2. Disable a feature:

    cras disable wbs
    cras disable noise_cancellation
    

Managing Telephony Events

  1. Call Management:

    # Simulate incoming call
    cras telephony IncomingCall 12345678
    
    # Answer call
    cras telephony AnswerCall
    
    # End call
    cras telephony TerminateCall
    
  2. System Status:

    # Set battery level (0-5)
    cras telephony SetBatteryLevel 4
    
    # Set signal strength (0-5)
    cras telephony SetSignalStrength 5
    
    # Set service availability
    cras telephony SetServiceAvailability 1
    
  3. Call Status Management:

    # Set call held status
    cras telephony SetCallheld 0  # No calls held
    cras telephony SetCallheld 1  # Call on hold or swapped
    cras telephony SetCallheld 2  # Call on hold, no active call
    
  4. Call Setup Status:

    # Set call setup state
    cras telephony SetCallsetup 0  # No setup in progress
    cras telephony SetCallsetup 1  # Incoming call setup
    cras telephony SetCallsetup 2  # Outgoing call dialing
    cras telephony SetCallsetup 3  # Outgoing call alerting
    

Best Practices

Feature Management

  1. Flag Usage
  2. Test features before deployment
  3. Document enabled features
  4. Monitor system impact
  5. Note reboot requirements

  6. Telephony Testing

  7. Test complete call flows
  8. Verify status indicators
  9. Check system responses
  10. Document test scenarios

Common Use Cases

Audio Enhancement

  • Enabling wideband speech for better call quality
  • Activating noise cancellation for clearer input
  • Testing audio features in different scenarios
  • Optimizing audio settings for specific uses

Telephony Testing

  • Simulating complete call flows
  • Testing call handling
  • Verifying status indicators
  • Debugging telephony features

Safety Considerations

System Impact

  1. Feature Flags
  2. Changes don't persist after reboot
  3. May affect system performance
  4. Could impact battery life
  5. Might affect other audio features

  6. Telephony Simulation

  7. Test in controlled environment
  8. Monitor system resources
  9. Check for conflicts
  10. Verify normal operation

Troubleshooting

Common Issues

  1. Audio Problems
  2. Feature compatibility
  3. Device support
  4. Configuration issues
  5. Performance impact

  6. Telephony Simulation

  7. Event timing
  8. Status synchronization
  9. State management
  10. System response

Remember: Changes made using feature flags do not persist after a system reboot. Always document your changes and be prepared to reapply them after system restarts.