{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/9330","labels_url":"https://api.github.com/repos/golang/go/issues/9330/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/9330/comments","events_url":"https://api.github.com/repos/golang/go/issues/9330/events","html_url":"https://github.com/golang/go/issues/9330","id":52032122,"number":9330,"title":"mobile/sensor: implement sensor library","user":{"login":"crawshaw","id":161319,"avatar_url":"https://avatars.githubusercontent.com/u/161319?v=3","gravatar_id":"","url":"https://api.github.com/users/crawshaw","html_url":"https://github.com/crawshaw","followers_url":"https://api.github.com/users/crawshaw/followers","following_url":"https://api.github.com/users/crawshaw/following{/other_user}","gists_url":"https://api.github.com/users/crawshaw/gists{/gist_id}","starred_url":"https://api.github.com/users/crawshaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crawshaw/subscriptions","organizations_url":"https://api.github.com/users/crawshaw/orgs","repos_url":"https://api.github.com/users/crawshaw/repos","events_url":"https://api.github.com/users/crawshaw/events{/privacy}","received_events_url":"https://api.github.com/users/crawshaw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/golang/go/labels/repo-mobile","name":"repo-mobile","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2014-12-15T20:06:59Z","updated_at":"2015-03-11T17:39:02Z","closed_at":null,"body":"Mobile devices have a range of common sensors:\r\n\r\n- accelerometer\r\n- gyroscope\r\n- magnetometer\r\n- barometer\r\n- GPS / wifi location\r\n\r\nWe need a package golang.org/x/mobile/sensor to give us access to this data.\r\n\r\nThe challenging part here is, as always, designing an API that will work on both Android and iOS. This will require mapping the differences between sensor APIs on both platforms. There may be more than one Go package under the heading sensor.\r\n\r\nAs an added challenge, some of these sensors (in particular location) require app permissions to use. The permission models are different on android/iOS. I suspect we can design an API that does both: if a binary imports a particular sensor package, it will ask for the permission at installation time (that is, it will be baked into a generated AndroidManifest.xml file). When the package is used at run time, we ask iOS for permission."},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/78314721","html_url":"https://github.com/golang/go/issues/9330#issuecomment-78314721","issue_url":"https://api.github.com/repos/golang/go/issues/9330","id":78314721,"user":{"login":"minux","id":135652,"avatar_url":"https://avatars.githubusercontent.com/u/135652?v=3","gravatar_id":"","url":"https://api.github.com/users/minux","html_url":"https://github.com/minux","followers_url":"https://api.github.com/users/minux/followers","following_url":"https://api.github.com/users/minux/following{/other_user}","gists_url":"https://api.github.com/users/minux/gists{/gist_id}","starred_url":"https://api.github.com/users/minux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minux/subscriptions","organizations_url":"https://api.github.com/users/minux/orgs","repos_url":"https://api.github.com/users/minux/repos","events_url":"https://api.github.com/users/minux/events{/privacy}","received_events_url":"https://api.github.com/users/minux/received_events","type":"User","site_admin":false},"created_at":"2015-03-11T17:39:02Z","updated_at":"2015-03-11T17:39:02Z","body":"we can use a leaking channel though.\n\nloop: for {\n  select {\n  case ch <- value: break loop\n  case _ = <- ch: continue loop\n  }\n}\n\nThis way, if the channel is buffered channel with cap=1, we can be\nsure that no matter when does the client read, it will read the last\nupdate or block waiting for an update.\n\nHowever, I agree that we need to think about the big picture about\nsensors and decide whether we want a callback based design (like\nwe did for touch events) or a channel based design. It's better to be\nuniform. Besides location, is there any other sensor that doesn't\nprovide instantaneous update? heart rate?\n"}}