{"action":"created","issue":{"url":"https://api.github.com/repos/open-keychain/open-keychain/issues/1697","labels_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/1697/labels{/name}","comments_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/1697/comments","events_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/1697/events","html_url":"https://github.com/open-keychain/open-keychain/issues/1697","id":127665777,"number":1697,"title":"PendingIntent (for unlocking key / enter password) returned be decrypt operation becomes stale on next decrypt operation.","user":{"login":"mgeier63","id":5276926,"avatar_url":"https://avatars.githubusercontent.com/u/5276926?v=3","gravatar_id":"","url":"https://api.github.com/users/mgeier63","html_url":"https://github.com/mgeier63","followers_url":"https://api.github.com/users/mgeier63/followers","following_url":"https://api.github.com/users/mgeier63/following{/other_user}","gists_url":"https://api.github.com/users/mgeier63/gists{/gist_id}","starred_url":"https://api.github.com/users/mgeier63/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgeier63/subscriptions","organizations_url":"https://api.github.com/users/mgeier63/orgs","repos_url":"https://api.github.com/users/mgeier63/repos","events_url":"https://api.github.com/users/mgeier63/events{/privacy}","received_events_url":"https://api.github.com/users/mgeier63/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-20T11:48:04Z","updated_at":"2016-01-27T10:39:59Z","closed_at":null,"body":"Consider this use case:\r\n\r\nAn app calls decrypt and gets back a PendingIntent to enter the key password in OpenKeyChain. The app then shows a notification that tells the user that he needs to enter the password in OpenKeyChain, when tapping that notification the original PendignIntent from OpenKeyChain will get fired.\r\n\r\nIf the app now does another decrypt information (in the background), before it uses the original PendingIntent to unlock the key, it gets a new PendingIntent and the PendingIntent from the first operation becomes stale, i.e. can't be used any more, will throw an IntentSender exception or so when attempting to use. (Note that possibly this might also happen if another app does a decrypt operation requiring the same key, but I haven't checked this scenario yet) \r\n\r\nI had to do implement quite some workaround in my app to make sure that only the latest PendingIntent gets used and/or that no other decrypt operation happens before using the PendingIntent of the last operation.\r\n\r\nA possibly simply solution for this would be if you would just somehow expose (possibly in the OpenKeyChain Intent API) a method or intent that one could call _anytime_ to unlock a specific key - even _preemptively_ before attempting a decrypt operation."},"comment":{"url":"https://api.github.com/repos/open-keychain/open-keychain/issues/comments/175544919","html_url":"https://github.com/open-keychain/open-keychain/issues/1697#issuecomment-175544919","issue_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/1697","id":175544919,"user":{"login":"Valodim","id":27813,"avatar_url":"https://avatars.githubusercontent.com/u/27813?v=3","gravatar_id":"","url":"https://api.github.com/users/Valodim","html_url":"https://github.com/Valodim","followers_url":"https://api.github.com/users/Valodim/followers","following_url":"https://api.github.com/users/Valodim/following{/other_user}","gists_url":"https://api.github.com/users/Valodim/gists{/gist_id}","starred_url":"https://api.github.com/users/Valodim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Valodim/subscriptions","organizations_url":"https://api.github.com/users/Valodim/orgs","repos_url":"https://api.github.com/users/Valodim/repos","events_url":"https://api.github.com/users/Valodim/events{/privacy}","received_events_url":"https://api.github.com/users/Valodim/received_events","type":"User","site_admin":false},"created_at":"2016-01-27T10:39:59Z","updated_at":"2016-01-27T10:39:59Z","body":"none of these solutions sounds very good to me. :(\n\nIs serialising these operations really not feasible for your app? keep in mind it's no problem to retrieve a new pending intent at a later point, and you need to interrupt for user interaction anyways. Given your notification use case, storing and executing the PI might not really be what you want, but rather a restart of the whole operation - the password might have been cached in the meantime, for example. "}}