├── Android.mk ├── AndroidManifest.xml ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── res ├── drawable │ ├── google.png │ ├── ic_logo_google.png │ └── magnifying_glass.png ├── values-cs │ └── strings.xml ├── values-da │ └── strings.xml ├── values-de │ └── strings.xml ├── values-el │ └── strings.xml ├── values-es-rUS │ └── strings.xml ├── values-es │ └── strings.xml ├── values-fr │ └── strings.xml ├── values-it │ └── strings.xml ├── values-ja │ └── strings.xml ├── values-ko │ └── strings.xml ├── values-mcc204 │ └── strings.xml ├── values-mcc230 │ └── strings.xml ├── values-mcc232 │ └── strings.xml ├── values-mcc260 │ └── strings.xml ├── values-mcc262 │ └── strings.xml ├── values-nb │ └── strings.xml ├── values-nl │ └── strings.xml ├── values-pl │ └── strings.xml ├── values-pt-rPT │ └── strings.xml ├── values-pt │ └── strings.xml ├── values-ru │ └── strings.xml ├── values-sv │ └── strings.xml ├── values-tr │ └── strings.xml ├── values-zh-rCN │ └── strings.xml ├── values-zh-rTW │ └── strings.xml ├── values │ └── strings.xml └── xml │ ├── preferences.xml │ └── searchable.xml └── src └── com └── android └── googlesearch ├── GoogleSearch.java ├── LocationUtils.java ├── Settings.java └── SuggestionProvider.java /Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | include $(CLEAR_VARS) 19 | 20 | LOCAL_MODULE_TAGS := user # should be optional, but launcher crashes without this 21 | 22 | LOCAL_STATIC_JAVA_LIBRARIES := google-framework 23 | 24 | LOCAL_SRC_FILES := $(call all-subdir-java-files) 25 | 26 | LOCAL_PACKAGE_NAME := GoogleSearch 27 | LOCAL_CERTIFICATE := shared 28 | 29 | include $(BUILD_PACKAGE) 30 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 58 | 59 | 60 | 61 | 62 | 63 | 66 | 67 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_packages_apps_googlesearch/5cde4d72c6a0b0d01eeb139e75a4a97e7439b6a8/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2005-2008, The Android Open Source Project 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | 13 | 14 | Apache License 15 | Version 2.0, January 2004 16 | http://www.apache.org/licenses/ 17 | 18 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 19 | 20 | 1. Definitions. 21 | 22 | "License" shall mean the terms and conditions for use, reproduction, 23 | and distribution as defined by Sections 1 through 9 of this document. 24 | 25 | "Licensor" shall mean the copyright owner or entity authorized by 26 | the copyright owner that is granting the License. 27 | 28 | "Legal Entity" shall mean the union of the acting entity and all 29 | other entities that control, are controlled by, or are under common 30 | control with that entity. For the purposes of this definition, 31 | "control" means (i) the power, direct or indirect, to cause the 32 | direction or management of such entity, whether by contract or 33 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 34 | outstanding shares, or (iii) beneficial ownership of such entity. 35 | 36 | "You" (or "Your") shall mean an individual or Legal Entity 37 | exercising permissions granted by this License. 38 | 39 | "Source" form shall mean the preferred form for making modifications, 40 | including but not limited to software source code, documentation 41 | source, and configuration files. 42 | 43 | "Object" form shall mean any form resulting from mechanical 44 | transformation or translation of a Source form, including but 45 | not limited to compiled object code, generated documentation, 46 | and conversions to other media types. 47 | 48 | "Work" shall mean the work of authorship, whether in Source or 49 | Object form, made available under the License, as indicated by a 50 | copyright notice that is included in or attached to the work 51 | (an example is provided in the Appendix below). 52 | 53 | "Derivative Works" shall mean any work, whether in Source or Object 54 | form, that is based on (or derived from) the Work and for which the 55 | editorial revisions, annotations, elaborations, or other modifications 56 | represent, as a whole, an original work of authorship. For the purposes 57 | of this License, Derivative Works shall not include works that remain 58 | separable from, or merely link (or bind by name) to the interfaces of, 59 | the Work and Derivative Works thereof. 60 | 61 | "Contribution" shall mean any work of authorship, including 62 | the original version of the Work and any modifications or additions 63 | to that Work or Derivative Works thereof, that is intentionally 64 | submitted to Licensor for inclusion in the Work by the copyright owner 65 | or by an individual or Legal Entity authorized to submit on behalf of 66 | the copyright owner. For the purposes of this definition, "submitted" 67 | means any form of electronic, verbal, or written communication sent 68 | to the Licensor or its representatives, including but not limited to 69 | communication on electronic mailing lists, source code control systems, 70 | and issue tracking systems that are managed by, or on behalf of, the 71 | Licensor for the purpose of discussing and improving the Work, but 72 | excluding communication that is conspicuously marked or otherwise 73 | designated in writing by the copyright owner as "Not a Contribution." 74 | 75 | "Contributor" shall mean Licensor and any individual or Legal Entity 76 | on behalf of whom a Contribution has been received by Licensor and 77 | subsequently incorporated within the Work. 78 | 79 | 2. Grant of Copyright License. Subject to the terms and conditions of 80 | this License, each Contributor hereby grants to You a perpetual, 81 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 82 | copyright license to reproduce, prepare Derivative Works of, 83 | publicly display, publicly perform, sublicense, and distribute the 84 | Work and such Derivative Works in Source or Object form. 85 | 86 | 3. Grant of Patent License. Subject to the terms and conditions of 87 | this License, each Contributor hereby grants to You a perpetual, 88 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 89 | (except as stated in this section) patent license to make, have made, 90 | use, offer to sell, sell, import, and otherwise transfer the Work, 91 | where such license applies only to those patent claims licensable 92 | by such Contributor that are necessarily infringed by their 93 | Contribution(s) alone or by combination of their Contribution(s) 94 | with the Work to which such Contribution(s) was submitted. If You 95 | institute patent litigation against any entity (including a 96 | cross-claim or counterclaim in a lawsuit) alleging that the Work 97 | or a Contribution incorporated within the Work constitutes direct 98 | or contributory patent infringement, then any patent licenses 99 | granted to You under this License for that Work shall terminate 100 | as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the 103 | Work or Derivative Works thereof in any medium, with or without 104 | modifications, and in Source or Object form, provided that You 105 | meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or 108 | Derivative Works a copy of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices 111 | stating that You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works 114 | that You distribute, all copyright, patent, trademark, and 115 | attribution notices from the Source form of the Work, 116 | excluding those notices that do not pertain to any part of 117 | the Derivative Works; and 118 | 119 | (d) If the Work includes a "NOTICE" text file as part of its 120 | distribution, then any Derivative Works that You distribute must 121 | include a readable copy of the attribution notices contained 122 | within such NOTICE file, excluding those notices that do not 123 | pertain to any part of the Derivative Works, in at least one 124 | of the following places: within a NOTICE text file distributed 125 | as part of the Derivative Works; within the Source form or 126 | documentation, if provided along with the Derivative Works; or, 127 | within a display generated by the Derivative Works, if and 128 | wherever such third-party notices normally appear. The contents 129 | of the NOTICE file are for informational purposes only and 130 | do not modify the License. You may add Your own attribution 131 | notices within Derivative Works that You distribute, alongside 132 | or as an addendum to the NOTICE text from the Work, provided 133 | that such additional attribution notices cannot be construed 134 | as modifying the License. 135 | 136 | You may add Your own copyright statement to Your modifications and 137 | may provide additional or different license terms and conditions 138 | for use, reproduction, or distribution of Your modifications, or 139 | for any such Derivative Works as a whole, provided Your use, 140 | reproduction, and distribution of the Work otherwise complies with 141 | the conditions stated in this License. 142 | 143 | 5. Submission of Contributions. Unless You explicitly state otherwise, 144 | any Contribution intentionally submitted for inclusion in the Work 145 | by You to the Licensor shall be under the terms and conditions of 146 | this License, without any additional terms or conditions. 147 | Notwithstanding the above, nothing herein shall supersede or modify 148 | the terms of any separate license agreement you may have executed 149 | with Licensor regarding such Contributions. 150 | 151 | 6. Trademarks. This License does not grant permission to use the trade 152 | names, trademarks, service marks, or product names of the Licensor, 153 | except as required for reasonable and customary use in describing the 154 | origin of the Work and reproducing the content of the NOTICE file. 155 | 156 | 7. Disclaimer of Warranty. Unless required by applicable law or 157 | agreed to in writing, Licensor provides the Work (and each 158 | Contributor provides its Contributions) on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 160 | implied, including, without limitation, any warranties or conditions 161 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 162 | PARTICULAR PURPOSE. You are solely responsible for determining the 163 | appropriateness of using or redistributing the Work and assume any 164 | risks associated with Your exercise of permissions under this License. 165 | 166 | 8. Limitation of Liability. In no event and under no legal theory, 167 | whether in tort (including negligence), contract, or otherwise, 168 | unless required by applicable law (such as deliberate and grossly 169 | negligent acts) or agreed to in writing, shall any Contributor be 170 | liable to You for damages, including any direct, indirect, special, 171 | incidental, or consequential damages of any character arising as a 172 | result of this License or out of the use or inability to use the 173 | Work (including but not limited to damages for loss of goodwill, 174 | work stoppage, computer failure or malfunction, or any and all 175 | other commercial damages or losses), even if such Contributor 176 | has been advised of the possibility of such damages. 177 | 178 | 9. Accepting Warranty or Additional Liability. While redistributing 179 | the Work or Derivative Works thereof, You may choose to offer, 180 | and charge a fee for, acceptance of support, warranty, indemnity, 181 | or other liability obligations and/or rights consistent with this 182 | License. However, in accepting such obligations, You may act only 183 | on Your own behalf and on Your sole responsibility, not on behalf 184 | of any other Contributor, and only if You agree to indemnify, 185 | defend, and hold each Contributor harmless for any liability 186 | incurred by, or claims asserted against, such Contributor by reason 187 | of your accepting any such warranty or additional liability. 188 | 189 | END OF TERMS AND CONDITIONS 190 | 191 | -------------------------------------------------------------------------------- /res/drawable/google.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_packages_apps_googlesearch/5cde4d72c6a0b0d01eeb139e75a4a97e7439b6a8/res/drawable/google.png -------------------------------------------------------------------------------- /res/drawable/ic_logo_google.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_packages_apps_googlesearch/5cde4d72c6a0b0d01eeb139e75a4a97e7439b6a8/res/drawable/ic_logo_google.png -------------------------------------------------------------------------------- /res/drawable/magnifying_glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aosp-mirror/platform_packages_apps_googlesearch/5cde4d72c6a0b0d01eeb139e75a4a97e7439b6a8/res/drawable/magnifying_glass.png -------------------------------------------------------------------------------- /res/values-cs/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Vyhledávání Google" 20 | "Vyhledávání Google" 21 | "Nastavení vyhledávání Google" 22 | "Zobrazovat návrhy webů" 23 | "Při psaní zobrazovat návrhy od Googlu" 24 | "Při psaní nezobrazovat návrhy od Googlu" 25 | 26 | -------------------------------------------------------------------------------- /res/values-da/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google-søgning" 20 | "Google-søgning" 21 | "Google-søgeindstillinger" 22 | "Vis webforslag" 23 | "Vis forslag fra Google, mens du indtaster" 24 | "Vis ikke forslag fra Google, mens du indtaster" 25 | 26 | -------------------------------------------------------------------------------- /res/values-de/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google-Suche" 20 | "Google-Suche" 21 | "Einstellungen der Google-Suche" 22 | "Webvorschläge anzeigen" 23 | "Vorschläge von Google während der Eingabe anzeigen" 24 | "Keine Vorschläge von Google während der Eingabe anzeigen" 25 | 26 | -------------------------------------------------------------------------------- /res/values-el/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Αναζήτηση Google" 20 | "Αναζήτηση Google" 21 | "Ρυθμίσεις αναζήτησης Google" 22 | "Εμφάνιση προτάσεων ιστού" 23 | "Εμφάνιση προτάσεων από το Google κατά την πληκτρολόγηση" 24 | "Χωρίς εμφάνιση προτάσεων από το Google κατά την πληκτρολόγηση" 25 | 26 | -------------------------------------------------------------------------------- /res/values-es-rUS/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Búsqueda de Google" 20 | "Búsqueda de Google" 21 | "Configuración de búsqueda de Google" 22 | "Mostrar suger. web" 23 | "Mostrar sugerencias de Google mientras escribes" 24 | "No mostrar sugerencias de Google mientras escribes" 25 | 26 | -------------------------------------------------------------------------------- /res/values-es/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Búsqueda de Google" 20 | "Búsqueda de Google" 21 | "Configuración de búsqueda de Google" 22 | "Mostrar sugerencias web" 23 | "Mostrar sugerencias de Google al escribir" 24 | "No mostrar sugerencias de Google al escribir" 25 | 26 | -------------------------------------------------------------------------------- /res/values-fr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Recherche Google" 20 | "Recherche Google" 21 | "Paramètres de recherche Google" 22 | "Afficher les suggestions Web" 23 | "Afficher les suggestions de Google lors de la saisie" 24 | "Ne pas afficher les suggestions de Google lors de la saisie" 25 | 26 | -------------------------------------------------------------------------------- /res/values-it/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google Search" 20 | "Ricerca Google" 21 | "Impostazioni ricerca Google" 22 | "Mostra suggerimenti web" 23 | "Mostra suggerimenti Google durante la digitazione" 24 | "Non mostrare suggerimenti da Google durante la digitazione" 25 | 26 | -------------------------------------------------------------------------------- /res/values-ja/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google検索" 20 | "Google検索" 21 | "Google検索の設定" 22 | "検索候補の表示" 23 | "入力時にGoogleの入力候補を表示します" 24 | "入力時にGoogleの入力候補を表示しません" 25 | 26 | -------------------------------------------------------------------------------- /res/values-ko/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google 검색" 20 | "Google 검색" 21 | "Google 검색 설정" 22 | "웹 추천 검색어 표시" 23 | "입력하는 동안 Google에서 추천 검색어 표시" 24 | "입력하는 동안 Google에서 추천 검색어 표시 안함" 25 | 26 | -------------------------------------------------------------------------------- /res/values-mcc204/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | http://www.google.com/complete/search?hl=%1$s&gl=nl& 29 | 30 | -------------------------------------------------------------------------------- /res/values-mcc230/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | http://www.google.com/complete/search?hl=%1$s&gl=cz& 28 | 29 | -------------------------------------------------------------------------------- /res/values-mcc232/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | http://www.google.com/complete/search?hl=%1$s&gl=at& 28 | 29 | -------------------------------------------------------------------------------- /res/values-mcc260/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | http://www.google.com/complete/search?hl=%1$s&gl=pl& 27 | 28 | -------------------------------------------------------------------------------- /res/values-mcc262/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | http://www.google.com/complete/search?hl=%1$s&gl=de& 28 | 29 | -------------------------------------------------------------------------------- /res/values-nb/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google-søk" 20 | "Google-søk" 21 | "Innst. for Google-søk" 22 | "Vis søkeforslag" 23 | "Vis forslag fra Google mens du skriver" 24 | "Ikke vis forslag fra Google mens du skriver" 25 | 26 | -------------------------------------------------------------------------------- /res/values-nl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google Zoeken" 20 | "Google Zoeken" 21 | "Google-zoekinstellingen" 22 | "Websuggesties weergeven" 23 | "Suggesties van Google weergeven terwijl u typt" 24 | "Geen suggesties van Google weergeven terwijl u typt" 25 | 26 | -------------------------------------------------------------------------------- /res/values-pl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Wyszukiwarka Google" 20 | "Szukaj w Google" 21 | "Ustawienia wyszukiwarki Google" 22 | "Pokaż sugestie internetowe" 23 | "Pokaż w trakcie pisania sugestie od Google" 24 | "Nie pokazuj w trakcie pisania sugestii od Google" 25 | 26 | -------------------------------------------------------------------------------- /res/values-pt-rPT/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Pesquisa do Google" 20 | "Pesquisa do Google" 21 | "Definições de pesquisa do Google" 22 | "Mostrar sugestões da Web" 23 | "Mostrar sugestões do Google enquanto escreve" 24 | "Não mostrar sugestões do Google enquanto escreve" 25 | 26 | -------------------------------------------------------------------------------- /res/values-pt/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Pesquisa do Google" 20 | "Pesquisa do Google" 21 | "Configurações de pesquisa do Google" 22 | "Sugestões da web" 23 | "Mostrar sugestões do Google enquanto você digita" 24 | "Não mostrar sugestões do Google enquanto você digita" 25 | 26 | -------------------------------------------------------------------------------- /res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Поиск Google" 20 | "Поиск Google" 21 | "Настройки поиска Google" 22 | "Показывать подсказки веб-поиска" 23 | "Показывать подсказки Google при вводе слов" 24 | "Не показывать подсказки Google при вводе" 25 | 26 | -------------------------------------------------------------------------------- /res/values-sv/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google Sökning" 20 | "Sök på Google" 21 | "Inställningar för Google Sökning" 22 | "Visa webbförslag" 23 | "Visa förslag från Google medan du skriver" 24 | "Visa inte förslag från Google medan du skriver" 25 | 26 | -------------------------------------------------------------------------------- /res/values-tr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google Arama" 20 | "Google Arama" 21 | "Google arama ayarları" 22 | "Web önerilerini göster" 23 | "Yazarken Google önerilerini göster" 24 | "Yazarken Google önerilerini gösterme" 25 | 26 | -------------------------------------------------------------------------------- /res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google 搜索" 20 | "Google 搜索" 21 | "Google 搜索设置" 22 | "显示网络建议" 23 | "输入时显示 Google 提供的建议" 24 | "输入时不显示 Google 提供的建议" 25 | 26 | -------------------------------------------------------------------------------- /res/values-zh-rTW/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | "Google" 19 | "Google 搜尋" 20 | "Google 搜尋" 21 | "Google 搜尋設定" 22 | "顯示網頁建議" 23 | "輸入時顯示 Google 提供的建議" 24 | "輸入時不要顯示 Google 提供的建議" 25 | 26 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | Google 20 | 21 | 22 | Google Search 23 | 24 | 25 | 27 | Google Search 28 | 29 | 30 | Google search settings 31 | 32 | 33 | Show web suggestions 34 | Show suggestions from Google as you type 35 | Don\'t show suggestions from Google as you type 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | http://www.google.com/m?hl=%1$s&gl=%2$s& 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | http://www.google.com/complete/search?hl=%1$s&gl=%2$s& 54 | 55 | -------------------------------------------------------------------------------- /res/xml/preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | 20 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /res/xml/searchable.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 30 | -------------------------------------------------------------------------------- /src/com/android/googlesearch/GoogleSearch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.googlesearch; 18 | 19 | import com.google.android.providers.GoogleSettings.Partner; 20 | 21 | import java.io.UnsupportedEncodingException; 22 | import java.net.URLEncoder; 23 | import java.util.Locale; 24 | 25 | import android.app.Activity; 26 | import android.app.SearchManager; 27 | import android.content.ContentResolver; 28 | import android.content.Context; 29 | import android.content.Intent; 30 | import android.location.Location; 31 | import android.location.LocationManager; 32 | import android.net.Uri; 33 | import android.os.Bundle; 34 | import android.provider.Browser; 35 | import android.provider.Settings; 36 | import android.text.TextUtils; 37 | import android.util.Log; 38 | 39 | /** 40 | * This class is purely here to get search queries and route them to 41 | * the global {@link Intent#ACTION_WEB_SEARCH}. 42 | */ 43 | public class GoogleSearch extends Activity { 44 | private static final String TAG = "GoogleSearch"; 45 | 46 | // The template URL we should use to format google search requests. 47 | private String googleSearchUrlBase = null; 48 | 49 | // "source" parameter for Google search requests from unknown sources (e.g. apps). This will get 50 | // prefixed with the string 'android-' before being sent on the wire. 51 | final static String GOOGLE_SEARCH_SOURCE_UNKNOWN = "unknown"; 52 | 53 | private LocationUtils mLocationUtils; 54 | 55 | @Override 56 | protected void onCreate(Bundle savedInstanceState) { 57 | super.onCreate(savedInstanceState); 58 | mLocationUtils = LocationUtils.getLocationUtils(this); 59 | Intent intent = getIntent(); 60 | String action = intent != null ? intent.getAction() : null; 61 | if (Intent.ACTION_WEB_SEARCH.equals(action) || Intent.ACTION_SEARCH.equals(action)) { 62 | handleWebSearchIntent(intent); 63 | } 64 | finish(); 65 | } 66 | 67 | /** 68 | * NOTE: This function is similar to the one found in 69 | * com.google.android.providers.enhancedgooglesearch.Launcher. If you are changing this 70 | * make sure you change both. 71 | */ 72 | private void handleWebSearchIntent(Intent intent) { 73 | String query = intent.getStringExtra(SearchManager.QUERY); 74 | if (TextUtils.isEmpty(query)) { 75 | Log.w(TAG, "Got search intent with no query."); 76 | return; 77 | } 78 | 79 | if (googleSearchUrlBase == null) { 80 | Locale l = Locale.getDefault(); 81 | String language = l.getLanguage(); 82 | String country = l.getCountry().toLowerCase(); 83 | // Chinese and Portuguese have two langauge variants. 84 | if ("zh".equals(language)) { 85 | if ("cn".equals(country)) { 86 | language = "zh-CN"; 87 | } else if ("tw".equals(country)) { 88 | language = "zh-TW"; 89 | } 90 | } else if ("pt".equals(language)) { 91 | if ("br".equals(country)) { 92 | language = "pt-BR"; 93 | } else if ("pt".equals(country)) { 94 | language = "pt-PT"; 95 | } 96 | } 97 | googleSearchUrlBase = getResources().getString( 98 | R.string.google_search_base, language, country) 99 | + "client=ms-" 100 | + Partner.getString(this.getContentResolver(), Partner.CLIENT_ID); 101 | } 102 | 103 | // If the caller specified a 'source' url parameter, use that and if not use default. 104 | Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA); 105 | String source = GOOGLE_SEARCH_SOURCE_UNKNOWN; 106 | if (appSearchData != null) { 107 | source = appSearchData.getString(SearchManager.SOURCE); 108 | } 109 | 110 | // The browser can pass along an application id which it uses to figure out which 111 | // window to place a new search into. So if this exists, we'll pass it back to 112 | // the browser. Otherwise, add our own package name as the application id, so that 113 | // the browser can organize all searches launched from this provider together. 114 | String applicationId = intent.getStringExtra(Browser.EXTRA_APPLICATION_ID); 115 | if (applicationId == null) { 116 | applicationId = getPackageName(); 117 | } 118 | 119 | try { 120 | String searchUri = googleSearchUrlBase 121 | + "&source=android-" + source 122 | + "&q=" + URLEncoder.encode(query, "UTF-8"); 123 | Intent launchUriIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(searchUri)); 124 | launchUriIntent.putExtra(Browser.EXTRA_APPLICATION_ID, applicationId); 125 | launchUriIntent.putExtra(Browser.EXTRA_POST_DATA, getLocationData()); 126 | launchUriIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 127 | startActivity(launchUriIntent); 128 | } catch (UnsupportedEncodingException e) { 129 | Log.w(TAG, "Error", e); 130 | } 131 | } 132 | 133 | private byte[] getLocationData() { 134 | byte[] postData = null; 135 | ContentResolver cr = getContentResolver(); 136 | 137 | // Don't send any location if the system does not have GoogleSettingsProvider. 138 | if (!mLocationUtils.systemHasGoogleSettingsProvider()) return postData; 139 | 140 | if (!mLocationUtils.userRespondedToLocationOptIn()) { 141 | // Bring up the consent dialog if it the user has yet responded to it. We 142 | // will not send the location info for this query. 143 | mLocationUtils.showLocationOptIn(); 144 | } else if (mLocationUtils.userAcceptedLocationOptIn() && 145 | Settings.Secure.isLocationProviderEnabled(cr, LocationManager.NETWORK_PROVIDER)) { 146 | Location location = ((LocationManager) getSystemService( 147 | Context.LOCATION_SERVICE)).getLastKnownLocation( 148 | LocationManager.NETWORK_PROVIDER); 149 | if (location != null) { 150 | StringBuilder str = new StringBuilder("action=devloc&sll="); 151 | str.append(location.getLatitude()).append(',').append(location.getLongitude()); 152 | postData = str.toString().getBytes(); 153 | } 154 | } 155 | return postData; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/com/android/googlesearch/LocationUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.googlesearch; 18 | 19 | import android.content.Context; 20 | import android.content.Intent; 21 | import android.content.pm.PackageManager; 22 | 23 | /** 24 | * Utility methods for dealing with location (such as opt-in stuff). 25 | */ 26 | public class LocationUtils { 27 | private Context mContext; 28 | 29 | // The singleton object. 30 | private static LocationUtils sLocationUtils; 31 | 32 | /** 33 | * Gets the singleton. 34 | */ 35 | public static synchronized LocationUtils getLocationUtils(Context context) { 36 | if (sLocationUtils == null) { 37 | sLocationUtils = new LocationUtils(context); 38 | } 39 | return sLocationUtils; 40 | } 41 | 42 | /** 43 | * Private constructor for singleton class; use {@link #getLocationUtils(Context)}. 44 | */ 45 | private LocationUtils(Context context) { 46 | mContext = context; 47 | } 48 | 49 | /** 50 | * Identifies whether this system has the GoogleSettingsProvider, which determines 51 | * whether the other methods in this class are relevant, or if we should just avoid 52 | * using location. 53 | */ 54 | public boolean systemHasGoogleSettingsProvider() { 55 | try { 56 | return mContext.getPackageManager().getPackageInfo( 57 | "com.google.android.providers.settings", 0) != null; 58 | } catch (PackageManager.NameNotFoundException e) { 59 | return false; 60 | } 61 | } 62 | 63 | /** 64 | * Checks whether the user has responded (either positively or negatively) to the 65 | * Google location opt-in. 66 | */ 67 | public boolean userRespondedToLocationOptIn() { 68 | return android.provider.Settings.Secure.getInt(mContext.getContentResolver(), 69 | android.provider.Settings.Secure.USE_LOCATION_FOR_SERVICES, 2) != 2; 70 | } 71 | 72 | /** 73 | * Shows the location opt-in because the user has not yet responded to it. If 74 | * we have GoogleSettingsProvider, this fires up the 'security & location' settings 75 | * and requests to show the opt-in. If we do not, this does nothing. 76 | */ 77 | public void showLocationOptIn() { 78 | if (systemHasGoogleSettingsProvider()) { 79 | Intent consent = new Intent( 80 | android.provider.Settings.ACTION_SECURITY_SETTINGS); 81 | consent.putExtra("SHOW_USE_LOCATION", true); 82 | consent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 83 | mContext.startActivity(consent); 84 | } 85 | } 86 | 87 | /** 88 | * Indicates whether the user has accepted the Google location opt-in. Checks the appropriate 89 | * setting depending on whether we are using the GoogleSettingsProvider setting or our 90 | * own package-local setting. 91 | * 92 | * If the answer is false, it could be because the user responded negatively to the opt-in, 93 | * or because the system does not have GoogleSettingsProvider. Use 94 | * {@link #userRespondedToLocationOptIn()} to distinguish between these two cases. 95 | */ 96 | public boolean userAcceptedLocationOptIn() { 97 | if (systemHasGoogleSettingsProvider()) { 98 | return android.provider.Settings.Secure.getInt(mContext.getContentResolver(), 99 | android.provider.Settings.Secure.USE_LOCATION_FOR_SERVICES, 2) == 1; 100 | } else { 101 | return false; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/com/android/googlesearch/Settings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.googlesearch; 18 | 19 | import android.os.Bundle; 20 | import android.preference.CheckBoxPreference; 21 | import android.preference.Preference; 22 | import android.preference.PreferenceActivity; 23 | import android.preference.PreferenceScreen; 24 | import android.preference.Preference.OnPreferenceClickListener; 25 | import android.provider.Settings.System; 26 | 27 | /** 28 | * Activity for setting Google search preferences. 29 | */ 30 | public class Settings extends PreferenceActivity implements OnPreferenceClickListener { 31 | 32 | private static final String SHOW_WEB_SUGGESTIONS_PREF = "show_web_suggestions"; 33 | 34 | private CheckBoxPreference mShowWebSuggestionsPreference; 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | addPreferencesFromResource(R.xml.preferences); 40 | PreferenceScreen preferenceScreen = getPreferenceScreen(); 41 | mShowWebSuggestionsPreference = (CheckBoxPreference) 42 | findPreference(SHOW_WEB_SUGGESTIONS_PREF); 43 | mShowWebSuggestionsPreference.setOnPreferenceClickListener(this); 44 | } 45 | 46 | public synchronized boolean onPreferenceClick(Preference preference) { 47 | if (preference == mShowWebSuggestionsPreference) { 48 | System.putInt( 49 | getContentResolver(), 50 | System.SHOW_WEB_SUGGESTIONS, 51 | mShowWebSuggestionsPreference.isChecked() ? 1 : 0); 52 | return true; 53 | } 54 | return false; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/com/android/googlesearch/SuggestionProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.googlesearch; 18 | 19 | import com.google.android.net.GoogleHttpClient; 20 | 21 | import org.apache.http.HttpResponse; 22 | import org.apache.http.client.HttpClient; 23 | import org.apache.http.client.methods.HttpPost; 24 | import org.apache.http.entity.StringEntity; 25 | import org.apache.http.params.HttpParams; 26 | import org.apache.http.util.EntityUtils; 27 | import org.json.JSONArray; 28 | import org.json.JSONException; 29 | 30 | import android.app.SearchManager; 31 | import android.content.ContentProvider; 32 | import android.content.ContentValues; 33 | import android.content.Context; 34 | import android.database.AbstractCursor; 35 | import android.database.Cursor; 36 | import android.net.ConnectivityManager; 37 | import android.net.NetworkInfo; 38 | import android.net.Uri; 39 | import android.text.TextUtils; 40 | import android.util.Log; 41 | 42 | import java.io.IOException; 43 | import java.io.UnsupportedEncodingException; 44 | import java.net.URLEncoder; 45 | import java.util.Locale; 46 | 47 | /** 48 | * Use network-based Google Suggests to provide search suggestions. 49 | * 50 | * Future: Merge live suggestions with saved recent queries 51 | */ 52 | public class SuggestionProvider extends ContentProvider { 53 | 54 | private static final String LOG_TAG = "GoogleSearch"; 55 | 56 | private static final String USER_AGENT = "Android/1.0"; 57 | private String mSuggestUri; 58 | private static final int HTTP_TIMEOUT_MS = 1000; 59 | 60 | // TODO: this should be defined somewhere 61 | private static final String HTTP_TIMEOUT = "http.connection-manager.timeout"; 62 | 63 | private static final String SUGGESTION_ICON = 64 | "android.resource://com.android.googlesearch/" + R.drawable.magnifying_glass; 65 | 66 | // Indexes into COLUMNS 67 | private static final int COL_ID = 0; 68 | private static final int COL_TEXT_1 = 1; 69 | private static final int COL_TEXT_2 = 2; 70 | private static final int COL_ICON_1 = 3; 71 | private static final int COL_ICON_2 = 4; 72 | private static final int COL_QUERY = 5; 73 | 74 | /* The suggestion columns used */ 75 | private static final String[] COLUMNS = new String[] { 76 | "_id", 77 | SearchManager.SUGGEST_COLUMN_TEXT_1, 78 | SearchManager.SUGGEST_COLUMN_TEXT_2, 79 | SearchManager.SUGGEST_COLUMN_ICON_1, 80 | SearchManager.SUGGEST_COLUMN_ICON_2, 81 | SearchManager.SUGGEST_COLUMN_QUERY 82 | }; 83 | 84 | private HttpClient mHttpClient; 85 | 86 | @Override 87 | public boolean onCreate() { 88 | mHttpClient = new GoogleHttpClient(getContext(), USER_AGENT, false /* not gzip capable */); 89 | HttpParams params = mHttpClient.getParams(); 90 | params.setLongParameter(HTTP_TIMEOUT, HTTP_TIMEOUT_MS); 91 | 92 | // NOTE: Do not look up the resource here; Localization changes may not have completed 93 | // yet (e.g. we may still be reading the SIM card). 94 | mSuggestUri = null; 95 | return true; 96 | } 97 | 98 | /** 99 | * This will always return {@link SearchManager#SUGGEST_MIME_TYPE} as this 100 | * provider is purely to provide suggestions. 101 | */ 102 | @Override 103 | public String getType(Uri uri) { 104 | return SearchManager.SUGGEST_MIME_TYPE; 105 | } 106 | 107 | /** 108 | * Queries for a given search term and returns a cursor containing 109 | * suggestions ordered by best match. 110 | */ 111 | @Override 112 | public Cursor query(Uri uri, String[] projection, String selection, 113 | String[] selectionArgs, String sortOrder) { 114 | String query = selectionArgs[0]; 115 | if (TextUtils.isEmpty(query)) { 116 | return null; 117 | } 118 | if (!isNetworkConnected()) { 119 | Log.i(LOG_TAG, "Not connected to network."); 120 | return null; 121 | } 122 | try { 123 | query = URLEncoder.encode(query, "UTF-8"); 124 | // NOTE: This code uses resources to optionally select the search Uri, based on the 125 | // MCC value from the SIM. iThe default string will most likely be fine. It is 126 | // paramerterized to accept info from the Locale, the language code is the first 127 | // parameter (%1$s) and the country code is the second (%2$s). This code *must* 128 | // function in the same way as a similar lookup in 129 | // com.android.browser.BrowserActivity#onCreate(). If you change 130 | // either of these functions, change them both. (The same is true for the underlying 131 | // resource strings, which are stored in mcc-specific xml files.) 132 | if (mSuggestUri == null) { 133 | Locale l = Locale.getDefault(); 134 | String language = l.getLanguage(); 135 | String country = l.getCountry().toLowerCase(); 136 | // Chinese and Portuguese have two langauge variants. 137 | if ("zh".equals(language)) { 138 | if ("cn".equals(country)) { 139 | language = "zh-CN"; 140 | } else if ("tw".equals(country)) { 141 | language = "zh-TW"; 142 | } 143 | } else if ("pt".equals(language)) { 144 | if ("br".equals(country)) { 145 | language = "pt-BR"; 146 | } else if ("pt".equals(country)) { 147 | language = "pt-PT"; 148 | } 149 | } 150 | mSuggestUri = getContext().getResources().getString(R.string.google_suggest_base, 151 | language, 152 | country) 153 | + "json=true&q="; 154 | } 155 | 156 | HttpPost method = new HttpPost(mSuggestUri + query); 157 | StringEntity content = new StringEntity(""); 158 | method.setEntity(content); 159 | HttpResponse response = mHttpClient.execute(method); 160 | if (response.getStatusLine().getStatusCode() == 200) { 161 | 162 | /* Goto http://www.google.com/complete/search?json=true&q=foo 163 | * to see what the data format looks like. It's basically a json 164 | * array containing 4 other arrays. We only care about the middle 165 | * 2 which contain the suggestions and their popularity. 166 | */ 167 | JSONArray results = new JSONArray(EntityUtils.toString(response.getEntity())); 168 | JSONArray suggestions = results.getJSONArray(1); 169 | JSONArray popularity = results.getJSONArray(2); 170 | return new SuggestionsCursor(suggestions, popularity); 171 | } 172 | } catch (UnsupportedEncodingException e) { 173 | Log.w(LOG_TAG, "Error", e); 174 | } catch (IOException e) { 175 | Log.w(LOG_TAG, "Error", e); 176 | } catch (JSONException e) { 177 | Log.w(LOG_TAG, "Error", e); 178 | } 179 | return null; 180 | } 181 | 182 | private boolean isNetworkConnected() { 183 | NetworkInfo networkInfo = getActiveNetworkInfo(); 184 | return networkInfo != null && networkInfo.isConnected(); 185 | } 186 | 187 | private NetworkInfo getActiveNetworkInfo() { 188 | ConnectivityManager connectivity = 189 | (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); 190 | if (connectivity == null) { 191 | return null; 192 | } 193 | return connectivity.getActiveNetworkInfo(); 194 | } 195 | 196 | private static class SuggestionsCursor extends AbstractCursor { 197 | 198 | /* Contains the actual suggestions */ 199 | final JSONArray mSuggestions; 200 | 201 | /* This contains the popularity of each suggestion 202 | * i.e. 165,000 results. It's not related to sorting. 203 | */ 204 | final JSONArray mPopularity; 205 | public SuggestionsCursor(JSONArray suggestions, JSONArray popularity) { 206 | mSuggestions = suggestions; 207 | mPopularity = popularity; 208 | } 209 | 210 | @Override 211 | public int getCount() { 212 | return mSuggestions.length(); 213 | } 214 | 215 | @Override 216 | public String[] getColumnNames() { 217 | return COLUMNS; 218 | } 219 | 220 | @Override 221 | public String getString(int column) { 222 | if (mPos == -1) return null; 223 | try { 224 | switch (column) { 225 | case COL_ID: 226 | return String.valueOf(mPos); 227 | case COL_TEXT_1: 228 | case COL_QUERY: 229 | return mSuggestions.getString(mPos); 230 | case COL_TEXT_2: 231 | return mPopularity.getString(mPos); 232 | case COL_ICON_1: 233 | return SUGGESTION_ICON; 234 | case COL_ICON_2: 235 | return null; 236 | default: 237 | Log.w(LOG_TAG, "Bad column: " + column); 238 | return null; 239 | } 240 | } catch (JSONException e) { 241 | Log.w(LOG_TAG, "Error parsing response: " + e); 242 | return null; 243 | } 244 | 245 | } 246 | 247 | @Override 248 | public double getDouble(int column) { 249 | throw new UnsupportedOperationException(); 250 | } 251 | 252 | @Override 253 | public float getFloat(int column) { 254 | throw new UnsupportedOperationException(); 255 | } 256 | 257 | @Override 258 | public int getInt(int column) { 259 | throw new UnsupportedOperationException(); 260 | } 261 | 262 | @Override 263 | public long getLong(int column) { 264 | if (column == COL_ID) { 265 | return mPos; // use row# as the _Id 266 | } 267 | throw new UnsupportedOperationException(); 268 | } 269 | 270 | @Override 271 | public short getShort(int column) { 272 | throw new UnsupportedOperationException(); 273 | } 274 | 275 | @Override 276 | public boolean isNull(int column) { 277 | throw new UnsupportedOperationException(); 278 | } 279 | } 280 | 281 | @Override 282 | public Uri insert(Uri uri, ContentValues values) { 283 | throw new UnsupportedOperationException(); 284 | } 285 | 286 | @Override 287 | public int update(Uri uri, ContentValues values, String selection, 288 | String[] selectionArgs) { 289 | throw new UnsupportedOperationException(); 290 | } 291 | 292 | @Override 293 | public int delete(Uri uri, String selection, String[] selectionArgs) { 294 | throw new UnsupportedOperationException(); 295 | } 296 | } 297 | --------------------------------------------------------------------------------