The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 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 | |
Daniel Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
Sunny Goyal | 22ca9ec | 2017-05-18 15:03:13 -0700 | [diff] [blame] | 19 | import android.annotation.TargetApi; |
Mike Cleron | b87bd16 | 2009-10-30 16:36:56 -0700 | [diff] [blame] | 20 | import android.appwidget.AppWidgetManager; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 21 | import android.content.ComponentName; |
Adam Cohen | 228da5a | 2011-07-27 22:23:47 -0700 | [diff] [blame] | 22 | import android.content.ContentProvider; |
Yura | 085c853 | 2014-02-11 15:15:29 +0000 | [diff] [blame] | 23 | import android.content.ContentProviderOperation; |
| 24 | import android.content.ContentProviderResult; |
Adam Cohen | 228da5a | 2011-07-27 22:23:47 -0700 | [diff] [blame] | 25 | import android.content.ContentUris; |
| 26 | import android.content.ContentValues; |
Yura | 085c853 | 2014-02-11 15:15:29 +0000 | [diff] [blame] | 27 | import android.content.OperationApplicationException; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 28 | import android.database.Cursor; |
Adam Cohen | 228da5a | 2011-07-27 22:23:47 -0700 | [diff] [blame] | 29 | import android.database.sqlite.SQLiteQueryBuilder; |
Adam Cohen | 228da5a | 2011-07-27 22:23:47 -0700 | [diff] [blame] | 30 | import android.net.Uri; |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 31 | import android.os.Binder; |
Sunny Goyal | 22ca9ec | 2017-05-18 15:03:13 -0700 | [diff] [blame] | 32 | import android.os.Build; |
Sunny Goyal | b2d46ce | 2015-03-26 11:32:11 -0700 | [diff] [blame] | 33 | import android.os.Bundle; |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 34 | import android.os.Process; |
Adam Cohen | 228da5a | 2011-07-27 22:23:47 -0700 | [diff] [blame] | 35 | import android.text.TextUtils; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 36 | import android.util.Log; |
Adam Cohen | 228da5a | 2011-07-27 22:23:47 -0700 | [diff] [blame] | 37 | |
Sunny Goyal | 0fe505b | 2014-08-06 09:55:36 -0700 | [diff] [blame] | 38 | import com.android.launcher3.LauncherSettings.Favorites; |
Sunny Goyal | a9e2f5a | 2016-06-10 12:22:04 -0700 | [diff] [blame] | 39 | import com.android.launcher3.config.FeatureFlags; |
Sunny Goyal | 1ae46ca | 2023-04-10 15:28:59 -0700 | [diff] [blame] | 40 | import com.android.launcher3.model.ModelDbController; |
Sunny Goyal | dbfc901 | 2017-04-17 16:58:36 -0700 | [diff] [blame] | 41 | import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction; |
Sihua Ma | 8bbfcb6 | 2022-11-08 16:46:07 -0800 | [diff] [blame] | 42 | import com.android.launcher3.widget.LauncherWidgetHolder; |
Michael Jurka | 8b805b1 | 2012-04-18 14:23:14 -0700 | [diff] [blame] | 43 | |
Hyunyoung Song | 6aa3729 | 2017-02-06 10:46:24 -0800 | [diff] [blame] | 44 | import java.io.FileDescriptor; |
| 45 | import java.io.PrintWriter; |
Adam Cohen | 228da5a | 2011-07-27 22:23:47 -0700 | [diff] [blame] | 46 | import java.util.ArrayList; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 47 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 48 | public class LauncherProvider extends ContentProvider { |
Sunny Goyal | c74e419 | 2015-09-08 14:01:03 -0700 | [diff] [blame] | 49 | private static final String TAG = "LauncherProvider"; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 50 | |
Sunny Goyal | 4276e7b | 2018-11-26 23:44:41 -0800 | [diff] [blame] | 51 | public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".settings"; |
Winson Chung | 3d503fb | 2011-07-13 17:25:49 -0700 | [diff] [blame] | 52 | |
Hyunyoung Song | 6aa3729 | 2017-02-06 10:46:24 -0800 | [diff] [blame] | 53 | /** |
| 54 | * $ adb shell dumpsys activity provider com.android.launcher3 |
| 55 | */ |
| 56 | @Override |
| 57 | public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { |
| 58 | LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); |
| 59 | if (appState == null || !appState.getModel().isModelLoaded()) { |
| 60 | return; |
| 61 | } |
| 62 | appState.getModel().dumpState("", fd, writer, args); |
| 63 | } |
| 64 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 65 | @Override |
| 66 | public boolean onCreate() { |
Zak Cohen | 3eeb41d | 2020-02-14 14:15:13 -0800 | [diff] [blame] | 67 | if (FeatureFlags.IS_STUDIO_BUILD) { |
Sunny Goyal | e26d100 | 2016-06-20 14:52:14 -0700 | [diff] [blame] | 68 | Log.d(TAG, "Launcher process started"); |
| 69 | } |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 70 | |
Sunny Goyal | fdbef27 | 2017-02-01 12:52:54 -0800 | [diff] [blame] | 71 | // The content provider exists for the entire duration of the launcher main process and |
Sunny Goyal | 66f2b35 | 2018-02-09 10:57:12 -0800 | [diff] [blame] | 72 | // is the first component to get created. |
| 73 | MainProcessInitializer.initialize(getContext().getApplicationContext()); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 74 | return true; |
| 75 | } |
| 76 | |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 77 | public ModelDbController getModelDbController() { |
| 78 | return LauncherAppState.getInstance(getContext()).getModel().getModelDbController(); |
| 79 | } |
| 80 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 81 | @Override |
| 82 | public String getType(Uri uri) { |
| 83 | SqlArguments args = new SqlArguments(uri, null, null); |
| 84 | if (TextUtils.isEmpty(args.where)) { |
| 85 | return "vnd.android.cursor.dir/" + args.table; |
| 86 | } else { |
| 87 | return "vnd.android.cursor.item/" + args.table; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public Cursor query(Uri uri, String[] projection, String selection, |
| 93 | String[] selectionArgs, String sortOrder) { |
| 94 | |
| 95 | SqlArguments args = new SqlArguments(uri, selection, selectionArgs); |
| 96 | SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); |
| 97 | qb.setTables(args.table); |
| 98 | |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 99 | Cursor result = getModelDbController().query( |
Sunny Goyal | 1ae46ca | 2023-04-10 15:28:59 -0700 | [diff] [blame] | 100 | args.table, projection, args.where, args.args, sortOrder); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 101 | result.setNotificationUri(getContext().getContentResolver(), uri); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 102 | return result; |
| 103 | } |
| 104 | |
Sunny Goyal | d106418 | 2015-08-13 12:08:30 -0700 | [diff] [blame] | 105 | private void reloadLauncherIfExternal() { |
Sunny Goyal | 8c48d8b | 2019-01-25 15:10:18 -0800 | [diff] [blame] | 106 | if (Binder.getCallingPid() != Process.myPid()) { |
Sunny Goyal | d106418 | 2015-08-13 12:08:30 -0700 | [diff] [blame] | 107 | LauncherAppState app = LauncherAppState.getInstanceNoCreate(); |
| 108 | if (app != null) { |
Sunny Goyal | dd96a5e | 2017-02-17 11:22:34 -0800 | [diff] [blame] | 109 | app.getModel().forceReload(); |
Sunny Goyal | d106418 | 2015-08-13 12:08:30 -0700 | [diff] [blame] | 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 114 | @Override |
| 115 | public Uri insert(Uri uri, ContentValues initialValues) { |
Sunny Goyal | d106418 | 2015-08-13 12:08:30 -0700 | [diff] [blame] | 116 | // In very limited cases, we support system|signature permission apps to modify the db. |
| 117 | if (Binder.getCallingPid() != Process.myPid()) { |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 118 | if (!initializeExternalAdd(initialValues)) { |
Adam Cohen | a043fa8 | 2014-07-23 14:49:38 -0700 | [diff] [blame] | 119 | return null; |
| 120 | } |
| 121 | } |
| 122 | |
Sunny Goyal | 1ae46ca | 2023-04-10 15:28:59 -0700 | [diff] [blame] | 123 | SqlArguments args = new SqlArguments(uri); |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 124 | int rowId = getModelDbController().insert(args.table, initialValues); |
Sunny Goyal | e72f3d5 | 2015-03-02 14:24:21 -0800 | [diff] [blame] | 125 | if (rowId < 0) return null; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 126 | |
| 127 | uri = ContentUris.withAppendedId(uri, rowId); |
Sunny Goyal | 8c48d8b | 2019-01-25 15:10:18 -0800 | [diff] [blame] | 128 | reloadLauncherIfExternal(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 129 | return uri; |
| 130 | } |
| 131 | |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 132 | private boolean initializeExternalAdd(ContentValues values) { |
| 133 | // 1. Ensure that externally added items have a valid item id |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 134 | int id = getModelDbController().generateNewItemId(); |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 135 | values.put(LauncherSettings.Favorites._ID, id); |
| 136 | |
| 137 | // 2. In the case of an app widget, and if no app widget id is specified, we |
| 138 | // attempt allocate and bind the widget. |
| 139 | Integer itemType = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE); |
| 140 | if (itemType != null && |
| 141 | itemType.intValue() == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET && |
| 142 | !values.containsKey(LauncherSettings.Favorites.APPWIDGET_ID)) { |
| 143 | |
| 144 | final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getContext()); |
| 145 | ComponentName cn = ComponentName.unflattenFromString( |
| 146 | values.getAsString(Favorites.APPWIDGET_PROVIDER)); |
| 147 | |
| 148 | if (cn != null) { |
Sunny Goyal | 1ae46ca | 2023-04-10 15:28:59 -0700 | [diff] [blame] | 149 | LauncherWidgetHolder widgetHolder = LauncherWidgetHolder.newInstance(getContext()); |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 150 | try { |
Sihua Ma | aa2b872 | 2022-10-25 15:17:58 -0700 | [diff] [blame] | 151 | int appWidgetId = widgetHolder.allocateAppWidgetId(); |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 152 | values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId); |
| 153 | if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) { |
Sihua Ma | aa2b872 | 2022-10-25 15:17:58 -0700 | [diff] [blame] | 154 | widgetHolder.deleteAppWidgetId(appWidgetId); |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 155 | return false; |
| 156 | } |
| 157 | } catch (RuntimeException e) { |
| 158 | Log.e(TAG, "Failed to initialize external widget", e); |
| 159 | return false; |
Sihua Ma | aa2b872 | 2022-10-25 15:17:58 -0700 | [diff] [blame] | 160 | } finally { |
| 161 | // Necessary to destroy the holder to free up possible activity context |
| 162 | widgetHolder.destroy(); |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 163 | } |
| 164 | } else { |
| 165 | return false; |
| 166 | } |
| 167 | } |
| 168 | |
Sunny Goyal | c593939 | 2018-12-07 11:43:47 -0800 | [diff] [blame] | 169 | return true; |
Sunny Goyal | b5b55c8 | 2016-05-10 12:28:59 -0700 | [diff] [blame] | 170 | } |
| 171 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 172 | @Override |
| 173 | public int bulkInsert(Uri uri, ContentValues[] values) { |
| 174 | SqlArguments args = new SqlArguments(uri); |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 175 | getModelDbController().bulkInsert(args.table, values); |
Sunny Goyal | d106418 | 2015-08-13 12:08:30 -0700 | [diff] [blame] | 176 | reloadLauncherIfExternal(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 177 | return values.length; |
| 178 | } |
| 179 | |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 180 | @TargetApi(Build.VERSION_CODES.M) |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 181 | @Override |
Yura | 085c853 | 2014-02-11 15:15:29 +0000 | [diff] [blame] | 182 | public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) |
| 183 | throws OperationApplicationException { |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 184 | try (SQLiteTransaction t = getModelDbController().newTransaction()) { |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 185 | final int numOperations = operations.size(); |
| 186 | final ContentProviderResult[] results = new ContentProviderResult[numOperations]; |
| 187 | for (int i = 0; i < numOperations; i++) { |
| 188 | ContentProviderOperation op = operations.get(i); |
| 189 | results[i] = op.apply(this, results, i); |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 190 | } |
Sunny Goyal | dbfc901 | 2017-04-17 16:58:36 -0700 | [diff] [blame] | 191 | t.commit(); |
Sunny Goyal | d106418 | 2015-08-13 12:08:30 -0700 | [diff] [blame] | 192 | reloadLauncherIfExternal(); |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 193 | return results; |
Yura | 085c853 | 2014-02-11 15:15:29 +0000 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | |
| 197 | @Override |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 198 | public int delete(Uri uri, String selection, String[] selectionArgs) { |
| 199 | SqlArguments args = new SqlArguments(uri, selection, selectionArgs); |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 200 | int count = getModelDbController().delete(args.table, args.where, args.args); |
Louis Begin | a9c21c6 | 2016-08-15 15:18:41 -0700 | [diff] [blame] | 201 | if (count > 0) { |
Louis Begin | a9c21c6 | 2016-08-15 15:18:41 -0700 | [diff] [blame] | 202 | reloadLauncherIfExternal(); |
| 203 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 204 | return count; |
| 205 | } |
| 206 | |
| 207 | @Override |
| 208 | public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { |
| 209 | SqlArguments args = new SqlArguments(uri, selection, selectionArgs); |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 210 | int count = getModelDbController().update(args.table, values, args.where, args.args); |
Sunny Goyal | d106418 | 2015-08-13 12:08:30 -0700 | [diff] [blame] | 211 | reloadLauncherIfExternal(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 212 | return count; |
| 213 | } |
| 214 | |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 215 | @Override |
Tony Wickham | 827cef2 | 2016-03-17 15:39:39 -0700 | [diff] [blame] | 216 | public Bundle call(String method, final String arg, final Bundle extras) { |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 217 | if (Binder.getCallingUid() != Process.myUid()) { |
| 218 | return null; |
| 219 | } |
| 220 | |
| 221 | switch (method) { |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 222 | case LauncherSettings.Settings.METHOD_CLEAR_EMPTY_DB_FLAG: { |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 223 | getModelDbController().clearEmptyDbFlag(); |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 224 | return null; |
| 225 | } |
| 226 | case LauncherSettings.Settings.METHOD_DELETE_EMPTY_FOLDERS: { |
| 227 | Bundle result = new Bundle(); |
Sunny Goyal | 1ae46ca | 2023-04-10 15:28:59 -0700 | [diff] [blame] | 228 | result.putIntArray(LauncherSettings.Settings.EXTRA_VALUE, |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 229 | getModelDbController().deleteEmptyFolders().toArray()); |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 230 | return result; |
| 231 | } |
| 232 | case LauncherSettings.Settings.METHOD_NEW_ITEM_ID: { |
| 233 | Bundle result = new Bundle(); |
Tracy Zhou | 7df93d2 | 2020-01-27 13:44:06 -0800 | [diff] [blame] | 234 | result.putInt(LauncherSettings.Settings.EXTRA_VALUE, |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 235 | getModelDbController().generateNewItemId()); |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 236 | return result; |
| 237 | } |
| 238 | case LauncherSettings.Settings.METHOD_NEW_SCREEN_ID: { |
| 239 | Bundle result = new Bundle(); |
Tracy Zhou | 7df93d2 | 2020-01-27 13:44:06 -0800 | [diff] [blame] | 240 | result.putInt(LauncherSettings.Settings.EXTRA_VALUE, |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 241 | getModelDbController().getNewScreenId()); |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 242 | return result; |
| 243 | } |
| 244 | case LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB: { |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 245 | getModelDbController().createEmptyDB(); |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 246 | return null; |
| 247 | } |
| 248 | case LauncherSettings.Settings.METHOD_LOAD_DEFAULT_FAVORITES: { |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 249 | getModelDbController().loadDefaultFavoritesIfNecessary(); |
Sunny Goyal | d249748 | 2015-09-22 18:24:19 -0700 | [diff] [blame] | 250 | return null; |
| 251 | } |
Sunny Goyal | 55fddc8 | 2017-04-06 15:02:52 -0700 | [diff] [blame] | 252 | case LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS: { |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 253 | getModelDbController().removeGhostWidgets(); |
Sunny Goyal | 55fddc8 | 2017-04-06 15:02:52 -0700 | [diff] [blame] | 254 | return null; |
| 255 | } |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 256 | case LauncherSettings.Settings.METHOD_NEW_TRANSACTION: { |
| 257 | Bundle result = new Bundle(); |
| 258 | result.putBinder(LauncherSettings.Settings.EXTRA_VALUE, |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 259 | getModelDbController().newTransaction()); |
Sunny Goyal | 161a214 | 2018-10-29 14:02:20 -0700 | [diff] [blame] | 260 | return result; |
| 261 | } |
Samuel Fufa | f667a13 | 2020-05-29 14:47:42 -0700 | [diff] [blame] | 262 | case LauncherSettings.Settings.METHOD_REFRESH_HOTSEAT_RESTORE_TABLE: { |
Sunny Goyal | ce953a3 | 2023-04-14 14:08:37 -0700 | [diff] [blame] | 263 | getModelDbController().refreshHotseatRestoreTable(); |
Samuel Fufa | f667a13 | 2020-05-29 14:47:42 -0700 | [diff] [blame] | 264 | return null; |
| 265 | } |
Sunny Goyal | 7779d62 | 2015-06-11 16:18:39 -0700 | [diff] [blame] | 266 | } |
| 267 | return null; |
| 268 | } |
| 269 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 270 | static class SqlArguments { |
| 271 | public final String table; |
| 272 | public final String where; |
| 273 | public final String[] args; |
| 274 | |
| 275 | SqlArguments(Uri url, String where, String[] args) { |
| 276 | if (url.getPathSegments().size() == 1) { |
| 277 | this.table = url.getPathSegments().get(0); |
| 278 | this.where = where; |
| 279 | this.args = args; |
| 280 | } else if (url.getPathSegments().size() != 2) { |
| 281 | throw new IllegalArgumentException("Invalid URI: " + url); |
| 282 | } else if (!TextUtils.isEmpty(where)) { |
| 283 | throw new UnsupportedOperationException("WHERE clause not supported: " + url); |
| 284 | } else { |
| 285 | this.table = url.getPathSegments().get(0); |
Daniel Lehmann | c3a8040 | 2012-04-23 21:35:11 -0700 | [diff] [blame] | 286 | this.where = "_id=" + ContentUris.parseId(url); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 287 | this.args = null; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | SqlArguments(Uri url) { |
| 292 | if (url.getPathSegments().size() == 1) { |
| 293 | table = url.getPathSegments().get(0); |
| 294 | where = null; |
| 295 | args = null; |
| 296 | } else { |
| 297 | throw new IllegalArgumentException("Invalid URI: " + url); |
| 298 | } |
| 299 | } |
| 300 | } |
Adam Cohen | 7296097 | 2014-01-15 18:13:55 -0800 | [diff] [blame] | 301 | } |