在以下位置做如下注释掉其中一部分即可(最后面几行):

frameworks / base/services/core/java/com/android/server/audio/AudioService.java

private void adjustStreamVolume(int streamType, int direction, int flags,            String callingPackage, String caller, int uid) {        if (mUseFixedVolume) {            return;        }        if (DEBUG_VOL) Log.d(TAG, "adjustStreamVolume() stream=" + streamType + ", dir=" + direction                + ", flags=" + flags + ", caller=" + caller);        ensureValidDirection(direction);        ensureValidStreamType(streamType);        boolean isMuteAdjust = isMuteAdjust(direction);        if (isMuteAdjust && !isStreamAffectedByMute(streamType)) {            return;        }        // use stream type alias here so that streams with same alias have the same behavior,        // including with regard to silent mode control (e.g the use of STREAM_RING below and in        // checkForRingerModeChange() in place of STREAM_RING or STREAM_NOTIFICATION)        int streamTypeAlias = mStreamVolumeAlias[streamType];        VolumeStreamState streamState = mStreamStates[streamTypeAlias];        final int device = getDeviceForStream(streamTypeAlias);        int aliasIndex = streamState.getIndex(device);        boolean adjustVolume = true;        int step;        // skip a2dp absolute volume control request when the device        // is not an a2dp device        if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) == 0 &&            (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) != 0) {            return;        }        // If we are being called by the system (e.g. hardware keys) check for current user        // so we handle user restrictions correctly.        if (uid == android.os.Process.SYSTEM_UID) {            uid = UserHandle.getUid(getCurrentUserId(), UserHandle.getAppId(uid));        }        if (mAppOps.noteOp(STREAM_VOLUME_OPS[streamTypeAlias], uid, callingPackage)                != AppOpsManager.MODE_ALLOWED) {            return;        }        // reset any pending volume command        synchronized (mSafeMediaVolumeState) {            mPendingVolumeCommand = null;        }        flags &= ~AudioManager.FLAG_FIXED_VOLUME;        if ((streamTypeAlias == AudioSystem.STREAM_MUSIC) &&               ((device & mFixedVolumeDevices) != 0)) {            flags |= AudioManager.FLAG_FIXED_VOLUME;            // Always toggle between max safe volume and 0 for fixed volume devices where safe            // volume is enforced, and max and 0 for the others.            // This is simulated by stepping by the full allowed volume range            if (mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_ACTIVE &&                    (device & mSafeMediaVolumeDevices) != 0) {                step = mSafeMediaVolumeIndex;            } else {                step = streamState.getMaxIndex();            }            if (aliasIndex != 0) {                aliasIndex = step;            }        } else {            // convert one UI step (+/-1) into a number of internal units on the stream alias            step = rescaleIndex(10, streamType, streamTypeAlias);        }        // If either the client forces allowing ringer modes for this adjustment,        // or the stream type is one that is affected by ringer modes        if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||                (streamTypeAlias == getUiSoundsStreamType())) {            int ringerMode = getRingerModeInternal();            // do not vibrate if already in vibrate mode            if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {                flags &= ~AudioManager.FLAG_VIBRATE;            }            // Check if the ringer mode handles this adjustment. If it does we don't            // need to adjust the volume further.            final int result = checkForRingerModeChange(aliasIndex, direction, step,                    streamState.mIsMuted, callingPackage, flags);            adjustVolume = (result & FLAG_ADJUST_VOLUME) != 0;            // If suppressing a volume adjustment in silent mode, display the UI hint            if ((result & AudioManager.FLAG_SHOW_SILENT_HINT) != 0) {                flags |= AudioManager.FLAG_SHOW_SILENT_HINT;            }            // If suppressing a volume down adjustment in vibrate mode, display the UI hint            if ((result & AudioManager.FLAG_SHOW_VIBRATE_HINT) != 0) {                flags |= AudioManager.FLAG_SHOW_VIBRATE_HINT;            }        }        // If the ringermode is suppressing media, prevent changes        if (!volumeAdjustmentAllowedByDnd(streamTypeAlias, flags)) {            adjustVolume = false;        }        int oldIndex = mStreamStates[streamType].getIndex(device);        if (adjustVolume && (direction != AudioManager.ADJUST_SAME)) {            mAudioHandler.removeMessages(MSG_UNMUTE_STREAM);            // Check if volume update should be send to AVRCP            if (streamTypeAlias == AudioSystem.STREAM_MUSIC &&                (device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 &&                (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {                synchronized (mA2dpAvrcpLock) {                    if (mA2dp != null && mAvrcpAbsVolSupported) {                        mA2dp.adjustAvrcpAbsoluteVolume(direction);                    }                }            }            if (isMuteAdjust) {                boolean state;                if (direction == AudioManager.ADJUST_TOGGLE_MUTE) {                    state = !streamState.mIsMuted;                } else {                    state = direction == AudioManager.ADJUST_MUTE;                }                if (streamTypeAlias == AudioSystem.STREAM_MUSIC) {                    setSystemAudioMute(state);                }                for (int stream = 0; stream < mStreamStates.length; stream++) {                    if (streamTypeAlias == mStreamVolumeAlias[stream]) {                        if (!(readCameraSoundForced()                                    && (mStreamStates[stream].getStreamType()                                        == AudioSystem.STREAM_SYSTEM_ENFORCED))) {                            mStreamStates[stream].mute(state);                        }                    }                }            } else if ((direction == AudioManager.ADJUST_RAISE) &&                    !checkSafeMediaVolume(streamTypeAlias, aliasIndex + step, device)) {                Log.e(TAG, "adjustStreamVolume() safe volume index = " + oldIndex);                mVolumeController.postDisplaySafeVolumeWarning(flags);            } else if (streamState.adjustIndex(direction * step, device, caller)                    || streamState.mIsMuted) {                // Post message to set system volume (it in turn will post a                // message to persist).                if (streamState.mIsMuted) {                    // Unmute the stream if it was previously muted                    if (direction == AudioManager.ADJUST_RAISE) {                        // unmute immediately for volume up                        streamState.mute(false);                          mStreamStates[1].mute(false);                    }                     else if (direction == AudioManager.ADJUST_LOWER) {  **//注释掉这个条件中的代码即可**                        if (mIsSingleVolume) {                            sendMsg(mAudioHandler, MSG_UNMUTE_STREAM, SENDMSG_QUEUE,                                    streamTypeAlias, flags, null, UNMUTE_STREAM_DELAY);                        }                    }                }                sendMsg(mAudioHandler,                        MSG_SET_DEVICE_VOLUME,                        SENDMSG_QUEUE,                        device,                        0,                        streamState,                        0);            }

更多相关文章

  1. android 当系统存在多个Launcher时,如何设置开机自动进入默认的La
  2. AndroidStudio使用ViewPagerIndicator
  3. Ubuntu上安装和使用Android(安卓)Studio
  4. 自定义SeekBar主题
  5. Android(安卓)启动时闪一下黑屏问题的解决办法
  6. Android(安卓)Studio更改SDK或者JDK路径
  7. android问题解答
  8. android 设置linelayout让按钮自动适应屏大小
  9. Android(安卓)fragment在xml中使用没添加ID

随机推荐

  1. PHP学习笔记(三):mysqli_fetch_row和mysqli_
  2. Mysql查询时,对于数值型字段加单引号会引
  3. mysqlbinlog 查看二进制日志
  4. SQL Server 执行计划操作符详解(1)——断言
  5. 在多个查询和子查询中更正连接语法
  6. SQL语句练习(1)
  7. Mysql order by语句未使用索引的思考
  8. 为什么我不能在此查询中进行任何类型的加
  9. 使用SQL使用从左到右和从右到左混合语言
  10. SQL Server 2005与SQL Server 2000相比性