{ "id": "152608", "key": "TIMOB-19851", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "14826", "description": "Release 5.1.0-remaining iOS9 features, Android M features", "name": "Release 5.1.0", "archived": false, "released": true, "releaseDate": "2015-11-20" }, { "id": "16997", "name": "Release 5.2.0", "archived": false, "released": true, "releaseDate": "2016-02-23" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-11-05T02:52:20.000+0000", "created": "2015-11-03T10:44:01.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "permissions" ], "versions": [ { "id": "14826", "description": "Release 5.1.0-remaining iOS9 features, Android M features", "name": "Release 5.1.0", "archived": false, "released": true, "releaseDate": "2015-11-20" } ], "issuelinks": [ { "id": "49762", "type": { "id": "10011", "name": "Includes", "inward": "is included by", "outward": "includes" }, "inwardIssue": { "id": "153010", "key": "TIMOB-19933", "fields": { "summary": "Android: Required uses-permission are not always added to AndroidManifest", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "None", "id": "6" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "49618", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "152609", "key": "TIMOB-19852", "fields": { "summary": "Android: Media - automatically add necessary permissions to tiapp.xml", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-01-26T17:38:29.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "The following sample will always call back with {{success:false}} without showing the dialog:\r\n\r\n{code:javascript}\r\nif (Ti.Media.hasCameraPermissions()) {\r\n\treturn alert('You already have permission.');\r\n}\r\n\r\nTi.Media.requestCameraPermissions(function(e) {\r\n\tif (e.success) {\r\n\t\talert('You were granted permission.');\r\n\t} else {\r\n\t\talert('ou were denied permission for now, forever or the dialog did not show at all because it was denied forever before.');\r\n\t}\r\n});\r\n{code}\r\n\r\nTo make it work you need to declare the permission in {{tiapp.xml}}, which is not documented in either the [Ti.Media Reference|https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media] nor [Camera and Photo Gallery APIs Guide|https://docs.appcelerator.com/platform/latest/#!/guide/Camera_and_Photo_Gallery_APIs] or [tiapp.xml Common Requirements|https://docs.appcelerator.com/platform/latest/#!/guide/tiapp.xml_and_timodule.xml_Reference-section-29004921_tiapp.xmlandtimodule.xmlReference-CommonRequirements].\r\n\r\n{code:xml}\r\n \r\n \r\n \r\n \r\n \r\n{code}\r\n\r\nIf you do so Android 6+ will prompt for two permissions:\r\n\r\n!android_20151103-113339.png|thumbnail!\r\n\r\nThe first time after each new install I deny either one of two the callback will receive {{success:true}} but the next call to {{Ti.Media.hasCameraPermissions()}} will still return {{false}} and {{Ti.Media.requestCameraPermissions()}} will again prompt for both permissions, including the one I already granted.\r\n\r\nAfter the first time I deny only one of two permissions, every next time I do the exact same thing the app crashes with the attached log as soon as I deny the first or second permission.", "attachment": [ { "id": "57239", "filename": "android_20151103-113339.png", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-11-03T10:37:53.000+0000", "size": 92223, "mimeType": "image/png" }, { "id": "57238", "filename": "crash.log", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-11-03T10:38:19.000+0000", "size": 10747, "mimeType": "text/plain" } ], "flagged": false, "summary": "Android: Permissions (Camera) crash and other bugs", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "SDK 5.1.0.v20151028190028", "closedSprints": [ { "id": 517, "state": "closed", "name": "2015 Sprint 22 SDK", "startDate": "2015-10-24T00:30:42.059Z", "endDate": "2015-11-07T01:30:00.000Z", "completeDate": "2015-11-09T02:37:29.441Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "368807", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Updated tiapp.xml guide", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-11-03T10:48:43.000+0000", "updated": "2015-11-03T10:48:53.000+0000" }, { "id": "368808", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "PR for API reference:\r\nhttps://github.com/appcelerator/titanium_mobile/pull/7386", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-11-03T10:51:13.000+0000", "updated": "2015-11-03T10:51:13.000+0000" }, { "id": "368819", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Ti 5.1.0 sample app for testing:\r\nhttps://github.com/appcelerator-developer-relations/appc-sample-ti510/blob/master/app/controllers/permissions.js", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-11-03T12:32:10.000+0000", "updated": "2015-11-03T12:32:10.000+0000" }, { "id": "368913", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "master PR: https://github.com/appcelerator/titanium_mobile/pull/7394\r\nbackport PR: https://github.com/appcelerator/titanium_mobile/pull/7402\r\nLogic changes include:\r\n1. If one or more permissions are denied, we will not return success\r\n2. We will not re-ask for granted permission(s).", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-04T01:26:43.000+0000", "updated": "2015-11-04T21:23:52.000+0000" }, { "id": "368998", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I was able to reproduce the first three issues what fokke is seeing on android 6.0:\r\nI used snippet in the description.\r\n* Without the permissions in the tiapp.xml the callback always returned false with the alert even if both the permissions were allowed.\r\n* Adding the permission for camera in the tiapp.xml the callback returned success.\r\n* Denying one permission after each install returns success but again launching the app asks for permission for both.\r\n* Tried to reproduce the crash but was not able to.\r\n* Used : Ti SDK : 5.1.0.v20151028190028 & Nexus 6 : android 6.0", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-04T18:37:24.000+0000", "updated": "2015-11-04T18:37:24.000+0000" }, { "id": "369046", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Both Master and Backport 5_1_X pr merged. No longer crashing.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-11-05T02:52:57.000+0000", "updated": "2015-11-05T02:53:07.000+0000" }, { "id": "369504", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix. \r\n* Camera permissions need to be added to tiapp.xml for it to work.\r\n* Denying one permission after each install returns failure, again launching the app asks for permission for the one which was denied & not both.\r\n* No app crash seen.\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.4.0.201511040454\r\nTi SDK : 5.2.0.v20151109145129, 5.1.0.v20151104190037\r\nTi CLI : 5.0.5\r\nAlloy : 1.7.24\r\nMAC Yosemite : 10.10.5\r\nAppc NPM : 4.2.1\r\nAppc CLI : 5.1.0-44\r\nNode: v0.10.37\r\nNexus 5 - Android 6.0", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-10T02:15:25.000+0000", "updated": "2015-11-10T02:21:14.000+0000" }, { "id": "369716", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "I was wrong... the permissions *will* be added, but only if {{Ti.Media.showCamera()}} is used. I'll create a separate ticket to request the new permission methods to trigger the related permissions to be added as well.", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-11-11T09:03:29.000+0000", "updated": "2015-11-11T09:03:29.000+0000" }, { "id": "370047", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Reverted tiapp.xml guide common requirements and closed PR\r\nhttps://wiki.appcelerator.org/display/guides2/tiapp.xml+and+timodule.xml+Reference#tiapp.xmlandtimodule.xmlReference-CommonRequirements", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-11-12T08:21:33.000+0000", "updated": "2015-11-12T08:21:33.000+0000" }, { "id": "375293", "author": { "name": "c3k", "key": "c3k", "displayName": "carlo", "active": true, "timeZone": "Europe/Berlin" }, "body": "there's a big problem in the actual (5.1.2) API...\r\n\r\n*requestCameraPermissions is also the only way to get an external_write permission on Android 6+*, but:\r\n* requestCameraPermissions asks for code-needed permission\r\n* hasCameraPermissions & requestCameraPermissions returns true if camera + external_write permission are granted\r\n\r\nso if you only need to write a file it will asks for only an external_write permission, but the actual only way to check if user grant the permission is to try to create a file, since hasCameraPermissions and requestCameraPermissions will return false\r\n\r\nother way is to manually add camera permission to tiapp.xml, but I don't want to ask the user the camera permission for a writing need\r\n\r\n*we need a requestStoragePermissions & hasStoragePermissions asap* :)\r\n\r\ntest app: https://www.dropbox.com/s/qz18sl1p2oap7d4/Externalwrite.apk?dl=1\r\n\r\ntest code:\r\n{code:java}\r\n\r\nfunction writeFile(){\r\n\tvar filenameBase = new Date().getTime();\r\n\tvar file = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory + filenameBase);\r\n\tfile.write(\"a\");\r\n\treturn file.exists();\r\n}\r\n\r\n\r\nvar win = Titanium.UI.createWindow({layout:'vertical', height:Titanium.UI.FILL, backgroundColor:\"#FFF\"});\r\n\r\n\r\nvar button1 = Titanium.UI.createButton({top:50,title:\"Test external write\"});\r\nbutton1.addEventListener('click', function(){\r\n\talert(\"File created: \" + writeFile());\r\n});\r\nwin.add(button1);\r\n\r\nvar button2 = Titanium.UI.createButton({top:50,title:\"Ti.Media.hasCameraPermissions\"});\r\nbutton2.addEventListener('click', function(){\r\n\talert(\"Ti.Media.hasCameraPermissions: \"+Ti.Media.hasCameraPermissions());\r\n});\r\nwin.add(button2);\r\n\r\nvar button3 = Titanium.UI.createButton({top:50,title:\"Ti.Media.requestCameraPermissions\"});\r\nbutton3.addEventListener('click', function(){\r\n\tTi.Media.requestCameraPermissions(function(e) {\r\n alert(\"Ti.Media.requestCameraPermissions: \"+e.success);\r\n });\r\n});\r\nwin.add(button3);\r\n\r\n\r\nvar button4 = Titanium.UI.createButton({top:50,title:\"Workaround\"});\r\nbutton4.addEventListener('click', function(){\r\n\t\r\n\tif(Ti.Media.hasCameraPermissions()){//for older device returns true (can't use requestCameraPermissions because callback is not called)\r\n\t\tif(writeFile()){\r\n\t\t\talert('OK');\r\n\t\t}\r\n\t\telse alert('Write error');\r\n\t} \r\n\telse{\r\n\t\tTi.Media.requestCameraPermissions(function(e) {//aways request, beacause we can't check if already granteed\r\n\t\t\t//don't check e.success because it's always false\r\n\t\t\tif(writeFile()){\r\n\t\t\t\talert('OK');\r\n\t\t\t}\r\n\t\t\telse alert('Permission not granted or other write error');\r\n\t\t});\r\n\t}\r\n});\r\nwin.add(button4);\r\n\r\n\r\nwin.open();\r\n\r\n{code}\r\n", "updateAuthor": { "name": "c3k", "key": "c3k", "displayName": "carlo", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-01-26T15:03:58.000+0000", "updated": "2016-01-26T15:03:58.000+0000" }, { "id": "375296", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-01-26T17:38:29.000+0000", "updated": "2016-01-26T17:38:29.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }