Skip to content

Commit

Permalink
v2.19
Browse files Browse the repository at this point in the history
Fix problem with recent Android versions
Migrate to Kalman filter for RSSI
Migrate to WayToday and GPS SKDs
  • Loading branch information
dsame committed Jun 13, 2024
1 parent 66190a5 commit a21bad0
Show file tree
Hide file tree
Showing 30 changed files with 1,009 additions and 251 deletions.
16 changes: 13 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
id 'com.google.firebase.crashlytics'
id 'com.google.gms.google-services'
}

Properties properties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
Expand All @@ -16,7 +20,7 @@ android {

defaultConfig {
applicationId "s4y.itag"
minSdkVersion 23 // due to mad-location-manager
minSdkVersion 23
targetSdkVersion 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "WAYTODAY_SECRET", "\"${System.getenv('WAYTODAY_SECRET') ?: properties.getProperty('waytoday.secret')}\""
Expand Down Expand Up @@ -58,7 +62,13 @@ dependencies {
implementation project(':itagble')
implementation "androidx.preference:preference:1.2.1"
implementation "com.github.s4ysolutions:rasat-android:1.0.5"
implementation "com.github.s4ysolutions:WayTodaySDK-Android:1.0.36"

implementation(platform("com.google.firebase:firebase-bom:33.1.0"))
implementation("com.google.firebase:firebase-crashlytics")
implementation("com.google.firebase:firebase-analytics")

// implementation "solutions.s4y.gps:gps-sdk-android:1.0.0-dev.7"
implementation 'com.github.s4ysolutions:WayTodaySDK-Android:3.0.0-alpha1'

/*
testImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
38 changes: 23 additions & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="s4y.itag"
android:versionCode="145"
android:versionName="2.18">
android:versionCode="153"
android:versionName="2.19.0">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- this is needed to open BT Settings activity-->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission
android:name="com.google.android.gms.permission.AD_ID"
tools:node="remove" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />


<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
Expand All @@ -26,24 +32,26 @@

<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="false"
android:name=".ITagApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/AppTheme">
android:theme="@style/Theme.AppCompat.Light">
<meta-data
android:name="firebase_analytics_collection_deactivated"
android:value="${analytics_deactivated}" />
<activity android:name=".MainActivity" android:exported="true">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true"
tools:targetApi="m">
<intent-filter android:autoVerify="true" >
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -58,9 +66,9 @@

<service
android:name=".ITagsService"
android:foregroundServiceType="location"
android:enabled="true"
android:exported="false" />
android:exported="false"
android:foregroundServiceType="connectedDevice" />
<receiver
android:name=".BootReceiver"
android:enabled="true"
Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/s4y/itag/BootReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

import androidx.annotation.NonNull;

import s4y.gps.sdk.android.GPSUpdatesForegroundService;
import s4y.itag.itag.ITagsStoreDefault;
import s4y.itag.itag.ITagsStoreInterface;
import s4y.itag.waytoday.Waytoday;
import s4y.itag.waytoday.WayToday;
import solutions.s4y.waytoday.sdk.AndroidWayTodayClient;

public class BootReceiver extends BroadcastReceiver {

Expand All @@ -20,8 +22,14 @@ public void onReceive(@NonNull Context context, @NonNull Intent intent) {
"android.intent.action.QUICKBOOT_POWERON".equals(intent.getAction())
) {
ITagsStoreInterface store = new ITagsStoreDefault(ITagApplication.context);
if (store.isDisconnectAlert() || Waytoday.tracker.isOn(context)) {
ITagsService.start(context); // expected to create application and thus start waytooday
if (store.isDisconnectAlert()) {
ITagsService.start(context);
// expected to create application and thus init waytooday
// and enter foreground
} else if (AndroidWayTodayClient.isTrackingOn(context)) {
// expected to create application and thus init waytooday
// and enter foreground
GPSUpdatesForegroundService.start(context);
}
}
}
Expand Down
46 changes: 30 additions & 16 deletions app/src/main/java/s4y/itag/ITagApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

import androidx.annotation.NonNull;

import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.crashlytics.FirebaseCrashlytics;

import s4y.gps.sdk.android.GPSPermissionManager;
import s4y.gps.sdk.android.GPSUpdatesForegroundService;
import s4y.itag.itag.ITag;
import s4y.itag.waytoday.Waytoday;
import s4y.itag.waytoday.WayToday;

public final class ITagApplication extends Application {
private final static String LT = ITagApplication.class.getName();
Expand All @@ -33,13 +38,13 @@ static public void handleError(@NonNull Throwable th, boolean toast) {
new Handler(Looper.getMainLooper()).post(() -> {
if (context == null) {
Log.e(LT, "Attempt to handle error before application created", th);
// FirebaseCrashlytics.getInstance().recordException(th);
FirebaseCrashlytics.getInstance().recordException(th);
} else {
Log.e(LT, "Toasted", th);
if (toast) {
Toast.makeText(context, th.getMessage(), Toast.LENGTH_LONG).show();
}
// FirebaseCrashlytics.getInstance().recordException(th);
FirebaseCrashlytics.getInstance().recordException(th);
}
});
}
Expand All @@ -61,16 +66,17 @@ static public void handleError(@NonNull Throwable th) {
handleError(th, BuildConfig.DEBUG);
}

// private static FirebaseAnalytics sFirebaseAnalytics;
private static FirebaseAnalytics sFirebaseAnalytics;

static public void fa(@NonNull final String event, Bundle bundle) {
if (context == null) return;
/*
if (context == null) {
FirebaseCrashlytics.getInstance().recordException(new IllegalStateException("Attempt to log event before the context assigned"));
return;
}
if (sFirebaseAnalytics == null) {
sFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
}
sFirebaseAnalytics.logEvent(event, bundle);
*/
if (BuildConfig.DEBUG) {
Log.d(LT, "FA log " + event);
}
Expand Down Expand Up @@ -98,23 +104,19 @@ static public void faNotITag() {

static public void faScanView(boolean empty) {
Bundle bundle = new Bundle();
/*
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "itag_scan_view_is_empty");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "First Scan");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "boolean");
bundle.putBoolean(FirebaseAnalytics.Param.VALUE, empty);
*/
fa("itag_scan_view", bundle);
}

static public void faITagsView(int devices) {
Bundle bundle = new Bundle();
/*
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "itag_itags_view_device");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Remembered Devices");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "int");
bundle.putInt(FirebaseAnalytics.Param.VALUE, devices);
*/
fa("itag_itags_view");
}

Expand Down Expand Up @@ -172,12 +174,10 @@ static public void faITagFindStopped() {

static public void faITagLost(boolean error) {
Bundle bundle = new Bundle();
/*
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "itag_itag_lost_error");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Lost with error");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "boolean");
bundle.putBoolean(FirebaseAnalytics.Param.VALUE, error);
*/
fa("itag_itag_lost");
}

Expand All @@ -200,21 +200,27 @@ static public void faShowLastLocation() {
static public void faIssuedGpsRequest() {
fa("itag_issued_gps_request");
}

static public void faRemovedGpsRequestBySuccess() {
fa("itag_removed_gps_request_by_success");
}

static public void faRemovedGpsRequestByConnect() {
fa("itag_removed_gps_request_by_connect");
}

static public void faRemovedGpsRequestByTimeout() {
fa("itag_removed_gps_request_by_timeout");
}

static public void faGotGpsLocation() {
fa("itag_got_gps_location");
}

static public void faGpsPermissionError() {
fa("itag_gps_permission_error");
}

static public void faDisconnectDuringCall() {
fa("itag_disconnect_during_call");
}
Expand All @@ -230,10 +236,15 @@ static public void faWtOn1() {
@Override
public void onCreate() {
super.onCreate();
faAppCreated();
context = this;

faAppCreated();
ITag.initITag(context);
Waytoday.init(this);

WayToday.init(context);
if (WayToday.getInstance().isTrackingOn() && !GPSPermissionManager.needPermissionRequest(this)) {
GPSUpdatesForegroundService.start(this);
}
}

static public void faWtNoTrackID() {
Expand All @@ -242,7 +253,6 @@ static public void faWtNoTrackID() {

@Override
public void onTerminate() {
Waytoday.done();
try {
ITag.close();
} catch (Exception e) {
Expand Down Expand Up @@ -274,4 +284,8 @@ static public void faWtPlaymarket() {
static public void faWtRemove() {
fa("itag_wt_remove");
}

static public void faWtRequestBlePermissions() {
fa("itag_ble_request_permissions");
}
}
Loading

0 comments on commit a21bad0

Please sign in to comment.