修改1:frameworks\base\services\core\java\com\android\server\display\DisplayManagerService.java
a、
import android.view.Display;import android.view.DisplayInfo;import android.view.Surface;import android.view.WindowManagerInternal;
- //import android.media.AudioManager;
+ import android.media.AudioManager;import com.android.server.AnimationThread;
b、
private final DisplayAdapterListener mDisplayAdapterListener;private WindowManagerInternal mWindowManagerInternal;private InputManagerInternal mInputManagerInternal;private IMediaProjectionManager mProjectionService;-//AudioManager mAudioManager;
+ AudioManager mAudioManager;// The synchronization root for the display manager.// This lock guards most of the display manager's state.
c、
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);mGlobalDisplayBrightness = pm.getDefaultScreenBrightnessSetting();-//mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);+ mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
}public void setupSchedulerPolicies() {
d、
int diff = device.mDebugLastLoggedDeviceInfo.diff(info);if (diff == DisplayDeviceInfo.DIFF_STATE) {
Slog.i(TAG, "Display device changed state: \"" + info.name+ "\", " + Display.stateToString(info.state));- /*- if (info.state == Display.STATE_OFF){ - mAudioManager.setStreamVolume(AudioManager.STREAM_RING, 0, AudioManager.FLAG_PLAY_SOUND);- mAudioManager.setStreamVolume(AudioManager.STREAM_ALARM, 0, AudioManager.FLAG_PLAY_SOUND);- mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_PLAY_SOUND);- }- */+ if (info.state == Display.STATE_OFF){
+ mAudioManager.setStreamVolume(AudioManager.STREAM_RING, 0, AudioManager.FLAG_PLAY_SOUND);+ mAudioManager.setStreamVolume(AudioManager.STREAM_ALARM, 0, AudioManager.FLAG_PLAY_SOUND);+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_PLAY_SOUND);+ }} else if (diff != 0) {
修改2:\frameworks\base\services\java\com\android\server\HookObserver.java
a、
private boolean flag = true;private WifiManager wifiManager;- AudioManager audioManager;+AudioManager mAudioManager;//private EthernetManager mEthManager;
b、
mCpuWakeLock.acquire(); */- audioManager =(AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);+mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); init(); // set initial status
c、
// if (mHookState != EXTRA_HOOK_STATE_INIT) {
update();Slog.v(TAG, "hook update"+ mHookState);// } -// mAudioManager.setStreamVolume(AudioManager.STREAM_RING, 0, AudioManager.FLAG_PLAY_SOUND);-// mAudioManager.setStreamVolume(AudioManager.STREAM_ALARM, 0, AudioManager.FLAG_PLAY_SOUND);-// mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_PLAY_SOUND);+ mAudioManager.setStreamVolume(AudioManager.STREAM_RING, 0, AudioManager.FLAG_PLAY_SOUND);+ mAudioManager.setStreamVolume(AudioManager.STREAM_ALARM, 0, AudioManager.FLAG_PLAY_SOUND);+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_PLAY_SOUND);}else if(action.equals(SHUTDOWN_ACTION)){