Initial commit
This commit is contained in:
162
sources/com/ubtrobot/jimu/bluetooth/proxy/BluetoothProxy.java
Normal file
162
sources/com/ubtrobot/jimu/bluetooth/proxy/BluetoothProxy.java
Normal file
@@ -0,0 +1,162 @@
|
||||
package com.ubtrobot.jimu.bluetooth.proxy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.ubtech.jimu.storage.UbtPrefs;
|
||||
import com.ubtrobot.jimu.bluetooth.Cancellable;
|
||||
import com.ubtrobot.jimu.bluetooth.base.BluetoothLib;
|
||||
import com.ubtrobot.jimu.bluetooth.base.discover.ScanResult;
|
||||
import com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter;
|
||||
import com.ubtrobot.jimu.bluetooth.ble.BleLib;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BluetoothProxy implements Proxy {
|
||||
private static final String i = "BluetoothProxy";
|
||||
private static BluetoothProxy j;
|
||||
private Context c;
|
||||
private DeviceListener d;
|
||||
private UbtPrefs e;
|
||||
private Cancellable g;
|
||||
private Cancellable h;
|
||||
private Proxy b = BleLib.b();
|
||||
private ArrayList<String> f = new ArrayList<>();
|
||||
|
||||
private BluetoothProxy() {
|
||||
this.f.add("lemobile");
|
||||
this.f.add("meizu");
|
||||
this.f.add("vivo");
|
||||
this.f.add("oneplus");
|
||||
this.f.add("oppo");
|
||||
this.f.add("lenove");
|
||||
}
|
||||
|
||||
public static synchronized BluetoothProxy c() {
|
||||
BluetoothProxy bluetoothProxy;
|
||||
synchronized (BluetoothProxy.class) {
|
||||
if (j == null) {
|
||||
j = new BluetoothProxy();
|
||||
}
|
||||
bluetoothProxy = j;
|
||||
}
|
||||
return bluetoothProxy;
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.proxy.Proxy
|
||||
public boolean a(Context context, DeviceListener deviceListener) {
|
||||
this.c = context;
|
||||
this.d = deviceListener;
|
||||
this.e = new UbtPrefs(context);
|
||||
Log.i(i, "init ble");
|
||||
BluetoothLib.d().a(context, deviceListener);
|
||||
return BleLib.b().a(context, deviceListener);
|
||||
}
|
||||
|
||||
public Cancellable a(final ScannedHubEmitter scannedHubEmitter, final int i2) {
|
||||
if (this.e.a("sp_key_is_last_connect_ble", (Boolean) true).booleanValue()) {
|
||||
this.g = BleLib.b().a(new ScannedHubEmitter(this) { // from class: com.ubtrobot.jimu.bluetooth.proxy.BluetoothProxy.1
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a(ScanResult scanResult) {
|
||||
scannedHubEmitter.a(scanResult);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a(int i3, String str) {
|
||||
scannedHubEmitter.a(i3, str);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a() {
|
||||
ALog.a(BluetoothProxy.i).d("Ble scan end, start classical bluetooth scan");
|
||||
BluetoothLib.d().a(scannedHubEmitter, i2 / 2);
|
||||
}
|
||||
}, i2 / 2);
|
||||
} else {
|
||||
this.h = BluetoothLib.d().a(new ScannedHubEmitter(this) { // from class: com.ubtrobot.jimu.bluetooth.proxy.BluetoothProxy.2
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a(ScanResult scanResult) {
|
||||
scannedHubEmitter.a(scanResult);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a(int i3, String str) {
|
||||
scannedHubEmitter.a(i3, str);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a() {
|
||||
ALog.a(BluetoothProxy.i).d("Classical Bluetooth scan end, start ble scan");
|
||||
BleLib.b().a(scannedHubEmitter, i2 / 2);
|
||||
}
|
||||
}, i2 / 2);
|
||||
}
|
||||
return new Cancellable() { // from class: com.ubtrobot.jimu.bluetooth.proxy.BluetoothProxy.3
|
||||
@Override // com.ubtrobot.jimu.bluetooth.Cancellable
|
||||
public boolean cancel() {
|
||||
if (BluetoothProxy.this.g != null) {
|
||||
BluetoothProxy.this.g.cancel();
|
||||
}
|
||||
if (BluetoothProxy.this.h == null) {
|
||||
return true;
|
||||
}
|
||||
BluetoothProxy.this.h.cancel();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.Cancellable
|
||||
public boolean isCancelled() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.proxy.Proxy
|
||||
public void a(String str) {
|
||||
boolean z;
|
||||
Iterator<Device> it = Proxy.a.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
Device next = it.next();
|
||||
String mac = next.getMac();
|
||||
String name = next.getName();
|
||||
if (mac.equals(str) && name.startsWith("My_")) {
|
||||
z = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!z) {
|
||||
Log.i(i, "reinit-classify bluetooth");
|
||||
this.e.a("sp_key_is_last_connect_ble", (Object) false);
|
||||
this.b = null;
|
||||
this.b = BluetoothLib.d();
|
||||
this.b.a(this.c, this.d);
|
||||
this.b.a(str);
|
||||
return;
|
||||
}
|
||||
Log.i(i, "reinit-ble");
|
||||
this.e.a("sp_key_is_last_connect_ble", (Object) true);
|
||||
this.b = BleLib.b();
|
||||
this.b.a(this.c, this.d);
|
||||
this.b.a(str);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.proxy.Proxy
|
||||
public void a() {
|
||||
this.b.a();
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.proxy.Proxy
|
||||
public void a(String str, boolean z) {
|
||||
this.b.a(str, z);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.proxy.Proxy
|
||||
public void a(String str, byte b, byte[] bArr, int i2) {
|
||||
this.b.a(str, b, bArr, i2);
|
||||
}
|
||||
}
|
10
sources/com/ubtrobot/jimu/bluetooth/proxy/Callback.java
Normal file
10
sources/com/ubtrobot/jimu/bluetooth/proxy/Callback.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.ubtrobot.jimu.bluetooth.proxy;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class Callback {
|
||||
public abstract void a(boolean z, String str);
|
||||
|
||||
public abstract void b(String str);
|
||||
|
||||
public abstract void b(String str, byte b, byte[] bArr, int i);
|
||||
}
|
30
sources/com/ubtrobot/jimu/bluetooth/proxy/Device.java
Normal file
30
sources/com/ubtrobot/jimu/bluetooth/proxy/Device.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.ubtrobot.jimu.bluetooth.proxy;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Device implements Serializable {
|
||||
private String mac;
|
||||
private String name;
|
||||
|
||||
public Device(String str, String str2) {
|
||||
this.mac = str;
|
||||
this.name = str2;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return this.mac;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setMac(String str) {
|
||||
this.mac = str;
|
||||
}
|
||||
|
||||
public void setName(String str) {
|
||||
this.name = str;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.ubtrobot.jimu.bluetooth.proxy;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface DeviceListener {
|
||||
/* renamed from: a */
|
||||
void disconnect(String str);
|
||||
|
||||
void a(String str, byte b, byte[] bArr, int i);
|
||||
|
||||
/* renamed from: a */
|
||||
void onConnectState(boolean z, String str);
|
||||
|
||||
String b(String str);
|
||||
}
|
20
sources/com/ubtrobot/jimu/bluetooth/proxy/Proxy.java
Normal file
20
sources/com/ubtrobot/jimu/bluetooth/proxy/Proxy.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.ubtrobot.jimu.bluetooth.proxy;
|
||||
|
||||
import android.content.Context;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Proxy {
|
||||
public static final List<Device> a = new ArrayList();
|
||||
|
||||
void a();
|
||||
|
||||
void a(String str);
|
||||
|
||||
void a(String str, byte b, byte[] bArr, int i);
|
||||
|
||||
void a(String str, boolean z);
|
||||
|
||||
boolean a(Context context, DeviceListener deviceListener);
|
||||
}
|
Reference in New Issue
Block a user