OSDN Git Service

resolved conflicts for merge of 42f55d1e to master
authorMarco Nelissen <marcone@google.com>
Thu, 12 Mar 2015 23:17:45 +0000 (16:17 -0700)
committerMarco Nelissen <marcone@google.com>
Thu, 12 Mar 2015 23:17:45 +0000 (16:17 -0700)
Change-Id: I9c26861c5b0e26bb55e50b2133b7561348a01aec

1  2 
core/java/android/widget/VideoView.java
media/java/android/media/AudioManager.java

@@@ -56,10 -58,12 +56,10 @@@ import java.util.Iterator
   */
  public class AudioManager {
  
-     private final Context mContext;
+     private final Context mApplicationContext;
      private long mVolumeKeyUpTime;
 -    private final boolean mUseMasterVolume;
      private final boolean mUseVolumeKeySounds;
      private final boolean mUseFixedVolume;
 -    private final Binder mToken = new Binder();
      private static String TAG = "AudioManager";
      private static final AudioPortEventHandler sAudioPortEventHandler = new AudioPortEventHandler();
  
       * @hide
       */
      public AudioManager(Context context) {
-         mContext = context;
-         mUseVolumeKeySounds = mContext.getResources().getBoolean(
 -        mApplicationContext = context.getApplicationContext();
 -        mUseMasterVolume = mApplicationContext.getResources().getBoolean(
 -                com.android.internal.R.bool.config_useMasterVolume);
++        mApplicationContext = context;
+         mUseVolumeKeySounds = mApplicationContext.getResources().getBoolean(
                  com.android.internal.R.bool.config_useVolumeKeySounds);
-         mUseFixedVolume = mContext.getResources().getBoolean(
+         mUseFixedVolume = mApplicationContext.getResources().getBoolean(
                  com.android.internal.R.bool.config_useFixedVolume);
          sAudioPortEventHandler.init();
      }
      public void adjustStreamVolume(int streamType, int direction, int flags) {
          IAudioService service = getService();
          try {
 -            if (mUseMasterVolume) {
 -                service.adjustMasterVolume(direction, flags,
 -                        mApplicationContext.getOpPackageName());
 -            } else {
 -                service.adjustStreamVolume(streamType, direction, flags,
 -                        mApplicationContext.getOpPackageName());
 -            }
 +            service.adjustStreamVolume(streamType, direction, flags,
-                     mContext.getOpPackageName());
++                    mApplicationContext.getOpPackageName());
          } catch (RemoteException e) {
              Log.e(TAG, "Dead object in adjustStreamVolume", e);
          }
       * @see #isVolumeFixed()
       */
      public void adjustVolume(int direction, int flags) {
-         MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext);
 -        IAudioService service = getService();
 -        try {
 -            if (mUseMasterVolume) {
 -                service.adjustMasterVolume(direction, flags,
 -                        mApplicationContext.getOpPackageName());
 -            } else {
 -                MediaSessionLegacyHelper helper =
 -                        MediaSessionLegacyHelper.getHelper(mApplicationContext);
 -                helper.sendAdjustVolumeBy(USE_DEFAULT_STREAM_TYPE, direction, flags);
 -            }
 -        } catch (RemoteException e) {
 -            Log.e(TAG, "Dead object in adjustVolume", e);
 -        }
++        MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mApplicationContext);
 +        helper.sendAdjustVolumeBy(USE_DEFAULT_STREAM_TYPE, direction, flags);
      }
  
      /**
       * @see #isVolumeFixed()
       */
      public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) {
-         MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext);
 -        IAudioService service = getService();
 -        try {
 -            if (mUseMasterVolume) {
 -                service.adjustMasterVolume(direction, flags,
 -                        mApplicationContext.getOpPackageName());
 -            } else {
 -                MediaSessionLegacyHelper helper =
 -                        MediaSessionLegacyHelper.getHelper(mApplicationContext);
 -                helper.sendAdjustVolumeBy(suggestedStreamType, direction, flags);
 -            }
 -        } catch (RemoteException e) {
 -            Log.e(TAG, "Dead object in adjustSuggestedStreamVolume", e);
 -        }
