Skip to content

Commit 3735dd0

Browse files
committed
Fix(core): Fix android 14 compatibility
1 parent d93244c commit 3735dd0

16 files changed

+502
-812
lines changed

.github/workflows/continuous-integration.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,20 @@ jobs:
5656
run: gcloud config set project ${{ secrets.FIREBASE_PROJECT_ID }}
5757

5858
# Run Instrumentation Tests in Firebase Test Lab
59+
# dm3q Samasung galaxy s23 SDK 33
60+
# e1q Samasung galaxy s24 SDK 34
61+
# bluejay Google Pixel 6a SDK 32
62+
# a51 Samsung Galaxy A51 SDK 31
63+
# q2q Samsung Galaxy Z Fold3 SDK 30
64+
# cactus Xiaomi Redmi 6A SDK 27
5965
- name: Run Instrumentation Tests in Firebase Test Lab
60-
run: gcloud firebase test android run --type instrumentation --app ${{ env.module_app }}/build/outputs/apk/debug/${{ env.module_app }}-debug.apk --test ${{ env.module_app }}/build/outputs/apk/androidTest/debug/${{ env.module_app }}-debug-androidTest.apk --device model=oriole,version=31,locale=en,orientation=portrait
66+
run: |
67+
gcloud firebase test android run --type instrumentation --app ${{ env.module_app }}/build/outputs/apk/debug/${{ env.module_app }}-debug.apk --test ${{ env.module_app }}/build/outputs/apk/androidTest/debug/${{ env.module_app }}-debug-androidTest.apk --device model=e1q,version=34,locale=en,orientation=portrait
68+
gcloud firebase test android run --type instrumentation --app ${{ env.module_app }}/build/outputs/apk/debug/${{ env.module_app }}-debug.apk --test ${{ env.module_app }}/build/outputs/apk/androidTest/debug/${{ env.module_app }}-debug-androidTest.apk --device model=dm3q,version=33,locale=en,orientation=portrait
69+
gcloud firebase test android run --type instrumentation --app ${{ env.module_app }}/build/outputs/apk/debug/${{ env.module_app }}-debug.apk --test ${{ env.module_app }}/build/outputs/apk/androidTest/debug/${{ env.module_app }}-debug-androidTest.apk --device model=bluejay,version=32,locale=en,orientation=portrait
70+
gcloud firebase test android run --type instrumentation --app ${{ env.module_app }}/build/outputs/apk/debug/${{ env.module_app }}-debug.apk --test ${{ env.module_app }}/build/outputs/apk/androidTest/debug/${{ env.module_app }}-debug-androidTest.apk --device model=a51,version=31,locale=en,orientation=portrait
71+
gcloud firebase test android run --type instrumentation --app ${{ env.module_app }}/build/outputs/apk/debug/${{ env.module_app }}-debug.apk --test ${{ env.module_app }}/build/outputs/apk/androidTest/debug/${{ env.module_app }}-debug-androidTest.apk --device model=q2q,version=30,locale=en,orientation=portrait
72+
gcloud firebase test android run --type instrumentation --app ${{ env.module_app }}/build/outputs/apk/debug/${{ env.module_app }}-debug.apk --test ${{ env.module_app }}/build/outputs/apk/androidTest/debug/${{ env.module_app }}-debug-androidTest.apk --device model=cactus,version=27,locale=en,orientation=portrait
6173
6274
6375
##########################################

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ Now you can choose (from the server information) whether this inventory should c
5050

5151
### GLPI Android Inventory Agent
5252

