当前位置: 代码迷 >> 综合 >> Android8.1开机后铃声,闹铃,媒体的声音设置为0,休眠后声音也为0
  详细解决方案

Android8.1开机后铃声,闹铃,媒体的声音设置为0,休眠后声音也为0

热度:11   发布时间:2023-12-15 14:06:11.0

修改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)){
    
  相关解决方案