++        MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mApplicationContext);
 +        helper.sendAdjustVolumeBy(suggestedStreamType, direction, flags);
      }
  
 -    /**
 -     * Adjusts the master volume for the device's audio amplifier.
 -     * <p>
 -     *
 -     * @param steps The number of volume steps to adjust. A positive
 -     *            value will raise the volume.
 -     * @param flags One or more flags.
 -     * @hide
 -     */
 -    public void adjustMasterVolume(int steps, int flags) {
 +    /** @hide */
 +    public void setMasterMute(boolean mute, int flags) {
          IAudioService service = getService();
          try {
-             service.setMasterMute(mute, flags, mContext.getOpPackageName());
 -            service.adjustMasterVolume(steps, flags, mApplicationContext.getOpPackageName());
++            service.setMasterMute(mute, flags, mApplicationContext.getOpPackageName());
          } catch (RemoteException e) {
 -            Log.e(TAG, "Dead object in adjustMasterVolume", e);
 +            Log.e(TAG, "Dead object in setMasterMute", e);
          }
      }
  
      public void setStreamVolume(int streamType, int index, int flags) {
          IAudioService service = getService();
          try {
-             service.setStreamVolume(streamType, index, flags, mContext.getOpPackageName());
 -            if (mUseMasterVolume) {
 -                service.setMasterVolume(index, flags, mApplicationContext.getOpPackageName());
 -            } else {
 -                service.setStreamVolume(streamType, index, flags,
 -                        mApplicationContext.getOpPackageName());
 -            }
++            service.setStreamVolume(streamType, index, flags, mApplicationContext.getOpPackageName());
          } catch (RemoteException e) {
              Log.e(TAG, "Dead object in setStreamVolume", e);
          }
      public void setMode(int mode) {
          IAudioService service = getService();
          try {
-             service.setMode(mode, mICallBack, mContext.getOpPackageName());
 -            service.setMode(mode, mICallBack);
++            service.setMode(mode, mICallBack, mApplicationContext.getOpPackageName());
          } catch (RemoteException e) {
              Log.e(TAG, "Dead object in setMode", e);
          }
              service.requestAudioFocus(new AudioAttributes.Builder()
                          .setInternalLegacyStreamType(streamType).build(),
                      durationHint, mICallBack, null,
 -                    MediaFocusControl.IN_VOICE_COMM_FOCUS_ID,
 +                    AudioSystem.IN_VOICE_COMM_FOCUS_ID,
-                     mContext.getOpPackageName(),
+                     mApplicationContext.getOpPackageName(),
                      AUDIOFOCUS_FLAG_LOCK,
                      null /* policy token */);
          } catch (RemoteException e) {
       * @param name   device name
       * {@hide}
       */
 -    public void setWiredDeviceConnectionState(int device, int state, String name) {
 +    public void setWiredDeviceConnectionState(int type, int state, String address, String name) {
          IAudioService service = getService();
          try {
 -            service.setWiredDeviceConnectionState(device, state, name);
 +            service.setWiredDeviceConnectionState(type, state, address, name,
-                     mContext.getOpPackageName());
++                    mApplicationContext.getOpPackageName());
          } catch (RemoteException e) {
              Log.e(TAG, "Dead object in setWiredDeviceConnectionState "+e);
          }
       * Only useful for volume controllers.
       * @hide
       */
 +    public boolean isStreamAffectedByMute(int streamType) {
 +        try {
 +            return getService().isStreamAffectedByMute(streamType);
 +        } catch (RemoteException e) {
 +            Log.w(TAG, "Error calling isStreamAffectedByMute", e);
 +            return false;
 +        }
 +    }
 +
 +    /**
 +     * Only useful for volume controllers.
 +     * @hide
 +     */
      public void disableSafeMediaVolume() {
          try {
-             getService().disableSafeMediaVolume(mContext.getOpPackageName());
 -            getService().disableSafeMediaVolume();
++            getService().disableSafeMediaVolume(mApplicationContext.getOpPackageName());
          } catch (RemoteException e) {
              Log.w(TAG, "Error disabling safe media volume", e);
          }