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

Update to Java 11, react-native-ble-plx 3.1.2 #299

Merged
merged 3 commits into from
May 17, 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msupply-ble-service",
"version": "0.5.3",
"name": "@openmsupply/msupply-ble-service",
"version": "0.5.5",
"description": "Low level bluetooth library",
"author": "Chester Wood <[email protected]> (https://github.com/chetstone)",
"license": "GPL-3.0-or-later",
Expand Down Expand Up @@ -86,5 +86,5 @@
"dependencies": {
"buffer": "^6.0.3"
},
"yalcSig": "e0f2ac2763896db23b9eb3398b7fcecc"
"yalcSig": "4b8a288aa30f2b811289676652db5d3d"
}
1 change: 1 addition & 0 deletions .yalc/@openmsupply/msupply-ble-service/yalc.sig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4b8a288aa30f2b811289676652db5d3d
1 change: 0 additions & 1 deletion .yalc/msupply-ble-service/yalc.sig

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ See [https://docs.msupply.foundation/en:cold_chain:start](https://docs.msupply.f
- Install Android Studio and SDK tools: https://developer.android.com/studio.
- Install SDKMAN for managing Java versions: https://sdkman.io/.

The application is using java v1.8 you may need to target a specific java version in order to run the app locally.
e.g.
The application is using java v11 you may need to target a specific java version in order to run the app locally.
e.g. (with sdkman installed):

```
export JDK_HOME=~/.jenv/versions/oracle64-1.8.0.192 && JAVA_HOME=~/.jenv/versions/oracle64-1.8.0.192 && yarn start
sdk use java 11.0.23-zulu
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this as it seems we need java11+ now that we're targeting a SDK 23.
Haven't tired 17 or other more modern ones, wasn't working before...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api level 23 is android 6 - given that the samsung I'm using is older, and android 12.. we're probably ok

```

#### React Native
Expand All @@ -45,7 +45,7 @@ The node version should be >= 12.8.4.

### Building

Simply run `yarn build` to build the app.
Simply run `yarn build` to build the app.
If you have the following error:
`A problem occurred starting process 'command 'node''`

Expand Down
82 changes: 43 additions & 39 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.msupplycoldchain">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />

<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme" android:usesCleartextTraffic="true" android:requestLegacyExternalStorage="true">
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:theme="@style/Theme.App.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity" android:exported="true"/>
<meta-data android:name="com.bugsnag.android.API_KEY" android:value="9083556ae736617ad9680a60a402824e"/>
<service android:name="com.voximplant.foregroundservice.VIForegroundService" />
<service android:name="com.msupplycoldchain.SchedulerService" android:enabled="true" android:exported="false" />
<service android:name="com.msupplycoldchain.SchedulerEventService" />
<receiver android:name="com.msupplycoldchain.BootUpReceiver" android:enabled="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Android >= 12 -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
Copy link
Contributor Author

@jmbrunskill jmbrunskill Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we're using now if I understand correctly...

<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Android < 12 -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<!-- common -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme" android:usesCleartextTraffic="true" android:requestLegacyExternalStorage="true">
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:theme="@style/Theme.App.SplashScreen" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="true" />
<activity android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity" android:exported="true" />
<meta-data android:name="com.bugsnag.android.API_KEY" android:value="9083556ae736617ad9680a60a402824e" />
<service android:name="com.voximplant.foregroundservice.VIForegroundService" />
<service android:name="com.msupplycoldchain.SchedulerService" android:enabled="true" android:exported="true" />
<service android:name="com.msupplycoldchain.SchedulerEventService" />
<receiver android:name="com.msupplycoldchain.BootUpReceiver" android:enabled="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ public void onDestroy() {

public static Notification buildNotification(Context context, String text) {
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
PendingIntent contentIntent = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
contentIntent = PendingIntent.getActivity
(context, 0, notificationIntent, PendingIntent.FLAG_MUTABLE);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparenlty IMMUTABLE Is safer but wanted to just get it working for now...

}
else
{
contentIntent = PendingIntent.getActivity
(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}

return new NotificationCompat.Builder(context, CHANNEL_ID)
.setContentTitle("ColdChain service") // getApplicationName
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
minSdkVersion = 23
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "20.1.5948944"
}
repositories {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"dependencies": {
"@bugsnag/react-native": "^7.19.0",
"@openmsupply/msupply-ble-service": "file:.yalc/@openmsupply/msupply-ble-service",
"@react-native-async-storage/async-storage": "^1.15.2",
"@react-native-community/cli": "^5.0.1-alpha.2",
"@react-native-community/datetimepicker": "^3.4.6",
Expand Down Expand Up @@ -74,12 +75,11 @@
"json2csv": "^5.0.6",
"lodash": "^4.17.21",
"moment": "2.27.0",
"msupply-ble-service": "file:.yalc/msupply-ble-service",
"path": "^0.12.7",
"prop-types": "15.7.2",
"react": "17.0.1",
"react-native": "0.64.4",
"react-native-ble-plx": "^2.0.2",
"react-native-ble-plx": "^3.1.2",
"react-native-calendars": "^1.1257.0",
"react-native-camera": "^4.2.1",
"react-native-clean-project": "^3.6.4",
Expand Down
3 changes: 1 addition & 2 deletions src/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ export { ICON } from './Icon';
export { FORMAT } from './Format';
export { CHART } from './Chart';
export { NAVIGATION } from './Navigation';
export { BLUETOOTH } from 'msupply-ble-service';
export { BLUETOOTH, BLUE_MAESTRO } from '@openmsupply/msupply-ble-service';
export { SETTING } from './Setting';
export { SPECIAL_CHARACTER } from './SpecialCharacter';
export { BLUE_MAESTRO } from 'msupply-ble-service';
export { ENVIRONMENT } from './Environment';

export { SETTINGS_STACK } from './Navigation';
Expand Down
2 changes: 1 addition & 1 deletion src/common/services/DependencyLocator/DependencyLocator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BtUtilService } from 'msupply-ble-service';
import { BtUtilService } from '@openmsupply/msupply-ble-service';
import {
AcknowledgeBreachManager,
CumulativeBreachManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SensorState } from '../../Entities/Sensor/SensorSlice';
import { MILLISECONDS, REDUCER } from '~constants';
import { SensorAction, SensorManager } from '~features/Entities';
import { getDependency } from '~features/utils/saga';
import { BleService } from 'msupply-ble-service';
import { BleService } from '@openmsupply/msupply-ble-service';
import { isSensorDownloading } from '../Download/DownloadSlice';
import { RootState } from '~common/store';

Expand Down
2 changes: 1 addition & 1 deletion src/features/Bluetooth/Download/DownloadSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from 'redux-saga/effects';
import { getDependency } from '~features/utils/saga';
import { SensorState } from '~features/Entities/Sensor/SensorSlice';
import { BleService } from 'msupply-ble-service';
import { BleService } from '@openmsupply/msupply-ble-service';
import { MILLISECONDS, REDUCER } from '~common/constants';
import {
DownloadManager,
Expand Down
3 changes: 1 addition & 2 deletions src/features/Bluetooth/Program/ProgramSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { ToastAndroid } from 'react-native';
import { call, getContext, put, retry, takeEvery, takeLeading } from 'redux-saga/effects';

import { SettingManager } from '~features/Entities/Setting/SettingManager';
import { BleService } from 'msupply-ble-service';
import { InfoLog } from 'msupply-ble-service/types';
import { BleService, InfoLog } from '@openmsupply/msupply-ble-service';
import { RootState } from '~store/store';
import { DEPENDENCY, REDUCER } from '~constants';
import { getDependency } from '~features/utils/saga';
Expand Down
2 changes: 1 addition & 1 deletion src/features/Bluetooth/Scan/ScanSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import { eventChannel } from 'redux-saga';
import { SagaIterator } from '@redux-saga/types';
import { ActionReducerMapBuilder, createSlice } from '@reduxjs/toolkit';
import { BleService, BleError } from 'msupply-ble-service';
import { BleService, BleError } from '@openmsupply/msupply-ble-service';
import {
take,
getContext,
Expand Down
2 changes: 1 addition & 1 deletion src/features/Entities/Sensor/SensorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { classToPlain } from 'class-transformer';
import { ENTITIES } from '../../../common/constants';

import { IsNull } from 'typeorm/browser';
import { BtUtilService } from 'msupply-ble-service';
import { BtUtilService } from '@openmsupply/msupply-ble-service';

const SENSOR_STATE = `
with breach as (
Expand Down
2 changes: 1 addition & 1 deletion src/features/Monitor/MonitorSlice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Bugsnag from '@bugsnag/react-native';
import { SagaIterator } from '@redux-saga/types';
import { createSlice } from '@reduxjs/toolkit';
import { BleService } from 'msupply-ble-service';
import { BleService } from '@openmsupply/msupply-ble-service';
import { BleManager } from 'react-native-ble-plx';
import { call, delay, select, takeLeading } from 'redux-saga/effects';
import { DependencyLocator } from '~common/services';
Expand Down
7 changes: 6 additions & 1 deletion src/ui/containers/DependencyContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React, { FC, useEffect, useState } from 'react';
import { BleService, BleManager, DevBleManager, BtUtilService } from 'msupply-ble-service';
import {
BleService,
BleManager,
DevBleManager,
BtUtilService,
} from '@openmsupply/msupply-ble-service';

import { ENVIRONMENT } from '~common/constants';
import { DevContainer } from './DevContainer';
Expand Down
2 changes: 1 addition & 1 deletion src/ui/hooks/useDependency.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { BtUtilService } from 'msupply-ble-service';
import { BtUtilService } from '@openmsupply/msupply-ble-service';
import { Dependency, DependencyKey } from '~services/DependencyLocator/DependencyLocator';
import {
DatabaseService,
Expand Down
6 changes: 5 additions & 1 deletion yalc.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"version": "v1",
"packages": {
"msupply-ble-service": {
"signature": "e0f2ac2763896db23b9eb3398b7fcecc",
"signature": "57cb36a5493fb3a5be4b81d5224c77ec",
"file": true,
"replaced": "link:../msupply-ble-service"
},
"@openmsupply/msupply-ble-service": {
"signature": "4b8a288aa30f2b811289676652db5d3d",
"file": true
}
}
}
Loading