Search in sources :

Example 31 with IntSparseArrayMap

use of com.android.launcher3.util.IntSparseArrayMap in project android_packages_apps_Launcher3 by ArrowOS.

the class QuickstepModelDelegate method modelLoadComplete.

@Override
@WorkerThread
public void modelLoadComplete() {
    super.modelLoadComplete();
    // Log snapshot of the model
    SharedPreferences prefs = getDevicePrefs(mApp.getContext());
    long lastSnapshotTimeMillis = prefs.getLong(LAST_SNAPSHOT_TIME_MILLIS, 0);
    // Log snapshot only if previous snapshot was older than a day
    long now = System.currentTimeMillis();
    if (now - lastSnapshotTimeMillis < DAY_IN_MILLIS) {
        if (IS_DEBUG) {
            String elapsedTime = formatElapsedTime((now - lastSnapshotTimeMillis) / 1000);
            Log.d(TAG, String.format("Skipped snapshot logging since previous snapshot was %s old.", elapsedTime));
        }
    } else {
        IntSparseArrayMap<ItemInfo> itemsIdMap;
        synchronized (mDataModel) {
            itemsIdMap = mDataModel.itemsIdMap.clone();
        }
        InstanceId instanceId = new InstanceIdSequence().newInstanceId();
        for (ItemInfo info : itemsIdMap) {
            FolderInfo parent = getContainer(info, itemsIdMap);
            StatsLogCompatManager.writeSnapshot(info.buildProto(parent), instanceId);
        }
        additionalSnapshotEvents(instanceId);
        prefs.edit().putLong(LAST_SNAPSHOT_TIME_MILLIS, now).apply();
    }
    // instance, as there will be additional instances that may be destroyed at any time.
    if (mIsPrimaryInstance) {
        registerSnapshotLoggingCallback();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) PredictionHelper.getAppTargetFromItemInfo(com.android.launcher3.model.PredictionHelper.getAppTargetFromItemInfo) InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkerThread(androidx.annotation.WorkerThread)

Example 32 with IntSparseArrayMap

use of com.android.launcher3.util.IntSparseArrayMap in project android_packages_apps_Launcher3 by ProtonAOSP.

the class QuickstepModelDelegate method modelLoadComplete.

@Override
@WorkerThread
public void modelLoadComplete() {
    super.modelLoadComplete();
    // Log snapshot of the model
    SharedPreferences prefs = getDevicePrefs(mApp.getContext());
    long lastSnapshotTimeMillis = prefs.getLong(LAST_SNAPSHOT_TIME_MILLIS, 0);
    // Log snapshot only if previous snapshot was older than a day
    long now = System.currentTimeMillis();
    if (now - lastSnapshotTimeMillis < DAY_IN_MILLIS) {
        if (IS_DEBUG) {
            String elapsedTime = formatElapsedTime((now - lastSnapshotTimeMillis) / 1000);
            Log.d(TAG, String.format("Skipped snapshot logging since previous snapshot was %s old.", elapsedTime));
        }
    } else {
        IntSparseArrayMap<ItemInfo> itemsIdMap;
        synchronized (mDataModel) {
            itemsIdMap = mDataModel.itemsIdMap.clone();
        }
        InstanceId instanceId = new InstanceIdSequence().newInstanceId();
        for (ItemInfo info : itemsIdMap) {
            FolderInfo parent = getContainer(info, itemsIdMap);
            StatsLogCompatManager.writeSnapshot(info.buildProto(parent), instanceId);
        }
        additionalSnapshotEvents(instanceId);
        prefs.edit().putLong(LAST_SNAPSHOT_TIME_MILLIS, now).apply();
    }
    // instance, as there will be additional instances that may be destroyed at any time.
    if (mIsPrimaryInstance) {
        registerSnapshotLoggingCallback();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) PredictionHelper.getAppTargetFromItemInfo(com.android.launcher3.model.PredictionHelper.getAppTargetFromItemInfo) InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkerThread(androidx.annotation.WorkerThread)

Example 33 with IntSparseArrayMap

use of com.android.launcher3.util.IntSparseArrayMap in project android_packages_apps_Launcher3 by AOSPA.

the class QuickstepModelDelegate method modelLoadComplete.

@Override
@WorkerThread
public void modelLoadComplete() {
    super.modelLoadComplete();
    // Log snapshot of the model
    SharedPreferences prefs = getDevicePrefs(mApp.getContext());
    long lastSnapshotTimeMillis = prefs.getLong(LAST_SNAPSHOT_TIME_MILLIS, 0);
    // Log snapshot only if previous snapshot was older than a day
    long now = System.currentTimeMillis();
    if (now - lastSnapshotTimeMillis < DAY_IN_MILLIS) {
        if (IS_DEBUG) {
            String elapsedTime = formatElapsedTime((now - lastSnapshotTimeMillis) / 1000);
            Log.d(TAG, String.format("Skipped snapshot logging since previous snapshot was %s old.", elapsedTime));
        }
    } else {
        IntSparseArrayMap<ItemInfo> itemsIdMap;
        synchronized (mDataModel) {
            itemsIdMap = mDataModel.itemsIdMap.clone();
        }
        InstanceId instanceId = new InstanceIdSequence().newInstanceId();
        for (ItemInfo info : itemsIdMap) {
            FolderInfo parent = getContainer(info, itemsIdMap);
            StatsLogCompatManager.writeSnapshot(info.buildProto(parent), instanceId);
        }
        additionalSnapshotEvents(instanceId);
        prefs.edit().putLong(LAST_SNAPSHOT_TIME_MILLIS, now).apply();
    }
    // instance, as there will be additional instances that may be destroyed at any time.
    if (mIsPrimaryInstance) {
        registerSnapshotLoggingCallback();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) PredictionHelper.getAppTargetFromItemInfo(com.android.launcher3.model.PredictionHelper.getAppTargetFromItemInfo) InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

IntArray (com.android.launcher3.util.IntArray)14 IntSparseArrayMap (com.android.launcher3.util.IntSparseArrayMap)14 ItemInfo (com.android.launcher3.model.data.ItemInfo)11 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)11 FolderInfo (com.android.launcher3.model.data.FolderInfo)10 InstanceId (com.android.launcher3.logging.InstanceId)9 InstanceIdSequence (com.android.launcher3.logging.InstanceIdSequence)9 Point (android.graphics.Point)8 PredictionHelper.getAppTargetFromItemInfo (com.android.launcher3.model.PredictionHelper.getAppTargetFromItemInfo)8 ArrayList (java.util.ArrayList)8 Before (org.junit.Before)7 Utilities.parsePoint (com.android.launcher3.Utilities.parsePoint)6 GridOccupancy (com.android.launcher3.util.GridOccupancy)6 LauncherModelHelper (com.android.launcher3.util.LauncherModelHelper)6 SharedPreferences (android.content.SharedPreferences)5 WorkerThread (androidx.annotation.WorkerThread)5 HashSet (java.util.HashSet)5 StatsEvent (android.util.StatsEvent)4 LauncherAtom (com.android.launcher3.logger.LauncherAtom)4 ContentProviderOperation (android.content.ContentProviderOperation)3