Skip to content

Commit

Permalink
Merge pull request #159 from prey/huawei
Browse files Browse the repository at this point in the history
supports Android 12 and handle some rules for Huawei and chromebook devices
  • Loading branch information
patriciojofre authored Aug 19, 2021
2 parents 98a563a + 544cfc0 commit b4d8abf
Show file tree
Hide file tree
Showing 20 changed files with 170 additions and 67 deletions.
18 changes: 9 additions & 9 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 30
compileSdkVersion 31

defaultConfig {
applicationId "com.prey"
minSdkVersion 21

targetSdkVersion 30
targetSdkVersion 31

versionCode 250
versionName '2.3.7'
versionCode 252
versionName '2.3.8'

multiDexEnabled true
}
Expand All @@ -38,10 +38,10 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'

implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
Expand All @@ -51,8 +51,8 @@ dependencies {
implementation 'com.google.firebase:firebase-iid:21.1.0'
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation 'com.google.firebase:firebase-analytics:19.0.0'
implementation 'com.google.firebase:firebase-crashlytics:18.1.0'
implementation 'com.google.firebase:firebase-database:20.0.0'
implementation 'com.google.firebase:firebase-crashlytics:18.2.1'
implementation 'com.google.firebase:firebase-database:20.0.1'

implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'com.android.support:multidex:1.0.3'
Expand Down
41 changes: 34 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />

<!-- Exported added for android 12 -->
<activity
android:name="com.prey.activities.LoginActivity"
android:clearTaskOnLaunch="true"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleInstance"
android:noHistory="true"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -191,6 +193,16 @@
android:windowSoftInputMode="stateHidden|adjustResize"
android:configChanges="keyboardHidden|orientation"
/>

<!-- New Activity for Chromebook -->
<activity
android:name="com.prey.activities.ChromeActivity"
android:launchMode="singleTask"
android:noHistory="true"
android:windowSoftInputMode="stateHidden|adjustResize"
android:configChanges="keyboardHidden|orientation"
/>

<activity
android:name="com.prey.activities.PreyConfigurationActivity"
android:configChanges="orientation|keyboardHidden"
Expand Down Expand Up @@ -259,21 +271,21 @@
android:configChanges="keyboardHidden|orientation"
/>

<!-- Exported added for android 12 -->
<receiver
android:name="com.prey.receivers.PreyBootController"
android:enabled="true"
android:exported="false"
android:exported="true"
android:label="PreyBootController" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>


<!-- Exported added for android 12 -->
<receiver
android:name="com.prey.events.receivers.EventReceiver"


android:exported="true"
>
<intent-filter android:priority="20000">

Expand Down Expand Up @@ -331,9 +343,11 @@
</intent-filter>
</receiver>

<!-- Exported added for android 12 -->
<receiver
android:name="com.prey.receivers.PreyDeviceAdmin"
android:label="@string/device_admin_label"
android:exported="true"
android:permission="android.permission.BIND_DEVICE_ADMIN" >
<meta-data
android:name="android.app.device_admin"
Expand Down Expand Up @@ -373,7 +387,11 @@

<receiver android:name="com.prey.receivers.AlarmDisablePowerReceiver" />

<receiver android:name="com.prey.receivers.PreyDisablePowerOptionsReceiver" android:enabled="true" android:exported="false">
<!-- Exported added for android 12 -->
<receiver
android:name="com.prey.receivers.PreyDisablePowerOptionsReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter android:priority="20000">
<action android:name="android.intent.action.CLOSE_SYSTEM_DIALOGS" />
<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -382,9 +400,11 @@
<service android:name="com.prey.services.PreyDisablePowerOptionsService" />
<service android:name="com.prey.services.PreySecureService" />

<!-- Exported added for android 12 -->
<!-- [START firebase_service] -->
<service
android:name="com.prey.services.MyFirebaseMessagingService">
android:name="com.prey.services.MyFirebaseMessagingService"
android:exported="true" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
Expand All @@ -408,7 +428,14 @@
android:exported="true"/>

<service android:name="com.prey.services.PreyAccessibilityService" />
<service android:name="com.prey.services.AppAccessibilityService" android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" android:enabled="true">

<!-- Exported added for android 12 -->
<service
android:name="com.prey.services.AppAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:enabled="true"
android:exported="true"
>
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService"/>
</intent-filter>
Expand Down
10 changes: 5 additions & 5 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.104a486e.chunk.css",
"main.js": "./static/js/main.38f962d2.chunk.js",
"main.js.map": "./static/js/main.38f962d2.chunk.js.map",
"main.js": "./static/js/main.c1aa6443.chunk.js",
"main.js.map": "./static/js/main.c1aa6443.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.637a8e7e.chunk.js": "./static/js/2.637a8e7e.chunk.js",
"static/js/2.637a8e7e.chunk.js.map": "./static/js/2.637a8e7e.chunk.js.map",
"static/js/2.2267c831.chunk.js": "./static/js/2.2267c831.chunk.js",
"static/js/2.2267c831.chunk.js.map": "./static/js/2.2267c831.chunk.js.map",
"index.html": "./index.html",
"precache-manifest.c88b1c09787536be796a85467f1faad6.js": "./precache-manifest.c88b1c09787536be796a85467f1faad6.js",
"precache-manifest.cfb08de85f5f04ee1fdfea628292fe48.js": "./precache-manifest.cfb08de85f5f04ee1fdfea628292fe48.js",
"service-worker.js": "./service-worker.js",
"static/css/main.104a486e.chunk.css.map": "./static/css/main.104a486e.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.104a486e.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.637a8e7e.chunk.js"></script><script src="./static/js/main.38f962d2.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.104a486e.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.2267c831.chunk.js"></script><script src="./static/js/main.c1aa6443.chunk.js"></script></body></html>
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
self.__precacheManifest = [
{
"revision": "38f962d28fbd679b1e1c",
"revision": "c1aa6443cdff76c5b77d",
"url": "./static/css/main.104a486e.chunk.css"
},
{
"revision": "38f962d28fbd679b1e1c",
"url": "./static/js/main.38f962d2.chunk.js"
"revision": "c1aa6443cdff76c5b77d",
"url": "./static/js/main.c1aa6443.chunk.js"
},
{
"revision": "8c97409f0ee389fe75da",
"url": "./static/js/runtime~main.8c97409f.js"
},
{
"revision": "637a8e7e2ac2a5e42bef",
"url": "./static/js/2.637a8e7e.chunk.js"
"revision": "2267c83143f3a43e6852",
"url": "./static/js/2.2267c831.chunk.js"
},
{
"revision": "c3679e2d8686db6f8013ffe2ad603c2c",
"url": "./static/media/prey-logo-monotono-alt.c3679e2d.svg"
},
{
"revision": "6e26bdc9c9316e31084263223a3aa74e",
"url": "./static/media/missing-report.6e26bdc9.png"
},
{
"revision": "ce31486d2c6e0b6d55bbf5dbf26992f0",
"url": "./static/media/prey-iso-monotono-alt.ce31486d.svg"
},
{
"revision": "6e26bdc9c9316e31084263223a3aa74e",
"url": "./static/media/missing-report.6e26bdc9.png"
},
{
"revision": "6dd5ae67bb0dc9ae0c9886ef62c28dca",
"url": "./static/media/04-Evidencev.6dd5ae67.png"
Expand Down Expand Up @@ -124,19 +124,19 @@ self.__precacheManifest = [
"url": "./static/media/regular-book-webfont.6e899114.woff"
},
{
"revision": "391159c582e0897e8d64ed22abe1ee2d",
"url": "./static/media/regular-bold-webfont.391159c5.woff"
"revision": "c44603b2b93c1b7a984f21255d556ee9",
"url": "./static/media/magdaclean-regular-webfont.c44603b2.woff"
},
{
"revision": "baaac74770efd8c34382afa00468f635",
"url": "./static/media/magdaclean-bold-webfont.baaac747.woff"
},
{
"revision": "c44603b2b93c1b7a984f21255d556ee9",
"url": "./static/media/magdaclean-regular-webfont.c44603b2.woff"
"revision": "391159c582e0897e8d64ed22abe1ee2d",
"url": "./static/media/regular-bold-webfont.391159c5.woff"
},
{
"revision": "45ced7ded14ae220febed2c0e161271e",
"revision": "9345119d8e4a20c097de732164495ca4",
"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.c88b1c09787536be796a85467f1faad6.js"
"./precache-manifest.cfb08de85f5f04ee1fdfea628292fe48.js"
);

workbox.clientsClaim();
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/main/assets/html/static/js/2.2267c831.chunk.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion app/src/main/assets/html/static/js/2.637a8e7e.chunk.js.map

This file was deleted.

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

This file was deleted.

This file was deleted.

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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

28 changes: 11 additions & 17 deletions app/src/main/java/com/prey/PreyPermission.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@
******************************************************************************/
package com.prey;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ServiceInfo;
import android.os.Build;
import android.provider.Settings;
import android.view.accessibility.AccessibilityManager;

import androidx.core.app.ActivityCompat;
import androidx.core.content.PermissionChecker;

import java.util.List;

public class PreyPermission {

public static final String ACCESS_BACKGROUND_LOCATION = "android.permission.ACCESS_BACKGROUND_LOCATION";
Expand Down Expand Up @@ -108,19 +103,18 @@ public static boolean checkBiometricSupport(Context ctx) {
return false;
}

/**
* Method to obtain if accessibility service is enabled
* @param context
* @return true if accessibility service enabled, false otherwise
*/
public static boolean isAccessibilityServiceEnabled(Context context) {
AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
List<AccessibilityServiceInfo> accessibilityServices =
am.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
for (AccessibilityServiceInfo info : accessibilityServices) {
PreyLogger.d("id:"+info.getId()+" st:"+info.toString());
ServiceInfo enabledServiceInfo = info.getResolveInfo().serviceInfo;
if (info.getId().indexOf("com.prey")>=0){
PreyLogger.d("id:__"+info.getId()+" st:"+info.toString());
return true;
}
}
return false;
String settingValue = Settings.Secure.getString(
context.getApplicationContext().getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (settingValue == null)
return false;
return settingValue.indexOf("prey") > 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public void run(final Context ctx) {
builder.addGeofences(mGeofenceList);
GeofencingRequest geofencingRequest = builder.build();
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M || ActivityCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(ctx, 0, new Intent(ctx, AwareGeofenceReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
//Added for android 12
PendingIntent pendingIntent = PendingIntent.getBroadcast(ctx, 0, new Intent(ctx, AwareGeofenceReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
LocationServices.getGeofencingClient(ctx).addGeofences(geofencingRequest, pendingIntent)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
Expand Down
68 changes: 68 additions & 0 deletions app/src/main/java/com/prey/activities/ChromeActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*******************************************************************************
* Created by Orlando Aliaga
* Copyright 2021 Prey Inc. All rights reserved.
* License: GPLv3
* Full license at "/LICENSE"
******************************************************************************/
package com.prey.activities;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.webkit.WebSettings;
import android.webkit.WebView;

import androidx.appcompat.app.AppCompatActivity;

import com.prey.PreyLogger;
import com.prey.PreyUtils;
import com.prey.R;

/****
* This activity shows the html view for Chromebook
*/
public class ChromeActivity extends AppCompatActivity {

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreyLogger.d("ChromeActivity: onCreate");
try {
getSupportActionBar().hide();
}catch (Exception e){
PreyLogger.e("Error ActionBar().hide",e);
}
setContentView(R.layout.webview);
}

@Override
protected void onResume() {
super.onResume();
PreyLogger.d("ChromeActivity: onResume");
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
}
String lng = PreyUtils.getLanguage();
String url = CheckPasswordHtmlActivity.URL_ONB + "#/" + lng + "/chrome";
WebView myWebView = (WebView) findViewById(R.id.install_browser);
WebSettings settings = myWebView.getSettings();
myWebView.setBackgroundColor(0x00000000);
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setLoadsImagesAutomatically(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
myWebView.loadUrl(url);
myWebView.loadUrl("javascript:window.location.reload(true)");
}

protected void onDestroy() {
super.onDestroy();
PreyLogger.d("ChromeActivity: onDestroy");
}

}
Loading

0 comments on commit b4d8abf

Please sign in to comment.