Skip to content

Commit

Permalink
Merge pull request #530 from enviroCar/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dewall authored Jul 14, 2020
2 parents 8f4ccb5 + 79a4995 commit 5525770
Show file tree
Hide file tree
Showing 17 changed files with 248 additions and 306 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ allprojects {
ext {
androidPlugin = 'com.android.tools.build:gradle:3.1.2'
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = '28.0.3'
versionCode = 47
versionName = "1.1.7"
compileSdkVersion = 29
targetSdkVersion = 29
buildToolsVersion = '29.0.2'
versionCode = 48
versionName = "1.1.8"

javaCompileVersion = JavaVersion.VERSION_1_8

Expand Down
50 changes: 21 additions & 29 deletions org.envirocar.app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
xmlns:tools="http://schemas.android.com/tools"
package="org.envirocar.app"
android:installLocation="internalOnly"
android:versionCode="47"
android:versionName="1.1.7">
android:versionCode="48"
android:versionName="1.1.8">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android:permission:ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
Expand All @@ -33,7 +34,6 @@
android:name="android.hardware.location.gps"
android:required="true" />


<application
android:name=".BaseApplication"
android:allowBackup="true"
Expand Down Expand Up @@ -78,10 +78,27 @@
<activity
android:name=".views.settings.SettingsActivity"
android:screenOrientation="portrait" />
<activity
android:name=".views.SplashScreenActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/Theme.Cario">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".views.recordingscreen.RecordingScreenActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait" />

<!-- Services -->
<service android:name=".recording.RecordingService"
android:enabled="true"/>
android:enabled="true"
android:foregroundServiceType="location"/>
<service
android:name=".services.autoconnect.AutoRecordingService"
android:enabled="true" />
Expand Down Expand Up @@ -111,31 +128,6 @@
</intent-filter>
</receiver>

<activity
android:name=".views.SplashScreenActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/Theme.Cario">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- <activity-->
<!-- android:name=".views.recordingscreen.OBDPlusGPSTrackRecordingScreen"-->
<!-- android:launchMode="singleTop"-->
<!-- android:screenOrientation="portrait" />-->
<!-- <activity-->
<!-- android:name=".views.recordingscreen.GPSOnlyTrackRecordingScreen"-->
<!-- android:launchMode="singleTop"-->
<!-- android:screenOrientation="portrait" />-->
<activity
android:name=".views.recordingscreen.RecordingScreenActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,40 +145,6 @@ public BluetoothHandler(@InjectApplicationScope Context context, Bus bus) {
this.context.registerReceiver(mBluetoothStateChangedReceiver, filter);
}

/**
* Starts the connection to the bluetooth device if not already active.
*/
public void startOBDConnectionService() {
if (!ServiceUtils.isServiceRunning(context, RecordingService.class))
context.getApplicationContext()
.startService(new Intent(context, RecordingService.class));
}


public void stopOBDConnectionService() {
if (ServiceUtils.isServiceRunning(context, RecordingService.class)) {
context.getApplicationContext()
.stopService(new Intent(context, RecordingService.class));
}

ActivityManager amgr = (ActivityManager) context.getSystemService(Context
.ACTIVITY_SERVICE);

List<ActivityManager.RunningAppProcessInfo> list = amgr.getRunningAppProcesses();
if (list != null) {
for (int i = 0; i < list.size(); i++) {
ActivityManager.RunningAppProcessInfo apinfo = list.get(i);

String[] pkgList = apinfo.pkgList;
if (apinfo.processName.startsWith("org.envirocar.app.services.OBD")) {
for (int j = 0; j < pkgList.length; j++) {
amgr.killBackgroundProcesses(pkgList[j]);
}
}
}
}
}

@Produce
public BluetoothStateChangedEvent produceBluetoothStateChangedEvent() {
return new BluetoothStateChangedEvent(isBluetoothEnabled(), getSelectedBluetoothDevice());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import android.content.Context;
import android.content.Intent;
import android.icu.text.AlphabeticIndex;

import com.squareup.otto.Bus;

Expand Down Expand Up @@ -98,67 +99,6 @@ public TrackRecordingHandler(Context context) {
BaseApplication.get(context).getBaseApplicationComponent().inject(this);
}

// public DisposableSingleObserver<Track> startNewTrack(PublishSubject<Measurement> publishSubject) {
// return getActiveTrackReference(true)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.io())
// .subscribeWith(new DisposableSingleObserver<Track>() {
//
// @Override
// public void onError(Throwable e) {
// LOGGER.error(e.getMessage(), e);
// }
//
// @Override
// public void onSuccess(Track track) {
// publishSubject.doOnDispose(() -> {
// LOGGER.info("doOnUnsubscribe(): finish current track.");
// finishCurrentTrack();
// }).subscribeWith(new DisposableObserver<Measurement>() {
//
// @Override
// protected void onStart() {
// LOGGER.info("NewMeasurementSubject onStart()");
// }
//
// @Override
// public void onComplete() {
// LOGGER.info("NewMeasurementSubject onCompleted()");
// currentTrack = track;
// finishCurrentTrack();
// }
//
// @Override
// public void onError(Throwable e) {
// LOGGER.error(e.getMessage(), e);
// currentTrack = track;
// finishCurrentTrack();
// }
//
// @Override
// public void onNext(Measurement measurement) {
// LOGGER.info("onNextMeasurement()");
// if (isDisposed())
// return;
// LOGGER.info("Insert new measurement ");
//
// // set the track database ID of the current active track
// measurement.setTrackId(track.getTrackID());
// track.getMeasurements().add(measurement);
// currentTrack = track;
// try {
// mEnvirocarDB.insertMeasurement(measurement);
// } catch (MeasurementSerializationException e) {
// LOGGER.error(e.getMessage(), e);
// finishCurrentTrack();
// }
// }
// });
// }
// });
// }


private Observable<Track> createNewDatabaseTrackObservable() {
return Observable.create(emitter -> {
String date = format.format(new Date());
Expand Down Expand Up @@ -227,12 +167,7 @@ private Completable stopRecordingService() {
return Completable.create(emitter -> {
LOGGER.info("Stopping the recording service.");
try {
if (ServiceUtils.isServiceRunning(mContext, RecordingService.class)) {
mContext.getApplicationContext().stopService(new Intent(mContext, RecordingService.class));
}
if (ServiceUtils.isServiceRunning(mContext, RecordingService.class)) {
mContext.getApplicationContext().stopService(new Intent(mContext, RecordingService.class));
}
ServiceUtils.stopService(mContext, RecordingService.class);
LOGGER.info("Recording services stopped");
emitter.onComplete();
} catch (Exception e) {
Expand Down Expand Up @@ -262,35 +197,6 @@ private Single<Track> stopTrack() {
});
}

/* public void stopBackgroundRecordingServices() {
LOGGER.info("stopBackgroundRecordingServices()");
if (ServiceUtils.isServiceRunning(mContext, OBDRecordingService.class)) {
mContext.getApplicationContext()
.stopService(new Intent(mContext, OBDRecordingService.class));
}
if (ServiceUtils.isServiceRunning(mContext, GPSOnlyRecordingService.class)) {
mContext.getApplicationContext()
.stopService(new Intent(mContext, GPSOnlyRecordingService.class));
}
*//* ActivityManager amgr = (ActivityManager) mContext.getSystemService(Context
.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> list = amgr.getRunningAppProcesses();
if (list != null) {
for (int i = 0; i < list.size(); i++) {
ActivityManager.RunningAppProcessInfo apinfo = list.get(i);
String[] pkgList = apinfo.pkgList;
if (apinfo.processName.startsWith("org.envirocar.app.services.OBD")) {
for (int j = 0; j < pkgList.length; j++) {
amgr.killBackgroundProcesses(pkgList[j]);
}
}
}
}*//*
}*/

/**
* Returns the most recent track, which is not finished yet. It only returns the track when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
@Module
public class OBDServiceModule {

@Singleton
@Provides
PowerManager.WakeLock provideWakeLock(@InjectApplicationScope Context context) {
return ((PowerManager) context.getSystemService(Context.POWER_SERVICE))
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "org.envirocar.app:wakelock");
}
// @Singleton
// @Provides
// PowerManager.WakeLock provideWakeLock(@InjectApplicationScope Context context) {
// return ((PowerManager) context.getSystemService(Context.POWER_SERVICE))
// .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "org.envirocar.app:wakelock");
// }

// @Singleton
// @Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.envirocar.app.recording;

import android.content.Context;
import android.os.PowerManager;

import com.squareup.otto.Bus;

Expand All @@ -38,6 +39,8 @@
import org.envirocar.core.injection.InjectApplicationScope;
import org.envirocar.core.EnviroCarDB;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

Expand Down Expand Up @@ -81,6 +84,13 @@ public LocationProvider provideLocationProvider(@InjectApplicationScope Context
// return new RecordingNotification(context, eventBus);
// }

@Provides
@RecordingScope
public PowerManager.WakeLock provideWakeLock(@InjectApplicationScope Context context) {
return ((PowerManager) context.getSystemService(Context.POWER_SERVICE))
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "org.envirocar.app:wakelock");
}

@Provides
@RecordingScope
public RecordingDetailsProvider provideTrackDetailsProvider(Bus eventBus) {
Expand Down
Loading

0 comments on commit 5525770

Please sign in to comment.