{ "id": "171997", "key": "TIMOB-26253", "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": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-09-12T00:52:46.000+0000", "created": "2018-08-03T00:45:55.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "notification", "permissions" ], "versions": [ { "id": "18414", "description": "", "name": "Release 6.2.0", "archived": false, "released": true, "releaseDate": "2017-09-13" } ], "issuelinks": [ { "id": "56777", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "167291", "key": "TIMOB-24629", "fields": { "summary": "Android: Add wakeLock to NotificationManager", "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": "Critical", "id": "1" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-09-21T21:19:02.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": "*Summary:*\r\nAs of Titanium 6.2.0, posting a local notification while the screen is off will cause the app to crash if the app does not have the {{WAKE_LOCK}} permission.\r\n\r\nTitanium should not require the {{WAKE_LOCK}} permission.\r\n\r\n*Steps to reproduce:*\r\n# Connect an Android device to your machine.\r\n# Turn the Android device's screen off.\r\n# Build and run the below code on that Android device.\r\n# View the log and notice an exception was printed on startup.\r\n# Turn on the device's screen and view the app. Notice an exception dialog was displayed.\r\n\r\n{code:javascript}\r\nTi.Android.NotificationManager.notify(123, Ti.Android.createNotification({\r\n\tcontentTitle: \"Titanium Notification\",\r\n\tcontentText: \"Content Text\",\r\n\tcontentIntent: Ti.Android.createPendingIntent({\r\n\t\tintent: Ti.App.Android.launchIntent,\r\n\t}),\r\n}));\r\n{code}\r\n\r\n*Result:*\r\nThe following exception gets logged...\r\n{code}\r\n[ERROR] : TiExceptionHandler: Error: Neither user 10256 nor current process has android.permission.WAKE_LOCK.\r\n[ERROR] : TiExceptionHandler: at /ActivitySingleTaskTest.js:29:32\r\n[ERROR] : TiExceptionHandler: at Module._runScript (ti:/module.js:613:9)\r\n[ERROR] : TiExceptionHandler: at Module.load (ti:/module.js:105:7)\r\n[ERROR] : TiExceptionHandler: at Module.loadJavascriptText (ti:/module.js:457:9)\r\n[ERROR] : TiExceptionHandler: at Module.loadAsFile (ti:/module.js:512:15)\r\n[ERROR] : TiExceptionHandler: at Module.loadAsFileOrDirectory (ti:/module.js:429:20)\r\n[ERROR] : TiExceptionHandler: at Module.require (ti:/module.js:296:17)\r\n[ERROR] : TiExceptionHandler: at require (ti:/module.js:570:15)\r\n[ERROR] : TiExceptionHandler: at /app.js:7:1\r\n[ERROR] : TiExceptionHandler: at Module._runScript (ti:/module.js:596:17)\r\n[ERROR] : TiExceptionHandler:\r\n[ERROR] : TiExceptionHandler: android.os.Parcel.readException(Parcel.java:1942)\r\n[ERROR] : TiExceptionHandler: android.os.Parcel.readException(Parcel.java:1888)\r\n[ERROR] : TiExceptionHandler: android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:405)\r\n[ERROR] : TiExceptionHandler: android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:1342)\r\n[ERROR] : TiExceptionHandler: android.os.PowerManager$WakeLock.acquire(PowerManager.java:1326)\r\n[ERROR] : TiExceptionHandler: ti.modules.titanium.android.notificationmanager.NotificationManagerModule.notify(NotificationManagerModule.java:159)\r\n[ERROR] : TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)\r\n[ERROR] : TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:184)\r\n[ERROR] : TiExceptionHandler: org.appcelerator.kroll.KrollRuntime.runModule(KrollRuntime.java:247)\r\n[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiLaunchActivity.loadActivityScript(TiLaunchActivity.java:135)\r\n[{code}\r\n\r\n*Expected Result:*\r\nApp should not require the {{WAKE_LOCK}} permission. Java code should check if app has {{WAKE_LOCK}} before attempting to use it. If the permission is missing, then avoid it and do not turn on the screen.\r\n\r\nNote that many Android users tend to avoid apps that use the {{WAKE_LOCK}} permission since they're considered to waste battery life. This permission is a dirty word in the Android world and is best avoided if possible.\r\n\r\n*Cause:*\r\nThis is an issue in Titanium's Java {{NotificationManagerModule.notify()}} method...\r\n[NotificationManagerModule.java#L137|https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/android/src/java/ti/modules/titanium/android/notificationmanager/NotificationManagerModule.java#L137]\r\n\r\nThe solution is to do the following:\r\n* Check if {{WAKE_LOCK}} permission is defined in \"AndroidManifest.xml\" via the {{Context}} class before creating a wake lock.\r\n* {{catch}} block should catch the {{Exception}} type to catch all exception.\r\n", "attachment": [], "flagged": false, "summary": "Android: NotificationManager.notify() will crash while screen is off and if app is missing WAKE_LOCK permission", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "441401", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (master): https://github.com/appcelerator/titanium_mobile/pull/10311", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-09-07T02:40:55.000+0000", "updated": "2018-09-07T02:40:55.000+0000" }, { "id": "441488", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FR Passed.\r\nWaiting for merge to be enabled.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-09-12T00:21:42.000+0000", "updated": "2018-09-12T00:21:42.000+0000" }, { "id": "441489", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR Merged.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-09-12T00:52:42.000+0000", "updated": "2018-09-12T00:52:42.000+0000" }, { "id": "441907", "author": { "name": "kmahalingam", "key": "kmahalingam", "displayName": "Keerthi Mahalingam", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix on Sdk 7.5.0.v20180921103412. Works fine. Closing.\r\n{code}\r\nOperating System\r\n Name = Mac OS X\r\n Version = 10.13.6\r\n Architecture = 64bit\r\nNode.js\r\n Node.js Version = 8.9.1\r\n npm Version = 5.5.1\r\nTitanium CLI\r\n CLI Version = 5.1.1\r\nTitanium SDK\r\n SDK Version = 7.5.0.v20180921103412\r\nDevice =Samsung s5 android 6, Pixel android 8\r\n{code}", "updateAuthor": { "name": "kmahalingam", "key": "kmahalingam", "displayName": "Keerthi Mahalingam", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2018-09-21T21:18:53.000+0000", "updated": "2018-09-21T21:18:53.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }