Merge "EMBMS test app" am: 3d8fcd7f1a am: b24d2f0d85
am: ae3a284bc2
Change-Id: Ib9bddfde5a2577e62a98ec0aa98e15a79548c7a4
diff --git a/testapps/Android.mk b/testapps/Android.mk
new file mode 100644
index 0000000..5053e7d
--- /dev/null
+++ b/testapps/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/testapps/EmbmsServiceTestApp/Android.mk b/testapps/EmbmsServiceTestApp/Android.mk
new file mode 100644
index 0000000..4dc522c
--- /dev/null
+++ b/testapps/EmbmsServiceTestApp/Android.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Build the Sample Embms Services
+include $(CLEAR_VARS)
+
+src_dirs := src
+res_dirs := res
+
+LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs))
+LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs))
+
+LOCAL_PACKAGE_NAME := EmbmsTestService
+
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVILEGED_MODULE := true
+# Change the following to "debug" to build the EmbmsTestService into the userdebug build.
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_PACKAGE)
diff --git a/testapps/EmbmsServiceTestApp/AndroidManifest.xml b/testapps/EmbmsServiceTestApp/AndroidManifest.xml
new file mode 100644
index 0000000..3adab28
--- /dev/null
+++ b/testapps/EmbmsServiceTestApp/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ package="com.android.phone.testapps.embmsmw"
+ coreApp="true">
+ <application android:label="EmbmsTestMiddleware">
+ <service android:name="com.android.phone.testapps.embmsmw.EmbmsTestStreamingService"
+ android:launchMode="singleInstance"
+ androidprv:systemUserOnly="true">
+ <intent-filter>
+ <action android:name="android.telephony.action.EmbmsStreaming" />
+ </intent-filter>
+ </service>
+ </application>
+</manifest>
+
diff --git a/testapps/EmbmsServiceTestApp/res/values/donottranslate_strings.xml b/testapps/EmbmsServiceTestApp/res/values/donottranslate_strings.xml
new file mode 100644
index 0000000..d33abb0
--- /dev/null
+++ b/testapps/EmbmsServiceTestApp/res/values/donottranslate_strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<resources>
+</resources>
diff --git a/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/EmbmsTestStreamingService.java b/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/EmbmsTestStreamingService.java
new file mode 100644
index 0000000..c0e601f
--- /dev/null
+++ b/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/EmbmsTestStreamingService.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.testapps.embmsmw;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.telephony.mbms.IMbmsStreamingManagerCallback;
+import android.telephony.mbms.MbmsException;
+import android.telephony.mbms.vendor.IMbmsStreamingService;
+import android.telephony.mbms.vendor.MbmsStreamingServiceBase;
+import android.util.Log;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class EmbmsTestStreamingService extends Service {
+ private final static String TAG = "EmbmsTestStreaming";
+ private final Map<String, IMbmsStreamingManagerCallback> mAppCallbacks = new HashMap<>();
+
+ private final IMbmsStreamingService.Stub mBinder = new MbmsStreamingServiceBase() {
+ @Override
+ public int initialize(IMbmsStreamingManagerCallback listener, String appName, int subId)
+ throws MbmsException {
+ String appKey = appName + subId;
+ if (!mAppCallbacks.containsKey(appKey)) {
+ mAppCallbacks.put(appKey, listener);
+ } else {
+ return MbmsException.ERROR_ALREADY_INITIALIZED;
+ }
+ return 0;
+ }
+ };
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ logd("EmbmsTestStreamingService onCreate");
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onCreate();
+ logd("EmbmsTestStreamingService onDestroy");
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mBinder;
+ }
+
+ private static void logd(String s) {
+ Log.d(TAG, s);
+ }
+}
diff --git a/testapps/EmbmsTestStreamingApp/Android.mk b/testapps/EmbmsTestStreamingApp/Android.mk
new file mode 100644
index 0000000..2700522
--- /dev/null
+++ b/testapps/EmbmsTestStreamingApp/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Build the Sample Embms Streaming frontend
+include $(CLEAR_VARS)
+
+src_dirs := src
+res_dirs := res
+
+LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs))
+LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs))
+
+LOCAL_PACKAGE_NAME := EmbmsTestStreamingApp
+
+LOCAL_CERTIFICATE := platform
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_PACKAGE)
diff --git a/testapps/EmbmsTestStreamingApp/AndroidManifest.xml b/testapps/EmbmsTestStreamingApp/AndroidManifest.xml
new file mode 100644
index 0000000..d13425d
--- /dev/null
+++ b/testapps/EmbmsTestStreamingApp/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.phone.testapps.embmsfrontend">
+ <application android:label="EmbmsTestStreamingApp">
+ <activity
+ android:name=".EmbmsTestStreamingApp"
+ android:label="EmbmsStreamingFrontend">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/testapps/EmbmsTestStreamingApp/res/layout/activity_main.xml b/testapps/EmbmsTestStreamingApp/res/layout/activity_main.xml
new file mode 100644
index 0000000..866e127
--- /dev/null
+++ b/testapps/EmbmsTestStreamingApp/res/layout/activity_main.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+ <Button
+ android:id="@+id/bind_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bind_button" />
+</LinearLayout>
diff --git a/testapps/EmbmsTestStreamingApp/res/values/donottranslate_strings.xml b/testapps/EmbmsTestStreamingApp/res/values/donottranslate_strings.xml
new file mode 100644
index 0000000..71808fa
--- /dev/null
+++ b/testapps/EmbmsTestStreamingApp/res/values/donottranslate_strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<resources>
+ <string name="bind_button">Bind to service</string>
+</resources>
\ No newline at end of file
diff --git a/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/EmbmsTestStreamingApp.java b/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/EmbmsTestStreamingApp.java
new file mode 100644
index 0000000..ed4fb6b
--- /dev/null
+++ b/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/EmbmsTestStreamingApp.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.testapps.embmsfrontend;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.telephony.MbmsStreamingManager;
+import android.telephony.mbms.MbmsException;
+import android.telephony.mbms.MbmsStreamingManagerCallback;
+import android.widget.Button;
+import android.widget.Toast;
+
+public class EmbmsTestStreamingApp extends Activity {
+ private MbmsStreamingManagerCallback mStreamingListener = new MbmsStreamingManagerCallback() {};
+ private MbmsStreamingManager mStreamingManager;
+
+ private Handler mHandler;
+ private HandlerThread mHandlerThread;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ mHandlerThread = new HandlerThread("EmbmsSampleFrontendWorker");
+ mHandlerThread.start();
+ mHandler = new Handler(mHandlerThread.getLooper());
+
+ Button bindButton = (Button) findViewById(R.id.bind_button);
+ bindButton.setOnClickListener((view) ->
+ mHandler.post(() -> {
+ try {
+ mStreamingManager = MbmsStreamingManager.create(
+ EmbmsTestStreamingApp.this, mStreamingListener, getPackageName());
+ } catch (MbmsException e) {
+ EmbmsTestStreamingApp.this.runOnUiThread(() ->
+ Toast.makeText(EmbmsTestStreamingApp.this,
+ "Init error: " + e.getErrorCode(), Toast.LENGTH_SHORT).show());
+ return;
+ }
+ EmbmsTestStreamingApp.this.runOnUiThread(() ->
+ Toast.makeText(EmbmsTestStreamingApp.this, "Successfully bound",
+ Toast.LENGTH_SHORT).show());
+ })
+ );
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mHandlerThread.quit();
+ }
+}