Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Are android permissions fixed on unity 5 latest version?

Discussion in 'Android' started by xandelee, Dec 29, 2017.

  1. xandelee

    xandelee

    Joined:
    Sep 12, 2013
    Posts:
    29
    Are android permissions fixed on unity 5?
    On unity 4 the runtime permissions of android api 23+ especially android 6.0 do not work and we have to find out a way to do that with some plugin or else permissions that my app need to work aren't even asked at anytime, is it still that way on unity 5 or its implemented already on unity code?
    Actual version of unity is Unity 5.6.5

    I can't release a version of my app on play store using unity 5 just to test that because my project is 4 and when upgrading assets that use physics like cars lead to strange behaviours and will have to be redone.
     
    Last edited: Jan 13, 2018
  2. TheHighGround

    TheHighGround

    Joined:
    Nov 19, 2017
    Posts:
    68
    Unity 4 to 5 had a physics update as well as some other things.

    As far as permissions go as of Android 6.0 (Marshmallow) you have to ask for permissions at* run-time because Google PlayStore no longer has the user accept all permissions before downloading the app. This means, that before you do something that is considered "dangerous" by Google see here, you must check if your application has the permission see here. So you have to build a plug-in yourself.
     
  3. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    824
    Building your application with Unity 5.6.5 and running the app on Android 6.0 (Marshmallow) or later OS will display a permissions pop-up at the start of the app. You can test that with a simple new project (without upgrading your main project).
     
  4. xandelee

    xandelee

    Joined:
    Sep 12, 2013
    Posts:
    29
    Thank you for the answer
    So unity 5 will display automatically the window on the start of the app and if anything that needs permision at any point of the game it will already be authorized (if user said alow) on all android versions?

    I can't test it because i don't have an android 6.0 device, i have a motorola with android 7.0 that on unity 4 at the start of the app permission is corretcly asked after installation first launch.

    For testing with users and several android versions i would need to upgrade my project to 5 wich i'm already doing, i'm having to redo the car physics and lightmaps but getting all sorted out eventually.
     
    Last edited: Jan 4, 2018
  5. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    824
    Ok, so here you've mentioned additional things which you did not specify in the original post. Permissions dialog should work exactly the same on Android 6 and Android 7. According to release notes https://unity3d.com/unity/whats-new/unity-4.7.0 runtime permissions support was aded in Unity 4.7.0, so if you are using this or newer Unity 4.7.x version, runtime permissions dialog should work exactly the same on Android 6 as it does on Android 7. This makes me wonder, maybe I misunderstood your original question and you are having a different issue? Can you specify once again what exactly does not work for you on Android 6 that works on Android 7 when you build with Unity 4? Also please specify the exact Unity version number.
     
  6. xandelee

    xandelee

    Joined:
    Sep 12, 2013
    Posts:
    29
    My app is currently using unity 4.7.2 f1 and its on play store, the following tests we're run on that version.

    My game needs 2 permissions, telephone id/status and files.
    Recently i found out that device unique identifier of unity was identifiying more than 3 thousand of 9 thousand users of my game in my database with the same following hash:
    cd9e459ea708a948d5c2f5a6ca8838cf wich decrypted is 00000000000000000000000000000000
    The rest 6thousand+ was working properlly with unique hashes to identify them.

    I managed to reproduce this problem by denying permission to telephone id/status at startup after the installation of the app on my motorola android 7.0.

    So i made my system not allow that cd9e... hash anymore, so some users came and said that only files permission was being asked and the telephone id was not, they sent me a screenshot of permission configurations of the app and only files permission was avaliable to change to allow or disalow and others permissions we're not listed at all.
    Users that sent me the screenshoot we're using samsung android 6.0 marshmellow, i could not keep it that way so i could not identify if there's more issues with another android versions/brands.

    Also the changelog says 'Android: Added support for Marshmallow OS runtime permissions.' it doesn't say marshmallow and above, maybe it's a especific problem of android marshmallow
     
    Last edited: Jan 5, 2018
  7. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    824
    Thanks for the detailed explanation. So the actual issue is that you get an incorrect device unique identifier and that seems to be caused by the missing "telephone id/status" permission. Could you check the final manifest of your apk to see if the expected permission is not added there at all or have a max version specified which would cause it not to be asked for on Android 6 and newer devices? This still makes me wonder why it would work differently on Android 6 and Android 7. I will look into the source, maybe I'll notice something that could cause your issue.

    Unity 4.7.0 was released 17 Dec, 2015. At that time Marshmallow was the latest Android OS version (released a month ago) and that was the first Android version to have runtime permissions. That's why release notes specifically mention Marshmallow and not any other Android version :)

    Update:
    I've looked at the code. Since Unity 5.4.0a6 we only use ANDROID_ID when determining the unique identifier. This does not require telephony permissions and the unique identifier should be much more consistent. So upgrading your project to Unity 5 should fix the issue of 1/3 of the users having an empty unique identifier. However keep in mind that since this changes the way unique identifier is calculated, you might get different values than before for most (or all) of your users.
     
    Last edited: Jan 5, 2018
  8. xandelee

    xandelee

    Joined:
    Sep 12, 2013
    Posts:
    29
    When i ran into this problem i started to collecting android id, imei, mac and video memory manually via script.
    I found out that users that had the cd9... hash would not give any of the above information only 00000000 zero's, in other words, it seems like even to get the android id permission is needed on those also, at least on unity 4.7.2 f1, users with normal hashes would give out those info normally.
    I'm maybe wondering if android 6 of samsung it's configured not to give any personal information about the device by default or something...

    (Their values changing is not a problem because they are prompted to update their info when that happen and it should not happen often, it's a system that i'm using for my game that's working fine for a year.)

    And i think unity should keep using the imei as first resource of identification just its because its not good for the user changing it with root apps i believe changing their android id doesn't affect anything, changing their imei is illegal and dangerous for warranty, theft recovery etc. and for us developers that need it for security is no good. (I know we should not trust it but it's my only resource)


    *UPDATE*
    I think i MAY have solved the problem by adding this to the manifest:
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
    (It was not present at all before saying true or false, i fully added to the builded by unity manifest it some days ago)
    When i uploaded the app with that line google prompted me for the first time saying i was asking dangerous permissions, privacy policy info etc. (I was not asking before??)
    Notice that this line below we're always present since unity add's it automatically and i haven't changed anything the manifest before i discovered the cd9 problem and 60% of the users we're already giving me their hashed android info correctly.
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    Yesterday i blocked cd9... again and today no complaining on the support, if it stays like that i'll come back and update below if that solved the problem or not.
     
    Last edited: Jan 5, 2018
  9. xandelee

    xandelee

    Joined:
    Sep 12, 2013
    Posts:
    29
    Adding to the manifest
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
    Solved the problem that was happening only on android 6.0.

    Sorry for my english because i'm from brazil and sorry if i didn't explained more since the beggining because this topic https://forum.unity.com/threads/systeminfo-deviceuniqueidentifier-android-6-0.367028/ led me to believe that unity was not implementing the runtime permissions.

    Thank you for the support JuliusM.
     
    IlyaSakhatskiy and JuliusM like this.