Skip to content

Commit

Permalink
修改bug,兼容华为选择文件
Browse files Browse the repository at this point in the history
  • Loading branch information
liuwenzheng committed Mar 20, 2020
1 parent 21b9e36 commit cac053f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#MokoBeacon Android SDK Instruction DOC(English)
# MokoBeacon Android SDK Instruction DOC(English)

----

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.moko.beacon"
minSdkVersion 18
targetSdkVersion 28
versionCode 8
versionName "1.3.2"
versionCode 9
versionName "1.3.3"

javaCompileOptions {
annotationProcessorOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ public BeaconInfo parseDeviceInfo(DeviceInfo deviceInfo) {
String mac = deviceInfo.mac;
double distance = MokoUtils.getDistance(deviceInfo.rssi, acc);
String distanceDesc = "Unknown";
if (distance <= 1.0) {
if (distance <= 0.1) {
distanceDesc = "Immediate";
} else if (distance > 1.0 && distance <= 3.0) {
} else if (distance > 0.1 && distance <= 1.0) {
distanceDesc = "Near";
} else if (distance > 3.0) {
} else if (distance > 1.0) {
distanceDesc = "Far";
}
// txPower;
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/moko/beacon/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ else if ("content".equalsIgnoreCase(uri.getScheme())) {
File file = new File(fileDir, path.substring("/QQBrowser".length(), path.length()));
return file.exists() ? file.toString() : null;
}
//判断华为文件管理器
if (isHuaweiMediaDocument(uri)) {
String path = uri.getPath();
File file = new File(path.substring("/root".length(), path.length()));
return file.exists() ? file.toString() : null;
}
return getDataColumn(context, uri, null, null);
}
// File
Expand Down Expand Up @@ -189,4 +195,15 @@ public static byte[] readFile(String filePath) throws Exception {
public static boolean isQQMediaDocument(Uri uri) {
return "com.tencent.mtt.fileprovider".equals(uri.getAuthority());
}

/**
* 使用第三方华为文件管理器打开
*
* @param uri
*
* @return
*/
public static boolean isHuaweiMediaDocument(Uri uri) {
return "com.huawei.hidisk.fileprovider".equals(uri.getAuthority());
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.injected.testOnly=false
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void onScanResult(int callbackType, ScanResult result) {
return;
}
DeviceInfo deviceInfo = new DeviceInfo();
deviceInfo.name = device.getName();
deviceInfo.name = result.getScanRecord().getDeviceName();
deviceInfo.rssi = rssi;
deviceInfo.mac = device.getAddress();
String scanRecordStr = MokoUtils.bytesToHexString(scanRecord);
Expand Down

0 comments on commit cac053f

Please sign in to comment.