Skip to content

Commit

Permalink
bluetooth scan use ACCESS_FINE_LOCATION permission
Browse files Browse the repository at this point in the history
  • Loading branch information
xtc committed Aug 13, 2020
1 parent 4ff0414 commit dde824a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
gradle/
.DS_Store
/build
/captures
.externalNativeBuild
.idea/
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ implementation 'com.tongtonglock:ttlock:3.0.6'
```
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ implementation 'com.tongtonglock:ttlock:3.0.6'
```
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
```
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
}

8 changes: 8 additions & 0 deletions app/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri May 15 08:53:19 CST 2020
sdk.dir=D\:\\Users\\Administrator\\AppData\\Local\\Android\\sdk
6 changes: 3 additions & 3 deletions app/src/main/java/ttlock/demo/gateway/GatewayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ private void initListener() {
*/
@TargetApi(Build.VERSION_CODES.M)
private void startScan(){
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
return;
}
getScanGatewayCallback();
Expand Down Expand Up @@ -98,7 +98,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
getScanGatewayCallback();
} else {
if (permissions[0].equals(Manifest.permission.ACCESS_COARSE_LOCATION)){
if (permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)){

}
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/ttlock/demo/lock/ScanLockActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ private void initListener(){
*/
@TargetApi(Build.VERSION_CODES.M)
private void startScan(){
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
return;
}

Expand Down Expand Up @@ -133,7 +133,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
getScanLockCallback();
} else {
if (permissions[0].equals(Manifest.permission.ACCESS_COARSE_LOCATION)){
if (permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)){

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private void initListener(){
*/
@TargetApi(Build.VERSION_CODES.M)
private void startScan(){
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
return;
}

Expand Down Expand Up @@ -143,7 +143,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
getScanWirelessKeyboardCallback();
} else {
if (permissions[0].equals(Manifest.permission.ACCESS_COARSE_LOCATION)){
if (permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)){

}
}
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:3.4.1'

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
Expand All @@ -31,10 +31,10 @@ ext {
// Support library and architecture components support minSdk 14 and above.
minSdkVersion = 18
targetSdkVersion = 23
compileSdkVersion = 27
buildToolsVersion = '27.0.3'
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
// App dependencies
supportLibraryVersion = '27.1.1'
supportLibraryVersion = '28.0.0'
lifecycle_version = "1.1.1"
}

Expand Down

0 comments on commit dde824a

Please sign in to comment.