Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28122] Android: Ti.Geolocation.hasLocationPermission() must return false if missing permission in manifest on OS versions older than 6.0

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, geolocation, manifest, permission
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-09-10T06:37:00.000+0000
Updated2021-02-22T18:36:48.000+0000

Description

*Summary:* If the below permission are missing in the app's "AndroidManifest.xml" file, then the [Ti.Geolocation.hasLocationPermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-hasLocationPermissions) method wrongly returns true on OS versions older than Android 6.0. *Steps to reproduce:*

Create a Classic Titanium app project.

In the "tiapp.xml", set <override-permissions/> to true as shown below.

Use the below "app.js".

Build and run on Android 5.1 or older.

In the log, notice it wrongly returns true.

<ti:app>
	<override-permissions>true</override-permissions>
</ti:app>
// app.js
var hasPermission = Ti.Geolocation.hasLocationPermissions();
console.log("@@@ hasLocationPermissions: " + hasPermission);
*Recommended Solution:* We should modify the code [here](https://github.com/appcelerator/titanium_mobile/blob/ab87f2e1288bf30cb2f70d9565553ee42c57fee4/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/GeolocationModule.java#L498-L500) to call the Java [Context.checkCallingPermission()](https://developer.android.com/reference/android/content/Context#checkCallingPermission(java.lang.String)) to see if the location permission is defined in the "AndroidManifest.xml". *Note:* The Titanium build system will normally automatically add location permissions to the generated "AndroidManifest.xml" file. So, this issue will only happen if this behavior has been overridden via the <override-permissions/> property in the "tiapp.xml" file. Even if this is the case, the developer should add this locations by hand to the "tiapp.xml" file's Android manifest section like how a native developer would do it.

Comments

No comments

JSON Source