Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28122

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

    Details

      Description

      Summary:
      If the below permission are missing in the app's "AndroidManifest.xml" file, then the Ti.Geolocation.hasLocationPermissions() method wrongly returns true on OS versions older than Android 6.0.

      Steps to reproduce:

      1. Create a Classic Titanium app project.
      2. In the "tiapp.xml", set <override-permissions/> to true as shown below.
      3. Use the below "app.js".
      4. Build and run on Android 5.1 or older.
      5. 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 to call the Java Context.checkCallingPermission() 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.

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              jquick Joshua Quick
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration