Commit 127b0042 authored by Lily Tsai's avatar Lily Tsai

trying out foreground service stuff

parent 825cf046
...@@ -35,7 +35,7 @@ android { ...@@ -35,7 +35,7 @@ android {
commandLine './ndk-build-script.sh' commandLine './ndk-build-script.sh'
} }
//tasks.withType(JavaCompile) { //tasks.withType(JavaCompile) {
//compileTask -> compileTask.dependsOn buildNDK //compileTask -> compileTask.dependsOn buildNDK
//} //}
buildTypes { buildTypes {
debug { debug {
...@@ -54,6 +54,7 @@ dependencies { ...@@ -54,6 +54,7 @@ dependencies {
// need to put this here or else the class files from ebcutils aren't included in the aar deployed to bintray // need to put this here or else the class files from ebcutils aren't included in the aar deployed to bintray
//implementation fileTree(include: ['*.jar'], dir: '../ebcutils/build/libs') //implementation fileTree(include: ['*.jar'], dir: '../ebcutils/build/libs')
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:26.1.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
......
...@@ -12,25 +12,29 @@ ...@@ -12,25 +12,29 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature android:name="android.hardware.bluetooth_le" /> <uses-feature android:name="android.hardware.bluetooth_le" />
<uses-permission android:name="android.permission.VIBRATE" />
<application> <application>
<service android:name="org.mpisws.encounters.encounterformation.EncounterFormationService" /> <service android:name=".encounterformation.EncounterFormationService" />
<receiver android:name="org.mpisws.encounters.encounterhistory.events.EncounterEventReceiver" />
<receiver android:name=".encounterhistory.events.EncounterEventReceiver" />
<provider android:name="org.mpisws.encounters.encounterhistory.EncounterHistoryContentProvider" <provider
android:name=".encounterhistory.EncounterHistoryContentProvider"
android:authorities="org.mpisws.encounters.encounterhistory" android:authorities="org.mpisws.encounters.encounterhistory"
android:exported="true"
android:enabled="true" android:enabled="true"
android:exported="true"
android:readPermission="READPERM" android:readPermission="READPERM"
android:writePermission="WRITEPERM"/> android:writePermission="WRITEPERM" />
<provider
<provider android:name="org.mpisws.encounters.linkability.LinkabilityContentProvider" android:name=".linkability.LinkabilityContentProvider"
android:authorities="org.mpisws.encounters.linkability" android:authorities="org.mpisws.encounters.linkability"
android:exported="true"
android:enabled="true" android:enabled="true"
android:exported="true"
android:readPermission="READPERM" android:readPermission="READPERM"
android:writePermission="WRITEPERM"/> android:writePermission="WRITEPERM" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -43,7 +43,7 @@ import java.util.List; ...@@ -43,7 +43,7 @@ import java.util.List;
* *
**/ **/
public class EncounterBasedCommunication { public class EncounterBasedCommunication {
public static final long CHANGE_EPOCH_TIME = 2*60000; public static final long CHANGE_EPOCH_TIME = 15*60000;
public static final long SCAN_BATCH_INTERVAL = (long) (2 * 60000); public static final long SCAN_BATCH_INTERVAL = (long) (2 * 60000);
public static final int REQUEST_ENABLE_BT = 1; public static final int REQUEST_ENABLE_BT = 1;
public static final int REQUEST_ACCESS_FINE_LOCATION = 2; public static final int REQUEST_ACCESS_FINE_LOCATION = 2;
......
package org.mpisws.encounters.encounterformation; package org.mpisws.encounters.encounterformation;
import android.Manifest; import android.Manifest;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothManager;
...@@ -12,6 +15,13 @@ import android.support.v4.app.ActivityCompat; ...@@ -12,6 +15,13 @@ import android.support.v4.app.ActivityCompat;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import org.mpisws.encounters.R;
import org.mpisws.helpers.ESCredentials;
import org.mpisws.helpers.GlobalObjectRegistry;
import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
import static android.support.v4.app.NotificationCompat.PRIORITY_LOW;
/** /**
* Created by tslilyai on 10/27/17. * Created by tslilyai on 10/27/17.
*/ */
...@@ -26,6 +36,7 @@ public class EncounterFormationService extends Service { ...@@ -26,6 +36,7 @@ public class EncounterFormationService extends Service {
private EncounterFormationCore core; private EncounterFormationCore core;
private Thread thread; private Thread thread;
public boolean was_destroyed = false; public boolean was_destroyed = false;
private static final int FOREGROUND_SERVICE_ON = 321;
private void check_and_start_core() { private void check_and_start_core() {
if (was_destroyed) { if (was_destroyed) {
...@@ -63,14 +74,30 @@ public class EncounterFormationService extends Service { ...@@ -63,14 +74,30 @@ public class EncounterFormationService extends Service {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startID) { public int onStartCommand(Intent intent, int flags, int startID) {
Log.v(TAG, "Got start command"); /*if (GlobalObjectRegistry.getObject(ESCredentials.class) == null ||
GlobalObjectRegistry.getObject(ESCredentials.class).getUserHandle() == null) {
Intent dialogIntent = new Intent(this, Login.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);
}*/
if (intent == null) { if (intent == null) {
return START_STICKY; return START_STICKY;
} }
if (intent.getExtras().containsKey("@string.start_sddr_service")) if (intent.getExtras().containsKey("@string.start_sddr_service")) {
{
check_and_start_core(); check_and_start_core();
Intent notificationIntent = new Intent(this, getApplicationContext().getClass());
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Notification notification = new Notification.Builder(this, DEFAULT_CHANNEL_ID)
.setContentTitle("EbC")
.setContentText("Forming encounters")
.setSmallIcon(R.drawable.ic_ebc_formation)
.setContentIntent(pendingIntent)
.setTicker("EbCTicker?")
.build();
startForeground(FOREGROUND_SERVICE_ON, notification);
return START_STICKY; return START_STICKY;
} }
......
...@@ -29,7 +29,7 @@ import java.util.UUID; ...@@ -29,7 +29,7 @@ import java.util.UUID;
*/ */
public class SimulationClientBT { public class SimulationClientBT {
Context context; Context context;
protected static final int NUM_SIMULATED_DEVICES = 10; protected static final int NUM_SIMULATED_DEVICES = 50;
protected static final int NUM_SIMULATED_EPOCHS = 10; protected static final int NUM_SIMULATED_EPOCHS = 10;
private static final String TAG = SimulationClientBT.class.getSimpleName(); private static final String TAG = SimulationClientBT.class.getSimpleName();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment