include error log to determine root cause of sql statement failure when

restoring work profile

Bug: 147114476
Change-Id: I25e57413faa569a30e27a0cde1fc47233ff8b603
This commit is contained in:
Pinyao Ting committed 2020-01-06 11:21:41 -08:00
1 parent f10903e601
commit 3c79804f28
1 file changed
+13 -4
@@ -34,8 +34,8 @@ import com.android.launcher3.AppWidgetsRestoredReceiver;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherProvider.DatabaseHelper;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
import com.android.launcher3.util.IntArray;
@@ -112,9 +112,18 @@ public class RestoreDbTask {
whereClause.append(" AND profileId != ?");
profileIds[i] = Long.toString(profileMapping.keyAt(i));
}
int itemsDeleted = db.delete(Favorites.TABLE_NAME, whereClause.toString(), profileIds);
if (itemsDeleted > 0) {
FileLog.d(TAG, itemsDeleted + " items from unrestored user(s) were deleted");
try {
int itemsDeleted = db.delete(Favorites.TABLE_NAME, whereClause.toString(), profileIds);
if (itemsDeleted > 0) {
FileLog.d(TAG, itemsDeleted + " items from unrestored user(s) were deleted");
}
} catch (IllegalArgumentException exception) {
// b/147114476
FileLog.e(TAG, new StringBuilder("Failed to execute delete, where clause: '")
.append(whereClause).append("', profile Id size:").append(profileIds.length)
.append("profileIds: ").append(String.join(", ", profileIds)).toString()
);
throw exception;
}
// Mark all items as restored.