Skip to content

Commit

Permalink
sensor alerts should only be recorded if monitoring is active
Browse files Browse the repository at this point in the history
(a tester noticed camera events were being stored during countdown)
  • Loading branch information
n8fr8 committed Jul 5, 2018
1 parent b1b6d94 commit 85de67b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private void recordNewFrame (byte[] data, int width, int height, int rotationDeg
if (serviceMessenger != null) {
Message message = new Message();
message.what = EventTrigger.CAMERA_VIDEO;
message.getData().putString("path", videoFile);
message.getData().putString(MonitorService.KEY_PATH, videoFile);
try {
serviceMessenger.send(message);
} catch (RemoteException e) {
Expand Down
22 changes: 9 additions & 13 deletions src/main/java/org/havenapp/main/service/MonitorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
Expand All @@ -28,12 +26,6 @@
import android.support.v4.app.NotificationCompat;
import android.telephony.SmsManager;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;

import com.google.android.cameraview.CameraView;

import org.havenapp.main.HavenApp;
import org.havenapp.main.MonitorActivity;
Expand Down Expand Up @@ -82,7 +74,7 @@ public class MonitorService extends Service {
private BarometerMonitor mBaroMonitor = null;
private AmbientLightMonitor mLightMonitor = null;

private boolean mIsRunning = false;
private boolean mIsMonitoringActive = false;

/**
* Last Event instances
Expand All @@ -101,9 +93,13 @@ private class MessageHandler extends Handler {
@Override
public void handleMessage(Message msg) {

alert(msg.what,msg.getData().getString("path"));
//only accept alert if monitor is running
if (mIsMonitoringActive)
alert(msg.what,msg.getData().getString(KEY_PATH));
}
}

public final static String KEY_PATH = "path";

/**
* Messenger interface used by clients to interact
Expand Down Expand Up @@ -222,13 +218,13 @@ private void showNotification() {

public boolean isRunning ()
{
return mIsRunning;
return mIsMonitoringActive;

}

private void startSensors ()
{
mIsRunning = true;
mIsMonitoringActive = true;

if (!mPrefs.getAccelerometerSensitivity().equals(PreferenceManager.OFF)) {
mAccelManager = new AccelerometerMonitor(this);
Expand Down Expand Up @@ -258,7 +254,7 @@ private void startSensors ()

private void stopSensors ()
{
mIsRunning = false;
mIsMonitoringActive = false;
//this will never be false:
// -you can't use ==, != for string comparisons, use equals() instead
// -Value is never set to OFF in the first place
Expand Down

0 comments on commit 85de67b

Please sign in to comment.