Skip to content
Open
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
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.3'
defaultConfig {
applicationId "com.microntek.threecats.autovolume"
minSdkVersion 21
targetSdkVersion 22
targetSdkVersion 29
versionCode 4
versionName "1.2.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand All @@ -21,9 +21,9 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}

This file was deleted.

22 changes: 3 additions & 19 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:allowBackup="true"
Expand All @@ -25,28 +26,11 @@
<receiver android:name="com.microntek.threecats.autovolume.AutoVolumeBooter">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.SCREEN_ON" />
</intent-filter>
</receiver>
<!--activity
android:name=".TestVolActivity"
android:label="AutoTestVol">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-->
<!--activity
android:name=".MainActivity"
android:label="AutoVolume">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-->

<service android:name="com.microntek.threecats.autovolume.VolumeService" android:exported="false" />
<service android:name="com.microntek.threecats.autovolume.VolumeService" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package android.microntek;
package com.microntek;

import android.microntek.ICarManageCallback.Stub;
import android.os.Bundle;
import android.os.RemoteException;

public class CarManageCallback extends Stub {
public class CarManageCallback extends ICarManageCallback.Stub {
public void onStatusChanged(String type, Bundle bundle) throws RemoteException {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package android.microntek;
package com.microntek;

import android.microntek.ICarService.Stub;
import com.microntek.ICarService.Stub;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
Expand Down Expand Up @@ -43,7 +45,7 @@ public CarManager() {

private static IBinder getCarService() {
try {
Class localClass = Class.forName("android.os.ServiceManager");
@SuppressLint("PrivateApi") Class localClass = Class.forName("android.os.ServiceManager");
Method getService = localClass.getMethod("getService", new Class[] {String.class});

if(getService != null) {
Expand Down Expand Up @@ -203,4 +205,4 @@ public void putDataChanage(String type, String state) {
} catch (Exception e) {
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package android.microntek;
package com.microntek;

import android.os.Binder;
import android.os.Bundle;
Expand Down Expand Up @@ -92,4 +92,4 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws
}

void onStatusChanged(String str, Bundle bundle) throws RemoteException;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package android.microntek;
package com.microntek;

import android.os.Binder;
import android.os.IBinder;
Expand Down Expand Up @@ -456,12 +456,12 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws
return true;
case TRANSACTION_registerCallback /*15*/:
data.enforceInterface(DESCRIPTOR);
registerCallback(android.microntek.ICarManageCallback.Stub.asInterface(data.readStrongBinder()));
registerCallback(ICarManageCallback.Stub.asInterface(data.readStrongBinder()));
reply.writeNoException();
return true;
case TRANSACTION_unregisterCallback /*16*/:
data.enforceInterface(DESCRIPTOR);
unregisterCallback(android.microntek.ICarManageCallback.Stub.asInterface(data.readStrongBinder()));
unregisterCallback(ICarManageCallback.Stub.asInterface(data.readStrongBinder()));
reply.writeNoException();
return true;
case TRANSACTION_setParameters /*17*/:
Expand Down Expand Up @@ -527,4 +527,4 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws
int setParameters(String str) throws RemoteException;

void unregisterCallback(ICarManageCallback iCarManageCallback) throws RemoteException;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package android.microntek;
package com.microntek;

public class IRTable {
public static final int IR_AB = 363;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package android.microntek;
package com.microntek;

public class MTCData {
public static final int MAX_BALANCE = 28;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
package com.microntek.threecats.autovolume;

import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;

import java.util.Objects;

public class AutoVolumeBooter extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, VolumeService.class);
context.startService(i);
if (Objects.equals(intent.getAction(), Intent.ACTION_BOOT_COMPLETED) ||
Objects.equals(intent.getAction(), Intent.ACTION_SCREEN_ON)) {

Intent intentVolumeService = new Intent(context, VolumeService.class);
intentVolumeService.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);

if (isMyServiceRunning(context)) {
context.stopService(intentVolumeService);
}

startService(context, intentVolumeService);
}
}

private boolean isMyServiceRunning(Context context) {
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

if (manager != null) {
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (VolumeService.class.getName().equals(service.service.getClassName())) {
return true;
}
}
}
return false;
}

private void startService(Context context, Intent intent) {
if (Build.VERSION.SDK_INT < 26) {
context.startService(intent);
} else {
context.startForegroundService(intent);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.microntek.threecats.autovolume;

import android.microntek.CarManager;
import android.os.Handler;
import android.util.Log;

import com.microntek.CarManager;

public class CanBusDriver {
private static final String TAG = CanBusDriver.class.getSimpleName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ public void onReceive(Context context, Intent intent) {
double speed = 0;
if (rev > 0) {
speed = ((0xFF & data[5]) * 256 + (0xFF & data[6])) * 0.01d;

// some cars are jumping to 327km/h when stopped, set to 0 too
if (rev < 3000 && speed > 320.00) {
speed = 0;
}
}
bundle.putDouble(SPEED, speed);

double battery = ((0xFF & data[7]) * 256 + (0xFF & data[8])) * 0.01d;
bundle.putDouble(BATT, battery);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public void onStopTrackingTouch(SeekBar seekBar) {
staticVolumeView.setText("Static Volume: " + staticVolume);

debugVolView = (TextView) findViewById(R.id.debugVolView);

this.startService(new Intent(this, VolumeService.class));
}

private void switchSend(boolean on) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import android.app.Activity;
import android.content.Intent;
import android.microntek.CarManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.microntek.CarManager;

public class TestVolActivity extends Activity {
private static final String TAG = TestVolActivity.class.getName();

Expand Down
Loading