implemented 1st draft of service mock

This commit is contained in:
florian.bramer 2015-06-15 15:56:31 +02:00
parent c1370910a4
commit 6f473ff4c7
3 changed files with 57 additions and 4 deletions

View file

@ -1,9 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.esrlabs.headunitservicemock">
<application android:allowBackup="true" android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:theme="@style/AppTheme">
package="com.esrlabs.headunitservicemock" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service
android:name=".HeadUnitService"
android:enabled="true"
android:exported="true" >
</service>
</application>
</manifest>

View file

@ -0,0 +1,45 @@
package com.esrlabs.headunitservicemock;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import com.esrlabs.headunitinterface.HeadUnit;
/**
* A test implementation of the HeadUnit interface
*
* Provides a way to run against the interface without the presence of a real headunit
*
* Will use the Android UI instead
*/
public class HeadUnitService extends Service {
public HeadUnitService() {
}
@Override
public IBinder onBind(Intent intent) {
return binder;
}
private final HeadUnit.Stub binder = new HeadUnit.Stub() {
@Override
public void showNotification(String text) throws RemoteException {
Notification.Builder builder = new Notification.Builder(getBaseContext()).setContentText(text).setSmallIcon(R.drawable.tum_logo);
notificationService().notify(0,builder.build());
}
@Override
public void hideAllNotifications() throws RemoteException {
notificationService().cancelAll();
}
};
private NotificationManager notificationService() {
return (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB