blob: 27c41c2fcdcf774db1c0f8db12f0cc409bd88d35 [file] [log] [blame]
Sunny Goyal0fe505b2014-08-06 09:55:36 -07001/*
2 * Copyright (C) 2014 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
17package com.android.launcher3;
18
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +000019import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
20
Sunny Goyal0fe505b2014-08-06 09:55:36 -070021import android.content.ComponentName;
22import android.content.ContentValues;
23import android.content.Context;
24import android.content.Intent;
25import android.content.pm.ActivityInfo;
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +000026import android.content.pm.LauncherActivityInfo;
Sunny Goyal0fe505b2014-08-06 09:55:36 -070027import android.content.pm.PackageManager;
28import android.content.res.Resources;
Sunny Goyal0fe505b2014-08-06 09:55:36 -070029import android.database.sqlite.SQLiteDatabase;
30import android.graphics.drawable.Drawable;
31import android.net.Uri;
32import android.os.Bundle;
33import android.text.TextUtils;
Rajeev Kumar26453a22017-06-09 16:02:25 -070034import android.util.ArrayMap;
Sunny Goyal0d742312019-03-04 20:22:26 -080035import android.util.AttributeSet;
Sunny Goyal0fe505b2014-08-06 09:55:36 -070036import android.util.Log;
Sunny Goyal0fe505b2014-08-06 09:55:36 -070037import android.util.Patterns;
Sunny Goyal0d742312019-03-04 20:22:26 -080038import android.util.Xml;
Sunny Goyal36b54222018-07-10 13:50:50 -070039
Samuel Fufaca37b8a2019-08-19 17:04:36 -070040import androidx.annotation.Nullable;
41
Sunny Goyal0fe505b2014-08-06 09:55:36 -070042import com.android.launcher3.LauncherProvider.SqlArguments;
Sunny Goyal0fe505b2014-08-06 09:55:36 -070043import com.android.launcher3.LauncherSettings.Favorites;
Sunny Goyale62d2bb2018-11-06 10:28:37 -080044import com.android.launcher3.icons.GraphicsUtils;
Hyunyoung Song48cb7bc2018-09-25 17:03:34 -070045import com.android.launcher3.icons.LauncherIcons;
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +000046import com.android.launcher3.model.data.AppInfo;
Sunny Goyale396abf2020-04-06 15:11:17 -070047import com.android.launcher3.model.data.LauncherAppWidgetInfo;
48import com.android.launcher3.model.data.WorkspaceItemInfo;
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +000049import com.android.launcher3.pm.UserCache;
Samuel Fufaca37b8a2019-08-19 17:04:36 -070050import com.android.launcher3.qsb.QsbContainerView;
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +000051import com.android.launcher3.uioverrides.ApiWrapper;
Sunny Goyalefb7e842018-10-04 15:11:00 -070052import com.android.launcher3.util.IntArray;
Sunny Goyal3e58eea2022-11-14 14:30:07 -080053import com.android.launcher3.util.Partner;
Adam Cohen091440a2015-03-18 14:16:05 -070054import com.android.launcher3.util.Thunk;
Sihua Ma8bbfcb62022-11-08 16:46:07 -080055import com.android.launcher3.widget.LauncherWidgetHolder;
Sunny Goyal36b54222018-07-10 13:50:50 -070056
57import org.xmlpull.v1.XmlPullParser;
58import org.xmlpull.v1.XmlPullParserException;
59
Sunny Goyal0fe505b2014-08-06 09:55:36 -070060import java.io.IOException;
Sunny Goyalb2d46ce2015-03-26 11:32:11 -070061import java.util.Locale;
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +000062import java.util.Map;
Sunny Goyalc0f03d92019-03-22 14:13:36 -070063import java.util.function.Supplier;
Sunny Goyal0fe505b2014-08-06 09:55:36 -070064
65/**
Sunny Goyal3a5a9d12014-10-01 15:33:41 -070066 * Layout parsing code for auto installs layout
Sunny Goyal0fe505b2014-08-06 09:55:36 -070067 */
Sunny Goyal3a5a9d12014-10-01 15:33:41 -070068public class AutoInstallsLayout {
Sunny Goyal0fe505b2014-08-06 09:55:36 -070069 private static final String TAG = "AutoInstalls";
Sunny Goyal3a5a9d12014-10-01 15:33:41 -070070 private static final boolean LOGD = false;
Sunny Goyal0fe505b2014-08-06 09:55:36 -070071
72 /** Marker action used to discover a package which defines launcher customization */
73 static final String ACTION_LAUNCHER_CUSTOMIZATION =
Sunny Goyal2233c882014-09-18 14:36:48 -070074 "android.autoinstalls.config.action.PLAY_AUTO_INSTALL";
Sunny Goyal0fe505b2014-08-06 09:55:36 -070075
Sunny Goyalb2d46ce2015-03-26 11:32:11 -070076 /**
77 * Layout resource which also includes grid size and hotseat count, e.g., default_layout_6x6_h5
78 */
79 private static final String FORMATTED_LAYOUT_RES_WITH_HOSTEAT = "default_layout_%dx%d_h%s";
80 private static final String FORMATTED_LAYOUT_RES = "default_layout_%dx%d";
Sunny Goyal0fe505b2014-08-06 09:55:36 -070081 private static final String LAYOUT_RES = "default_layout";
82
Sihua Maaa2b8722022-10-25 15:17:58 -070083 static AutoInstallsLayout get(Context context, LauncherWidgetHolder appWidgetHolder,
Sunny Goyal0fe505b2014-08-06 09:55:36 -070084 LayoutParserCallback callback) {
Sunny Goyal3e58eea2022-11-14 14:30:07 -080085 Partner partner = Partner.get(context.getPackageManager(), ACTION_LAUNCHER_CUSTOMIZATION);
86 if (partner == null) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -070087 return null;
88 }
Sunny Goyal87f784c2017-01-11 10:48:34 -080089 InvariantDeviceProfile grid = LauncherAppState.getIDP(context);
Sunny Goyalb2d46ce2015-03-26 11:32:11 -070090
91 // Try with grid size and hotseat count
92 String layoutName = String.format(Locale.ENGLISH, FORMATTED_LAYOUT_RES_WITH_HOSTEAT,
Tony Wickhamb87f3cd2021-04-07 15:02:37 -070093 grid.numColumns, grid.numRows, grid.numDatabaseHotseatIcons);
Sunny Goyal3e58eea2022-11-14 14:30:07 -080094 int layoutId = partner.getXmlResId(layoutName);
Sunny Goyalb2d46ce2015-03-26 11:32:11 -070095
96 // Try with only grid size
97 if (layoutId == 0) {
98 Log.d(TAG, "Formatted layout: " + layoutName
99 + " not found. Trying layout without hosteat");
100 layoutName = String.format(Locale.ENGLISH, FORMATTED_LAYOUT_RES,
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700101 grid.numColumns, grid.numRows);
Sunny Goyal3e58eea2022-11-14 14:30:07 -0800102 layoutId = partner.getXmlResId(layoutName);
Sunny Goyalb2d46ce2015-03-26 11:32:11 -0700103 }
104
105 // Try the default layout
106 if (layoutId == 0) {
107 Log.d(TAG, "Formatted layout: " + layoutName + " not found. Trying the default layout");
Sunny Goyal3e58eea2022-11-14 14:30:07 -0800108 layoutId = partner.getXmlResId(LAYOUT_RES);
Sunny Goyalb2d46ce2015-03-26 11:32:11 -0700109 }
110
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700111 if (layoutId == 0) {
Sunny Goyal3e58eea2022-11-14 14:30:07 -0800112 Log.e(TAG, "Layout definition not found in package: " + partner.getPackageName());
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700113 return null;
114 }
Sunny Goyal3e58eea2022-11-14 14:30:07 -0800115 return new AutoInstallsLayout(context, appWidgetHolder, callback, partner.getResources(),
116 layoutId, TAG_WORKSPACE);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700117 }
118
119 // Object Tags
Sunny Goyalb564efb2015-01-23 13:45:20 -0800120 private static final String TAG_INCLUDE = "include";
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700121 public static final String TAG_WORKSPACE = "workspace";
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700122 private static final String TAG_APP_ICON = "appicon";
123 private static final String TAG_AUTO_INSTALL = "autoinstall";
124 private static final String TAG_FOLDER = "folder";
125 private static final String TAG_APPWIDGET = "appwidget";
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700126 protected static final String TAG_SEARCH_WIDGET = "searchwidget";
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700127 private static final String TAG_SHORTCUT = "shortcut";
128 private static final String TAG_EXTRA = "extra";
129
130 private static final String ATTR_CONTAINER = "container";
131 private static final String ATTR_RANK = "rank";
132
133 private static final String ATTR_PACKAGE_NAME = "packageName";
134 private static final String ATTR_CLASS_NAME = "className";
135 private static final String ATTR_TITLE = "title";
Sunny Goyal55e2b162020-06-09 15:44:48 -0700136 private static final String ATTR_TITLE_TEXT = "titleText";
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700137 private static final String ATTR_SCREEN = "screen";
Sunny Goyal96a09632015-12-16 11:32:54 -0800138
139 // x and y can be specified as negative integers, in which case -1 represents the
140 // last row / column, -2 represents the second last, and so on.
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700141 private static final String ATTR_X = "x";
142 private static final String ATTR_Y = "y";
Sunny Goyal96a09632015-12-16 11:32:54 -0800143
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700144 private static final String ATTR_SPAN_X = "spanX";
145 private static final String ATTR_SPAN_Y = "spanY";
146 private static final String ATTR_ICON = "icon";
147 private static final String ATTR_URL = "url";
148
Sunny Goyalb564efb2015-01-23 13:45:20 -0800149 // Attrs for "Include"
150 private static final String ATTR_WORKSPACE = "workspace";
151
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700152 // Style attrs -- "Extra"
153 private static final String ATTR_KEY = "key";
154 private static final String ATTR_VALUE = "value";
155
156 private static final String HOTSEAT_CONTAINER_NAME =
157 Favorites.containerToString(Favorites.CONTAINER_HOTSEAT);
158
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700159 @Thunk
160 final Context mContext;
161 @Thunk
Sihua Maaa2b8722022-10-25 15:17:58 -0700162 final LauncherWidgetHolder mAppWidgetHolder;
Sunny Goyalbb3b02f2015-01-15 12:00:14 -0800163 protected final LayoutParserCallback mCallback;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700164
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700165 protected final PackageManager mPackageManager;
166 protected final Resources mSourceRes;
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700167 protected final Supplier<XmlPullParser> mInitialLayoutSupplier;
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700168
Sunny Goyalbb011da2016-06-15 15:42:29 -0700169 private final InvariantDeviceProfile mIdp;
Sunny Goyal96a09632015-12-16 11:32:54 -0800170 private final int mRowCount;
171 private final int mColumnCount;
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +0000172 private final Map<String, LauncherActivityInfo> mActivityOverride;
Sunny Goyalefb7e842018-10-04 15:11:00 -0700173 private final int[] mTemp = new int[2];
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700174 @Thunk
175 final ContentValues mValues;
Sunny Goyalbb3b02f2015-01-15 12:00:14 -0800176 protected final String mRootTag;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700177
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700178 protected SQLiteDatabase mDb;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700179
Sihua Maaa2b8722022-10-25 15:17:58 -0700180 public AutoInstallsLayout(Context context, LauncherWidgetHolder appWidgetHolder,
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700181 LayoutParserCallback callback, Resources res,
182 int layoutId, String rootTag) {
Sihua Maaa2b8722022-10-25 15:17:58 -0700183 this(context, appWidgetHolder, callback, res, () -> res.getXml(layoutId), rootTag);
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700184 }
185
Sihua Maaa2b8722022-10-25 15:17:58 -0700186 public AutoInstallsLayout(Context context, LauncherWidgetHolder appWidgetHolder,
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700187 LayoutParserCallback callback, Resources res,
188 Supplier<XmlPullParser> initialLayoutSupplier, String rootTag) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700189 mContext = context;
Sihua Maaa2b8722022-10-25 15:17:58 -0700190 mAppWidgetHolder = appWidgetHolder;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700191 mCallback = callback;
192
193 mPackageManager = context.getPackageManager();
194 mValues = new ContentValues();
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700195 mRootTag = rootTag;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700196
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700197 mSourceRes = res;
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700198 mInitialLayoutSupplier = initialLayoutSupplier;
Sunny Goyal96a09632015-12-16 11:32:54 -0800199
Sunny Goyal87f784c2017-01-11 10:48:34 -0800200 mIdp = LauncherAppState.getIDP(context);
Sunny Goyalbb011da2016-06-15 15:42:29 -0700201 mRowCount = mIdp.numRows;
202 mColumnCount = mIdp.numColumns;
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +0000203 mActivityOverride = ApiWrapper.getActivityOverrides(context);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700204 }
205
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700206 /**
207 * Loads the layout in the db and returns the number of entries added on the desktop.
208 */
Sunny Goyalefb7e842018-10-04 15:11:00 -0700209 public int loadLayout(SQLiteDatabase db, IntArray screenIds) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700210 mDb = db;
211 try {
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700212 return parseLayout(mInitialLayoutSupplier.get(), screenIds);
Sameer Padala8fd74832014-09-08 16:00:29 -0700213 } catch (Exception e) {
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700214 Log.e(TAG, "Error parsing layout: ", e);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700215 return -1;
216 }
217 }
218
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700219 /**
220 * Parses the layout and returns the number of elements added on the homescreen.
221 */
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700222 protected int parseLayout(XmlPullParser parser, IntArray screenIds)
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700223 throws XmlPullParserException, IOException {
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700224 beginDocument(parser, mRootTag);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700225 final int depth = parser.getDepth();
226 int type;
Rajeev Kumar26453a22017-06-09 16:02:25 -0700227 ArrayMap<String, TagParser> tagParserMap = getLayoutElementsMap();
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700228 int count = 0;
229
230 while (((type = parser.next()) != XmlPullParser.END_TAG ||
231 parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
232 if (type != XmlPullParser.START_TAG) {
233 continue;
234 }
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700235 count += parseAndAddNode(parser, tagParserMap, screenIds);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700236 }
237 return count;
238 }
239
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700240 /**
241 * Parses container and screenId attribute from the current tag, and puts it in the out.
242 * @param out array of size 2.
243 */
Sunny Goyal0d742312019-03-04 20:22:26 -0800244 protected void parseContainerAndScreen(XmlPullParser parser, int[] out) {
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700245 if (HOTSEAT_CONTAINER_NAME.equals(getAttributeValue(parser, ATTR_CONTAINER))) {
246 out[0] = Favorites.CONTAINER_HOTSEAT;
247 // Hack: hotseat items are stored using screen ids
Sunny Goyalefb7e842018-10-04 15:11:00 -0700248 out[1] = Integer.parseInt(getAttributeValue(parser, ATTR_RANK));
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700249 } else {
250 out[0] = Favorites.CONTAINER_DESKTOP;
Sunny Goyalefb7e842018-10-04 15:11:00 -0700251 out[1] = Integer.parseInt(getAttributeValue(parser, ATTR_SCREEN));
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700252 }
253 }
254
255 /**
256 * Parses the current node and returns the number of elements added.
257 */
258 protected int parseAndAddNode(
Sunny Goyal0d742312019-03-04 20:22:26 -0800259 XmlPullParser parser, ArrayMap<String, TagParser> tagParserMap, IntArray screenIds)
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700260 throws XmlPullParserException, IOException {
Sunny Goyalb564efb2015-01-23 13:45:20 -0800261
262 if (TAG_INCLUDE.equals(parser.getName())) {
263 final int resId = getAttributeResourceValue(parser, ATTR_WORKSPACE, 0);
264 if (resId != 0) {
265 // recursively load some more favorites, why not?
Sunny Goyalc0f03d92019-03-22 14:13:36 -0700266 return parseLayout(mSourceRes.getXml(resId), screenIds);
Sunny Goyalb564efb2015-01-23 13:45:20 -0800267 } else {
268 return 0;
269 }
270 }
271
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700272 mValues.clear();
273 parseContainerAndScreen(parser, mTemp);
Sunny Goyalefb7e842018-10-04 15:11:00 -0700274 final int container = mTemp[0];
275 final int screenId = mTemp[1];
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700276
277 mValues.put(Favorites.CONTAINER, container);
278 mValues.put(Favorites.SCREEN, screenId);
Sunny Goyal96a09632015-12-16 11:32:54 -0800279
280 mValues.put(Favorites.CELLX,
Sunny Goyalf82e5472016-01-06 15:09:22 -0800281 convertToDistanceFromEnd(getAttributeValue(parser, ATTR_X), mColumnCount));
Sunny Goyal96a09632015-12-16 11:32:54 -0800282 mValues.put(Favorites.CELLY,
Sunny Goyalf82e5472016-01-06 15:09:22 -0800283 convertToDistanceFromEnd(getAttributeValue(parser, ATTR_Y), mRowCount));
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700284
285 TagParser tagParser = tagParserMap.get(parser.getName());
286 if (tagParser == null) {
287 if (LOGD) Log.d(TAG, "Ignoring unknown element tag: " + parser.getName());
288 return 0;
289 }
Sunny Goyalefb7e842018-10-04 15:11:00 -0700290 int newElementId = tagParser.parseAndAdd(parser);
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700291 if (newElementId >= 0) {
292 // Keep track of the set of screens which need to be added to the db.
293 if (!screenIds.contains(screenId) &&
294 container == Favorites.CONTAINER_DESKTOP) {
295 screenIds.add(screenId);
296 }
297 return 1;
298 }
299 return 0;
300 }
301
Sunny Goyalefb7e842018-10-04 15:11:00 -0700302 protected int addShortcut(String title, Intent intent, int type) {
303 int id = mCallback.generateNewItemId();
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700304 mValues.put(Favorites.INTENT, intent.toUri(0));
305 mValues.put(Favorites.TITLE, title);
306 mValues.put(Favorites.ITEM_TYPE, type);
307 mValues.put(Favorites.SPANX, 1);
308 mValues.put(Favorites.SPANY, 1);
309 mValues.put(Favorites._ID, id);
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +0000310
311 maybeReplaceShortcut(intent.getComponent().getPackageName(), type);
312
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700313 if (mCallback.insertAndCheck(mDb, mValues) < 0) {
314 return -1;
315 } else {
316 return id;
317 }
318 }
319
Rajeev Kumar26453a22017-06-09 16:02:25 -0700320 protected ArrayMap<String, TagParser> getFolderElementsMap() {
321 ArrayMap<String, TagParser> parsers = new ArrayMap<>();
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700322 parsers.put(TAG_APP_ICON, new AppShortcutParser());
323 parsers.put(TAG_AUTO_INSTALL, new AutoInstallParser());
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700324 parsers.put(TAG_SHORTCUT, new ShortcutParser(mSourceRes));
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700325 return parsers;
326 }
327
Rajeev Kumar26453a22017-06-09 16:02:25 -0700328 protected ArrayMap<String, TagParser> getLayoutElementsMap() {
329 ArrayMap<String, TagParser> parsers = new ArrayMap<>();
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700330 parsers.put(TAG_APP_ICON, new AppShortcutParser());
331 parsers.put(TAG_AUTO_INSTALL, new AutoInstallParser());
332 parsers.put(TAG_FOLDER, new FolderParser());
Sunny Goyal86df1382016-08-10 15:03:22 -0700333 parsers.put(TAG_APPWIDGET, new PendingWidgetParser());
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700334 parsers.put(TAG_SEARCH_WIDGET, new SearchWidgetParser());
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700335 parsers.put(TAG_SHORTCUT, new ShortcutParser(mSourceRes));
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700336 return parsers;
337 }
338
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700339 protected interface TagParser {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700340 /**
341 * Parses the tag and adds to the db
342 * @return the id of the row added or -1;
343 */
Sunny Goyal0d742312019-03-04 20:22:26 -0800344 int parseAndAdd(XmlPullParser parser)
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700345 throws XmlPullParserException, IOException;
346 }
347
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700348 /**
349 * App shortcuts: required attributes packageName and className
350 */
351 protected class AppShortcutParser implements TagParser {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700352
353 @Override
Sunny Goyal0d742312019-03-04 20:22:26 -0800354 public int parseAndAdd(XmlPullParser parser) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700355 final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME);
356 final String className = getAttributeValue(parser, ATTR_CLASS_NAME);
357
358 if (!TextUtils.isEmpty(packageName) && !TextUtils.isEmpty(className)) {
359 ActivityInfo info;
360 try {
361 ComponentName cn;
362 try {
363 cn = new ComponentName(packageName, className);
364 info = mPackageManager.getActivityInfo(cn, 0);
365 } catch (PackageManager.NameNotFoundException nnfe) {
366 String[] packages = mPackageManager.currentToCanonicalPackageNames(
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700367 new String[]{packageName});
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700368 cn = new ComponentName(packages[0], className);
369 info = mPackageManager.getActivityInfo(cn, 0);
370 }
371 final Intent intent = new Intent(Intent.ACTION_MAIN, null)
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700372 .addCategory(Intent.CATEGORY_LAUNCHER)
373 .setComponent(cn)
374 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
375 | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700376
377 return addShortcut(info.loadLabel(mPackageManager).toString(),
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +0000378 intent, ITEM_TYPE_APPLICATION);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700379 } catch (PackageManager.NameNotFoundException e) {
Sunny Goyaleb3ba0f2017-03-27 11:22:36 -0700380 Log.e(TAG, "Favorite not found: " + packageName + "/" + className);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700381 }
382 return -1;
383 } else {
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700384 return invalidPackageOrClass(parser);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700385 }
386 }
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700387
388 /**
389 * Helper method to allow extending the parser capabilities
390 */
Sunny Goyal0d742312019-03-04 20:22:26 -0800391 protected int invalidPackageOrClass(XmlPullParser parser) {
Adam Cohencf0c7462015-08-06 14:02:23 -0700392 Log.w(TAG, "Skipping invalid <favorite> with no component");
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700393 return -1;
394 }
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700395 }
396
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700397 /**
398 * AutoInstall: required attributes packageName and className
399 */
400 protected class AutoInstallParser implements TagParser {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700401
402 @Override
Sunny Goyal0d742312019-03-04 20:22:26 -0800403 public int parseAndAdd(XmlPullParser parser) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700404 final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME);
405 final String className = getAttributeValue(parser, ATTR_CLASS_NAME);
406 if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) {
407 if (LOGD) Log.d(TAG, "Skipping invalid <favorite> with no component");
408 return -1;
409 }
410
Sunny Goyal95899162019-03-27 16:03:06 -0700411 mValues.put(Favorites.RESTORED, WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700412 final Intent intent = new Intent(Intent.ACTION_MAIN, null)
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700413 .addCategory(Intent.CATEGORY_LAUNCHER)
414 .setComponent(new ComponentName(packageName, className))
415 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
416 | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700417 return addShortcut(mContext.getString(R.string.package_state_unknown), intent,
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +0000418 ITEM_TYPE_APPLICATION);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700419 }
420 }
421
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700422 /**
423 * Parses a web shortcut. Required attributes url, icon, title
424 */
425 protected class ShortcutParser implements TagParser {
426
427 private final Resources mIconRes;
428
429 public ShortcutParser(Resources iconRes) {
430 mIconRes = iconRes;
431 }
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700432
433 @Override
Sunny Goyal0d742312019-03-04 20:22:26 -0800434 public int parseAndAdd(XmlPullParser parser) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700435 final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0);
436 final int iconId = getAttributeResourceValue(parser, ATTR_ICON, 0);
437
438 if (titleResId == 0 || iconId == 0) {
439 if (LOGD) Log.d(TAG, "Ignoring shortcut");
440 return -1;
441 }
442
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700443 final Intent intent = parseIntent(parser);
444 if (intent == null) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700445 return -1;
446 }
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700447
448 Drawable icon = mIconRes.getDrawable(iconId);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700449 if (icon == null) {
450 if (LOGD) Log.d(TAG, "Ignoring shortcut, can't load icon");
451 return -1;
452 }
453
Sunny Goyalad7ff442017-09-12 12:42:26 -0700454 // Auto installs should always support the current platform version.
Sunny Goyal18a4e5a2018-01-09 15:34:38 -0800455 LauncherIcons li = LauncherIcons.obtain(mContext);
Sunny Goyale62d2bb2018-11-06 10:28:37 -0800456 mValues.put(LauncherSettings.Favorites.ICON, GraphicsUtils.flattenBitmap(
Sunny Goyald872a972021-11-24 18:07:04 -0800457 li.createBadgedIconBitmap(icon).icon));
Sunny Goyal18a4e5a2018-01-09 15:34:38 -0800458 li.recycle();
459
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700460 mValues.put(Favorites.ICON_PACKAGE, mIconRes.getResourcePackageName(iconId));
461 mValues.put(Favorites.ICON_RESOURCE, mIconRes.getResourceName(iconId));
462
463 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700464 Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700465 return addShortcut(mSourceRes.getString(titleResId),
466 intent, Favorites.ITEM_TYPE_SHORTCUT);
467 }
468
Sunny Goyal0d742312019-03-04 20:22:26 -0800469 protected Intent parseIntent(XmlPullParser parser) {
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700470 final String url = getAttributeValue(parser, ATTR_URL);
471 if (TextUtils.isEmpty(url) || !Patterns.WEB_URL.matcher(url).matches()) {
472 if (LOGD) Log.d(TAG, "Ignoring shortcut, invalid url: " + url);
473 return null;
474 }
475 return new Intent(Intent.ACTION_VIEW, null).setData(Uri.parse(url));
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700476 }
477 }
478
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700479 /**
480 * AppWidget parser: Required attributes packageName, className, spanX and spanY.
481 * Options child nodes: <extra key=... value=... />
Sunny Goyal86df1382016-08-10 15:03:22 -0700482 * It adds a pending widget which allows the widget to come later. If there are extras, those
483 * are passed to widget options during bind.
484 * The config activity for the widget (if present) is not shown, so any optional configurations
485 * should be passed as extras and the widget should support reading these widget options.
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700486 */
Sunny Goyal86df1382016-08-10 15:03:22 -0700487 protected class PendingWidgetParser implements TagParser {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700488
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700489 @Nullable
490 public ComponentName getComponentName(XmlPullParser parser) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700491 final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME);
492 final String className = getAttributeValue(parser, ATTR_CLASS_NAME);
493 if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) {
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700494 return null;
495 }
496 return new ComponentName(packageName, className);
497 }
498
499
500 @Override
501 public int parseAndAdd(XmlPullParser parser)
502 throws XmlPullParserException, IOException {
503 ComponentName cn = getComponentName(parser);
504 if (cn == null) {
Sunny Goyal86df1382016-08-10 15:03:22 -0700505 if (LOGD) Log.d(TAG, "Skipping invalid <appwidget> with no component");
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700506 return -1;
507 }
508
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700509 mValues.put(Favorites.SPANX, getAttributeValue(parser, ATTR_SPAN_X));
510 mValues.put(Favorites.SPANY, getAttributeValue(parser, ATTR_SPAN_Y));
Sunny Goyal86df1382016-08-10 15:03:22 -0700511 mValues.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700512
513 // Read the extras
514 Bundle extras = new Bundle();
515 int widgetDepth = parser.getDepth();
516 int type;
517 while ((type = parser.next()) != XmlPullParser.END_TAG ||
518 parser.getDepth() > widgetDepth) {
519 if (type != XmlPullParser.START_TAG) {
520 continue;
521 }
522
523 if (TAG_EXTRA.equals(parser.getName())) {
524 String key = getAttributeValue(parser, ATTR_KEY);
525 String value = getAttributeValue(parser, ATTR_VALUE);
526 if (key != null && value != null) {
527 extras.putString(key, value);
528 } else {
529 throw new RuntimeException("Widget extras must have a key and value");
530 }
531 } else {
532 throw new RuntimeException("Widgets can contain only extras");
533 }
534 }
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700535 return verifyAndInsert(cn, extras);
Sunny Goyal86df1382016-08-10 15:03:22 -0700536 }
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700537
Sunny Goyalefb7e842018-10-04 15:11:00 -0700538 protected int verifyAndInsert(ComponentName cn, Bundle extras) {
Sunny Goyal86df1382016-08-10 15:03:22 -0700539 mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString());
540 mValues.put(Favorites.RESTORED,
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700541 LauncherAppWidgetInfo.FLAG_ID_NOT_VALID
542 | LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY
543 | LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG);
Sunny Goyal86df1382016-08-10 15:03:22 -0700544 mValues.put(Favorites._ID, mCallback.generateNewItemId());
545 if (!extras.isEmpty()) {
546 mValues.put(Favorites.INTENT, new Intent().putExtras(extras).toUri(0));
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700547 }
Sunny Goyal86df1382016-08-10 15:03:22 -0700548
Sunny Goyalefb7e842018-10-04 15:11:00 -0700549 int insertedId = mCallback.insertAndCheck(mDb, mValues);
Sunny Goyal86df1382016-08-10 15:03:22 -0700550 if (insertedId < 0) {
551 return -1;
552 } else {
553 return insertedId;
554 }
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700555 }
556 }
557
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700558 protected class SearchWidgetParser extends PendingWidgetParser {
559 @Override
560 @Nullable
561 public ComponentName getComponentName(XmlPullParser parser) {
562 return QsbContainerView.getSearchComponentName(mContext);
563 }
564
565 @Override
566 protected int verifyAndInsert(ComponentName cn, Bundle extras) {
567 mValues.put(Favorites.OPTIONS, LauncherAppWidgetInfo.OPTION_SEARCH_WIDGET);
568 int flags = mValues.getAsInteger(Favorites.RESTORED)
569 | WorkspaceItemInfo.FLAG_RESTORE_STARTED;
570 mValues.put(Favorites.RESTORED, flags);
571 return super.verifyAndInsert(cn, extras);
572 }
573 }
574
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700575 protected class FolderParser implements TagParser {
Rajeev Kumar26453a22017-06-09 16:02:25 -0700576 private final ArrayMap<String, TagParser> mFolderElements;
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700577
578 public FolderParser() {
579 this(getFolderElementsMap());
580 }
581
Rajeev Kumar26453a22017-06-09 16:02:25 -0700582 public FolderParser(ArrayMap<String, TagParser> elements) {
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700583 mFolderElements = elements;
584 }
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700585
586 @Override
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +0000587 public int parseAndAdd(XmlPullParser parser) throws XmlPullParserException, IOException {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700588 final String title;
589 final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0);
590 if (titleResId != 0) {
Sunny Goyal3a5a9d12014-10-01 15:33:41 -0700591 title = mSourceRes.getString(titleResId);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700592 } else {
Sunny Goyal55e2b162020-06-09 15:44:48 -0700593 String titleText = getAttributeValue(parser, ATTR_TITLE_TEXT);
594 title = TextUtils.isEmpty(titleText) ? "" : titleText;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700595 }
596
597 mValues.put(Favorites.TITLE, title);
598 mValues.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_FOLDER);
599 mValues.put(Favorites.SPANX, 1);
600 mValues.put(Favorites.SPANY, 1);
601 mValues.put(Favorites._ID, mCallback.generateNewItemId());
Sunny Goyalefb7e842018-10-04 15:11:00 -0700602 int folderId = mCallback.insertAndCheck(mDb, mValues);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700603 if (folderId < 0) {
604 if (LOGD) Log.e(TAG, "Unable to add folder");
605 return -1;
606 }
607
608 final ContentValues myValues = new ContentValues(mValues);
Sunny Goyalefb7e842018-10-04 15:11:00 -0700609 IntArray folderItems = new IntArray();
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700610
611 int type;
612 int folderDepth = parser.getDepth();
Sunny Goyal56a57bb2015-07-06 11:15:45 -0700613 int rank = 0;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700614 while ((type = parser.next()) != XmlPullParser.END_TAG ||
615 parser.getDepth() > folderDepth) {
616 if (type != XmlPullParser.START_TAG) {
617 continue;
618 }
619 mValues.clear();
620 mValues.put(Favorites.CONTAINER, folderId);
Sunny Goyal56a57bb2015-07-06 11:15:45 -0700621 mValues.put(Favorites.RANK, rank);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700622
623 TagParser tagParser = mFolderElements.get(parser.getName());
624 if (tagParser != null) {
Sunny Goyalefb7e842018-10-04 15:11:00 -0700625 final int id = tagParser.parseAndAdd(parser);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700626 if (id >= 0) {
627 folderItems.add(id);
Sunny Goyal56a57bb2015-07-06 11:15:45 -0700628 rank++;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700629 }
630 } else {
631 throw new RuntimeException("Invalid folder item " + parser.getName());
632 }
633 }
634
Sunny Goyalefb7e842018-10-04 15:11:00 -0700635 int addedId = folderId;
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700636
637 // We can only have folders with >= 2 items, so we need to remove the
638 // folder and clean up if less than 2 items were included, or some
639 // failed to add, and less than 2 were actually added
640 if (folderItems.size() < 2) {
641 // Delete the folder
Sunny Goyal1d4a2df2015-03-30 11:11:46 -0700642 Uri uri = Favorites.getContentUri(folderId);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700643 SqlArguments args = new SqlArguments(uri, null, null);
644 mDb.delete(args.table, args.where, args.args);
645 addedId = -1;
646
647 // If we have a single item, promote it to where the folder
648 // would have been.
649 if (folderItems.size() == 1) {
650 final ContentValues childValues = new ContentValues();
651 copyInteger(myValues, childValues, Favorites.CONTAINER);
652 copyInteger(myValues, childValues, Favorites.SCREEN);
653 copyInteger(myValues, childValues, Favorites.CELLX);
654 copyInteger(myValues, childValues, Favorites.CELLY);
655
656 addedId = folderItems.get(0);
Sunny Goyalb5b55c82016-05-10 12:28:59 -0700657 mDb.update(Favorites.TABLE_NAME, childValues,
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700658 Favorites._ID + "=" + addedId, null);
659 }
660 }
661 return addedId;
662 }
663 }
664
Sunny Goyal762d0612020-07-29 15:03:46 -0700665 public static void beginDocument(XmlPullParser parser, String firstElementName)
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700666 throws XmlPullParserException, IOException {
667 int type;
668 while ((type = parser.next()) != XmlPullParser.START_TAG
669 && type != XmlPullParser.END_DOCUMENT);
670
671 if (type != XmlPullParser.START_TAG) {
672 throw new XmlPullParserException("No start tag found");
673 }
674
675 if (!parser.getName().equals(firstElementName)) {
676 throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() +
677 ", expected " + firstElementName);
678 }
679 }
680
Sunny Goyal96a09632015-12-16 11:32:54 -0800681 private static String convertToDistanceFromEnd(String value, int endValue) {
682 if (!TextUtils.isEmpty(value)) {
683 int x = Integer.parseInt(value);
684 if (x < 0) {
685 return Integer.toString(endValue + x);
686 }
687 }
688 return value;
689 }
690
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700691 /**
692 * Return attribute value, attempting launcher-specific namespace first
693 * before falling back to anonymous attribute.
694 */
Sunny Goyal0d742312019-03-04 20:22:26 -0800695 protected static String getAttributeValue(XmlPullParser parser, String attribute) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700696 String value = parser.getAttributeValue(
697 "http://schemas.android.com/apk/res-auto/com.android.launcher3", attribute);
698 if (value == null) {
699 value = parser.getAttributeValue(null, attribute);
700 }
701 return value;
702 }
703
704 /**
705 * Return attribute resource value, attempting launcher-specific namespace
706 * first before falling back to anonymous attribute.
707 */
Sunny Goyal0d742312019-03-04 20:22:26 -0800708 protected static int getAttributeResourceValue(XmlPullParser parser, String attribute,
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700709 int defaultValue) {
Sunny Goyal0d742312019-03-04 20:22:26 -0800710 AttributeSet attrs = Xml.asAttributeSet(parser);
711 int value = attrs.getAttributeResourceValue(
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700712 "http://schemas.android.com/apk/res-auto/com.android.launcher3", attribute,
713 defaultValue);
714 if (value == defaultValue) {
Sunny Goyal0d742312019-03-04 20:22:26 -0800715 value = attrs.getAttributeResourceValue(null, attribute, defaultValue);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700716 }
717 return value;
718 }
719
Rajeev Kumar26453a22017-06-09 16:02:25 -0700720 public interface LayoutParserCallback {
Sunny Goyalefb7e842018-10-04 15:11:00 -0700721 int generateNewItemId();
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700722
Sunny Goyalefb7e842018-10-04 15:11:00 -0700723 int insertAndCheck(SQLiteDatabase db, ContentValues values);
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700724 }
725
Samuel Fufaca37b8a2019-08-19 17:04:36 -0700726 @Thunk
727 static void copyInteger(ContentValues from, ContentValues to, String key) {
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700728 to.put(key, from.getAsInteger(key));
729 }
Nicolas Sleiman31e9fa42023-01-25 16:30:32 +0000730
731 private void maybeReplaceShortcut(String packageName, int type) {
732 if (mActivityOverride.containsKey(packageName) && type == ITEM_TYPE_APPLICATION) {
733 LauncherActivityInfo replacementInfo = mActivityOverride.get(packageName);
734 mValues.put(Favorites.PROFILE_ID, UserCache.INSTANCE.get(mContext)
735 .getSerialNumberForUser(replacementInfo.getUser()));
736 mValues.put(Favorites.INTENT, AppInfo.makeLaunchIntent(replacementInfo).toUri(0));
737 }
738 }
Sunny Goyal0fe505b2014-08-06 09:55:36 -0700739}