{ "id": "124186", "key": "TIMOB-16146", "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": [], "resolution": null, "resolutiondate": null, "created": "2013-12-25T19:34:13.000+0000", "priority": null, "labels": [ "3.1.3.GA", "3.2.0", "android", "orientation", "orientationmodes" ], "versions": [ { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:03:56.000+0000", "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" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "I am using the android:screenOrientation=\"portrait\" property to lock app activities into portrait mode. However, I noticed that the app was behaving very strangely when coming out of screen lock in landscape mode. Upon investigating, I realized that the window was being closed and re-opened when the screen lock went into landscape mode. Run the app below, and here is how to reproduce.\r\n1. Open the app - it will run in portrait mode as expected. Rotating the tablet has no effect - good.\r\n2. With the app active, lock the screen.\r\n3. Rotate the tablet to landscape mode, and wait for the screen lock to adjust accordingly.\r\n4. Unlock the screen in landscape mode: you will see that the window was opened multiple times, which will totally screw up application logic in most cases. Note that the window is instantiated only once, but the close and open events fire multiple times. \r\n\r\napp.js:\r\n{code}\r\nTi.API.info('This will print only once, as expected');\r\nvar win1 = Titanium.UI.createWindow({ \r\n backgroundColor:'#fff',\r\n modal: false // ensure heavyweight window in all SDKs\r\n});\r\nvar numOpens = 0;\r\nvar label1 = Titanium.UI.createLabel({\r\n\tcolor:'#999',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\ttextAlign:'center',\r\n\twidth: Ti.UI.FILL,\r\n\theight: Ti.UI.SIZE\r\n});\r\n\r\nwin1.add(label1);\r\nwin1.addEventListener('open', function() {\r\n\tnumOpens++;\r\n\tlabel1.text = 'Window was opened ' + numOpens + ' times';\t\r\n});\r\n\r\nwin1.addEventListener('close', function() {\r\n\tTi.API.info('window was closed');\r\n});\r\nwin1.open();\r\n{code}\r\n\r\nAndroid section in tiapp.xml:\r\n{code}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: orientation lock in Android manifest buggy when screen locked", "creator": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "subtasks": [], "reporter": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "environment": "SDK 3.2.0.GA and 3.1.3.GA, tested on Samsung Tab 2 running Android 4.2.2", "comment": { "comments": [ { "id": "285795", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~mokesmokes] TIMOB-8912 appears to be related to this issue. There was a work around suggested in that ticket and I am curious if the same work around works for you. Can you please try it and let us know?\n\nFrom TIMOB-8912\n---------------\nThis appears to be caused when setting the min SDK level to 13 or higher.\nAndroid added a new configChanges flag which if not set will cause a restart of the activity.\n\nA workaround is to customize the manifest and include \"screenSize\" and \"smallestScreenSize\" in the android:configChanges options.\nWe can't generate these yet in the default manifest since we need to support API level 8.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-12-26T04:35:02.000+0000", "updated": "2013-12-26T04:35:02.000+0000" }, { "id": "285832", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "The workaround does not seem to work:\r\nI added the following to the manifest (tested on 3.2.0.GA):\r\n{code}\r\n\r\n{code}\r\nAnd also added \"|screenSize\" to the configChanges in all activities - and the bug persists.\r\nIn any case, the text in the old bug report is wrong. The \"screenSize\" and \"smallestScreenSize\" changes *will never* cause an activity restart. In API 12 and earlier these changes will always cause onConfigurationChanged() to be called, and in API13 and later this function is called only when these attributes are set in configChanges. Please see the [android docs|http://developer.android.com/guide/topics/manifest/activity-element.html#config].\r\n\r\nBottom line - with this bug it seems impossible to prevent multiple window close and open events when the portrait-locked window is open, the screen is then locked, and rotated to landscape, so it's a serious issue which will cause almost all orientation locked apps to go bonkers.", "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2013-12-26T07:17:05.000+0000", "updated": "2013-12-26T07:23:20.000+0000" }, { "id": "286689", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~mokesmokes] I am curious how do you get your screen lock to display in both portrait and landscape modes. My Android phone screen lock remains in portrait mode even if I rotate it to landscape mode. There are few applications on the Google Play that allows you to achieve this but it does not appear to be a factory setting.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-06T00:00:54.000+0000", "updated": "2014-01-06T00:00:54.000+0000" }, { "id": "286755", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "Hi Ritu,\nMy phones also screen lock in portrait mode only, but note this bug occurs on a Samsung Tab 2 tablet.\nI'm guessing most, perhaps all tablets will screen lock in both modes.", "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-01-06T13:29:13.000+0000", "updated": "2014-01-06T13:29:13.000+0000" }, { "id": "286765", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks, Mark. I will try to reproduce it on a Samsung tablet.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-06T16:51:27.000+0000", "updated": "2014-01-06T16:51:27.000+0000" }, { "id": "286778", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "BTW - I'm guessing that if you lock the app in landscape mode on a phone (in Android manifest, etc), the portrait screen lock on your phone will cause the same bug.", "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-01-06T18:01:33.000+0000", "updated": "2014-01-06T18:01:33.000+0000" }, { "id": "287164", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Moving this ticket to engineering as I can reproduce the issue with the provided test case on Samsung Tab 2 tablet. This issue occurs only when the screen is locked and unlocked and that results in lock screen to switch from portrait mode to landscape mode.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-08T06:10:57.000+0000", "updated": "2014-01-08T06:10:57.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }