You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Open mSupply
2
2
3
3
This is the home of an open source version of the popular [mSupply](https://msupply.org.nz/) - providing pharmaceutical supply chain management and dispensing, all the way from national warehouses to remote clinics, on servers, laptops and mobile.
4
-
Used in over 30 countries and for over 20 years and now becoming open source.
4
+
Used in over 30 countries and for over 20 years and now becoming open source software.
5
5
6
6
The code is separated into two main areas, the client and server:
Copy file name to clipboardexpand all lines: client/packages/android/README.MD
+24-18
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
# Mobile App with Discovery
2
2
3
3
The Android app can run as standalone site with a local server, as a client connecting to another server or as a server for other clients.
4
-
On android, the server always starts and this allows for one mobile app for both client and client/server.
5
-
The mobile app will broadcast via dns sd and will be reachable by both Mobile and Electron clients on the local network.
6
-
We are using Capacitor to make use of existing optimisations and large library of native plugins.
4
+
On android, the server always starts and this allows for one mobile app for both client and client/server.
5
+
The mobile app will broadcast via dns sd and will be reachable by both Mobile and Electron clients on the local network.
6
+
We are using Capacitor to make use of existing optimisations and large library of native plugins.
7
7
UI is not bundled within Capacitor, it is served by the server the client connect to, and discovery UI is always served by local bundled server.
8
8
9
9
## Getting started
@@ -18,7 +18,7 @@ Next step is to open this directory in Android Studio, this will engage gradle s
18
18
19
19
It's recommended to use Android Studio for debugging and running Android App, there is a lot of functionality that cannot be replicated in Visual Studio Code (although there are some extensions for Visual Studio Code they are quite limited).
20
20
21
-
Debugging native code is straight forward, breakpoint in Android Studio and press debug.
21
+
Debugging native code is straight forward, breakpoint in Android Studio and press debug.
22
22
23
23
Debugging web app code is done by opening `chrome://inspect`, you should see Web View when app is running in emulator. When bundled is served from remote server (default setup), js bundle is minimised and this makes debugging very hard, however we can run the bundle from webpack server by commenting out plugins section in `capacitor.config.ts` and entering your local ip in the debugUrl field and running `yarn apply-config`. Please make sure that you start front end server with `yarn start-local` from 'client' directory for this to work.
24
24
@@ -28,7 +28,7 @@ When running the Android app in an emulator the service discovery will not work
28
28
29
29
## Scripts
30
30
31
-
The following scripts are available
31
+
The following scripts are available
32
32
33
33
```bash
34
34
# Builds remote server binaries for android and copies them to android package
@@ -41,7 +41,7 @@ yarn build:release
41
41
yarn apply-config
42
42
```
43
43
44
-
As per earlier comment, please make sure to build front end with `yarn build` from client directory prior to runner the above or run `yarn android:{command here}` from client directory to do both with one command.
44
+
As per earlier comment, please make sure to build front end with `yarn build` from client directory prior to runner the above or run `yarn android:{command here}` from client directory to do both with one command.
45
45
46
46
### Know script issues
47
47
@@ -81,10 +81,10 @@ A few configuration/modifications were made to make sure we can serve Android bu
81
81
82
82
1. capacitor.config.ts (see comment in that file)
83
83
2. Capacitor `proxies` inject some pre-requisite <scripts> into the target webpage.
84
-
Since the mSupply servers uses self signed certs, fetching the target webpage fails and the pre-requisite scripts are not inserted.
85
-
For this reason `ExtendedWebViewClient` was created to manually inject the required <script> tags.
86
-
[Discussion](https://github.com/ionic-team/capacitor/discussions/6166) was made on capacitor github to see if there is another way to overcome this.
87
-
3. Base url is loaded manually in `handleOnStart()` method in `NativeApi.java`
84
+
Since the mSupply servers uses self signed certs, fetching the target webpage fails and the pre-requisite scripts are not inserted.
85
+
For this reason `ExtendedWebViewClient` was created to manually inject the required <script> tags.
86
+
[Discussion](https://github.com/ionic-team/capacitor/discussions/6166) was made on capacitor github to see if there is another way to overcome this.
87
+
3. Base url is loaded manually in `handleOnStart()` method in `NativeApi.java`
88
88
89
89
## Extra
90
90
@@ -96,11 +96,11 @@ The cert plugin (`app/src/main/java/org/openmsupply/client/certplugin/CertPlugin
96
96
97
97
Capacitor comes with cli, we mainly use `npx cap copy` (or `yarn apply-config`), this moves bundled assets to app/src/main/assets/public. Usually capacitor would bundle web app within the APK, since we are serving front end bundle with server we don't need to move them (you will not that in capacitor.config.ts `webDir` is pointed to a non-existant directory). Capacitor also moves pre requisites to cordova plugins to that folder, which is automatically injected into served `html`. Another task of `npx cap copy` is to copy configuration files `capacitor.config.ts` is translated to JSON file and moved to app/src/main/assets
98
98
99
-
`app/src/main/assets/public` directory is typically not committed, but since it's only going to have cordova artifacts, it is in our case (to reduce setup).
99
+
`app/src/main/assets/public` directory is typically not committed, but since it's only going to have cordova artifacts, it is in our case (to reduce setup).
100
100
101
101
`npx cap copy` or `yarn apply-config` should only be run when cordova plugins are added or updated or when updating capacitor.config.ts
102
102
103
-
When adding plugins - add them to the android package; if they are not here, then `npx cap sync` does not detect them. You should see
103
+
When adding plugins - add them to the android package; if they are not here, then `npx cap sync` does not detect them. You should see
104
104
105
105
```
106
106
✔ Updating Android plugins in 2.09ms
@@ -111,24 +111,30 @@ When adding plugins - add them to the android package; if they are not here, the
with the new plugin showing up under the Cordova or Capacitor plugins sections.
116
+
Also, add the plugin to `onPageStarted` in `ExtendedWebViewClient` - see the other plugins for details.
116
117
If you require the plugin to be used in other packages, then you can also install in the root, or in individual packages, to make it available for use elsewhere.
117
118
118
119
You can check the plugins using `npx cap ls` or the configuration generally with `npx cap doctor`
119
120
120
-
If you are having gradle issues, open the project (packages/android folder) in Android Studio and then click on the "Sync Project with Gradle Files" button in the top right of Android Studio (the icon looks like an elephant).
121
+
If you are having gradle issues, open the project (packages/android folder) in Android Studio and then click on the "Sync Project with Gradle Files" button in the top right of Android Studio (the icon looks like an elephant).
121
122
122
123
## Self signed cert SSL security
123
124
124
125
To avoid an error being thrown by the native web view when the server certificate is self-signed, we override the web view certificate error listener and allow connection when:
125
-
* In debug mode
126
-
* The connection is local after verifying the certificate against the local `cert.pem` file : this is for discovery or when connecting to a local server
127
-
*The stored SSL fingerprint matches the server fingerprint
128
126
129
-
For the above to work we store the SSL fingerprint when we first connect to the server and then check that fingerprint on consecutive connections.
127
+
- In debug mode
128
+
- The connection is local after verifying the certificate against the local `cert.pem` file : this is for discovery or when connecting to a local server
129
+
\*The stored SSL fingerprint matches the server fingerprint
130
+
131
+
For the above to work we store the SSL fingerprint when we first connect to the server and then check that fingerprint on consecutive connections.
130
132
The SSL fingerprint is stored in app data and is associated with the `hardwareId` and `port` of the server.
131
133
This works very similar to ssh client, but we associate fingerprint with hardwareId and port instead of domain or ip since local ip can change for the server.
132
134
133
135
App data would need to be cleared if the local certificate was changed.
134
136
137
+
## Log files on Android
138
+
139
+
Go to `browse files` in device manager, then navigate to `data/org.openmsupply.client/files/(log_name).log` to view log, logs that have exceeded the max file size is compressed and saved as a `.gz` zip.
140
+
Alternatively when using an emulator, navigate to `data/user/0/org.openmsupply.client/files/(log_name).log`.
0 commit comments