53-
|GLPI|9.1|9.2+|9.3+|9.4+|9.5+|10.0+|
54-
|:---|:---:|:---:|:---:|:---:|:---:|:---:|
55-
|**GLPI Android Inventory Agent**|1.0.0|1.0.0|1.0.0|1.0.0|1.1.0|1.3.0|
56-
|**Plugin GLPI Agent Config**|1.0|1.0|1.0|1.0|1.1.0|1.2.0|
53+
|GLPI|9.1|9.2+|9.3+|9.4+|9.5+|10.0+|10.0+|10.0+|
54+
|:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
55+
|**GLPI Android Inventory Agent**|1.0.0|1.0.0|1.0.0|1.0.0|1.1.0|1.3.0|1.4.0|1.5.0|
56+
|**Plugin GLPI Agent Config**|1.0|1.0|1.0|1.0|1.1.0|1.2.0|1.2.1|1.2.1|
5757

5858
### Inventory Agent & Android Versions
5959

60-
GLPI Android Inventory Agent is compatible with Android 4.1 and higher (to Android 13).
60+
GLPI Android Inventory Agent is compatible with Android 5 and higher (to Android 13).
6161

6262
## Installation
6363

app/build.gradle

+5-12
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ apply plugin: 'com.android.application'
22
apply plugin: 'com.google.firebase.crashlytics'
33

44
android {
5-
compileSdkVersion 34
5+
compileSdk 34
66
useLibrary 'org.apache.http.legacy'
77

88
defaultConfig {
99
applicationId "org.glpi.inventory.agent"
1010
minSdkVersion 21
1111
targetSdkVersion 34
12+
1213
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14+
multiDexEnabled true
1315
}
1416

1517
testOptions {
@@ -28,19 +30,10 @@ android {
2830
}
2931
}
3032

31-
dexOptions {
32-
preDexLibraries true
33-
maxProcessCount 8
34-
}
35-
3633
namespace 'org.glpi.inventory.agent'
3734
lint {
3835
abortOnError false
3936
}
40-
41-
defaultConfig {
42-
multiDexEnabled true
43-
}
4437
}
4538

4639
dependencies {
@@ -63,8 +56,8 @@ dependencies {
6356

6457
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
6558

66-
testImplementation 'org.mockito:mockito-core:2.18.3'
67-
androidTestImplementation 'org.mockito:mockito-android:2.18.3'
59+
testImplementation 'org.mockito:mockito-android:5.5.0' // Use the latest version
60+
androidTestImplementation 'org.mockito:mockito-android:5.5.0'
6861

6962
implementation 'androidx.test.espresso:espresso-idling-resource:3.6.1'
7063
implementation fileTree(dir: 'libs', include: ['*.jar'])

app/src/main/AndroidManifest.xml

+10-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
android:versionCode="39403"
5-
android:versionName="">
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:versionCode="39413"
5+
android:versionName="">
66

77
<!-- Permissions -->
8+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
89
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
910
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
1011
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
@@ -30,9 +31,6 @@ android:versionName="">
3031
<!-- Allows changing locales -->
3132
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
3233

33-
<!-- Apps wanting to use foreground services, API 28 higher -->
34-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
35-
3634
<application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:largeHeap="true" android:name="org.glpi.inventory.agent.ui.InventoryAgentApp" android:requestLegacyExternalStorage="true" android:roundIcon="@drawable/ic_launcher_round" android:theme="@style/AppTheme" android:vmSafeMode="true">
3735

3836
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
@@ -56,12 +54,6 @@ android:versionName="">
5654
<activity android:label="@string/app_name" android:name="org.glpi.inventory.agent.preference.GlobalParametersPreference"/>
5755
<activity android:label="@string/app_name" android:launchMode="standard" android:name="org.glpi.inventory.agent.ui.ActivityInventoryReport" android:theme="@style/NoActionBar"/>
5856

59-
<service android:description="@string/agent_description" android:enabled="true" android:exported="true" android:icon="@mipmap/ic_launcher" android:label="Inventory Agent" android:name="org.glpi.inventory.agent.service.InventoryService" tools:ignore="ExportedService">
60-
<intent-filter>
61-
<action android:name="org.glpi.inventory.service"/>
62-
</intent-filter>
63-
</service>
64-
6557
<receiver android:enabled="true" android:exported="true" android:name="org.glpi.inventory.agent.broadcast.BootStartAgent" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
6658
<intent-filter>
6759
<action android:name="android.intent.action.BOOT_COMPLETED"/>
@@ -72,21 +64,19 @@ android:versionName="">
7264
<action android:name="android.intent.action.ACTION_SHUTDOWN"/>
7365
</intent-filter>
7466
</receiver>
75-
<receiver android:exported="true" android:name="org.glpi.inventory.agent.broadcast.TimeAlarm">
76-
<intent-filter>
77-
<action android:name="org.glpi.inventory.agent.ALARM"/>
78-
</intent-filter>
79-
</receiver>
67+
68+
<service android:name=".broadcast.InventoryJobScheduler"
69+
android:enabled="true"
70+
android:exported="false"
71+
android:permission="android.permission.BIND_JOB_SERVICE"/>
8072

8173
<activity android:name="org.glpi.inventory.agent.ui.PermissionActivity"/>
8274
<activity android:name="org.glpi.inventory.agent.ui.ActivityListServers"/>
8375
<activity android:exported="true" android:name="org.glpi.inventory.agent.ui.ActivityDetailServer">
8476
<intent-filter>
8577
<action android:name="android.intent.action.VIEW"/>
86-
8778
<category android:name="android.intent.category.DEFAULT"/>
8879
<category android:name="android.intent.category.BROWSABLE"/>
89-
9080
<data android:host="glpi-project.github.io" android:pathPrefix="/android-inventory-agent/deeplink"/>
9181
<data android:scheme="http"/>
9282
<data android:scheme="https"/>
@@ -96,4 +86,4 @@ android:versionName="">
9686
<activity android:name="org.glpi.inventory.agent.ui.ActivityCategories"/>
9787
</application>
9888

99-
</manifest>
89+
</manifest>

app/src/main/java/org/glpi/inventory/agent/broadcast/BootStartAgent.java

+4-41
Original file line numberDiff line numberDiff line change
@@ -38,53 +38,16 @@
3838
import android.content.BroadcastReceiver;
3939
import android.content.Context;
4040
import android.content.Intent;
41-
import android.content.SharedPreferences;
42-
import android.os.Build;
43-
import android.preference.PreferenceManager;
44-
import android.widget.Toast;
45-
46-
import org.flyve.inventory.InventoryLog;
47-
import org.glpi.inventory.agent.service.InventoryService;
4841
import org.glpi.inventory.agent.ui.ActivityMain;
49-
import org.glpi.inventory.agent.utils.AgentLog;
5042

5143
public class BootStartAgent extends BroadcastReceiver {
5244

53-
TimeAlarm alarm = new TimeAlarm();
54-
55-
/**
56-
* It sets an alarm after the user has finished booting
57-
* @param context in which the receiver is running
58-
* @param intent being received
59-
*/
6045
@Override
6146
public void onReceive(Context context, Intent intent) {
62-
63-
String action = intent.getAction();
64-
if(action==null) {
65-
return;
47+
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
48+
Intent activityIntent = new Intent(context, ActivityMain.class);
49+
activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
50+
context.startActivity(activityIntent);
6651
}
67-
68-
SharedPreferences customSharedPreference = PreferenceManager.getDefaultSharedPreferences(context);
69-
if (customSharedPreference.getBoolean("boot", false)) {
70-
try {
71-
72-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
73-
Intent myIntent = new Intent(context, InventoryService.class);
74-
context.startForegroundService(myIntent);
75-
} else {
76-
Intent myIntent = new Intent(context, ActivityMain.class);
77-
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
78-
context.startActivity(myIntent);
79-
}
80-
}catch(Exception ex) {
81-
Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
82-
}
83-
}
84-
85-
if(customSharedPreference.getBoolean("autoStartInventory", false)){
86-
alarm.setAlarm(context);
87-
}
88-
8952
}
9053
}

0 commit comments

Comments
 (0)