2018-10-25 14:09:50 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2018 The Android Open Source Project
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
package com.android.launcher3.logging;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
2020-04-15 10:22:28 -07:00
|
|
|
import android.util.Log;
|
2019-12-10 13:23:51 -08:00
|
|
|
|
2018-10-25 14:09:50 -07:00
|
|
|
import com.android.launcher3.R;
|
2020-03-26 01:48:24 -07:00
|
|
|
import com.android.launcher3.logger.LauncherAtom;
|
|
|
|
|
import com.android.launcher3.logger.LauncherAtom.ItemInfo;
|
2019-12-10 13:23:51 -08:00
|
|
|
import com.android.launcher3.logging.StatsLogUtils.LogStateProvider;
|
2018-10-25 14:09:50 -07:00
|
|
|
import com.android.launcher3.util.ResourceBasedOverride;
|
|
|
|
|
|
|
|
|
|
/**
|
2020-03-26 01:48:24 -07:00
|
|
|
* Handles the user event logging in R+.
|
2018-10-25 14:09:50 -07:00
|
|
|
*/
|
2018-11-14 15:11:48 -08:00
|
|
|
public class StatsLogManager implements ResourceBasedOverride {
|
2018-10-25 14:09:50 -07:00
|
|
|
|
2020-04-15 10:22:28 -07:00
|
|
|
private static final String TAG = "StatsLogManager";
|
|
|
|
|
|
2020-04-15 16:52:19 +00:00
|
|
|
interface EventEnum {
|
|
|
|
|
int getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LauncherEvent implements EventEnum {
|
|
|
|
|
@LauncherUiEvent(doc = "App launched from workspace, hotseat or folder in launcher")
|
|
|
|
|
APP_LAUNCH_TAP(1),
|
|
|
|
|
@LauncherUiEvent(doc = "Task launched from overview using TAP")
|
|
|
|
|
TASK_LAUNCH_TAP(2),
|
|
|
|
|
@LauncherUiEvent(doc = "Task launched from overview using SWIPE DOWN")
|
|
|
|
|
TASK_LAUNCH_SWIPE_DOWN(2),
|
|
|
|
|
@LauncherUiEvent(doc = "TASK dismissed from overview using SWIPE UP")
|
2020-04-15 10:22:28 -07:00
|
|
|
TASK_DISMISS_SWIPE_UP(3),
|
|
|
|
|
@LauncherUiEvent(doc = "User dragged a launcher item")
|
2020-05-01 13:54:53 -07:00
|
|
|
LAUNCHER_ITEM_DRAG_STARTED(383),
|
|
|
|
|
@LauncherUiEvent(doc = "A dragged launcher item is successfully dropped")
|
|
|
|
|
LAUNCHER_ITEM_DROP_COMPLETED(385);
|
2020-03-26 01:48:24 -07:00
|
|
|
// ADD MORE
|
|
|
|
|
|
|
|
|
|
private final int mId;
|
|
|
|
|
LauncherEvent(int id) {
|
|
|
|
|
mId = id;
|
|
|
|
|
}
|
|
|
|
|
public int getId() {
|
|
|
|
|
return mId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-25 14:09:50 -07:00
|
|
|
protected LogStateProvider mStateProvider;
|
2020-03-26 01:48:24 -07:00
|
|
|
|
2020-04-15 10:22:28 -07:00
|
|
|
/**
|
|
|
|
|
* Creates a new instance of {@link StatsLogManager} based on provided context.
|
|
|
|
|
*/
|
|
|
|
|
public static StatsLogManager newInstance(Context context) {
|
|
|
|
|
return newInstance(context, null);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-25 14:09:50 -07:00
|
|
|
public static StatsLogManager newInstance(Context context, LogStateProvider stateProvider) {
|
|
|
|
|
StatsLogManager mgr = Overrides.getObject(StatsLogManager.class,
|
|
|
|
|
context.getApplicationContext(), R.string.stats_log_manager_class);
|
|
|
|
|
mgr.mStateProvider = stateProvider;
|
|
|
|
|
mgr.verify();
|
|
|
|
|
return mgr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 13:23:51 -08:00
|
|
|
/**
|
2020-03-26 01:48:24 -07:00
|
|
|
* Logs an event and accompanying {@link ItemInfo}
|
2019-12-10 13:23:51 -08:00
|
|
|
*/
|
2020-04-15 10:22:28 -07:00
|
|
|
public void log(LauncherEvent event, LauncherAtom.ItemInfo itemInfo) {
|
|
|
|
|
Log.d(TAG, String.format("%s\n%s", event.name(), itemInfo));
|
|
|
|
|
// Call StatsLog method
|
|
|
|
|
}
|
2020-03-26 01:48:24 -07:00
|
|
|
|
2020-05-01 13:54:53 -07:00
|
|
|
/**
|
|
|
|
|
* Logs an event and accompanying {@link ItemInfo}
|
|
|
|
|
*/
|
|
|
|
|
public void log(LauncherEvent event, int instanceId, LauncherAtom.ItemInfo itemInfo) {
|
|
|
|
|
Log.d(TAG, String.format("%s(InstanceId:%s)\n%s", event.name(), instanceId, itemInfo));
|
|
|
|
|
// Call StatsLog method
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 01:48:24 -07:00
|
|
|
/**
|
|
|
|
|
* Logs snapshot, or impression of the current workspace.
|
|
|
|
|
*/
|
|
|
|
|
public void logSnapshot() { }
|
|
|
|
|
|
2018-10-25 14:09:50 -07:00
|
|
|
public void verify() {} // TODO: should move into robo tests
|
|
|
|
|
}
|