Skip to content

Commit

Permalink
fix: clean up permission (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
qingzhuozhen authored Oct 14, 2022
1 parent 917796c commit 0402c91
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 37 deletions.
3 changes: 3 additions & 0 deletions common-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ android {
includeAndroidResources = true
}
}
lintOptions {
abortOnError false
}
}

dependencies {
Expand Down
1 change: 0 additions & 1 deletion common-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amplitude.common.android">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.amplitude.common.android

import android.Manifest
import android.content.Context
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
Expand All @@ -10,6 +11,7 @@ import android.location.LocationManager
import android.os.Build
import android.provider.Settings.Secure
import android.telephony.TelephonyManager
import androidx.core.content.ContextCompat
import com.amplitude.common.ContextProvider
import java.io.IOException
import java.lang.Exception
Expand Down Expand Up @@ -351,7 +353,17 @@ class AndroidContextProvider(private val context: Context, locationListening: Bo
if (!isLocationListening) {
return null
}
if (!Utils.checkLocationPermissionAllowed(context)) {
if (!(
ContextCompat.checkSelfPermission(
context,
Manifest.permission.ACCESS_COARSE_LOCATION
) === PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(
context,
Manifest.permission.ACCESS_FINE_LOCATION
) === PackageManager.PERMISSION_GRANTED
)
) {
return null
}
val locationManager = context
Expand Down
35 changes: 0 additions & 35 deletions common-android/src/main/java/com/amplitude/common/android/Utils.kt

This file was deleted.

0 comments on commit 0402c91

Please sign in to comment.