resolve merge conflicts of 3ed74f4b6 to stage-aosp-master
Amit Mahajan [Fri, 24 Mar 2017 22:55:21 +0000 (15:55 -0700)]
Test: I solemnly swear I tested this conflict resolution.
Change-Id: Id6c90fa0f3b8821ac3e786ebc22e7aa5ac22cfad

1  2 
src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java

@@@ -100,7 -100,15 +100,7 @@@ public class ImsPhoneConnection extend
       */
      private boolean mShouldIgnoreVideoStateChanges = false;
  
 -    /**
 -     * Used to indicate whether the wifi state is based on
 -     * {@link com.android.ims.ImsConnectionStateListener#
 -     *      onFeatureCapabilityChanged(int, int[], int[])} callbacks, or values received via the
 -     * {@link ImsCallProfile#EXTRA_CALL_RAT_TYPE} extra.  Util we receive a value via the extras,
 -     * we will use the wifi state based on the {@code onFeatureCapabilityChanged}.  Once a value
 -     * is received via the extras, we will prefer those values going forward.
 -     */
 -    private boolean mIsWifiStateFromExtras = false;
 +    private ImsVideoCallProviderWrapper mImsVideoCallProviderWrapper;
  
      private int mPreciseDisconnectCause = 0;
  
          mCreateTime = System.currentTimeMillis();
          mUusInfo = null;
  
 -        updateWifiState();
 -
          // Ensure any extras set on the ImsCallProfile at the start of the call are cached locally
          // in the ImsPhoneConnection.  This isn't going to inform any listeners (since the original
          // connection is not likely to be associated with a TelephonyConnection yet).
  
      void
      releaseWakeLock() {
-         synchronized(mPartialWakeLock) {
-             if (mPartialWakeLock.isHeld()) {
-                 Rlog.d(LOG_TAG, "releaseWakeLock");
-                 mPartialWakeLock.release();
+         if (mPartialWakeLock != null) {
+             synchronized (mPartialWakeLock) {
+                 if (mPartialWakeLock.isHeld()) {
+                     Rlog.d(LOG_TAG, "releaseWakeLock");
+                     mPartialWakeLock.release();
+                 }
              }
          }
      }
          }
  
          boolean updateParent = mParent.update(this, imsCall, state);
 -        boolean updateWifiState = updateWifiState();
          boolean updateAddressDisplay = updateAddressDisplay(imsCall);
          boolean updateMediaCapabilities = updateMediaCapabilities(imsCall);
          boolean updateExtras = updateExtras(imsCall);
  
 -        return updateParent || updateWifiState || updateAddressDisplay || updateMediaCapabilities
 -                || updateExtras;
 +        return updateParent || updateAddressDisplay || updateMediaCapabilities || updateExtras;
      }
  
      @Override
      }
  
      /**
 -     * Check for a change in the wifi state of the ImsPhoneCallTracker and update the
 -     * {@link ImsPhoneConnection} with this information.
 -     *
 -     * @return Whether the ImsPhoneCallTracker's usage of wifi has been changed.
 -     */
 -    public boolean updateWifiState() {
 -        // If we've received the wifi state via the ImsCallProfile.EXTRA_CALL_RAT_TYPE extra, we
 -        // will no longer use state updates which are based on the onFeatureCapabilityChanged
 -        // callback.
 -        if (mIsWifiStateFromExtras) {
 -            return false;
 -        }
 -
 -        Rlog.d(LOG_TAG, "updateWifiState: " + mOwner.isVowifiEnabled());
 -        if (isWifi() != mOwner.isVowifiEnabled()) {
 -            setWifi(mOwner.isVowifiEnabled());
 -            return true;
 -        }
 -        return false;
 -    }
 -
 -    /**
       * Updates the wifi state based on the {@link ImsCallProfile#EXTRA_CALL_RAT_TYPE}.
       * The call is considered to be a WIFI call if the extra value is
       * {@link ServiceState#RIL_RADIO_TECHNOLOGY_IWLAN}.
          if (extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE) ||
                  extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT)) {
  
 -            // We've received the extra indicating the radio technology, so we will continue to
 -            // prefer the radio technology received via this extra going forward.
 -            mIsWifiStateFromExtras = true;
 -
              ImsCall call = getImsCall();
              boolean isWifi = false;
              if (call != null) {
          return sb.toString();
      }
  
 +    @Override
 +    public void setVideoProvider(android.telecom.Connection.VideoProvider videoProvider) {
 +        super.setVideoProvider(videoProvider);
 +
 +        if (videoProvider instanceof ImsVideoCallProviderWrapper) {
 +            mImsVideoCallProviderWrapper = (ImsVideoCallProviderWrapper) videoProvider;
 +        }
 +    }
 +
      /**
       * Indicates whether current phone connection is emergency or not
       * @return boolean: true if emergency, false otherwise
              setVideoState(currentVideoState);
          }
      }
 +
 +    /**
 +     * Issues a request to pause the video using {@link VideoProfile#STATE_PAUSED} from a source
 +     * other than the InCall UI.
 +     *
 +     * @param source The source of the pause request.
 +     */
 +    public void pauseVideo(int source) {
 +        if (mImsVideoCallProviderWrapper == null) {
 +            return;
 +        }
 +
 +        mImsVideoCallProviderWrapper.pauseVideo(getVideoState(), source);
 +    }
 +
 +    /**
 +     * Issues a request to resume the video using {@link VideoProfile#STATE_PAUSED} from a source
 +     * other than the InCall UI.
 +     *
 +     * @param source The source of the resume request.
 +     */
 +    public void resumeVideo(int source) {
 +        if (mImsVideoCallProviderWrapper == null) {
 +            return;
 +        }
 +
 +        mImsVideoCallProviderWrapper.resumeVideo(getVideoState(), source);
 +    }
 +
 +    /**
 +     * Determines if a specified source has issued a pause request.
 +     *
 +     * @param source The source.
 +     * @return {@code true} if the source issued a pause request, {@code false} otherwise.
 +     */
 +    public boolean wasVideoPausedFromSource(int source) {
 +        if (mImsVideoCallProviderWrapper == null) {
 +            return false;
 +        }
 +
 +        return mImsVideoCallProviderWrapper.wasVideoPausedFromSource(source);
 +    }
  }
