mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-15 05:04:22 +02:00
Fix package visibility for Android >= 11, see issue https://github.com/oliexdev/openScale-sync/issues/7
The sync apps were not visible to the main app on Android 11+ due to new package visibility restrictions. This change adds the necessary `<queries>` elements to `AndroidManifest.xml` to declare the sync app packages. Additionally, the `ComponentName` for the `SyncService` is now hardcoded to the correct FQCN `com.health.openscale.sync.core.service.SyncService` to avoid issues with different package names for the sync apps (e.g., `com.health.openscale.sync.oss`).
This commit is contained in:
@@ -22,6 +22,11 @@
|
|||||||
|
|
||||||
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
|
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
|
||||||
|
|
||||||
|
<queries>
|
||||||
|
<package android:name="com.health.openscale.sync.oss" />
|
||||||
|
<package android:name="com.health.openscale.sync" />
|
||||||
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
|
@@ -725,7 +725,7 @@ public class OpenScale {
|
|||||||
|
|
||||||
private void syncInsertMeasurement(ScaleMeasurement scaleMeasurement, String pkgName) {
|
private void syncInsertMeasurement(ScaleMeasurement scaleMeasurement, String pkgName) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setComponent(new ComponentName(pkgName, pkgName + ".core.service.SyncService"));
|
intent.setComponent(new ComponentName(pkgName, "com.health.openscale.sync.core.service.SyncService"));
|
||||||
intent.putExtra("mode", "insert");
|
intent.putExtra("mode", "insert");
|
||||||
intent.putExtra("userId", scaleMeasurement.getUserId());
|
intent.putExtra("userId", scaleMeasurement.getUserId());
|
||||||
intent.putExtra("weight", scaleMeasurement.getWeight());
|
intent.putExtra("weight", scaleMeasurement.getWeight());
|
||||||
@@ -738,7 +738,7 @@ public class OpenScale {
|
|||||||
|
|
||||||
private void syncUpdateMeasurement(ScaleMeasurement scaleMeasurement, String pkgName) {
|
private void syncUpdateMeasurement(ScaleMeasurement scaleMeasurement, String pkgName) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setComponent(new ComponentName(pkgName, pkgName + ".core.service.SyncService"));
|
intent.setComponent(new ComponentName(pkgName, "com.health.openscale.sync.core.service.SyncService"));
|
||||||
intent.putExtra("mode", "update");
|
intent.putExtra("mode", "update");
|
||||||
intent.putExtra("userId", scaleMeasurement.getUserId());
|
intent.putExtra("userId", scaleMeasurement.getUserId());
|
||||||
intent.putExtra("weight", scaleMeasurement.getWeight());
|
intent.putExtra("weight", scaleMeasurement.getWeight());
|
||||||
@@ -751,7 +751,7 @@ public class OpenScale {
|
|||||||
|
|
||||||
private void syncDeleteMeasurement(Date date, String pkgName) {
|
private void syncDeleteMeasurement(Date date, String pkgName) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setComponent(new ComponentName(pkgName, pkgName + ".core.service.SyncService"));
|
intent.setComponent(new ComponentName(pkgName, "com.health.openscale.sync.core.service.SyncService"));
|
||||||
intent.putExtra("mode", "delete");
|
intent.putExtra("mode", "delete");
|
||||||
intent.putExtra("date", date.getTime());
|
intent.putExtra("date", date.getTime());
|
||||||
ContextCompat.startForegroundService(context, intent);
|
ContextCompat.startForegroundService(context, intent);
|
||||||
@@ -759,7 +759,7 @@ public class OpenScale {
|
|||||||
|
|
||||||
private void syncClearMeasurements(String pkgName) {
|
private void syncClearMeasurements(String pkgName) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setComponent(new ComponentName(pkgName, pkgName + ".core.service.SyncService"));
|
intent.setComponent(new ComponentName(pkgName, "com.health.openscale.sync.core.service.SyncService"));
|
||||||
intent.putExtra("mode", "clear");
|
intent.putExtra("mode", "clear");
|
||||||
ContextCompat.startForegroundService(context, intent);
|
ContextCompat.startForegroundService(context, intent);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user