BroadcastReciever中有阻塞调用导致死机

现象: CPU占用率高,系统卡死
log:  Skipped 47 frames!  The application may be doing too much work on its main thread.

原因: 调用的底层接口中有阻塞:
sem_wait(&_uart_state.sem);

解决方法:创建一个线程来运行需要处理的代码:

if(action.equals(AudioManager.MASTER_MUTE_CHANGED_ACTION))
{
	final boolean muted = intent.getBooleanExtra(AudioManager.EXTRA_MASTER_VOLUME_MUTED, false);
	new Thread(new Runnable() { 
		public void run()  
		{    
			if(DEBUG) Log.v(TAG, "UartMcu mBroadcastReciever  MASTER_MUTE_CHANGED_ACTION muted = " + muted);
			if(muted)
			{
				SetMuteHw(true);
			}
			else
			{
				SetMuteHw(false);
			}
		}
	}).start();  
}





你可能感兴趣的:(android,framework,Broadcast,receiver)