Skip to content

Commit

Permalink
Merge pull request #188 from prey/feat/android34
Browse files Browse the repository at this point in the history
Feat/android34
  • Loading branch information
oaliaga authored Jun 12, 2024
2 parents 9af00ec + 1433180 commit 43ca1b7
Show file tree
Hide file tree
Showing 38 changed files with 459 additions and 308 deletions.
5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ apply plugin: 'com.google.firebase.crashlytics'

android {

compileSdkVersion 33
compileSdkVersion 34

defaultConfig {
applicationId "com.prey"
minSdkVersion 21

targetSdkVersion 33
targetSdkVersion 34

versionCode 328
versionName '2.5.3'
versionCode 341
versionName '2.6.1'

multiDexEnabled true

Expand All @@ -28,8 +28,8 @@ android {
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
lint {
abortOnError false
Expand All @@ -41,25 +41,25 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.android.gms:play-services-location:21.3.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation 'com.google.firebase:firebase-iid:21.1.0'
implementation 'com.google.firebase:firebase-messaging:23.2.1'
implementation 'com.google.firebase:firebase-analytics:21.3.0'
implementation 'com.google.firebase:firebase-crashlytics:18.4.1'
implementation 'com.google.firebase:firebase-database:20.2.2'
implementation 'com.google.firebase:firebase-messaging:24.0.0'
implementation 'com.google.firebase:firebase-analytics:22.0.1'
implementation 'com.google.firebase:firebase-crashlytics:19.0.1'
implementation 'com.google.firebase:firebase-database:21.0.0'

implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.code.gson:gson:2.10'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'androidx.biometric:biometric:1.2.0-alpha05'

testImplementation 'junit:junit:4.13.2'
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACTION_SHUTDOWN" />

<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM"/>

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

Expand Down Expand Up @@ -341,7 +343,9 @@
</receiver>

<receiver android:name="com.prey.receivers.AlarmReportReceiver" />
<receiver android:name="com.prey.actions.aware.AlarmAwareReceiver" />
<receiver android:name="com.prey.receivers.AlarmScheduledReceiver" />
<receiver android:name="com.prey.actions.location.daily.AlarmLocationReceiver" />

<receiver
android:name="com.prey.receivers.GeofenceReceiver"
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/assets/html/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"main.css": "./static/css/main.cb793387.chunk.css",
"main.js": "./static/js/main.4a2fa15e.chunk.js",
"main.js.map": "./static/js/main.4a2fa15e.chunk.js.map",
"main.js": "./static/js/main.85382003.chunk.js",
"main.js.map": "./static/js/main.85382003.chunk.js.map",
"runtime~main.js": "./static/js/runtime~main.8c97409f.js",
"runtime~main.js.map": "./static/js/runtime~main.8c97409f.js.map",
"static/js/2.63e74b66.chunk.js": "./static/js/2.63e74b66.chunk.js",
"static/js/2.63e74b66.chunk.js.map": "./static/js/2.63e74b66.chunk.js.map",
"index.html": "./index.html",
"precache-manifest.d9eeb8c0b21dd2973bbf31b8e4e7ecde.js": "./precache-manifest.d9eeb8c0b21dd2973bbf31b8e4e7ecde.js",
"precache-manifest.315520fcb252ed277b43f7d570f1f309.js": "./precache-manifest.315520fcb252ed277b43f7d570f1f309.js",
"service-worker.js": "./service-worker.js",
"static/css/main.cb793387.chunk.css.map": "./static/css/main.cb793387.chunk.css.map",
"static/media/02-Track-Find.png": "./static/media/02-Track-Find.ed00c298.png",
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/html/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><link rel="shortcut icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><title>Prey Client</title><link href="./static/css/main.cb793387.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={1:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="./";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="./static/js/2.63e74b66.chunk.js"></script><script src="./static/js/main.4a2fa15e.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><link rel="shortcut icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><title>Prey Client</title><link href="./static/css/main.cb793387.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={1:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="./";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="./static/js/2.63e74b66.chunk.js"></script><script src="./static/js/main.85382003.chunk.js"></script></body></html>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
self.__precacheManifest = [
{
"revision": "4a2fa15eca1644f5ec42",
"revision": "8538200376f4f098bcea",
"url": "./static/css/main.cb793387.chunk.css"
},
{
"revision": "4a2fa15eca1644f5ec42",
"url": "./static/js/main.4a2fa15e.chunk.js"
"revision": "8538200376f4f098bcea",
"url": "./static/js/main.85382003.chunk.js"
},
{
"revision": "8c97409f0ee389fe75da",
Expand Down Expand Up @@ -123,20 +123,20 @@ self.__precacheManifest = [
"revision": "391159c582e0897e8d64ed22abe1ee2d",
"url": "./static/media/regular-bold-webfont.391159c5.woff"
},
{
"revision": "6e8991140fc75b4927e2c440d9036429",
"url": "./static/media/regular-book-webfont.6e899114.woff"
},
{
"revision": "c44603b2b93c1b7a984f21255d556ee9",
"url": "./static/media/magdaclean-regular-webfont.c44603b2.woff"
},
{
"revision": "6e8991140fc75b4927e2c440d9036429",
"url": "./static/media/regular-book-webfont.6e899114.woff"
},
{
"revision": "baaac74770efd8c34382afa00468f635",
"url": "./static/media/magdaclean-bold-webfont.baaac747.woff"
},
{
"revision": "b6f91dd5a265cfd9c9209d7eefbaeb33",
"revision": "dbdf31c0b2373245be6b450ca3c944f1",
"url": "./index.html"
}
];
2 changes: 1 addition & 1 deletion app/src/main/assets/html/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");

importScripts(
"./precache-manifest.d9eeb8c0b21dd2973bbf31b8e4e7ecde.js"
"./precache-manifest.315520fcb252ed277b43f7d570f1f309.js"
);

workbox.clientsClaim();
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/assets/html/static/js/main.4a2fa15e.chunk.js

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions app/src/main/assets/html/static/js/main.85382003.chunk.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions app/src/main/java/com/prey/PreyApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
import com.google.firebase.FirebaseApp;

import com.prey.actions.aware.AwareController;
import com.prey.actions.aware.AwareScheduled;
import com.prey.actions.fileretrieval.FileretrievalController;
import com.prey.actions.geofences.GeofenceController;
import com.prey.actions.location.daily.LocationScheduled;
import com.prey.actions.report.ReportScheduled;
import com.prey.actions.report.ReportService;
import com.prey.actions.triggers.TriggerController;
import com.prey.activities.LoginActivity;
import com.prey.beta.actions.PreyBetaController;
Expand Down Expand Up @@ -111,12 +114,15 @@ public void run() {
if ((accessCoarseLocation || accessFineLocation) && canAccessBackgroundLocation) {
GeofenceController.getInstance().run(ctx);
AwareController.getInstance().init(ctx);
AwareScheduled.getInstance(ctx).run();
LocationScheduled.getInstance().run(ctx);
}
FileretrievalController.getInstance().run(ctx);
TriggerController.getInstance().run(ctx);
if (missing) {
if (PreyConfig.getPreyConfig(ctx).getIntervalReport() != null && !"".equals(PreyConfig.getPreyConfig(ctx).getIntervalReport())) {
ReportScheduled.getInstance(ctx).run();
new ReportService().run(ctx);
}
}
if (!PreyConfig.getPreyConfig(ctx).isChromebook()) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/prey/PreyBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String getToken() {
* Method returns if it has apikey batch
* @return
*/
public static boolean isThereBatchInstallationKey(Context ctx) {
public boolean isThereBatchInstallationKey() {
String apiKeyBatch = _instance.getApiKeyBatch();
return (apiKeyBatch != null && !"".equals(apiKeyBatch));
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/com/prey/PreyConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1610,4 +1610,15 @@ public void setDenyNotification(boolean denyNotification) {
public boolean getDenyNotification() {
return getBoolean(PreyConfig.DENY_NOTIFICATION, false);
}

public static final String DAILY_LOCATION = "DAILY_LOCATION";

public String getDailyLocation(){
return getString(PreyConfig.DAILY_LOCATION, "");
}

public void setDailyLocation(String dailyLocation){
PreyLogger.d(String.format("DAILY setDailyLocation [%s]", dailyLocation));
saveString(PreyConfig.DAILY_LOCATION, dailyLocation);
}
}
18 changes: 17 additions & 1 deletion app/src/main/java/com/prey/PreyPermission.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.prey;

import android.app.Activity;
import android.app.AlarmManager;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
Expand Down Expand Up @@ -134,7 +135,7 @@ public static boolean isAccessibilityServiceEnabled(Context context) {
* @return true if accessibility method should request it, false otherwise
*/
public static boolean isAccessibilityServiceView(Context ctx) {
boolean isThereBatchInstallationKey = PreyBatch.isThereBatchInstallationKey(ctx);
boolean isThereBatchInstallationKey = PreyBatch.getInstance(ctx).isThereBatchInstallationKey();
//If it is batch, do not request accessibility
if (isThereBatchInstallationKey) {
return isThereBatchInstallationKey;
Expand Down Expand Up @@ -202,4 +203,19 @@ public static boolean canAccessBackgroundLocationView(Context ctx) {
public static boolean areNotificationsEnabled(Context context){
return NotificationManagerCompat.from(context).areNotificationsEnabled();
}

/**
* Method that validates whether exact alarms can be programmed
*
* @param ctx context
* @return true if the caller can schedule exact alarms, false otherwise.
*/
public static boolean canScheduleExactAlarms(Context ctx){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
AlarmManager alarmMgr = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
return alarmMgr.canScheduleExactAlarms();
} else {
return true;
}
}
}
33 changes: 33 additions & 0 deletions app/src/main/java/com/prey/actions/aware/AlarmAwareReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* Created by Orlando Aliaga
* Copyright 2024 Prey Inc. All rights reserved.
* License: GPLv3
* Full license at "/LICENSE"
******************************************************************************/
package com.prey.actions.aware;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.prey.PreyLogger;

public class AlarmAwareReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
try {
PreyLogger.d("______________________________");
PreyLogger.d("______________________________");
PreyLogger.d("----------AlarmAwareReceiver onReceive");
final Context ctx = context;
new Thread() {
public void run() {
new AwareController().init(ctx);
}
}.start();
} catch (Exception e) {
PreyLogger.e(String.format("AlarmAwareReceiver error:%s", e.getMessage()), e);
}
}
}
62 changes: 62 additions & 0 deletions app/src/main/java/com/prey/actions/aware/AwareScheduled.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*******************************************************************************
* Created by Orlando Aliaga
* Copyright 2024 Prey Inc. All rights reserved.
* License: GPLv3
* Full license at "/LICENSE"
******************************************************************************/
package com.prey.actions.aware;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.prey.PreyLogger;

public class AwareScheduled {

private static AwareScheduled instance = null;
private Context context = null;
private AlarmManager alarmMgr = null;
private PendingIntent pendingIntent = null;

private AwareScheduled(Context context) {
this.context = context;
}

public synchronized static AwareScheduled getInstance(Context context) {
if (instance == null) {
instance = new AwareScheduled(context);
}
return instance;
}

public void run() {
try {
int minute = 15;
Intent intent = new Intent(context, AlarmAwareReceiver.class);
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
PreyLogger.d("----------setRepeating");
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 60 * minute, pendingIntent);
} else {
PreyLogger.d("----------setInexactRepeating");
alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 60 * minute, pendingIntent);
}
PreyLogger.d(String.format("----------start aware [%s] AwareScheduled", minute));
} catch (Exception e) {
PreyLogger.e(String.format("----------Error AwareScheduled :%s", e.getMessage()), e);
}
}

public void reset() {
if (alarmMgr != null) {
try {
alarmMgr.cancel(pendingIntent);
} catch (Exception e) {
PreyLogger.d(String.format("----------Error AwareScheduled :%s", e.getMessage()));
}
}
}
}
Loading

0 comments on commit 43ca1b7

Please sign in to comment.