├── .github └── workflows │ ├── build.yml │ └── reuse.yml ├── .gitignore ├── .reuse └── dep5 ├── LICENSES ├── Apache-2.0.txt ├── CC-BY-3.0.txt ├── CC-BY-SA-4.0.txt └── CC0-1.0.txt ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ ├── gradle-wrapper.jar.license │ └── gradle-wrapper.properties ├── gradlew ├── settings.gradle └── src └── main ├── AndroidManifest.xml ├── java └── org │ └── microg │ └── nlp │ └── backend │ └── ichnaea │ ├── BackendService.java │ ├── CellDatabase.java │ ├── IchnaeaRequester.java │ ├── LocationCallback.java │ └── SettingsActivity.java └── res ├── mipmap-hdpi └── ic_launcher.png ├── mipmap-mdpi └── ic_launcher.png ├── mipmap-xhdpi └── ic_launcher.png ├── mipmap-xxhdpi └── ic_launcher.png ├── mipmap-xxxhdpi └── ic_launcher.png ├── values-pl └── strings.xml ├── values-ru └── strings.xml ├── values-uk └── strings.xml ├── values └── strings.xml └── xml └── preferences.xml /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021, microG Project Team 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | name: Build 5 | on: [pull_request, push] 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | with: 12 | fetch-depth: 0 13 | - run: ./gradlew --no-daemon build 14 | env: 15 | TERM: dumb 16 | JAVA_OPTS: -Xmx2048m 17 | -------------------------------------------------------------------------------- /.github/workflows/reuse.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021, microG Project Team 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | name: REUSE Compliance Check 5 | on: [pull_request, push] 6 | jobs: 7 | test: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: fsfe/reuse-action@v1 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2013, microG Project Team 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | *.iml 5 | gen/ 6 | bin/ 7 | build/ 8 | user.gradle 9 | .gradle/ 10 | local.properties 11 | .idea/ 12 | BuildConfig.java 13 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | 3 | Files: src/main/res/mipmap-*/*.png 4 | Copyright: 2015 microG Project Team 5 | License: CC-BY-3.0 6 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | 3 | Version 2.0, January 2004 4 | 5 | http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, 6 | AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | 11 | 12 | "License" shall mean the terms and conditions for use, reproduction, and distribution 13 | as defined by Sections 1 through 9 of this document. 14 | 15 | 16 | 17 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 18 | owner that is granting the License. 19 | 20 | 21 | 22 | "Legal Entity" shall mean the union of the acting entity and all other entities 23 | that control, are controlled by, or are under common control with that entity. 24 | For the purposes of this definition, "control" means (i) the power, direct 25 | or indirect, to cause the direction or management of such entity, whether 26 | by contract or otherwise, or (ii) ownership of fifty percent (50%) or more 27 | of the outstanding shares, or (iii) beneficial ownership of such entity. 28 | 29 | 30 | 31 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions 32 | granted by this License. 33 | 34 | 35 | 36 | "Source" form shall mean the preferred form for making modifications, including 37 | but not limited to software source code, documentation source, and configuration 38 | files. 39 | 40 | 41 | 42 | "Object" form shall mean any form resulting from mechanical transformation 43 | or translation of a Source form, including but not limited to compiled object 44 | code, generated documentation, and conversions to other media types. 45 | 46 | 47 | 48 | "Work" shall mean the work of authorship, whether in Source or Object form, 49 | made available under the License, as indicated by a copyright notice that 50 | is included in or attached to the work (an example is provided in the Appendix 51 | below). 52 | 53 | 54 | 55 | "Derivative Works" shall mean any work, whether in Source or Object form, 56 | that is based on (or derived from) the Work and for which the editorial revisions, 57 | annotations, elaborations, or other modifications represent, as a whole, an 58 | original work of authorship. For the purposes of this License, Derivative 59 | Works shall not include works that remain separable from, or merely link (or 60 | bind by name) to the interfaces of, the Work and Derivative Works thereof. 61 | 62 | 63 | 64 | "Contribution" shall mean any work of authorship, including the original version 65 | of the Work and any modifications or additions to that Work or Derivative 66 | Works thereof, that is intentionally submitted to Licensor for inclusion in 67 | the Work by the copyright owner or by an individual or Legal Entity authorized 68 | to submit on behalf of the copyright owner. For the purposes of this definition, 69 | "submitted" means any form of electronic, verbal, or written communication 70 | sent to the Licensor or its representatives, including but not limited to 71 | communication on electronic mailing lists, source code control systems, and 72 | issue tracking systems that are managed by, or on behalf of, the Licensor 73 | for the purpose of discussing and improving the Work, but excluding communication 74 | that is conspicuously marked or otherwise designated in writing by the copyright 75 | owner as "Not a Contribution." 76 | 77 | 78 | 79 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 80 | of whom a Contribution has been received by Licensor and subsequently incorporated 81 | within the Work. 82 | 83 | 2. Grant of Copyright License. Subject to the terms and conditions of this 84 | License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, 85 | no-charge, royalty-free, irrevocable copyright license to reproduce, prepare 86 | Derivative Works of, publicly display, publicly perform, sublicense, and distribute 87 | the Work and such Derivative Works in Source or Object form. 88 | 89 | 3. Grant of Patent License. Subject to the terms and conditions of this License, 90 | each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, 91 | no-charge, royalty-free, irrevocable (except as stated in this section) patent 92 | license to make, have made, use, offer to sell, sell, import, and otherwise 93 | transfer the Work, where such license applies only to those patent claims 94 | licensable by such Contributor that are necessarily infringed by their Contribution(s) 95 | alone or by combination of their Contribution(s) with the Work to which such 96 | Contribution(s) was submitted. If You institute patent litigation against 97 | any entity (including a cross-claim or counterclaim in a lawsuit) alleging 98 | that the Work or a Contribution incorporated within the Work constitutes direct 99 | or contributory patent infringement, then any patent licenses granted to You 100 | under this License for that Work shall terminate as of the date such litigation 101 | is filed. 102 | 103 | 4. Redistribution. You may reproduce and distribute copies of the Work or 104 | Derivative Works thereof in any medium, with or without modifications, and 105 | in Source or Object form, provided that You meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or Derivative Works a copy 108 | of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices stating that 111 | You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works that You distribute, 114 | all copyright, patent, trademark, and attribution notices from the Source 115 | form of the Work, excluding those notices that do not pertain to any part 116 | of the Derivative Works; and 117 | 118 | (d) If the Work includes a "NOTICE" text file as part of its distribution, 119 | then any Derivative Works that You distribute must include a readable copy 120 | of the attribution notices contained within such NOTICE file, excluding those 121 | notices that do not pertain to any part of the Derivative Works, in at least 122 | one of the following places: within a NOTICE text file distributed as part 123 | of the Derivative Works; within the Source form or documentation, if provided 124 | along with the Derivative Works; or, within a display generated by the Derivative 125 | Works, if and wherever such third-party notices normally appear. The contents 126 | of the NOTICE file are for informational purposes only and do not modify the 127 | License. You may add Your own attribution notices within Derivative Works 128 | that You distribute, alongside or as an addendum to the NOTICE text from the 129 | Work, provided that such additional attribution notices cannot be construed 130 | as modifying the License. 131 | 132 | You may add Your own copyright statement to Your modifications and may provide 133 | additional or different license terms and conditions for use, reproduction, 134 | or distribution of Your modifications, or for any such Derivative Works as 135 | a whole, provided Your use, reproduction, and distribution of the Work otherwise 136 | complies with the conditions stated in this License. 137 | 138 | 5. Submission of Contributions. Unless You explicitly state otherwise, any 139 | Contribution intentionally submitted for inclusion in the Work by You to the 140 | Licensor shall be under the terms and conditions of this License, without 141 | any additional terms or conditions. Notwithstanding the above, nothing herein 142 | shall supersede or modify the terms of any separate license agreement you 143 | may have executed with Licensor regarding such Contributions. 144 | 145 | 6. Trademarks. This License does not grant permission to use the trade names, 146 | trademarks, service marks, or product names of the Licensor, except as required 147 | for reasonable and customary use in describing the origin of the Work and 148 | reproducing the content of the NOTICE file. 149 | 150 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to 151 | in writing, Licensor provides the Work (and each Contributor provides its 152 | Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 153 | KIND, either express or implied, including, without limitation, any warranties 154 | or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR 155 | A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness 156 | of using or redistributing the Work and assume any risks associated with Your 157 | exercise of permissions under this License. 158 | 159 | 8. Limitation of Liability. In no event and under no legal theory, whether 160 | in tort (including negligence), contract, or otherwise, unless required by 161 | applicable law (such as deliberate and grossly negligent acts) or agreed to 162 | in writing, shall any Contributor be liable to You for damages, including 163 | any direct, indirect, special, incidental, or consequential damages of any 164 | character arising as a result of this License or out of the use or inability 165 | to use the Work (including but not limited to damages for loss of goodwill, 166 | work stoppage, computer failure or malfunction, or any and all other commercial 167 | damages or losses), even if such Contributor has been advised of the possibility 168 | of such damages. 169 | 170 | 9. Accepting Warranty or Additional Liability. While redistributing the Work 171 | or Derivative Works thereof, You may choose to offer, and charge a fee for, 172 | acceptance of support, warranty, indemnity, or other liability obligations 173 | and/or rights consistent with this License. However, in accepting such obligations, 174 | You may act only on Your own behalf and on Your sole responsibility, not on 175 | behalf of any other Contributor, and only if You agree to indemnify, defend, 176 | and hold each Contributor harmless for any liability incurred by, or claims 177 | asserted against, such Contributor by reason of your accepting any such warranty 178 | or additional liability. END OF TERMS AND CONDITIONS 179 | 180 | APPENDIX: How to apply the Apache License to your work. 181 | 182 | To apply the Apache License to your work, attach the following boilerplate 183 | notice, with the fields enclosed by brackets "[]" replaced with your own identifying 184 | information. (Don't include the brackets!) The text should be enclosed in 185 | the appropriate comment syntax for the file format. We also recommend that 186 | a file or class name and description of purpose be included on the same "printed 187 | page" as the copyright notice for easier identification within third-party 188 | archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | 194 | you may not use this file except in compliance with the License. 195 | 196 | You may obtain a copy of the License at 197 | 198 | http://www.apache.org/licenses/LICENSE-2.0 199 | 200 | Unless required by applicable law or agreed to in writing, software 201 | 202 | distributed under the License is distributed on an "AS IS" BASIS, 203 | 204 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 205 | 206 | See the License for the specific language governing permissions and 207 | 208 | limitations under the License. 209 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-3.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution 3.0 Unported 2 | 3 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE. 4 | 5 | License 6 | 7 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 8 | 9 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 10 | 11 | 1. Definitions 12 | 13 | a. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. 14 | 15 | b. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. 16 | 17 | c. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. 18 | 19 | d. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 20 | 21 | e. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. 22 | 23 | f. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. 24 | 25 | g. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 26 | 27 | h. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. 28 | 29 | i. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 30 | 31 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 32 | 33 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 34 | 35 | a. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; 36 | 37 | b. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; 38 | 39 | c. to Distribute and Publicly Perform the Work including as incorporated in Collections; and, 40 | 41 | d. to Distribute and Publicly Perform Adaptations. 42 | 43 | e. For the avoidance of doubt: 44 | 45 | i. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; 46 | 47 | ii. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, 48 | 49 | iii. Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. 50 | 51 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 52 | 53 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 54 | 55 | a. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested. 56 | 57 | b. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 58 | 59 | c. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 60 | 61 | 5. Representations, Warranties and Disclaimer 62 | 63 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 64 | 65 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 66 | 67 | 7. Termination 68 | 69 | a. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 70 | 71 | b. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 72 | 73 | 8. Miscellaneous 74 | 75 | a. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 76 | 77 | b. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 78 | 79 | c. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 80 | 81 | d. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. 82 | 83 | e. This License may not be modified without the mutual written agreement of the Licensor and You. 84 | 85 | f. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 86 | 87 | Creative Commons Notice 88 | 89 | Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor. 90 | 91 | Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of this License. 92 | 93 | Creative Commons may be contacted at http://creativecommons.org/. 94 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-SA-4.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution-ShareAlike 4.0 International 2 | 3 | Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. 4 | 5 | Using Creative Commons Public Licenses 6 | 7 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 8 | 9 | Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. 10 | 11 | Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. 12 | 13 | Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. 14 | 15 | Creative Commons Attribution-ShareAlike 4.0 International Public License 16 | 17 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 18 | 19 | Section 1 – Definitions. 20 | 21 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 22 | 23 | b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 24 | 25 | c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. 26 | 27 | d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 28 | 29 | e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 30 | 31 | f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 32 | 33 | g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. 34 | 35 | h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 36 | 37 | i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 38 | 39 | j. Licensor means the individual(s) or entity(ies) granting rights under this Public License. 40 | 41 | k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 42 | 43 | l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 44 | 45 | m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 46 | 47 | Section 2 – Scope. 48 | 49 | a. License grant. 50 | 51 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 52 | 53 | A. reproduce and Share the Licensed Material, in whole or in part; and 54 | 55 | B. produce, reproduce, and Share Adapted Material. 56 | 57 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 58 | 59 | 3. Term. The term of this Public License is specified in Section 6(a). 60 | 61 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 62 | 63 | 5. Downstream recipients. 64 | 65 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 66 | 67 | B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. 68 | 69 | C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 70 | 71 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 72 | 73 | b. Other rights. 74 | 75 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 76 | 77 | 2. Patent and trademark rights are not licensed under this Public License. 78 | 79 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. 80 | 81 | Section 3 – License Conditions. 82 | 83 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 84 | 85 | a. Attribution. 86 | 87 | 1. If You Share the Licensed Material (including in modified form), You must: 88 | 89 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 90 | 91 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 92 | 93 | ii. a copyright notice; 94 | 95 | iii. a notice that refers to this Public License; 96 | 97 | iv. a notice that refers to the disclaimer of warranties; 98 | 99 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 100 | 101 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 102 | 103 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 104 | 105 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 106 | 107 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 108 | 109 | b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. 110 | 111 | 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. 112 | 113 | 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. 114 | 115 | 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. 116 | 117 | Section 4 – Sui Generis Database Rights. 118 | 119 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 120 | 121 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; 122 | 123 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and 124 | 125 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 126 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 127 | 128 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 129 | 130 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 131 | 132 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 133 | 134 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 135 | 136 | Section 6 – Term and Termination. 137 | 138 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 139 | 140 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 141 | 142 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 143 | 144 | 2. upon express reinstatement by the Licensor. 145 | 146 | c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 147 | 148 | d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 149 | 150 | e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 151 | 152 | Section 7 – Other Terms and Conditions. 153 | 154 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 155 | 156 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 157 | 158 | Section 8 – Interpretation. 159 | 160 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 161 | 162 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 163 | 164 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 165 | 166 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 167 | 168 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 169 | 170 | Creative Commons may be contacted at creativecommons.org. 171 | -------------------------------------------------------------------------------- /LICENSES/CC0-1.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES 4 | NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE 5 | AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION 6 | ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE 7 | OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS 8 | LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION 9 | OR WORKS PROVIDED HEREUNDER. 10 | 11 | Statement of Purpose 12 | 13 | The laws of most jurisdictions throughout the world automatically confer exclusive 14 | Copyright and Related Rights (defined below) upon the creator and subsequent 15 | owner(s) (each and all, an "owner") of an original work of authorship and/or 16 | a database (each, a "Work"). 17 | 18 | Certain owners wish to permanently relinquish those rights to a Work for the 19 | purpose of contributing to a commons of creative, cultural and scientific 20 | works ("Commons") that the public can reliably and without fear of later claims 21 | of infringement build upon, modify, incorporate in other works, reuse and 22 | redistribute as freely as possible in any form whatsoever and for any purposes, 23 | including without limitation commercial purposes. These owners may contribute 24 | to the Commons to promote the ideal of a free culture and the further production 25 | of creative, cultural and scientific works, or to gain reputation or greater 26 | distribution for their Work in part through the use and efforts of others. 27 | 28 | For these and/or other purposes and motivations, and without any expectation 29 | of additional consideration or compensation, the person associating CC0 with 30 | a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright 31 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work 32 | and publicly distribute the Work under its terms, with knowledge of his or 33 | her Copyright and Related Rights in the Work and the meaning and intended 34 | legal effect of CC0 on those rights. 35 | 36 | 1. Copyright and Related Rights. A Work made available under CC0 may be protected 37 | by copyright and related or neighboring rights ("Copyright and Related Rights"). 38 | Copyright and Related Rights include, but are not limited to, the following: 39 | 40 | i. the right to reproduce, adapt, distribute, perform, display, communicate, 41 | and translate a Work; 42 | 43 | ii. moral rights retained by the original author(s) and/or performer(s); 44 | 45 | iii. publicity and privacy rights pertaining to a person's image or likeness 46 | depicted in a Work; 47 | 48 | iv. rights protecting against unfair competition in regards to a Work, subject 49 | to the limitations in paragraph 4(a), below; 50 | 51 | v. rights protecting the extraction, dissemination, use and reuse of data 52 | in a Work; 53 | 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal protection 56 | of databases, and under any national implementation thereof, including any 57 | amended or successor version of such directive); and 58 | 59 | vii. other similar, equivalent or corresponding rights throughout the world 60 | based on applicable law or treaty, and any national implementations thereof. 61 | 62 | 2. Waiver. To the greatest extent permitted by, but not in contravention of, 63 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and 64 | unconditionally waives, abandons, and surrenders all of Affirmer's Copyright 65 | and Related Rights and associated claims and causes of action, whether now 66 | known or unknown (including existing as well as future claims and causes of 67 | action), in the Work (i) in all territories worldwide, (ii) for the maximum 68 | duration provided by applicable law or treaty (including future time extensions), 69 | (iii) in any current or future medium and for any number of copies, and (iv) 70 | for any purpose whatsoever, including without limitation commercial, advertising 71 | or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the 72 | benefit of each member of the public at large and to the detriment of Affirmer's 73 | heirs and successors, fully intending that such Waiver shall not be subject 74 | to revocation, rescission, cancellation, termination, or any other legal or 75 | equitable action to disrupt the quiet enjoyment of the Work by the public 76 | as contemplated by Affirmer's express Statement of Purpose. 77 | 78 | 3. Public License Fallback. Should any part of the Waiver for any reason be 79 | judged legally invalid or ineffective under applicable law, then the Waiver 80 | shall be preserved to the maximum extent permitted taking into account Affirmer's 81 | express Statement of Purpose. In addition, to the extent the Waiver is so 82 | judged Affirmer hereby grants to each affected person a royalty-free, non 83 | transferable, non sublicensable, non exclusive, irrevocable and unconditional 84 | license to exercise Affirmer's Copyright and Related Rights in the Work (i) 85 | in all territories worldwide, (ii) for the maximum duration provided by applicable 86 | law or treaty (including future time extensions), (iii) in any current or 87 | future medium and for any number of copies, and (iv) for any purpose whatsoever, 88 | including without limitation commercial, advertising or promotional purposes 89 | (the "License"). The License shall be deemed effective as of the date CC0 90 | was applied by Affirmer to the Work. Should any part of the License for any 91 | reason be judged legally invalid or ineffective under applicable law, such 92 | partial invalidity or ineffectiveness shall not invalidate the remainder of 93 | the License, and in such case Affirmer hereby affirms that he or she will 94 | not (i) exercise any of his or her remaining Copyright and Related Rights 95 | in the Work or (ii) assert any associated claims and causes of action with 96 | respect to the Work, in either case contrary to Affirmer's express Statement 97 | of Purpose. 98 | 99 | 4. Limitations and Disclaimers. 100 | 101 | a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, 102 | licensed or otherwise affected by this document. 103 | 104 | b. Affirmer offers the Work as-is and makes no representations or warranties 105 | of any kind concerning the Work, express, implied, statutory or otherwise, 106 | including without limitation warranties of title, merchantability, fitness 107 | for a particular purpose, non infringement, or the absence of latent or other 108 | defects, accuracy, or the present or absence of errors, whether or not discoverable, 109 | all to the greatest extent permissible under applicable law. 110 | 111 | c. Affirmer disclaims responsibility for clearing rights of other persons 112 | that may apply to the Work or any use thereof, including without limitation 113 | any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims 114 | responsibility for obtaining any necessary consents, permissions or other 115 | rights required for any use of the Work. 116 | 117 | d. Affirmer understands and acknowledges that Creative Commons is not a party 118 | to this document and has no duty or obligation with respect to this CC0 or 119 | use of the Work. 120 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | IchnaeaNlpBackend 8 | =================== 9 | [![Build Status](https://github.com/microg/IchnaeaNlpBackend/workflows/Build/badge.svg)](https://github.com/microg/IchnaeaNlpBackend/actions) 10 | 11 | [UnifiedNlp](https://github.com/microg/UnifiedNlp) backend that uses [Mozilla Location Services](https://location.services.mozilla.com/) to resolve locations. 12 | 13 | License 14 | ------- 15 | Copyright (C) 2015-2022 microG Project Team 16 | 17 | Licensed under the Apache License, Version 2.0 (the "License"); 18 | you may not use this file except in compliance with the License. 19 | You may obtain a copy of the License at 20 | 21 | http://www.apache.org/licenses/LICENSE-2.0 22 | 23 | Unless required by applicable law or agreed to in writing, software 24 | distributed under the License is distributed on an "AS IS" BASIS, 25 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | See the License for the specific language governing permissions and 27 | limitations under the License. 28 | 29 | The launcher icon (res/mipmap-*/ic_launcher.png) is created using the [Launcher Icon Generator from Android Asset Studio](https://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-launcher.html) and thus licensed under [CC BY 3.0](http://creativecommons.org/licenses/by/3.0/). 30 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2013, microG Project Team 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | buildscript { 7 | repositories { 8 | mavenCentral() 9 | google() 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:7.0.4' 13 | } 14 | } 15 | 16 | /* This is a hack, trying to provide release updates to F-Droid until it can properly handle Gradle 17 | applicationId "org.microg.nlp.backend.ichnaea" 18 | versionName "1.5.0" 19 | versionCode "20036" 20 | */ 21 | 22 | apply plugin: 'com.android.application' 23 | 24 | String getMyVersionName() { 25 | def stdout = new ByteArrayOutputStream() 26 | if (rootProject.file("gradlew").exists()) 27 | exec { commandLine 'git', 'describe', '--tags', '--always', '--dirty'; standardOutput = stdout } 28 | else // automatic build system, don't tag dirty 29 | exec { commandLine 'git', 'describe', '--tags', '--always'; standardOutput = stdout } 30 | return stdout.toString().trim().substring(1) 31 | } 32 | 33 | int getMyVersionCode() { 34 | def stdout = new ByteArrayOutputStream() 35 | exec { 36 | commandLine 'git', 'rev-list', '--count', "HEAD" 37 | standardOutput = stdout 38 | } 39 | return Integer.parseInt(stdout.toString().trim()) 40 | } 41 | 42 | repositories { 43 | mavenCentral() 44 | google() 45 | } 46 | 47 | dependencies { 48 | implementation 'org.microg.nlp:api:2.0-alpha9' 49 | } 50 | 51 | android { 52 | compileSdkVersion 31 53 | buildToolsVersion "30.0.2" 54 | 55 | defaultConfig { 56 | versionName getMyVersionName() 57 | versionCode(getMyVersionCode() + 20000) 58 | minSdkVersion 10 59 | targetSdkVersion 29 60 | } 61 | 62 | compileOptions { 63 | sourceCompatibility = 1.8 64 | targetCompatibility = 1.8 65 | } 66 | } 67 | 68 | if (file('user.gradle').exists()) { 69 | apply from: 'user.gradle' 70 | } 71 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microg/IchnaeaNlpBackend/72df2b484b110fd59688661df124553dc62d7e5a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar.license: -------------------------------------------------------------------------------- 1 | Copyright 2015 the original author or authors. 2 | SPDX-License-Identifier: Apache-2.0 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2015, microG Project Team 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | distributionBase=GRADLE_USER_HOME 5 | distributionPath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip 7 | zipStoreBase=GRADLE_USER_HOME 8 | zipStorePath=wrapper/dists 9 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Copyright © 2015-2021 the original authors. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ############################################################################## 21 | # 22 | # Gradle start up script for POSIX generated by Gradle. 23 | # 24 | # Important for running: 25 | # 26 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 27 | # noncompliant, but you have some other compliant shell such as ksh or 28 | # bash, then to run this script, type that shell name before the whole 29 | # command line, like: 30 | # 31 | # ksh Gradle 32 | # 33 | # Busybox and similar reduced shells will NOT work, because this script 34 | # requires all of these POSIX shell features: 35 | # * functions; 36 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 37 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 38 | # * compound commands having a testable exit status, especially «case»; 39 | # * various built-in commands including «command», «set», and «ulimit». 40 | # 41 | # Important for patching: 42 | # 43 | # (2) This script targets any POSIX shell, so it avoids extensions provided 44 | # by Bash, Ksh, etc; in particular arrays are avoided. 45 | # 46 | # The "traditional" practice of packing multiple parameters into a 47 | # space-separated string is a well documented source of bugs and security 48 | # problems, so this is (mostly) avoided, by progressively accumulating 49 | # options in "$@", and eventually passing that to Java. 50 | # 51 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 52 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 53 | # see the in-line comments for details. 54 | # 55 | # There are tweaks for specific operating systems such as AIX, CygWin, 56 | # Darwin, MinGW, and NonStop. 57 | # 58 | # (3) This script is generated from the Groovy template 59 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 60 | # within the Gradle project. 61 | # 62 | # You can find Gradle at https://github.com/gradle/gradle/. 63 | # 64 | ############################################################################## 65 | 66 | # Attempt to set APP_HOME 67 | 68 | # Resolve links: $0 may be a link 69 | app_path=$0 70 | 71 | # Need this for daisy-chained symlinks. 72 | while 73 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 74 | [ -h "$app_path" ] 75 | do 76 | ls=$( ls -ld "$app_path" ) 77 | link=${ls#*' -> '} 78 | case $link in #( 79 | /*) app_path=$link ;; #( 80 | *) app_path=$APP_HOME$link ;; 81 | esac 82 | done 83 | 84 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 85 | 86 | APP_NAME="Gradle" 87 | APP_BASE_NAME=${0##*/} 88 | 89 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 90 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 138 | 139 | Please set the JAVA_HOME variable in your environment to match the 140 | location of your Java installation." 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | MAX_FD=$( ulimit -H -n ) || 148 | warn "Could not query maximum file descriptor limit" 149 | esac 150 | case $MAX_FD in #( 151 | '' | soft) :;; #( 152 | *) 153 | ulimit -n "$MAX_FD" || 154 | warn "Could not set maximum file descriptor limit to $MAX_FD" 155 | esac 156 | fi 157 | 158 | # Collect all arguments for the java command, stacking in reverse order: 159 | # * args from the command line 160 | # * the main class name 161 | # * -classpath 162 | # * -D...appname settings 163 | # * --module-path (only if needed) 164 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 165 | 166 | # For Cygwin or MSYS, switch paths to Windows format before running java 167 | if "$cygwin" || "$msys" ; then 168 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 169 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 170 | 171 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 172 | 173 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 174 | for arg do 175 | if 176 | case $arg in #( 177 | -*) false ;; # don't mess with options #( 178 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 179 | [ -e "$t" ] ;; #( 180 | *) false ;; 181 | esac 182 | then 183 | arg=$( cygpath --path --ignore --mixed "$arg" ) 184 | fi 185 | # Roll the args list around exactly as many times as the number of 186 | # args, so each arg winds up back in the position where it started, but 187 | # possibly modified. 188 | # 189 | # NB: a `for` loop captures its iteration list before it begins, so 190 | # changing the positional parameters here affects neither the number of 191 | # iterations, nor the values presented in `arg`. 192 | shift # remove old arg 193 | set -- "$@" "$arg" # push replacement arg 194 | done 195 | fi 196 | 197 | # Collect all arguments for the java command; 198 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 199 | # shell script including quotes and variable substitutions, so put them in 200 | # double quotes to make sure that they get re-expanded; and 201 | # * put everything else in single quotes, so that it's not re-expanded. 202 | 203 | set -- \ 204 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 205 | -classpath "$CLASSPATH" \ 206 | org.gradle.wrapper.GradleWrapperMain \ 207 | "$@" 208 | 209 | # Use "xargs" to parse quoted args. 210 | # 211 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 212 | # 213 | # In Bash we could simply go: 214 | # 215 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 216 | # set -- "${ARGS[@]}" "$@" 217 | # 218 | # but POSIX shell has neither arrays nor command substitution, so instead we 219 | # post-process each arg (as a line of input to sed) to backslash-escape any 220 | # character that might be a shell metacharacter, then use eval to reverse 221 | # that process (while maintaining the separation between arguments), and wrap 222 | # the whole thing up as a single "set" statement. 223 | # 224 | # This will of course break if any of these variables contains a newline or 225 | # an unmatched quote. 226 | # 227 | 228 | eval "set -- $( 229 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 230 | xargs -n1 | 231 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 232 | tr '\n' ' ' 233 | )" '"$@"' 234 | 235 | exec "$JAVACMD" "$@" 236 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microg/IchnaeaNlpBackend/72df2b484b110fd59688661df124553dc62d7e5a/settings.gradle -------------------------------------------------------------------------------- /src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 29 | 30 | 31 | 32 | 33 | 36 | 39 | 40 | 41 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/java/org/microg/nlp/backend/ichnaea/BackendService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 microG Project Team 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.microg.nlp.backend.ichnaea; 7 | 8 | import android.content.SharedPreferences; 9 | import android.location.Location; 10 | import android.os.Build; 11 | import android.os.Process; 12 | import android.preference.PreferenceManager; 13 | import android.util.Log; 14 | 15 | import org.json.JSONArray; 16 | import org.json.JSONException; 17 | import org.json.JSONObject; 18 | import org.microg.nlp.api.CellBackendHelper; 19 | import org.microg.nlp.api.HelperLocationBackendService; 20 | import org.microg.nlp.api.WiFiBackendHelper; 21 | 22 | import java.util.Set; 23 | 24 | import static org.microg.nlp.api.CellBackendHelper.Cell; 25 | import static org.microg.nlp.api.WiFiBackendHelper.WiFi; 26 | 27 | public class BackendService extends HelperLocationBackendService 28 | implements WiFiBackendHelper.Listener, 29 | CellBackendHelper.Listener, 30 | LocationCallback { 31 | 32 | private static final String TAG = "IchnaeaBackendService"; 33 | private static final long MAX_WIFI_AGE = 60000; 34 | private static final long MAX_CELLS_AGE = 120000; 35 | private static final long RATE_LIMIT_MS_FLOOR = 60000; 36 | private static final long RATE_LIMIT_MS_PADDING = 10000; 37 | private static final String PROVIDER = "ichnaea"; 38 | 39 | private long expBackoffFactor = 0; 40 | 41 | private static BackendService instance; 42 | 43 | private CellDatabase cellDatabase; 44 | private boolean running = false; 45 | private Set wiFis; 46 | private long lastWifiTime = 0; 47 | private boolean wiFisEnabled = false; 48 | private Set cells; 49 | private long lastCellTime = 0; 50 | private boolean cellsEnabled = false; 51 | private long lastRequestTime = 0; 52 | private long lastResponseTime = 0; 53 | 54 | private Location lastResponse = null; 55 | 56 | 57 | @Override 58 | public synchronized void onCreate() { 59 | super.onCreate(); 60 | reloadSettings(); 61 | reloadInstanceSettings(); 62 | } 63 | 64 | @Override 65 | public synchronized boolean canRun() { 66 | long delay = RATE_LIMIT_MS_FLOOR + (RATE_LIMIT_MS_PADDING * expBackoffFactor); 67 | return (Math.max(lastRequestTime, lastResponseTime) + delay < System.currentTimeMillis()); 68 | } 69 | 70 | // Methods to extend or reduce the backoff time 71 | 72 | @Override 73 | public synchronized void extendBackoff() { 74 | if (expBackoffFactor == 0) { 75 | expBackoffFactor = 1; 76 | } else if (expBackoffFactor > 0 && expBackoffFactor < 1024) { 77 | expBackoffFactor *= 2; 78 | } 79 | } 80 | 81 | @Override 82 | public synchronized void reduceBackoff() { 83 | if (expBackoffFactor == 1) { 84 | // Turn the exponential backoff off entirely 85 | expBackoffFactor = 0; 86 | } else { 87 | expBackoffFactor /= 2; 88 | } 89 | } 90 | 91 | @Override 92 | public synchronized void resultCallback(Location locationResult) { 93 | if (locationResult == null) { 94 | if (lastResponse == null) { 95 | // There isn't even a lastResponse to work with 96 | Log.d(TAG, "No previous location to replay"); 97 | return; 98 | } 99 | Log.d(TAG, "Replaying location " + lastResponse); 100 | } else { 101 | lastResponseTime = System.currentTimeMillis(); 102 | lastResponse = locationResult; 103 | } 104 | report(lastResponse); 105 | } 106 | 107 | @Override 108 | protected synchronized void onOpen() { 109 | super.onOpen(); 110 | reloadSettings(); 111 | instance = this; 112 | running = true; 113 | Log.d(TAG, "Activating instance at process " + Process.myPid()); 114 | } 115 | 116 | public static void reloadInstanceSettings() { 117 | if (instance != null) { 118 | instance.reloadSettings(); 119 | } else { 120 | Log.d(TAG, "No instance found active."); 121 | } 122 | } 123 | 124 | private void reloadSettings() { 125 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); 126 | removeHelpers(); 127 | if (preferences.getBoolean("use_cells", true) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 128 | cellsEnabled = true; 129 | addHelper(new CellBackendHelper(this, this)); 130 | cellDatabase = new CellDatabase(this); 131 | } else { 132 | cells = null; 133 | lastCellTime = 0; 134 | cellsEnabled = false; 135 | cellDatabase = null; 136 | } 137 | if (preferences.getBoolean("use_wifis", true)) { 138 | wiFisEnabled = true; 139 | addHelper(new WiFiBackendHelper(this, this)); 140 | } else { 141 | wiFis = null; 142 | lastWifiTime = 0; 143 | wiFisEnabled = false; 144 | } 145 | } 146 | 147 | @Override 148 | protected synchronized void onClose() { 149 | super.onClose(); 150 | running = false; 151 | if (instance == this) { 152 | instance = null; 153 | Log.d(TAG, "Deactivating instance at process " + Process.myPid()); 154 | } 155 | } 156 | 157 | @Override 158 | public void onWiFisChanged(Set wiFis) { 159 | this.wiFis = wiFis; 160 | this.lastWifiTime = System.currentTimeMillis(); 161 | Log.d(TAG, "WiFis: " + wiFis.size()); 162 | if (running) { 163 | startCalculate(); 164 | } 165 | } 166 | 167 | @Override 168 | public void onCellsChanged(Set cells) { 169 | this.cells = cells; 170 | this.lastCellTime = System.currentTimeMillis(); 171 | Log.d(TAG, "Cells: " + cells.size()); 172 | if (running) { 173 | startCalculate(); 174 | } 175 | } 176 | 177 | @Override 178 | protected synchronized Location update() { 179 | return super.update(); 180 | } 181 | 182 | private synchronized void startCalculate() { 183 | Set wiFis = this.wiFis; 184 | if (lastWifiTime < System.currentTimeMillis() - MAX_WIFI_AGE) wiFis = null; 185 | if (wiFis != null && wiFis.size() < 2) wiFis = null; 186 | Set cells = this.cells; 187 | if (lastCellTime < System.currentTimeMillis() - MAX_CELLS_AGE) cells = null; 188 | if (cells != null && cells.isEmpty()) cells = null; 189 | if (cells == null && wiFis == null) return; 190 | if ((lastWifiTime == 0 && wiFisEnabled) || (lastCellTime == 0 && cellsEnabled)) return; 191 | 192 | try { 193 | Location cachedCellLocation = null; 194 | if (cells != null && cells.size() == 1) { 195 | cachedCellLocation = cellDatabase.getLocation(cells.iterator().next()); 196 | } 197 | if (cachedCellLocation != null && wiFis == null) { 198 | // Just use the cached cell location instantly 199 | resultCallback(cachedCellLocation); 200 | return; 201 | } 202 | if (this.canRun()) { 203 | lastRequestTime = System.currentTimeMillis(); 204 | Cell singleCell = cells != null ? cells.iterator().next() : null; 205 | String cellRequest = cells != null ? createRequest(cells, null) : null; 206 | String wifiRequest = wiFis != null ? createRequest(cells, wiFis) : null; 207 | IchnaeaRequester requester = new IchnaeaRequester(this, cellDatabase, singleCell, cellRequest, wifiRequest); 208 | Thread t = new Thread(requester); 209 | t.start(); 210 | } else { 211 | if (cachedCellLocation != null && lastResponse != null 212 | && cachedCellLocation.getAccuracy() <= lastResponse.getAccuracy()) { 213 | resultCallback(cachedCellLocation); 214 | } else { 215 | resultCallback(null); 216 | } 217 | } 218 | } catch (Exception e) { 219 | Log.w(TAG, e); 220 | } 221 | } 222 | 223 | 224 | /** 225 | * see https://mozilla-ichnaea.readthedocs.org/en/latest/cell.html 226 | */ 227 | @SuppressWarnings("MagicNumber") 228 | private static int calculateAsu(Cell cell) { 229 | switch (cell.getType()) { 230 | case GSM: 231 | return Math.max(0, Math.min(31, (cell.getSignal() + 113) / 2)); 232 | case UMTS: 233 | return Math.max(-5, Math.max(91, cell.getSignal() + 116)); 234 | case LTE: 235 | return Math.max(0, Math.min(95, cell.getSignal() + 140)); 236 | case CDMA: 237 | int signal = cell.getSignal(); 238 | if (signal >= -75) { 239 | return 16; 240 | } 241 | if (signal >= -82) { 242 | return 8; 243 | } 244 | if (signal >= -90) { 245 | return 4; 246 | } 247 | if (signal >= -95) { 248 | return 2; 249 | } 250 | if (signal >= -100) { 251 | return 1; 252 | } 253 | return 0; 254 | } 255 | return 0; 256 | } 257 | 258 | private static String getRadioType(Cell cell) { 259 | switch (cell.getType()) { 260 | case CDMA: 261 | return "cdma"; 262 | case LTE: 263 | return "lte"; 264 | case UMTS: 265 | return "wcdma"; 266 | case GSM: 267 | default: 268 | return "gsm"; 269 | } 270 | } 271 | 272 | private static String createRequest(Set cells, Set wiFis) throws JSONException { 273 | JSONObject jsonObject = new JSONObject(); 274 | JSONArray cellTowers = new JSONArray(); 275 | 276 | if (cells != null) { 277 | Cell.CellType lastType = null; 278 | for (Cell cell : cells) { 279 | if (cell.getType() == Cell.CellType.CDMA) { 280 | jsonObject.put("radioType", "cdma"); 281 | } else if (lastType != null && lastType != cell.getType()) { 282 | // We can't contribute if different cell types are mixed. 283 | jsonObject.put("radioType", null); 284 | } else { 285 | jsonObject.put("radioType", getRadioType(cell)); 286 | } 287 | lastType = cell.getType(); 288 | JSONObject cellTower = new JSONObject(); 289 | cellTower.put("radioType", getRadioType(cell)); 290 | cellTower.put("mobileCountryCode", cell.getMcc()); 291 | cellTower.put("mobileNetworkCode", cell.getMnc()); 292 | cellTower.put("locationAreaCode", cell.getLac()); 293 | cellTower.put("cellId", cell.getCid()); 294 | cellTower.put("signalStrength", cell.getSignal()); 295 | if (cell.getPsc() != -1) 296 | cellTower.put("psc", cell.getPsc()); 297 | cellTower.put("asu", calculateAsu(cell)); 298 | cellTowers.put(cellTower); 299 | } 300 | } 301 | JSONArray wifiAccessPoints = new JSONArray(); 302 | if (wiFis != null) { 303 | for (WiFi wiFi : wiFis) { 304 | JSONObject wifiAccessPoint = new JSONObject(); 305 | wifiAccessPoint.put("macAddress", wiFi.getBssid()); 306 | //wifiAccessPoint.put("age", age); 307 | if (wiFi.getChannel() != -1) wifiAccessPoint.put("channel", wiFi.getChannel()); 308 | if (wiFi.getFrequency() != -1) 309 | wifiAccessPoint.put("frequency", wiFi.getFrequency()); 310 | wifiAccessPoint.put("signalStrength", wiFi.getRssi()); 311 | //wifiAccessPoint.put("signalToNoiseRatio", signalToNoiseRatio); 312 | wifiAccessPoints.put(wifiAccessPoint); 313 | } 314 | } 315 | jsonObject.put("cellTowers", cellTowers); 316 | jsonObject.put("wifiAccessPoints", wifiAccessPoints); 317 | jsonObject.put("fallbacks", new JSONObject().put("lacf", true).put("ipf", false)); 318 | return jsonObject.toString(); 319 | } 320 | } 321 | -------------------------------------------------------------------------------- /src/main/java/org/microg/nlp/backend/ichnaea/CellDatabase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 microG Project Team 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.microg.nlp.backend.ichnaea; 7 | 8 | import android.content.ContentValues; 9 | import android.content.Context; 10 | import android.database.Cursor; 11 | import android.database.sqlite.SQLiteDatabase; 12 | import android.database.sqlite.SQLiteOpenHelper; 13 | import android.location.Location; 14 | 15 | import org.microg.nlp.api.CellBackendHelper; 16 | import org.microg.nlp.api.LocationHelper; 17 | 18 | public class CellDatabase extends SQLiteOpenHelper { 19 | private final static String SELECTION = "mcc = ? AND mnc = ? AND type = ? AND lac = ? AND cid = ? AND psc = ?"; 20 | private long MAX_AGE = 1000L*60*60*24*30; // 1 month 21 | 22 | public CellDatabase(Context context) { 23 | super(context, "cellcache.db", null, 1); 24 | } 25 | 26 | private String[] getSelectionArgs(CellBackendHelper.Cell cell) { 27 | return new String[]{String.valueOf(cell.getMcc()), String.valueOf(cell.getMnc()), String.valueOf(cell.getType().ordinal()), String.valueOf(cell.getLac()), String.valueOf(cell.getCid()), String.valueOf(cell.getPsc())}; 28 | } 29 | 30 | public Location getLocation(CellBackendHelper.Cell cell) { 31 | if (cell == null) return null; 32 | try (Cursor cursor = getReadableDatabase().query("cells", new String[]{"lat", "lon", "acc", "time"}, SELECTION, getSelectionArgs(cell), null, null, null)) { 33 | if (cursor.moveToNext()) { 34 | if (cursor.getLong(3) > System.currentTimeMillis() - MAX_AGE) { 35 | return LocationHelper.create("ichnaea", cursor.getDouble(0), cursor.getDouble(1), (float) cursor.getDouble(2)); 36 | } 37 | } 38 | } 39 | return null; 40 | } 41 | 42 | public void putLocation(CellBackendHelper.Cell cell, Location location) { 43 | if (cell == null) return; 44 | ContentValues cv = new ContentValues(); 45 | cv.put("mcc", cell.getMcc()); 46 | cv.put("mnc", cell.getMnc()); 47 | cv.put("lac", cell.getLac()); 48 | cv.put("type", cell.getType().ordinal()); 49 | cv.put("cid", cell.getCid()); 50 | cv.put("psc", cell.getPsc()); 51 | if (location != null) { 52 | cv.put("lat", location.getLatitude()); 53 | cv.put("lon", location.getLongitude()); 54 | cv.put("acc", location.getAccuracy()); 55 | cv.put("time", location.getTime()); 56 | } else { 57 | cv.put("lat", 0.0); 58 | cv.put("lon", 0.0); 59 | cv.put("acc", 0.0); 60 | cv.put("time", System.currentTimeMillis()); 61 | } 62 | getWritableDatabase().insertWithOnConflict("cells", null, cv, SQLiteDatabase.CONFLICT_REPLACE); 63 | } 64 | 65 | @Override 66 | public void onCreate(SQLiteDatabase db) { 67 | db.execSQL("DROP TABLE IF EXISTS cells;"); 68 | db.execSQL("CREATE TABLE cells(mcc INTEGER NOT NULL, mnc INTEGER NOT NULL, type INTEGER NOT NULL, lac INTEGER NOT NULL, cid INTEGER NOT NULL, psc INTEGER NOT NULL, lat REAL NOT NULL, lon REAL NOT NULL, acc REAL NOT NULL, time INTEGER NOT NULL);"); 69 | db.execSQL("CREATE UNIQUE INDEX cells_index ON cells(mcc, mnc, type, lac, cid, psc);"); 70 | } 71 | 72 | @Override 73 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 74 | onCreate(db); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/microg/nlp/backend/ichnaea/IchnaeaRequester.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 microG Project Team 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.microg.nlp.backend.ichnaea; 7 | 8 | import android.location.Location; 9 | import android.util.Log; 10 | 11 | import org.json.JSONException; 12 | import org.json.JSONObject; 13 | import org.microg.nlp.api.CellBackendHelper; 14 | import org.microg.nlp.api.LocationHelper; 15 | 16 | import java.io.ByteArrayOutputStream; 17 | import java.io.IOException; 18 | import java.io.InputStream; 19 | import java.net.HttpURLConnection; 20 | import java.net.URL; 21 | 22 | /* 23 | * This class implements the runnable portion of a thread which 24 | * accepts requests to process a location request and returns results 25 | * via a callback 26 | */ 27 | public class IchnaeaRequester implements Runnable { 28 | 29 | private static final String TAG = "IchnaeaBackendService"; 30 | private static final String SERVICE_URL = "https://location.services.mozilla.com/v1/geolocate?key=%s"; 31 | private static final String API_KEY = "068ab754-c06b-473d-a1e5-60e7b1a2eb77"; 32 | private static final String PROVIDER = "ichnaea"; 33 | 34 | private final LocationCallback callback; 35 | private final CellDatabase cellDatabase; 36 | private final CellBackendHelper.Cell singleCell; 37 | private final String cellRequest; 38 | private final String wifiRequest; 39 | 40 | public IchnaeaRequester(LocationCallback backendService, CellDatabase cellDatabase, CellBackendHelper.Cell singleCell, String cellRequest, String wifiRequest) { 41 | this.callback = backendService; 42 | this.cellDatabase = cellDatabase; 43 | this.singleCell = singleCell; 44 | this.cellRequest = cellRequest; 45 | this.wifiRequest = wifiRequest; 46 | } 47 | 48 | 49 | public void run() { 50 | Location cellLocation = null; 51 | if (singleCell != null) { 52 | cellLocation = cellDatabase.getLocation(singleCell); 53 | } 54 | if (cellLocation == null && cellRequest != null) { 55 | cellLocation = request(cellRequest); 56 | if (cellLocation == null) { 57 | this.callback.extendBackoff(); 58 | this.callback.resultCallback(null); 59 | return; 60 | } 61 | if (singleCell != null) { 62 | cellDatabase.putLocation(singleCell, cellLocation); 63 | } 64 | } 65 | Location wifiLocation = null; 66 | if (wifiRequest != null) { 67 | wifiLocation = request(wifiRequest); 68 | if (wifiLocation == null) { 69 | this.callback.extendBackoff(); 70 | } 71 | } 72 | if (cellLocation == null || cellLocation.getAccuracy() == 0.0) { 73 | this.callback.resultCallback(wifiLocation); 74 | } else if (wifiLocation == null || wifiLocation.getAccuracy() == 0.0) { 75 | this.callback.resultCallback(cellLocation); 76 | } else { 77 | if (cellLocation.distanceTo(wifiLocation) > cellLocation.getAccuracy() * 2) { 78 | // Wifi Location is too far off 79 | this.callback.resultCallback(cellLocation); 80 | } else { 81 | this.callback.resultCallback(wifiLocation); 82 | } 83 | } 84 | } 85 | 86 | private Location request(String request) { 87 | HttpURLConnection conn = null; 88 | try { 89 | conn = (HttpURLConnection) new URL(String.format(SERVICE_URL, API_KEY)).openConnection(); 90 | conn.setDoOutput(true); 91 | conn.setDoInput(true); 92 | Log.d(TAG, "request: " + request); 93 | conn.getOutputStream().write(request.getBytes()); 94 | int respCode = conn.getResponseCode(); 95 | if ((respCode >= 400) && (respCode <= 599)) { 96 | Log.w(TAG, "response code 400-600 -> backoff"); 97 | return null; 98 | } 99 | String r = new String(readStreamToEnd(conn.getInputStream())); 100 | Log.d(TAG, "response: " + r); 101 | JSONObject responseJson = new JSONObject(r); 102 | double lat = responseJson.getJSONObject("location").getDouble("lat"); 103 | double lon = responseJson.getJSONObject("location").getDouble("lng"); 104 | double acc = responseJson.getDouble("accuracy"); 105 | return LocationHelper.create(PROVIDER, lat, lon, (float) acc); 106 | } catch (Exception e) { 107 | if (conn != null) { 108 | InputStream is = conn.getErrorStream(); 109 | if (is != null) { 110 | try { 111 | String error = new String(readStreamToEnd(is)); 112 | Log.w(TAG, "Error: " + error); 113 | } catch (Exception ignored) { 114 | } 115 | } 116 | } 117 | Log.w(TAG, "Error", e); 118 | return null; 119 | } 120 | } 121 | 122 | private static byte[] readStreamToEnd(InputStream is) throws IOException { 123 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 124 | if (is != null) { 125 | byte[] buff = new byte[1024]; 126 | while (true) { 127 | int nb = is.read(buff); 128 | if (nb < 0) { 129 | break; 130 | } 131 | bos.write(buff, 0, nb); 132 | } 133 | is.close(); 134 | } 135 | return bos.toByteArray(); 136 | } 137 | } 138 | 139 | -------------------------------------------------------------------------------- /src/main/java/org/microg/nlp/backend/ichnaea/LocationCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 microG Project Team 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.microg.nlp.backend.ichnaea; 7 | 8 | import android.location.Location; 9 | 10 | public interface LocationCallback { 11 | // returns True if the backoff expiry time doesn't cancel a run 12 | boolean canRun(); 13 | 14 | // Methods to extend or reduce the backoff time 15 | void extendBackoff(); 16 | void reduceBackoff(); 17 | 18 | // How you return data back to the caller 19 | void resultCallback(Location location_result); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/microg/nlp/backend/ichnaea/SettingsActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 microG Project Team 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.microg.nlp.backend.ichnaea; 7 | 8 | import android.os.Bundle; 9 | import android.preference.PreferenceActivity; 10 | import android.util.Log; 11 | 12 | public class SettingsActivity extends PreferenceActivity { 13 | private static final String TAG = "IchnaeaPreferences"; 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | addPreferencesFromResource(R.xml.preferences); 18 | } 19 | 20 | @Override 21 | protected void onPause() { 22 | super.onPause(); 23 | Log.d(TAG, "Preferences paused, reloading backend settings"); 24 | BackendService.reloadInstanceSettings(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microg/IchnaeaNlpBackend/72df2b484b110fd59688661df124553dc62d7e5a/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microg/IchnaeaNlpBackend/72df2b484b110fd59688661df124553dc62d7e5a/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microg/IchnaeaNlpBackend/72df2b484b110fd59688661df124553dc62d7e5a/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microg/IchnaeaNlpBackend/72df2b484b110fd59688661df124553dc62d7e5a/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microg/IchnaeaNlpBackend/72df2b484b110fd59688661df124553dc62d7e5a/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/values-pl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | Usługa Mozilla UnifiedNlp 9 | Usługa lokalizacji Mozilli 10 | Określ lokalizację za pomocą bazy danych online Mozilli 11 | 12 | Wsparcie danymi 13 | Wspomóż danymi 14 | Wyślij informacje o nadajnikach do publicznej bazy danych usługi lokalizacji Mozilli 15 | Ksywka 16 | Używana na liście najaktywniejszych usługi lokalizacji Mozilli (podczas wysyłania danych) 17 | Zainstaluj Mozilla Stumbler 18 | Mozilla Stumbler jest narzędziem pozwalającym zbierać i wysyłać dane do publicznej bazy usługi lokalizacji Mozilli 19 | 20 | Źródła danych 21 | Użyj Wi-Fi 22 | Czy wysyłać dane Wi-Fi do usługi geolokalizacji 23 | Użyj telefonii (GSM/UMTS/LTE/CDMA) 24 | Czy wysyłać dane telefonii komórkowej do usługi geolokalizacji.\nWymaga Androida 4.2 lub nowszego. 25 | 26 | Wspomóż usługę lokalizacji Mozilli 27 | 28 | Usługa lokalizacji Ichnaea pozwala wspomóc bazę danych, a przez to zwiększyć dokładność lokalizacji dla wszystkich użytkowników bez dodatkowego zużycia baterii bądź transferu.
29 | Stuknij tutaj, aby otworzyć ustawienia i aktywować wkład. Dziękujemy.]]>
30 |
31 | -------------------------------------------------------------------------------- /src/main/res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | Mozilla UnifiedNlp Backend 9 | Геолокационный сервис Mozilla 10 | Обнаружение, используя онлайн базу данных Mozilla 11 | 12 | Отправка данных 13 | Отправлять данные 14 | Отправлять информацию о точках доступа в открытую базу данных геолокационного сервиса Mozilla 15 | Псевдоним 16 | Будет использован в таблице лидеров геолокационного сервиса Mozilla (при внесении данных) 17 | Установить Mozilla Stumbler 18 | Mozilla Stumbler – инструмент, позволяющий вносить свой вклад в открытую базу данных геолокационного сервиса Mozilla 19 | 20 | Источники данных 21 | Использовать Wi-Fi 22 | Отправлять ли данные Wi-Fi геолокационному сервису 23 | Использовать сотовую связь (GSM/UMTS/LTE/CDMA) 24 | Отправлять ли данные сотовой связи геолокационному сервису.\nТребуется Android 4.2 или более новый. 25 | 26 | Вклад в геолокационный сервис Mozilla 27 | 28 | Ichnaea Backend позволяет вносить вклад в базу данных, таким образом увеличивая точность геолокации для всех пользователей без дополнительной траты батареи или трафика.
29 | Нажмите здесь, чтобы открыть настройки и включить отправку данных. Спасибо.]]>
30 |
31 | -------------------------------------------------------------------------------- /src/main/res/values-uk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | Mozilla UnifiedNlp Backend 9 | Сервіс позиціювання Mozilla 10 | Позиціювання на основі мережевої бази даних від Mozilla 11 | 12 | Внесок даних 13 | Внести дані 14 | Подавати інформацію про точки доступу до публічної бази даних сервісу позиціювання Mozilla 15 | Псевдонім 16 | Використовується для показу в таблиці лідерів постачальників даних до сервісу позиціювання Mozilla (за умови подачі даних) 17 | Встановити Mozilla Stumbler 18 | Mozilla Stumbler — інструмент для внесення інформації до публічної бази даних сервісу позиціювання Mozilla 19 | 20 | Джерела даних 21 | Використовувати Wi-Fi 22 | Чи подавати дані Wi-Fi до сервісу геолокації 23 | Використовувати стільники (GSM/UMTS/LTE/CDMA) 24 | Чи подавати дані стільникового зв\'язку до сервісу геолокації.\nНеобхідна версія Android 4.2 чи новіша. 25 | 26 | Внесок до сервісу позиціювання Mozilla 27 | 28 | Ichnaea Backend дозволяє вам робити внесок до бази даних, таким чином поліпшуючи точність для всіх користувачів без додаткового використання батареї та мережевого трафіку.
29 | Натисніть тут, аби відкрити налаштування та увімкнути надсилання даних. Дякую.]]>
30 |
31 | -------------------------------------------------------------------------------- /src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Mozilla UnifiedNlp Backend 8 | Mozilla Location Service 9 | Locate using Mozilla\'s online database 10 | 11 | Data contribution 12 | Contribute data 13 | Submit access point information to the public database of Mozilla Location Service 14 | Nickname 15 | Used for the leaderboard of Mozilla Location Service (when submitting) 16 | Install Mozilla Stumbler 17 | Mozilla Stumbler is a tool to contribute information to the public database of Mozilla Location Service 18 | 19 | Data sources 20 | Use Wi-Fi 21 | Whether to send Wi-Fi data to the geolocation service 22 | Use Cell (GSM/UMTS/LTE/CDMA) 23 | Whether to send Cell data to the geolocation service.\nThis requires Android 4.2 or later. 24 | 25 | Contribute to Mozilla Location Service 26 | 27 | Ichnaea Backend allows you to contribute to the database and thus increase location accuracy for all users without additional battery or network usage.
28 | Touch here to open settings and enable contribution. Thanks.]]>
29 |
30 | -------------------------------------------------------------------------------- /src/main/res/xml/preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 15 | 20 | 21 | 22 | 23 | 24 | --------------------------------------------------------------------------------