Skip to content

Commit

Permalink
Revert "Fix lint issues with attempting to get a device name"
Browse files Browse the repository at this point in the history
This reverts commit a8175e5.
  • Loading branch information
jrtberlin committed Oct 8, 2022
1 parent 26a2756 commit 059dfcd
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 67 deletions.
18 changes: 1 addition & 17 deletions app/src/main/java/org/asteroidos/sync/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.asteroidos.sync;

import android.Manifest;
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
Expand All @@ -9,7 +8,6 @@
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.location.LocationManager;
import android.os.Bundle;
Expand All @@ -30,7 +28,6 @@
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
Expand Down Expand Up @@ -95,14 +92,7 @@ public void onScanResult(int callbackType, @NonNull ScanResult result) {

if (mListFragment == null) return;
mListFragment.deviceDiscovered(result.getDevice());

// TODO Review the below github issue for info regarding bluetooth device querying
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 1
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 2
return;
}
Log.d(TAG, "SCAN RESULT:" + result.getDevice().toString() + " Name:" + result.getDevice().getName());
Log.d(TAG,"SCAN RESULT:" + result.getDevice().toString() + " Name:" + result.getDevice().getName());
ParcelUuid[] arr = result.getDevice().getUuids();
}
};
Expand Down Expand Up @@ -367,12 +357,6 @@ private void btEnable() {
BluetoothAdapter mBtAdapter;
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
if (!mBtAdapter.isEnabled()) {
// TODO Review the below github issue for info regarding bluetooth device querying
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 1
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 2
return;
}
mBtAdapter.enable();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package org.asteroidos.sync.asteroid;

import android.Manifest;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;

import org.asteroidos.sync.connectivity.IConnectivityService;
import org.asteroidos.sync.connectivity.IServiceCallback;
Expand Down Expand Up @@ -129,13 +126,6 @@ public final boolean isRequiredServiceSupported(@NonNull final BluetoothGatt gat

@Override
protected final void initialize() {

// TODO Review the below github issue for info regarding bluetooth device querying
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 1
if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 2
return;
}
beginAtomicRequestQueue()
.add(requestMtu(256) // Remember, GATT needs 3 bytes extra. This will allow packet size of 244 bytes.
.with((device, mtu) -> log(Log.INFO, "MTU set to " + mtu))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

package org.asteroidos.sync.fragments;

import android.Manifest;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -32,7 +30,6 @@
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
Expand Down Expand Up @@ -199,13 +196,6 @@ public View getView(int i, View view, ViewGroup viewGroup) {
}

BluetoothDevice device = mLeDevices.get(i);

// TODO Review the below github issue for info regarding bluetooth device querying
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 1
if (ActivityCompat.checkSelfPermission(view.getContext(), Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 2
return view;
}
final String deviceName = device.getName();
if (deviceName != null && deviceName.length() > 0)
viewHolder.deviceName.setText(deviceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.asteroidos.sync.services;

import android.Manifest;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
Expand All @@ -28,7 +27,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
Expand All @@ -38,7 +36,6 @@
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;

import org.asteroidos.sync.MainActivity;
Expand All @@ -60,6 +57,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;

import no.nordicsemi.android.ble.observer.ConnectionObserver;

Expand Down Expand Up @@ -100,13 +98,6 @@ final void handleConnect() {
if (defaultDevMacAddr.equals("")) return;
String defaultLocalName = mPrefs.getString(MainActivity.PREFS_DEFAULT_LOC_NAME, "");
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(defaultDevMacAddr);

// TODO Review the below github issue for info regarding bluetooth device querying
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 1
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 2
return;
}
device.createBond();
mBleMngr.connect(device)
.useAutoConnect(true)
Expand All @@ -132,13 +123,6 @@ final void handleSetDevice(BluetoothDevice device) {
Log.d(TAG, "handleSetDevice: " + device.toString());
editor.putString(MainActivity.PREFS_DEFAULT_MAC_ADDR, device.getAddress());
mDevice = device;

// TODO Review the below github issue for info regarding bluetooth device querying
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 1
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 2
return;
}
String name = mDevice.getName();
try {
Message answer = Message.obtain(null, MSG_SET_LOCAL_NAME);
Expand Down Expand Up @@ -221,13 +205,6 @@ public final void onDeviceConnected(@NonNull BluetoothDevice device) {

@Override
public void onDeviceFailedToConnect(@NonNull BluetoothDevice device, int reason) {

// TODO Review the below github issue for info regarding bluetooth device querying
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 1
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 2
return;
}
Log.d(TAG, "Failed to connect to " + device.getName() + ": " + reason);
}

Expand Down Expand Up @@ -308,12 +285,6 @@ private void updateNotification() {
handleUpdateConnectionStatus();
String status = getString(R.string.disconnected);
if (mDevice != null) {
// TODO Review the below github issue for info regarding bluetooth device querying
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 1
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// https://github.com/AsteroidOS/AsteroidOSSync/issues/164 Message 2
return;
}
if (mState == ConnectionState.STATUS_CONNECTING)
status = getString(R.string.connecting_formatted, mDevice.getName());
else if (mState == ConnectionState.STATUS_CONNECTED)
Expand Down

0 comments on commit 059dfcd

Please sign in to comment.