Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of pedometer probe (step count) on iOS (#390) #399

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
662 changes: 333 additions & 329 deletions carp_mobile_sensing/CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion carp_mobile_sensing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The pedometer (step count) probe uses `NSMotion` on iOS and the `NSMotionUsageDe

```xml
<key>NSMotionUsageDescription</key>
<string>Collecting step count.</string>
<string>This application tracks your steps</string>
```

-------------------------------------
Expand Down
5 changes: 1 addition & 4 deletions carp_mobile_sensing/example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSMotionUsageDescription</key>
<string>Collecting step count.</string>
<string>This application tracks your steps</string>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
Expand Down
14 changes: 7 additions & 7 deletions carp_mobile_sensing/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ class LocalStudyProtocolManager implements StudyProtocolManager {
var phone = Smartphone();
protocol.addPrimaryDevice(phone);

// Issue #384
protocol.addTaskControl(
PeriodicTrigger(period: const Duration(seconds: 5)),
BackgroundTask(
measures: [Measure(type: DeviceSamplingPackage.DEVICE_INFORMATION)],
),
phone);
// // Issue #384
// protocol.addTaskControl(
// PeriodicTrigger(period: const Duration(seconds: 5)),
// BackgroundTask(
// measures: [Measure(type: DeviceSamplingPackage.DEVICE_INFORMATION)],
// ),
// phone);

// Collect timezone info every time the app restarts.
protocol.addTaskControl(
Expand Down
4 changes: 2 additions & 2 deletions carp_mobile_sensing/lib/runtime/client_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ class SmartPhoneClientManager extends SmartphoneClient
/// [configure].
Future<void> askForAllPermissions() async {
if (SamplingPackageRegistry().permissions.isNotEmpty) {
info('Asking for permission for all measure types.');
info('Asking for permission for all measure types - status:');
_permissions = await SamplingPackageRegistry().permissions.request();
permissions.forEach((permission, status) =>
info('Permissions for $permission : $status'));
info(' - ${permission.toString().split('.').last} : ${status.name}'));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ part of 'sensors.dart';
/// It samples step counts directly from the native OS and reports step counts
/// as they are sensed, typically for each step taken.
///
/// Note that the [Pedometer] plugin returns the total steps taken since last
/// Note that the 'pedometer' plugin returns the total steps taken since last
/// system boot.
class PedometerProbe extends StreamProbe {
@override
Future<bool> onStart() async {
// Ask for permission before starting probe.
var status = await Permission.activityRecognition.request();
// Only relevant for Android - on iOS permission is automatically requested.
var status = Platform.isAndroid
? await Permission.activityRecognition.request()
: PermissionStatus.granted;

return (status == PermissionStatus.granted)
? super.onStart()
Expand Down
2 changes: 1 addition & 1 deletion carp_mobile_sensing/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: carp_mobile_sensing
description: Mobile Sensing Framework for Flutter. A software framework for collecting sensor data from the phone and attached wearable devices via probes. Can be extended.
version: 1.7.0
version: 1.7.1
homepage: https://github.com/cph-cachet/carp.sensing-flutter

environment:
Expand Down
Loading