10000 update to sdk 15 (android 15) by Furtif · Pull Request #25 · cedricp/ecutweaker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

update to sdk 15 (android 15) #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 3, 2025
Merged
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: 7 additions & 5 deletions EcuTweaker/src/main/java/org/quark/dr/canapp/CustomAdapter.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package org.quark.dr.canapp;

import android.content.Context;
import androidx.annotation.NonNull;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;

public class CustomAdapter extends ArrayAdapter<String> {
Context context;
int color;
String[] items;
private int textSize=20;
private int textSize = 20;

public CustomAdapter(final Context context, final int textViewResourceId, final String[] objects) {
super(context, textViewResourceId, objects);
Expand Down Expand Up @@ -53,10 +54,11 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
return convertView;
}

public void setSpinnerTextSize(int size){
textSize= size;
public void setSpinnerTextSize(int size) {
textSize = size;
}
public void setSpinnerTextColor(int color){

public void setSpinnerTextColor(int color) {
this.color = color;
}

Expand Down
139 changes: 68 additions & 71 deletions EcuTweaker/src/main/java/org/quark/dr/canapp/DeviceListActivity.java
< 10000 td id="diff-1a952f1e12203940a3a784d78b1f04c221b262c8e05c03547f6f7e5223a37cceR90" data-line-number="90" class="blob-num blob-num-addition js-linkable-line-number js-blob-rnum">
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,75 @@ public class DeviceListActivity extends Activity {

// Member fields
private BluetoothAdapter mBtAdapter;
// The on-click listener for all devices in the ListViews
private final OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
// Cancel discovery because it's costly and we're about to connect
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (!askBluetoothScanPermission()) {
return;
}
} else {
if (!askLocationPermission()) {
return;
}
}
}
mBtAdapter.cancelDiscovery();

// Get the device MAC address, which is the last 17 chars in the View
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);

// Create the result Intent and include the MAC address
Intent intent = new Intent();
intent.putExtra(EXTRA_DEVICE_ADDRESS, address);

// Set result and finish this Activity
setResult(Activity.RESULT_OK, intent);
finish();
}
};
private ArrayAdapter<String> mNewDevicesArrayAdapter;
// The BroadcastReceiver that listens for discovered devices and
// changes the title when discovery is finished
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (!askBluetoothScanPermission()) {
return;
}
} else {
if (!askLocationPermission()) {
return;
}
}
}
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
assert device != null;
if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
// When discovery is finished, change the Activity title
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
setProgressBarIndeterminateVisibility(false);
setTitle(R.string.select_device);
if (mNewDevicesArrayAdapter.getCount() == 0) {
String noDevices = getResources().getText(R.string.none_found).toString();
mNewDevicesArrayAdapter.add(noDevices);
}
}
}
};

@RequiresApi(api = Build.VERSION_CODES.S)
boolean askBluetoothPermission() {
Expand Down Expand Up @@ -115,7 +183,6 @@ boolean askBluetoothScanPermission() {
return false;
}


/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
Expand Down Expand Up @@ -268,76 +335,6 @@ private void doDiscovery() {
mBtAdapter.startDiscovery();
}

// The on-click listener for all devices in the ListViews
private final OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
// Cancel discovery because it's costly and we're about to connect
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (!askBluetoothScanPermission()) {
return;
}
} else {
if (!askLocationPermission()) {
return;
}
}
}
mBtAdapter.cancelDiscovery();

// Get the device MAC address, which is the last 17 chars in the View
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);

// Create the result Intent and include the MAC address
Intent intent = new Intent();
intent.putExtra(EXTRA_DEVICE_ADDRESS, address);

// Set result and finish this Activity
setResult(Activity.RESULT_OK, intent);
finish();
}
};

// The BroadcastReceiver that listens for discovered devices and
// changes the title when discovery is finished
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (!askBluetoothScanPermission()) {
return;
}
} else {
if (!askLocationPermission()) {
return;
}
}
}
// Get the 6DB6 BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
assert device != null;
if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
// When discovery is finished, change the Activity title
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
setProgressBarIndeterminateVisibility(false);
setTitle(R.string.select_device);
if (mNewDevicesArrayAdapter.getCount() == 0) {
String noDevices = getResources().getText(R.string.none_found).toString();
mNewDevicesArrayAdapter.add(noDevices);
}
}
}
};

