Skip to content

Commit

Permalink
Merge branch 'master' into work_profile_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shankari authored May 16, 2024
2 parents 141338c + 1ffad35 commit 7a3ee6e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
7 changes: 7 additions & 0 deletions hooks/android/addResourcesClassImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ module.exports = function (ctx) {
reject();
}

/*
console.log("For file "+file
+ " Results of match checks: R = "+contents.match(R_RE)
+ " BUILDCONFIG = "+contents.match(BUILDCONFIG_RE)
+ " MAINACT = "+contents.match(MAINACT_RE));
*/
if (contents.match(R_RE) || contents.match(BUILDCONFIG_RE) || contents.match(MAINACT_RE)) {
console.log('file '+filename+' needs to be rewritten, checking package');
const packages = contents.match(PACKAGE_RE);
Expand Down Expand Up @@ -136,6 +142,7 @@ module.exports = function (ctx) {
// since we re-check for the imports before re-writing them
// but it avoid unnecessary file rewrites, so we retain
// it for now
console.log("file "+file+" does not need to be rewritten");
resolve();
}
});
Expand Down
11 changes: 11 additions & 0 deletions src/android/bluetooth/BluetoothMonitoringService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import edu.berkeley.eecs.emission.cordova.tracker.ExplicitIntent;
import edu.berkeley.eecs.emission.cordova.tracker.verification.SensorControlChecks;

// Saving data
import edu.berkeley.eecs.emission.cordova.usercache.UserCacheFactory;
import edu.berkeley.eecs.emission.cordova.tracker.wrapper.BluetoothBLE;

public class BluetoothMonitoringService extends Service {
private static String TAG = "BluetoothMonitoringService";
Expand Down Expand Up @@ -53,6 +56,14 @@ private void startMonitoring() {
@Override
public void didEnterRegion(Region region) {
Log.d(BluetoothMonitoringService.this, TAG, "I just saw a beacon for the first time!");
// hack to use `R` so that we will rewrite it
if (region.getUniqueId().toString().equals(uuid)) {
BluetoothBLE currWrapper = BluetoothBLE.initRegionEnter(
region.getUniqueId(),
System.currentTimeMillis() / 1000); // timestamp in always in secs for us
UserCacheFactory.getUserCache(BluetoothMonitoringService.this)
.putSensorData(R.string.key_usercache_bluetooth_ble, currWrapper);
}
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/android/bluetooth/BluetoothService.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
beacon.getRssi());
UserCacheFactory.getUserCache(BluetoothService.this)
.putSensorData(R.string.key_usercache_bluetooth_ble, currWrapper);
// End scanning early
numScans = 5;
}
}
}

numScans++;

if (numScans >= 10 * 60) {
if (numScans >= 5) {
// Once we have hit certain number of scans, stop and determine if any beacons are in range
isInRange();
}
Expand Down
19 changes: 10 additions & 9 deletions src/ios/Location/TripDiaryDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -361,20 +361,21 @@ - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)
- (void)locationManager:(CLLocationManager *)manager
didRangeBeacons:(NSArray<CLBeacon *> *)beacons
satisfyingConstraint:(CLBeaconIdentityConstraint *)beaconConstraint {

for (int i = 0; i < beacons.count; i++) {
BluetoothBLE* currBeaconRegion = [[BluetoothBLE alloc] initWithCLBeacon:beacons[i]];
[[BuiltinUserCache database] putSensorData:@"key.usercache.bluetooth_ble" value:currBeaconRegion];
}

[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
object:CFCTransitionBeaconFound];

[LocalNotificationManager addNotification:
[NSString stringWithFormat:@"Successfully found Beacons: %@ in state %@",
beacons,
[TripDiaryStateMachine getStateName:_tdsm.currState]]
showUI:TRUE];
if (_tdsm.currState != kOngoingTripState) {
[[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
object:CFCTransitionBeaconFound];
[LocalNotificationManager addNotification:
[NSString stringWithFormat:@"Successfully found Beacons: %@ in state %@",
beacons,
[TripDiaryStateMachine getStateName:_tdsm.currState]]
showUI:TRUE];
}

}

Expand Down

0 comments on commit 7a3ee6e

Please sign in to comment.