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

Device info doesnt return device model #163

Open
nikitabalabanovdev opened this issue Sep 30, 2024 · 6 comments
Open

Device info doesnt return device model #163

nikitabalabanovdev opened this issue Sep 30, 2024 · 6 comments

Comments

@nikitabalabanovdev
Copy link

@matinzd
### Device metadata always returns null values in Health Connect library

Description:

When fetching activity data, the metadata?.device object consistently returns {"manufacturer": null, "model": null, "type": 0}. This behavior occurs regardless of whether the code is running on an emulator or a real device. The expectation is that the manufacturer and model fields should return the device information for real devices and appropriate metadata for emulators.

Steps to reproduce the behavior:

  1. Use the Health Connect library to fetch activity data (e.g., steps).
  2. Check the response in the metadata?.device field.
  3. Observe that manufacturer, model, and type are always null or 0.

Expected behavior:

The metadata?.device should return the actual device details

Minimal Reproducible

Here’s a code snippet demonstrating the issue:

const { records: stepCountRecords } = await readRecords('Steps', {
  timeRangeFilter: {
    operator: 'between',
    startTime: startDate,
    endTime: endDate,
  },
});

if (stepCountRecords && stepCountRecords.length > 0) {
  const stepFormatted = {
    anchor: endDate,
    fitnessData: stepCountRecords
      .filter(
        record => record.count > 0 && !!record.startTime && !!record.endTime
      )
      .map(({ count, startTime, endTime, metadata }) => {
        const recordingMethod = metadata?.recordingMethod ?? 0;
        const device = metadata?.device?.model ?? emptyValue;
        const dataOrigin = metadata?.dataOrigin ?? emptyValue;
        return metadata?.device;
      }),
  };
}

Environment:

Health Connect Version: ^3.1.0
React Native Version: 0.72.7
New architecture enabled: No
Using Expo: No
Android API Level: API 34 (Android 14)

@matinzd
Copy link
Owner

matinzd commented Sep 30, 2024

Hey!

Can you debug the app with Android Studio and add a breakpoint here? Then check what's in the record.metadata.

override fun parseRecord(record: StepsRecord): WritableNativeMap {
return WritableNativeMap().apply {
putString("startTime", record.startTime.toString())
putString("endTime", record.endTime.toString())
putDouble("count", record.count.toDouble())
putMap("metadata", convertMetadataToJSMap(record.metadata))
}
}

If the recording method is the same as you see in the javascript side, there is nothing I can help you with.

@nikitabalabanovdev
Copy link
Author

nikitabalabanovdev commented Sep 30, 2024

@matinzd Yes recording method is the same. Does it mean that this problem is not in the library, but in Google Fit or Health Connect itself ?

@matinzd
Copy link
Owner

matinzd commented Sep 30, 2024

How about other information like device metadata? Yes, then the problem is not with the react native lib. You need to open an issue in Google Issue Tracker.

@nikitabalabanovdev
Copy link
Author

@matinzd All the data is same. I get it, thanks a lot for you responses. I will open an issue in Google Issue Tracker

@nikitabalabanovdev
Copy link
Author

@matinzd I am super sorry for bothering you, but have you seen latest changes of
feature request
It seems that it is more issue report than feature request

@matinzd
Copy link
Owner

matinzd commented Nov 19, 2024

@nikitabalabanovdev What do you mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants