Adding support for derivative apps to safely extend LauncherLog proto

Bug: 37676962
Change-Id: I24716070841b41418ac57b8dc367278e3ebdd046
This commit is contained in:
Sunny Goyal 2017-07-19 01:24:07 -07:00 committed by Hyunyoung Song
parent 6cd0e46a8e
commit 2385ebebee
5 changed files with 53 additions and 6 deletions

View File

@ -33,7 +33,8 @@ LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
$(call all-java-files-under, src_config) \
$(call all-java-files-under, src_flags) \
$(call all-proto-files-under, protos)
$(call all-proto-files-under, protos) \
$(call all-proto-files-under, proto_overrides)
LOCAL_RESOURCE_DIR := \
$(LOCAL_PATH)/res \
@ -42,7 +43,7 @@ LOCAL_RESOURCE_DIR := \
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/ --proto_path=$(LOCAL_PATH)/proto_overrides/
LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java
LOCAL_AAPT_FLAGS := \
@ -66,10 +67,10 @@ include $(BUILD_PACKAGE)
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-proto-files-under, protos)
LOCAL_SRC_FILES := $(call all-proto-files-under, protos) $(call all-proto-files-under, proto_overrides)
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/ --proto_path=$(LOCAL_PATH)/proto_overrides/
LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java
LOCAL_MODULE_TAGS := optional

View File

@ -41,7 +41,10 @@ android {
res.srcDirs = ['res']
java.srcDirs = ['src', 'src_flags']
manifest.srcFile 'AndroidManifest-common.xml'
proto.srcDirs 'protos/'
proto {
srcDir 'protos/'
srcDir 'proto_overrides/'
}
}
androidTest {
@ -92,6 +95,7 @@ protobuf {
task.builtins {
remove java
javanano {
option "java_package=launcher_log_extension.proto|com.android.launcher3.userevent.nano"
option "java_package=launcher_log.proto|com.android.launcher3.userevent.nano"
option "java_package=launcher_dump.proto|com.android.launcher3.model.nano"
option "enum_style=java"

View File

@ -0,0 +1,30 @@
/*
* Copyright (C) 2017 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.
*/
syntax = "proto2";
option java_package = "com.android.launcher3.userevent";
option java_outer_classname = "LauncherLogExtensions";
package userevent;
//
// Use this to add any app specific extensions to the proto.
//
message LauncherEventExtension {
}
message TargetExtension {
}

View File

@ -15,6 +15,8 @@
*/
syntax = "proto2";
import "launcher_log_extension.proto";
option java_package = "com.android.launcher3.userevent";
option java_outer_classname = "LauncherLogProto";
@ -52,6 +54,7 @@ message Target {
optional int32 span_x = 13 [default = 1];// Used for ItemType.WIDGET
optional int32 span_y = 14 [default = 1];// Used for ItemType.WIDGET
optional int32 predictedRank = 15;
optional TargetExtension extension = 16;
}
// Used to define what type of item a Target would represent.
@ -144,7 +147,6 @@ message Action {
// Action (Touch) + Target + Target
//
message LauncherEvent {
required Action action = 1;
// List of targets that touch actions can be operated on.
@ -157,4 +159,6 @@ message LauncherEvent {
optional bool is_in_multi_window_mode = 7;
optional bool is_in_landscape_mode = 8;
optional LauncherEventExtension extension = 9;
}

View File

@ -25,6 +25,7 @@ import com.android.launcher3.InfoDropTarget;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.UninstallDropTarget;
import com.android.launcher3.userevent.nano.LauncherLogExtensions.TargetExtension;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
@ -159,6 +160,13 @@ public class LoggerUtils {
return t;
}
public static Target newTarget(int targetType, TargetExtension extension) {
Target t = new Target();
t.type = targetType;
t.extension = extension;
return t;
}
public static Target newTarget(int targetType) {
Target t = new Target();
t.type = targetType;