Add ability to send video upgrade requests using TestVideoProvider

Bug: 20090411
Change-Id: I5db96fd41efc3baee0d80c73988cc0d6fba23b37
diff --git a/testapps/AndroidManifest.xml b/testapps/AndroidManifest.xml
index 728c64a..1b296d4 100644
--- a/testapps/AndroidManifest.xml
+++ b/testapps/AndroidManifest.xml
@@ -70,6 +70,11 @@
                 <action android:name="android.telecom.testapps.ACTION_HANGUP_CALLS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
+            <intent-filter>
+                <action android:name="android.telecom.testapps.ACTION_SEND_UPGRADE_REQUEST" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="int" />
+            </intent-filter>
         </activity>
 
         <receiver android:name="com.android.server.telecom.testapps.CallNotificationReceiver"
diff --git a/testapps/src/com/android/server/telecom/testapps/CallNotificationReceiver.java b/testapps/src/com/android/server/telecom/testapps/CallNotificationReceiver.java
index 0589a8e..36a3493 100644
--- a/testapps/src/com/android/server/telecom/testapps/CallNotificationReceiver.java
+++ b/testapps/src/com/android/server/telecom/testapps/CallNotificationReceiver.java
@@ -112,4 +112,11 @@
         LocalBroadcastManager.getInstance(context).sendBroadcast(
                 new Intent(TestCallActivity.ACTION_HANGUP_CALLS));
     }
+
+    public static void sendUpgradeRequest(Context context, Uri data) {
+        Log.i(TAG, "Sending upgrade request of type: " + data);
+        final Intent intent = new Intent(TestCallActivity.ACTION_SEND_UPGRADE_REQUEST);
+        intent.setData(data);
+        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
+    }
 }
diff --git a/testapps/src/com/android/server/telecom/testapps/TestCallActivity.java b/testapps/src/com/android/server/telecom/testapps/TestCallActivity.java
index 38d2565..4ac151f 100644
--- a/testapps/src/com/android/server/telecom/testapps/TestCallActivity.java
+++ b/testapps/src/com/android/server/telecom/testapps/TestCallActivity.java
@@ -48,6 +48,9 @@
     public static final String ACTION_HANGUP_CALLS =
             "android.telecom.testapps.ACTION_HANGUP_CALLS";
 
+    public static final String ACTION_SEND_UPGRADE_REQUEST =
+            "android.telecom.testapps.ACTION_SEND_UPGRADE_REQUEST";
+
     @Override
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -60,6 +63,8 @@
             CallNotificationReceiver.addNewUnknownCall(this, data, intent.getExtras());
         } else if (ACTION_HANGUP_CALLS.equals(action)) {
             CallNotificationReceiver.hangupCalls(this);
+        } else if (ACTION_SEND_UPGRADE_REQUEST.equals(action)) {
+            CallNotificationReceiver.sendUpgradeRequest(this, data);
         } else {
             CallServiceNotifier.getInstance().updateNotification(this);
         }
diff --git a/testapps/src/com/android/server/telecom/testapps/TestConnectionService.java b/testapps/src/com/android/server/telecom/testapps/TestConnectionService.java
index b380e78..23df055 100644
--- a/testapps/src/com/android/server/telecom/testapps/TestConnectionService.java
+++ b/testapps/src/com/android/server/telecom/testapps/TestConnectionService.java
@@ -144,6 +144,15 @@
             }
         };
 
+        private BroadcastReceiver mUpgradeRequestReceiver = new BroadcastReceiver() {
+            @Override
+            public void onReceive(Context context, Intent intent) {
+                final int request = Integer.parseInt(intent.getData().getSchemeSpecificPart());
+                final VideoProfile videoProfile = new VideoProfile(request);
+                mTestVideoCallProvider.receiveSessionModifyRequest(videoProfile);
+            }
+        };
+
         TestConnection(boolean isIncoming) {
             mIsIncoming = isIncoming;
             // Assume all calls are video capable.
@@ -158,6 +167,11 @@
 
             LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(
                     mHangupReceiver, new IntentFilter(TestCallActivity.ACTION_HANGUP_CALLS));
+            final IntentFilter filter =
+                    new IntentFilter(TestCallActivity.ACTION_SEND_UPGRADE_REQUEST);
+            filter.addDataScheme("int");
+            LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(
+                    mUpgradeRequestReceiver, filter);
         }
 
         void startOutgoing() {
@@ -238,6 +252,8 @@
         public void cleanup() {
             LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(
                     mHangupReceiver);
+            LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(
+                    mUpgradeRequestReceiver);
         }
 
         /**