Skip to content

Commit 2385ebe

Browse files
Sunny GoyalHyunyoung Song
Sunny Goyal
authored and
Hyunyoung Song
committed
Adding support for derivative apps to safely extend LauncherLog proto
Bug: 37676962 Change-Id: I24716070841b41418ac57b8dc367278e3ebdd046
1 parent 6cd0e46 commit 2385ebe

File tree

5 files changed

+53
-6
lines changed

5 files changed

+53
-6
lines changed

Android.mk

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ LOCAL_SRC_FILES := \
3333
$(call all-java-files-under, src) \
3434
$(call all-java-files-under, src_config) \
3535
$(call all-java-files-under, src_flags) \
36-
$(call all-proto-files-under, protos)
36+
$(call all-proto-files-under, protos) \
37+
$(call all-proto-files-under, proto_overrides)
3738

3839
LOCAL_RESOURCE_DIR := \
3940
$(LOCAL_PATH)/res \
@@ -42,7 +43,7 @@ LOCAL_RESOURCE_DIR := \
4243
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
4344

4445
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
45-
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
46+
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/ --proto_path=$(LOCAL_PATH)/proto_overrides/
4647
LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java
4748

4849
LOCAL_AAPT_FLAGS := \
@@ -66,10 +67,10 @@ include $(BUILD_PACKAGE)
6667
#
6768
include $(CLEAR_VARS)
6869

69-
LOCAL_SRC_FILES := $(call all-proto-files-under, protos)
70+
LOCAL_SRC_FILES := $(call all-proto-files-under, protos) $(call all-proto-files-under, proto_overrides)
7071

7172
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
72-
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
73+
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/ --proto_path=$(LOCAL_PATH)/proto_overrides/
7374
LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java
7475

7576
LOCAL_MODULE_TAGS := optional

build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ android {
4141
res.srcDirs = ['res']
4242
java.srcDirs = ['src', 'src_flags']
4343
manifest.srcFile 'AndroidManifest-common.xml'
44-
proto.srcDirs 'protos/'
44+
proto {
45+
srcDir 'protos/'
46+
srcDir 'proto_overrides/'
47+
}
4548
}
4649

4750
androidTest {
@@ -92,6 +95,7 @@ protobuf {
9295
task.builtins {
9396
remove java
9497
javanano {
98+
option "java_package=launcher_log_extension.proto|com.android.launcher3.userevent.nano"
9599
option "java_package=launcher_log.proto|com.android.launcher3.userevent.nano"
96100
option "java_package=launcher_dump.proto|com.android.launcher3.model.nano"
97101
option "enum_style=java"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) 2017 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
syntax = "proto2";
17+
18+
option java_package = "com.android.launcher3.userevent";
19+
option java_outer_classname = "LauncherLogExtensions";
20+
21+
package userevent;
22+
23+
//
24+
// Use this to add any app specific extensions to the proto.
25+
//
26+
message LauncherEventExtension {
27+
}
28+
29+
message TargetExtension {
30+
}

protos/launcher_log.proto

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
syntax = "proto2";
1717

18+
import "launcher_log_extension.proto";
19+
1820
option java_package = "com.android.launcher3.userevent";
1921
option java_outer_classname = "LauncherLogProto";
2022

@@ -52,6 +54,7 @@ message Target {
5254
optional int32 span_x = 13 [default = 1];// Used for ItemType.WIDGET
5355
optional int32 span_y = 14 [default = 1];// Used for ItemType.WIDGET
5456
optional int32 predictedRank = 15;
57+
optional TargetExtension extension = 16;
5558
}
5659

5760
// Used to define what type of item a Target would represent.
@@ -144,7 +147,6 @@ message Action {
144147
// Action (Touch) + Target + Target
145148
//
146149
message LauncherEvent {
147-
148150
required Action action = 1;
149151

150152
// List of targets that touch actions can be operated on.
@@ -157,4 +159,6 @@ message LauncherEvent {
157159

158160
optional bool is_in_multi_window_mode = 7;
159161
optional bool is_in_landscape_mode = 8;
162+
163+
optional LauncherEventExtension extension = 9;
160164
}

src/com/android/launcher3/logging/LoggerUtils.java

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.android.launcher3.ItemInfo;
2626
import com.android.launcher3.LauncherSettings;
2727
import com.android.launcher3.UninstallDropTarget;
28+
import com.android.launcher3.userevent.nano.LauncherLogExtensions.TargetExtension;
2829
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
2930
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
3031
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
@@ -159,6 +160,13 @@ public static Target newDropTarget(View v) {
159160
return t;
160161
}
161162

163+
public static Target newTarget(int targetType, TargetExtension extension) {
164+
Target t = new Target();
165+
t.type = targetType;
166+
t.extension = extension;
167+
return t;
168+
}
169+
162170
public static Target newTarget(int targetType) {
163171
Target t = new Target();
164172
t.type = targetType;

0 commit comments

Comments
 (0)