@@@ -19,8 -19,7 +19,7 @@@ package com.android.internal.telephony
  import static org.junit.Assert.fail;
  import static org.mockito.Matchers.anyBoolean;
  import static org.mockito.Matchers.anyLong;
- import static org.mockito.Matchers.anyString;
- import static org.mockito.Mockito.any;
+ import static org.mockito.Matchers.nullable;
  import static org.mockito.Mockito.anyInt;
  import static org.mockito.Mockito.doAnswer;
  import static org.mockito.Mockito.doReturn;
@@@ -318,42 -317,45 +317,45 @@@ public abstract class TelephonyTest 
  
          //mTelephonyComponentFactory
          doReturn(mSST).when(mTelephonyComponentFactory)
-                 .makeServiceStateTracker(any(GsmCdmaPhone.class), any(CommandsInterface.class));
+                 .makeServiceStateTracker(nullable(GsmCdmaPhone.class),
+                         nullable(CommandsInterface.class));
          doReturn(mIccCardProxy).when(mTelephonyComponentFactory)
-                 .makeIccCardProxy(any(Context.class), any(CommandsInterface.class), anyInt());
+                 .makeIccCardProxy(nullable(Context.class), nullable(CommandsInterface.class),
+                         anyInt());
          doReturn(mCT).when(mTelephonyComponentFactory)
-                 .makeGsmCdmaCallTracker(any(GsmCdmaPhone.class));
+                 .makeGsmCdmaCallTracker(nullable(GsmCdmaPhone.class));
          doReturn(mIccPhoneBookIntManager).when(mTelephonyComponentFactory)
-                 .makeIccPhoneBookInterfaceManager(any(Phone.class));
+                 .makeIccPhoneBookInterfaceManager(nullable(Phone.class));
          doReturn(mDcTracker).when(mTelephonyComponentFactory)
-                 .makeDcTracker(any(Phone.class));
+                 .makeDcTracker(nullable(Phone.class));
          doReturn(mWspTypeDecoder).when(mTelephonyComponentFactory)
-                 .makeWspTypeDecoder(any(byte[].class));
+                 .makeWspTypeDecoder(nullable(byte[].class));
          doReturn(mInboundSmsTracker).when(mTelephonyComponentFactory)
-                 .makeInboundSmsTracker(any(byte[].class), anyLong(), anyInt(), anyBoolean(),
-                         anyBoolean(), anyString(), anyString(), anyString());
+                 .makeInboundSmsTracker(nullable(byte[].class), anyLong(), anyInt(), anyBoolean(),
+                         anyBoolean(), nullable(String.class), nullable(String.class),
+                         nullable(String.class));
          doReturn(mInboundSmsTracker).when(mTelephonyComponentFactory)
-                 .makeInboundSmsTracker(any(byte[].class), anyLong(), anyInt(), anyBoolean(),
-                         anyString(), anyString(), anyInt(), anyInt(), anyInt(), anyBoolean(),
-                         anyString());
+                 .makeInboundSmsTracker(nullable(byte[].class), anyLong(), anyInt(), anyBoolean(),
+                         nullable(String.class), nullable(String.class), anyInt(), anyInt(),
+                         anyInt(), anyBoolean(), nullable(String.class));
          doReturn(mInboundSmsTracker).when(mTelephonyComponentFactory)
-                 .makeInboundSmsTracker(any(Cursor.class), anyBoolean());
+                 .makeInboundSmsTracker(nullable(Cursor.class), anyBoolean());
          doReturn(mImsCT).when(mTelephonyComponentFactory)
-                 .makeImsPhoneCallTracker(any(ImsPhone.class));
+                 .makeImsPhoneCallTracker(nullable(ImsPhone.class));
          doReturn(mCdmaSSM).when(mTelephonyComponentFactory)
-                 .getCdmaSubscriptionSourceManagerInstance(any(Context.class),
-                         any(CommandsInterface.class), any(Handler.class),
-                         anyInt(), any(Object.class));
+                 .getCdmaSubscriptionSourceManagerInstance(nullable(Context.class),
+                         nullable(CommandsInterface.class), nullable(Handler.class),
+                         anyInt(), nullable(Object.class));
          doReturn(mIDeviceIdleController).when(mTelephonyComponentFactory)
                  .getIDeviceIdleController();
          doReturn(mImsExternalCallTracker).when(mTelephonyComponentFactory)
-                 .makeImsExternalCallTracker(any(ImsPhone.class));
+                 .makeImsExternalCallTracker(nullable(ImsPhone.class));
          doReturn(mCarrierSignalAgent).when(mTelephonyComponentFactory)
-                 .makeCarrierActionAgent(any(Phone.class));
 -                .makeCarrierSignalAgent(nullable(Phone.class));
++                .makeCarrierActionAgent(nullable(Phone.class));
          doReturn(mCarrierActionAgent).when(mTelephonyComponentFactory)
-                 .makeCarrierActionAgent(any(Phone.class));
+                 .makeCarrierActionAgent(nullable(Phone.class));
          doReturn(mDeviceStateMonitor).when(mTelephonyComponentFactory)
-                 .makeDeviceStateMonitor(any(Phone.class));
+                 .makeDeviceStateMonitor(nullable(Phone.class));
  
          //mPhone
          doReturn(mContext).when(mPhone).getContext();
  
          //SMS
          doReturn(true).when(mSmsStorageMonitor).isStorageAvailable();
-         doReturn(true).when(mSmsUsageMonitor).check(anyString(), anyInt());
+         doReturn(true).when(mSmsUsageMonitor).check(nullable(String.class), anyInt());
          doReturn(true).when(mTelephonyManager).getSmsReceiveCapableForPhone(anyInt(), anyBoolean());
          doReturn(true).when(mTelephonyManager).getSmsSendCapableForPhone(
                  anyInt(), anyBoolean());
          doReturn(mImsCallProfile).when(mImsCall).getCallProfile();
          doReturn(mIBinder).when(mIIntentSender).asBinder();
          doReturn(mIIntentSender).when(mIActivityManager).getIntentSender(anyInt(),
-                 anyString(), any(IBinder.class), anyString(), anyInt(), any(Intent[].class),
-                 any(String[].class), anyInt(), any(Bundle.class), anyInt());
+                 nullable(String.class), nullable(IBinder.class), nullable(String.class), anyInt(),
+                 nullable(Intent[].class), nullable(String[].class), anyInt(),
+                 nullable(Bundle.class), anyInt());
          mSST.mSS = mServiceState;
          mServiceManagerMockedServices.put("connectivity_metrics_logger", mConnMetLoggerBinder);