{"action":"created","issue":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android/issues/8830","repository_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android","labels_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android/issues/8830/labels{/name}","comments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android/issues/8830/comments","events_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android/issues/8830/events","html_url":"https://github.com/wordpress-mobile/WordPress-Android/issues/8830","id":392754550,"node_id":"MDU6SXNzdWUzOTI3NTQ1NTA=","number":8830,"title":"Not allowed to bind to service Intent (com.google.android.finsky.BIND_GET_INSTALL_REFERRER_SERVICE)","user":{"login":"jkmassel","id":1123407,"node_id":"MDQ6VXNlcjExMjM0MDc=","avatar_url":"https://avatars3.githubusercontent.com/u/1123407?v=4","gravatar_id":"","url":"https://api.github.com/users/jkmassel","html_url":"https://github.com/jkmassel","followers_url":"https://api.github.com/users/jkmassel/followers","following_url":"https://api.github.com/users/jkmassel/following{/other_user}","gists_url":"https://api.github.com/users/jkmassel/gists{/gist_id}","starred_url":"https://api.github.com/users/jkmassel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkmassel/subscriptions","organizations_url":"https://api.github.com/users/jkmassel/orgs","repos_url":"https://api.github.com/users/jkmassel/repos","events_url":"https://api.github.com/users/jkmassel/events{/privacy}","received_events_url":"https://api.github.com/users/jkmassel/received_events","type":"User","site_admin":false},"labels":[{"id":242747101,"node_id":"MDU6TGFiZWwyNDI3NDcxMDE=","url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android/labels/Analytics","name":"Analytics","color":"006b75","default":false},{"id":35106418,"node_id":"MDU6TGFiZWwzNTEwNjQxOA==","url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android/labels/[Type]%20Bug","name":"[Type] Bug","color":"fc2929","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-12-19T19:55:36Z","updated_at":"2018-12-25T15:34:29Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"It seems that in many cases, we're not able to use Google's download attribution.\r\n\r\nWe're not crashing because of it – but we are handling a `java.lang.SecurityException` thrown from \r\n\r\nhttps://github.com/wordpress-mobile/WordPress-Android/blob/develop/WordPress/src/main/java/org/wordpress/android/util/analytics/service/InstallationReferrerServiceLogic.java#L119-L127\r\n\r\n**Stack trace:**\r\n\r\n```\r\nNon-fatal Exception: java.lang.SecurityException: Not allowed to bind to service Intent { act=com.google.android.finsky.BIND_GET_INSTALL_REFERRER_SERVICE cmp=com.android.vending/com.google.android.finsky.externalreferrer.GetInstallReferrerService }\r\n       at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1480)\r\n       at android.app.ContextImpl.bindService(ContextImpl.java:1434)\r\n       at android.content.ContextWrapper.bindService(ContextWrapper.java:636)\r\n       at com.android.installreferrer.api.InstallReferrerClientImpl.startConnection(InstallReferrerClientImpl.java:135)\r\n       at org.wordpress.android.util.analytics.service.InstallationReferrerServiceLogic.performTask(InstallationReferrerServiceLogic.java:120)\r\n       at org.wordpress.android.util.analytics.service.InstallationReferrerService.onStartCommand(InstallationReferrerService.java:48)\r\n       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3394)\r\n       at android.app.ActivityThread.-wrap21(ActivityThread.java)\r\n       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1632)\r\n       at android.os.Handler.dispatchMessage(Handler.java:110)\r\n       at android.os.Looper.loop(Looper.java:203)\r\n       at android.app.ActivityThread.main(ActivityThread.java:6284)\r\n       at java.lang.reflect.Method.invoke(Method.java)\r\n       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1094)\r\n       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)\r\n```\r\n\r\nIt appears all that's required to fix this is the addition of the `com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE` permission, but that may or may not be something we want to add to the bundle?\r\n(source: https://stackoverflow.com/questions/47706419/installreferrerclient-startconnection-throwing-error)\r\n\r\n(someone else with the same issue: https://issuetracker.google.com/issues/70193614)\r\n\r\n**reference:** 5bab95e3f8b88c29636353be-fabric\r\n**impact:** we're not able to receive in-app attribution for downloads"},"comment":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android/issues/comments/449858737","html_url":"https://github.com/wordpress-mobile/WordPress-Android/issues/8830#issuecomment-449858737","issue_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Android/issues/8830","id":449858737,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTg1ODczNw==","user":{"login":"mzorz","id":6597771,"node_id":"MDQ6VXNlcjY1OTc3NzE=","avatar_url":"https://avatars0.githubusercontent.com/u/6597771?v=4","gravatar_id":"","url":"https://api.github.com/users/mzorz","html_url":"https://github.com/mzorz","followers_url":"https://api.github.com/users/mzorz/followers","following_url":"https://api.github.com/users/mzorz/following{/other_user}","gists_url":"https://api.github.com/users/mzorz/gists{/gist_id}","starred_url":"https://api.github.com/users/mzorz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzorz/subscriptions","organizations_url":"https://api.github.com/users/mzorz/orgs","repos_url":"https://api.github.com/users/mzorz/repos","events_url":"https://api.github.com/users/mzorz/events{/privacy}","received_events_url":"https://api.github.com/users/mzorz/received_events","type":"User","site_admin":false},"created_at":"2018-12-25T15:34:29Z","updated_at":"2018-12-25T15:34:29Z","author_association":"CONTRIBUTOR","body":"Oh I see the problem. I think the problem is that we've encapsulated the `InstallReferrer` client inside a Service, and the Service is not exported, hence it cannot be invoked / bound to externally. \r\n\r\nI checked the issue in Fabric, seeing that all of the devices having this problem have Android 6 or below. This indicates it's a problem with the `Service` (as opposed to the `JobService`) as we run it [for devices below API 26](https://github.com/wordpress-mobile/WordPress-Android/blob/develop/WordPress/src/main/java/org/wordpress/android/util/analytics/service/InstallationReferrerServiceStarter.java#L21).\r\n\r\nThe [gradle declaration](https://developer.android.com/google/play/installreferrer/library)  for the plugin already adds the `uses-permission` line for `BIND_GET_INSTALL_REFERRER_SERVICE`, I confirmed this by using `aapt` tool on the [production apk](https://github.com/wordpress-mobile/WordPress-Android/releases/tag/11.4) `aapt l -a wpandroid-11.4.apk`\r\n\r\n```\r\nE: uses-permission (line=64)\r\n      A: android:name(0x01010003)=\"com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE\" (Raw: \"com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE\")\r\n```\r\n\r\nThe specific documentation about install referrer doesn't mention the service part because it's assuming code is going to be called from elsewhere.\r\n\r\nFollowing this, I think we should, as per @theck13 's suggestion:\r\n1. add `android:exported=\"true\"` to make it available,  and \r\n2. add `android:permission=\"com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE\"`  to restrict it to only be called from the vending app. \r\n\r\nTo test @jkmassel , we'd need to deliver a new alpha through Google Play and try (that's the only way to test that path as it's not possible to issue 3rd party app intents artificially even from adb, for security reasons).\r\n"}}
{"actor":{"display_login":"mzorz"}}