Skip to content

Commit

Permalink
Fix(core): Fix androdi 14 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz committed Sep 24, 2024
1 parent 3853012 commit 08839c0
Show file tree
Hide file tree
Showing 11 changed files with 579 additions and 763 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

# Run Instrumentation Tests in Firebase Test Lab
- 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=akita,version=34,locale=en,orientation=portrait


##########################################
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'

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

defaultConfig {
Expand Down
39 changes: 27 additions & 12 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="39401"
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 @@ -20,6 +21,17 @@ android:versionName="">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
<uses-permission android:name="android.permission.NFC"/>

<uses-permission android:name="android.permission.TRANSMIT_IR"/>
<uses-permission android:name="android.permission.UWB_RANGING"/>

<!-- Allows for QR COde scanner -->
<uses-permission android:name="android.permission.VIBRATE"/>

Expand All @@ -31,6 +43,9 @@ android:versionName="">
<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_DATA_SYNC" android:minSdkVersion="34"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" android:minSdkVersion="34"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" android:minSdkVersion="34"/>
<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">
Expand All @@ -56,12 +71,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,11 +81,17 @@ 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">
<!--<receiver android:exported="true" android:name="org.glpi.inventory.agent.broadcast.InventoryJobScheduler">
<intent-filter>
<action android:name="org.glpi.inventory.agent.ALARM"/>
</intent-filter>
</receiver>
</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"/>
Expand All @@ -96,4 +111,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

0 comments on commit 08839c0

Please sign in to comment.