@Override
public void onStart() {
super.onStart();
Expand Down
125 changes: 61 additions & 64 deletions EcuTweaker/src/main/java/org/quark/dr/canapp/ElmBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.quark.dr.canapp;

import static java.lang.Math.min;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
Expand All @@ -19,8 +21,6 @@
import java.util.Date;
import java.util.HashMap;

import static java.lang.Math.min;

public abstract class ElmBase {
// Constants that indicate the current connection state
public static final int STATE_NONE = 0;
Expand All @@ -31,49 +31,6 @@ public abstract class ElmBase {
public static final int MODE_WIFI = 0;
public static final int MODE_BT = 1;
public static final int MODE_USB = 2;

protected ArrayList<String> mMessages;
protected int mRxa, mTxa;
protected HashMap<String, String> mEcuErrorCodeMap;
protected volatile Handler mConnectionHandler;
protected OutputStreamWriter mLogFile;
protected String mLogDir;
protected volatile boolean mRunningStatus;
static protected ElmBase mSingleton = null;
protected boolean mConnecting = false;
private int mState;
protected boolean mSessionActive;
private EcuDatabase mEcuDatabase;
private boolean mCFC0;
private String mProtocol;

static public ElmBase getSingleton() {
return mSingleton;
}

static public ElmBase createBluetoothSingleton(Context context, Handler handler, String logDir) {
mSingleton = new ElmBluetooth(context, handler, logDir);
return mSingleton;
}

static public ElmBase createWifiSingleton(Context context, Handler handler, String logDir) {
mSingleton = new ElmWifi(context, handler, logDir);
return mSingleton;
}

static public ElmBase createSerialSingleton(Context context, Handler handler, String logDir) {
mSingleton = new ElmUsbSerial(context, handler, logDir);
return mSingleton;
}

EcuDatabase getDB() {
return mEcuDatabase;
}

void setDB(EcuDatabase db) {
mEcuDatabase = db;
}

protected static final String mEcuErrorCo F438 deString =
"10:General Reject," +
"11:Service Not Supported," +
Expand Down Expand Up @@ -127,6 +84,61 @@ void setDB(EcuDatabase db) {
"91:Torque Converter Clutch Locked," +
"92:Voltage Too High," +
"93:Voltage Too Low";
static protected ElmBase mSingleton = null;
protected ArrayList<String> mMessages;
protected int mRxa, mTxa;
protected HashMap<String, String> mEcuErrorCodeMap;
protected volatile Handler mConnectionHandler;
protected OutputStreamWriter mLogFile;
protected String mLogDir;
protected volatile boolean mRunningStatus;
protected boolean mConnecting = false;
protected boolean mSessionActive;
private int mState;
private EcuDatabase mEcuDatabase;
private boolean mCFC0;
private String mProtocol;

public ElmBase(Handler handler, String logDir) {
mProtocol = "UNDEFINED";
mMessages = new ArrayList<>();
mConnectionHandler = handler;
mLogFile = null;
mLogDir = logDir;
mRxa = mTxa = -1;
mSessionActive = false;
mState = STATE_NONE;
mCFC0 = false;
createLogFile();
buildMaps();
}

static public ElmBase getSingleton() {
return mSingleton;
}

static public ElmBase createBluetoothSingleton(Context context, Handler handler, String logDir) {
mSingleton = new ElmBluetooth(context, handler, logDir);
return mSingleton;
}

static public ElmBase createWifiSingleton(Context context, Handler handler, String logDir) {
mSingleton = new ElmWifi(context, handler, logDir);
return mSingleton;
}

static public ElmBase createSerialSingleton(Context context, Handler handler, String logDir) {
mSingleton = new ElmUsbSerial(context, handler, logDir);
return mSingleton;
}

EcuDatabase getDB() {
return mEcuDatabase;
}

void setDB(EcuDatabase db) {
mEcuDatabase = db;
}

public abstract void disconnect();

Expand All @@ -145,21 +157,6 @@ public boolean hasDevicePermission() {
public void requestPermission() {
}


public ElmBase(Handler handler, String logDir) {
mProtocol = "UNDEFINED";
mMessages = new ArrayList<>();
mConnectionHandler = handler;
mLogFile = null;
mLogDir = logDir;
mRxa = mTxa = -1;
mSessionActive = false;
mState = STATE_NONE;
mCFC0 = false;
createLogFile();
buildMaps();
}

public void setSoftFlowControl(boolean b) {
mCFC0 = b;
}
Expand Down Expand Up @@ -190,6 +187,10 @@ public void changeHandler(Handler h) {
}
}

public int getState() {
return mState;
}

protected void setState(int state) {
mState = state;
// Give the new state to the Handler so the UI Activity can update
Expand All @@ -201,10 +202,6 @@ protected void setState(int state) {
}
}

public int getState() {
return mState;
}

protected void logInfo(String log) {
synchronized (this) {
if (mConnectionHandler != null) {
Expand Down
Loading
Loading
0