Search in sources :

Example 1 with InstanceIdSequence

use of com.android.launcher3.logging.InstanceIdSequence in project android_packages_apps_Launcher3 by crdroidandroid.

the class BaseDraggingActivity method startActivitySafely.

public boolean startActivitySafely(View v, Intent intent, @Nullable ItemInfo item) {
    if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) {
        Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
        return false;
    }
    Bundle optsBundle = (v != null) ? getActivityLaunchOptions(v, item).toBundle() : null;
    UserHandle user = item == null ? null : item.user;
    // Prepare intent
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (v != null) {
        intent.setSourceBounds(getViewBounds(v));
    }
    try {
        boolean isShortcut = (item instanceof WorkspaceItemInfo) && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) && !((WorkspaceItemInfo) item).isPromise();
        if (isShortcut) {
            // Shortcuts need some special checks due to legacy reasons.
            startShortcutIntentSafely(intent, optsBundle, item);
        } else if (user == null || user.equals(Process.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            getSystemService(LauncherApps.class).startMainActivity(intent.getComponent(), user, intent.getSourceBounds(), optsBundle);
        }
        if (item != null) {
            InstanceId instanceId = new InstanceIdSequence().newInstanceId();
            logAppLaunch(item, instanceId);
        }
        return true;
    } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e);
    }
    return false;
}
Also used : InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) ActivityNotFoundException(android.content.ActivityNotFoundException) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 2 with InstanceIdSequence

use of com.android.launcher3.logging.InstanceIdSequence in project android_packages_apps_Launcher3 by crdroidandroid.

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 = info.container > 0 ? (FolderInfo) itemsIdMap.get(info.container) : null;
            StatsLogCompatManager.writeSnapshot(info.buildProto(parent), instanceId);
        }
        additionalSnapshotEvents(instanceId);
        prefs.edit().putLong(LAST_SNAPSHOT_TIME_MILLIS, now).apply();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkerThread(androidx.annotation.WorkerThread)

Example 3 with InstanceIdSequence

use of com.android.launcher3.logging.InstanceIdSequence in project android_packages_apps_Launcher3 by crdroidandroid.

the class SettingsChangeLogger method dispatchUserEvent.

private void dispatchUserEvent() {
    StatsLogger logger = StatsLogManager.newInstance(mContext).logger().withInstanceId(new InstanceIdSequence().newInstanceId());
    logger.log(mNotificationDotsEnabled ? LAUNCHER_NOTIFICATION_DOT_ENABLED : LAUNCHER_NOTIFICATION_DOT_DISABLED);
    logger.log(mNavMode.launcherEvent);
    logger.log(getDevicePrefs(mContext).getBoolean(LAST_PREDICTION_ENABLED_STATE, true) ? LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED : LAUNCHER_HOME_SCREEN_SUGGESTIONS_DISABLED);
    SharedPreferences prefs = getPrefs(mContext);
    StatsLogManager.LauncherEvent gridSizeChangedEvent = null;
    // TODO(b/184981523): This doesn't work for 2-panel grid, which has 6 hotseat icons
    switch(prefs.getInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, -1)) {
        case 5:
            gridSizeChangedEvent = LAUNCHER_GRID_SIZE_5;
            break;
        case 4:
            gridSizeChangedEvent = LAUNCHER_GRID_SIZE_4;
            break;
        case 3:
            gridSizeChangedEvent = LAUNCHER_GRID_SIZE_3;
            break;
        case 2:
            gridSizeChangedEvent = LAUNCHER_GRID_SIZE_2;
            break;
        default:
            // Ignore illegal input.
            break;
    }
    if (gridSizeChangedEvent != null) {
        logger.log(gridSizeChangedEvent);
    }
    if (FeatureFlags.ENABLE_THEMED_ICONS.get()) {
        logger.log(prefs.getBoolean(KEY_THEMED_ICONS, false) ? LAUNCHER_THEMED_ICON_ENABLED : LAUNCHER_THEMED_ICON_DISABLED);
    }
    mLoggablePrefs.forEach((key, lp) -> logger.log(() -> prefs.getBoolean(key, lp.defaultValue) ? lp.eventIdOn : lp.eventIdOff));
}
Also used : StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) SharedPreferences(android.content.SharedPreferences) StatsLogManager(com.android.launcher3.logging.StatsLogManager)

Aggregations

InstanceIdSequence (com.android.launcher3.logging.InstanceIdSequence)3 SharedPreferences (android.content.SharedPreferences)2 InstanceId (com.android.launcher3.logging.InstanceId)2 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Bundle (android.os.Bundle)1 UserHandle (android.os.UserHandle)1 WorkerThread (androidx.annotation.WorkerThread)1 StatsLogManager (com.android.launcher3.logging.StatsLogManager)1 StatsLogger (com.android.launcher3.logging.StatsLogManager.StatsLogger)1 FolderInfo (com.android.launcher3.model.data.FolderInfo)1 ItemInfo (com.android.launcher3.model.data.ItemInfo)1