[TIMOB-19422] Android M: App crashes if using camera in device due to permissions
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-09-07T05:06:21.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.1.0 |
Components | Android |
Labels | camera, permissions |
Reporter | Chee Kiat Ng |
Assignee | Hieu Pham |
Created | 2015-08-28T04:13:16.000+0000 |
Updated | 2015-10-27T01:03:33.000+0000 |
Description
The problem is, the app doesn't prompt the user for permissions, and even if the permissions are set, the app crashes.
Steps to reproduce:
1. Use the sample app 2. ti build 3. it will show an error 4. Go to settings permissions, set the app permission such that storage = YES, camera = NO 5. App will crash *Note* if both permissions are set to YES MANUALLY like (4.), the app works.
Titanium.Media.showCamera({
success:function(event) {
// called when media returned from the camera
Ti.API.debug('Our type was: '+event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
var imageView = Ti.UI.createImageView({
width:win.width,
height:win.height,
image:event.media
});
win.add(imageView);
} else {
alert("got the wrong type back ="+event.mediaType);
}
},
cancel:function() {
// called when user cancels taking a picture
},
error:function(error) {
// called when there's an error
var a = Titanium.UI.createAlertDialog({title:'Camera'});
a.setMessage(JSON.stringify(error));
a.show();
},
saveToPhotoGallery:true
});
Useful commands for testing:- From terminal, to grant permission instead of going to Settings in phone.
From terminal, to revoke permission instead of going to Settings in phone.
master PR: https://github.com/appcelerator/titanium_mobile/pull/7125. This PR check permissions and exit gracefully (no-op) if permission is not granted.
Master PR and backport pr merged.
5_0_X revert https://github.com/appcelerator/titanium_mobile/pull/7149
Is still broken in the latest version from master. version: 5.1.0 git hash: ae65d5dd2d48289604d29d4be25607acfa1eab80 jenkins: Job #4515 parity: parity repor
Confirmed 5.0.0.v20150911123911 is working. Will test master once it goes through the build cycle.
[~ben.bahrenburg@gmail.com] Thanks!
Verified the fix. The app does not crash but, 1. If filesystem permission is granted & camera permission not granted. The app does nothing. 2. If camera permission is granted & filesystem permission not granted. The app does nothing. 3. If both the permissions are granted the app performs as normal. Closing Environment: Appc Studio : 4.4.0.201510231805 Ti SDK : 5.1.0.v20151022152020 Ti CLI : 5.0.5 Alloy : 1.7.18 MAC Yosemite : 10.10.5 Appc NPM : 4.2.1-6 Appc CLI : 5.1.0-38 Node: v0.10.37 Nexus 5 - Android 6.0