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

Fix(core): Android 14 compatibility #407

Merged
merged 1 commit into from
Oct 29, 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
14 changes: 13 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,20 @@ jobs:
run: gcloud config set project ${{ secrets.FIREBASE_PROJECT_ID }}

# Run Instrumentation Tests in Firebase Test Lab
# dm3q Samasung galaxy s23 SDK 33
# e1q Samasung galaxy s24 SDK 34
# bluejay Google Pixel 6a SDK 32
# a51 Samsung Galaxy A51 SDK 31
# q2q Samsung Galaxy Z Fold3 SDK 30
# cactus Xiaomi Redmi 6A SDK 27
- name: Run Instrumentation Tests in Firebase Test Lab
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
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=e1q,version=34,locale=en,orientation=portrait
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
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
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
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
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


##########################################
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ Now you can choose (from the server information) whether this inventory should c

### GLPI Android Inventory Agent

|GLPI|9.1|9.2+|9.3+|9.4+|9.5+|10.0+|
|:---|:---:|:---:|:---:|:---:|:---:|:---:|
|**GLPI Android Inventory Agent**|1.0.0|1.0.0|1.0.0|1.0.0|1.1.0|1.3.0|
|**Plugin GLPI Agent Config**|1.0|1.0|1.0|1.0|1.1.0|1.2.0|
|GLPI|9.1|9.2+|9.3+|9.4+|9.5+|10.0+|10.0+|10.0+|
|:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|**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|
|**Plugin GLPI Agent Config**|1.0|1.0|1.0|1.0|1.1.0|1.2.0|1.2.1|1.2.1|

### Inventory Agent & Android Versions

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

## Installation

Expand Down
17 changes: 5 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 34
compileSdk 34
useLibrary 'org.apache.http.legacy'

defaultConfig {
applicationId "org.glpi.inventory.agent"
minSdkVersion 21
targetSdkVersion 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}

testOptions {
Expand All @@ -28,19 +30,10 @@ android {
}
}

dexOptions {
preDexLibraries true
maxProcessCount 8
}

namespace 'org.glpi.inventory.agent'
lint {
abortOnError false
}

defaultConfig {
multiDexEnabled true
}
}

dependencies {
Expand All @@ -63,8 +56,8 @@ dependencies {

androidTestImplementation 'tools.fastlane:screengrab:2.1.1'

testImplementation 'org.mockito:mockito-core:2.18.3'
androidTestImplementation 'org.mockito:mockito-android:2.18.3'
testImplementation 'org.mockito:mockito-android:5.5.0' // Use the latest version
androidTestImplementation 'org.mockito:mockito-android:5.5.0'

implementation 'androidx.test.espresso:espresso-idling-resource:3.6.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
Expand Down
30 changes: 10 additions & 20 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="39403"
android:versionName="">
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="39413"
android:versionName="">

<!-- Permissions -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
Expand All @@ -30,9 +31,6 @@ android:versionName="">
<!-- Allows changing locales -->
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>

<!-- Apps wanting to use foreground services, API 28 higher -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

<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">

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

<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">
<intent-filter>
<action android:name="org.glpi.inventory.service"/>
</intent-filter>
</service>

<receiver android:enabled="true" android:exported="true" android:name="org.glpi.inventory.agent.broadcast.BootStartAgent" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
Expand All @@ -72,21 +64,19 @@ android:versionName="">
<action android:name="android.intent.action.ACTION_SHUTDOWN"/>
</intent-filter>
</receiver>
<receiver android:exported="true" android:name="org.glpi.inventory.agent.broadcast.TimeAlarm">
<intent-filter>
<action android:name="org.glpi.inventory.agent.ALARM"/>
</intent-filter>
</receiver>

<service android:name=".broadcast.InventoryJobScheduler"
android:enabled="true"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"/>

<activity android:name="org.glpi.inventory.agent.ui.PermissionActivity"/>
<activity android:name="org.glpi.inventory.agent.ui.ActivityListServers"/>
<activity android:exported="true" android:name="org.glpi.inventory.agent.ui.ActivityDetailServer">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>

<data android:host="glpi-project.github.io" android:pathPrefix="/android-inventory-agent/deeplink"/>
<data android:scheme="http"/>
<data android:scheme="https"/>
Expand All @@ -96,4 +86,4 @@ android:versionName="">
<activity android:name="org.glpi.inventory.agent.ui.ActivityCategories"/>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -38,53 +38,16 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import android.widget.Toast;

import org.flyve.inventory.InventoryLog;
import org.glpi.inventory.agent.service.InventoryService;
import org.glpi.inventory.agent.ui.ActivityMain;
import org.glpi.inventory.agent.utils.AgentLog;

public class BootStartAgent extends BroadcastReceiver {

TimeAlarm alarm = new TimeAlarm();

/**
* It sets an alarm after the user has finished booting
* @param context in which the receiver is running
* @param intent being received
*/
@Override
public void onReceive(Context context, Intent intent) {

String action = intent.getAction();
if(action==null) {
return;
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent activityIntent = new Intent(context, ActivityMain.class);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(activityIntent);
}

SharedPreferences customSharedPreference = PreferenceManager.getDefaultSharedPreferences(context);
if (customSharedPreference.getBoolean("boot", false)) {
try {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent myIntent = new Intent(context, InventoryService.class);
context.startForegroundService(myIntent);
} else {
Intent myIntent = new Intent(context, ActivityMain.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
}
}catch(Exception ex) {
Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
}
}

if(customSharedPreference.getBoolean("autoStartInventory", false)){
alarm.setAlarm(context);
}

}
}
Loading