Adding temporary logs to capture configuration changes and item deletions

Bug: 72481685
Bug: 73814840
Change-Id: I1e30632647ad08a08d84c49875bc7b6cac3be1fb
This commit is contained in:
Sunny Goyal
2018-02-27 12:20:50 -08:00
parent f1e9a706f6
commit 2bba1900e0
3 changed files with 48 additions and 23 deletions
+13 -6
View File
@@ -408,6 +408,11 @@ public class Launcher extends BaseActivity
if ((diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0) {
mUserEventDispatcher = null;
initDeviceProfile(mDeviceProfile.inv);
FileLog.d(TAG, "Config changed, my orientation=" +
getResources().getConfiguration().orientation +
", new orientation=" + newConfig.orientation +
", old orientation=" + mOldConfig.orientation +
", isTransposed=" + mDeviceProfile.isVerticalBarLayout());
dispatchDeviceProfileChanged();
getRootView().dispatchInsets();
@@ -2752,18 +2757,20 @@ public class Launcher extends BaseActivity
writer.println(prefix + " " + tag.toString());
}
}
try {
FileLog.flushAll(writer);
} catch (Exception e) {
// Ignore
}
}
writer.println(prefix + "Misc:");
writer.print(prefix + "\tmWorkspaceLoading=" + mWorkspaceLoading);
writer.print(" mPendingRequestArgs=" + mPendingRequestArgs);
writer.println(" mPendingActivityResult=" + mPendingActivityResult);
writer.println(" deviceProfile isTransposed=" + getDeviceProfile().isVerticalBarLayout());
writer.println(" orientation=" + getResources().getConfiguration().orientation);
try {
FileLog.flushAll(writer);
} catch (Exception e) {
// Ignore
}
mModel.dumpState(prefix, fd, writer, args);
@@ -56,6 +56,7 @@ import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.model.DbDowngradeHelper;
import com.android.launcher3.model.ModelWriter;
import com.android.launcher3.provider.LauncherDbUtils;
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
import com.android.launcher3.provider.RestoreDbTask;
@@ -320,6 +321,11 @@ public class LauncherProvider extends ContentProvider {
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
if (ModelWriter.DEBUG_DELETE) {
String args = selectionArgs == null ? null : TextUtils.join(",", selectionArgs);
FileLog.d(TAG, "Delete uri=" + uri + ", selection=" + selection
+ ", selectionArgs=" + args, new Exception());
}
createDbIfNotExists();
SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
@@ -32,6 +32,7 @@ import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.LauncherSettings.Settings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.util.ContentWriter;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LooperExecutor;
@@ -46,6 +47,7 @@ import java.util.concurrent.Executor;
public class ModelWriter {
private static final String TAG = "ModelWriter";
public static final boolean DEBUG_DELETE = true;
private final Context mContext;
private final BgDataModel mBgDataModel;
@@ -243,14 +245,21 @@ public class ModelWriter {
* Removes the specified items from the database
*/
public void deleteItemsFromDatabase(final Iterable<? extends ItemInfo> items) {
mWorkerExecutor.execute(new Runnable() {
public void run() {
for (ItemInfo item : items) {
final Uri uri = Favorites.getContentUri(item.id);
mContext.getContentResolver().delete(uri, null, null);
if (DEBUG_DELETE) {
// Log it on the colling thread to get the proper stack trace
FileLog.d(TAG, "Starting item deletion", new Exception());
for (ItemInfo item : items) {
FileLog.d(TAG, "deleting item " + item);
}
FileLog.d(TAG, "Finished deleting items");
}
mBgDataModel.removeItem(mContext, item);
}
mWorkerExecutor.execute(() -> {
for (ItemInfo item : items) {
final Uri uri = Favorites.getContentUri(item.id);
mContext.getContentResolver().delete(uri, null, null);
mBgDataModel.removeItem(mContext, item);
}
});
}
@@ -259,17 +268,20 @@ public class ModelWriter {
* Remove the specified folder and all its contents from the database.
*/
public void deleteFolderAndContentsFromDatabase(final FolderInfo info) {
mWorkerExecutor.execute(new Runnable() {
public void run() {
ContentResolver cr = mContext.getContentResolver();
cr.delete(LauncherSettings.Favorites.CONTENT_URI,
LauncherSettings.Favorites.CONTAINER + "=" + info.id, null);
mBgDataModel.removeItem(mContext, info.contents);
info.contents.clear();
if (DEBUG_DELETE) {
// Log it on the colling thread to get the proper stack trace
FileLog.d(TAG, "Deleting folder " + info, new Exception());
}
cr.delete(LauncherSettings.Favorites.getContentUri(info.id), null, null);
mBgDataModel.removeItem(mContext, info);
}
mWorkerExecutor.execute(() -> {
ContentResolver cr = mContext.getContentResolver();
cr.delete(LauncherSettings.Favorites.CONTENT_URI,
LauncherSettings.Favorites.CONTAINER + "=" + info.id, null);
mBgDataModel.removeItem(mContext, info.contents);
info.contents.clear();
cr.delete(LauncherSettings.Favorites.getContentUri(info.id), null, null);
mBgDataModel.removeItem(mContext, info);
});
}