File: context_fence.proto

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (1800 lines) | stat: -rw-r--r-- 66,876 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto2";

package personalization.context;

// Represents the parameters for a time-based fence.
message TimeFence {
  enum TriggerType {
    UNKNOWN_TIME_FENCE_TRIGGER_TYPE = 0;
    ABSOLUTE_INTERVAL = 1;
    DAILY_INTERVAL = 2;
    WEEKEND_INTERVAL = 3;
    WEEKDAY_INTERVAL = 4;
    SUNDAY_INTERVAL = 5;
    MONDAY_INTERVAL = 6;
    TUESDAY_INTERVAL = 7;
    WEDNESDAY_INTERVAL = 8;
    THURSDAY_INTERVAL = 9;
    FRIDAY_INTERVAL = 10;
    SATURDAY_INTERVAL = 11;
    // The enum type AFTER_LOCAL_TIME is not supported, and is here only for
    // backwards compatibility
    AFTER_LOCAL_TIME = 12;
  }

  optional TriggerType trigger_type = 1;

  // Unused for ABSOLUTE_INTERVAL.  For all other types, this
  // represents the time zone to determine when the beginning of
  // day is.
  // If the flag use_local_time_zone is set to True, this is not set.
  optional string time_zone = 2;

  // For ABSOLUTE_INTERVAL, this is the time in millis since epoch
  // January 1, 1970.  For other intervals, this is the time in
  // millis since the start of the day (where midnight is 0 and
  // 24*60*60*1000 millis is the end of the day).
  // This should not be set if triggerType is AFTER_LOCAL_TIME.
  optional int64 start_time_millis = 3;

  // For ABSOLUTE_INTERVAL, this is the time in millis since epoch
  // January 1, 1970.  For other intervals, this is the time in
  // millis since the start of the day (where midnight is 0 and
  // 24*60*60*1000 millis is the end of the day).
  // This should not be set if triggerType is AFTER_LOCAL_TIME.
  optional int64 stop_time_millis = 4;

  // Used for representing the 'AFTER_LOCAL_TIME' trigger.
  // NOTE: DEPRECATED, AND UNSUPPORTED. DO NOT USE.
  optional DateTime date = 5 [deprecated = true];

  // Used to specify whether a local time zone at device location should
  // be used for the time fence.
  optional bool use_local_time_zone = 6;
}

// Represents the parameters for a location-based fence.
message LocationFence {
  // The type of trigger for this location fence.
  enum TriggerType {
    UNKNOWN_LOCATION_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence which is triggered when the user's location
    // is within this location fence.
    IN = 1;

    // Represents a fence which is triggered when the user enters
    // this location fence.
    ENTERING = 2;

    // Represents a fence which is triggered when the user exits
    // this location fence.
    EXITING = 3;
  }

  // The type indicating how this location fence's geometry is defined.
  enum GeometryType {
    UNKNOWN_LOCATION_FENCE_GEOMETRY_TYPE = 0;

    // Represents a location fence's boundary as a center and radius.
    CIRCLE = 1;
  }

  optional TriggerType trigger_type = 1;

  optional GeometryType geometry_type = 2;

  // Unused for trigger type IN.
  // For trigger types ENTERING and EXITING, this is window of time
  // in millis after detecting that the user has entered or exited the
  // location fence, during which this fence is considered triggered.
  // This parameter is needed to account for the async nature of context
  // data collection.
  optional int64 delta_time_millis = 3;

  // For GeometryType CIRCLE, this represents the center latitude
  // in E7 representation.
  optional int32 center_latitude_e7 = 4;

  // For GeometryType CIRCLE, this represents the center longitude
  // in E7 representation.
  optional int32 center_longitude_e7 = 5;

  // For GeometryType CIRCLE, this represents the outer radius in meters of
  // the circular region.  A user's location transitions from inside to
  // outside only when the user's location is found to be farther than
  // outer_radius_meters away from the center.
  // Note that the outer_radius_meters must be greater than or equal to
  // inner_radius_meters, and effectively, implements hysteresis to deal
  // with noisy location data.
  optional double outer_radius_meters = 6;

  // For GeometryType CIRCLE, this represents the inner radius of the circular
  // region.  A user's location transitions from outside to inside only when
  // the user's location is found to be closer than inner_radius_meters away
  // from the center.
  // Note that the inner_radius_meters must be less than or equal to
  // outer_radius_meters, and effectively, implement hysteresis to deal with
  // noisy location data.
  optional double inner_radius_meters = 7;

  // Used for trigger type IN.
  // For trigger type IN, it indicates the minimum dwell time at a location
  // before triggering the location fence.
  optional int64 dwell_time_millis = 8;
}

// Represents the parameters for a place-based fence.
message PlaceFence {
  // The type of trigger for this place fence.
  enum TriggerType {
    UNKNOWN_PLACE_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence which is triggered when the user's place
    // is one of the specified places (either matches one of the
    // place types or matches one of the place ids).
    IN = 1;

    // Represents a fence which is triggered when the user enters
    // one of the specified places from some other place.
    ENTERING = 2;

    // Represents a fence which is triggered when the user is
    // currently in one of the specified places and exits to some
    // other place.
    EXITING = 3;

    // Represents a fence which is triggered when the place changes
    // in successive screen on events.
    SCREEN_ON_CHANGE = 4;

    // Represents a fence which is triggered when CURRENT_PLACE context changes.
    AT_A_PLACE_CHANGE = 5;
  }

  optional TriggerType trigger_type = 1;

  // Unused for trigger type IN.
  // For trigger types ENTERING and EXITING, this is window of time
  // in millis after detecting that the user has entered or exited the
  // place fence, during which this fence is considered triggered.
  // This parameter is needed to account for the async nature of context
  // data collection.
  optional int64 delta_time_millis = 2;

  // List of place types as provided by the PlacesApi. This field will not be
  // filled in for
  // the SCREEN_ON_CHANGE trigger type.  See
  // https://cs.corp.google.com/piper///depot/google3/java/com/google/android/gmscore/dev/client/placefencing/src/com/google/android/gms/location/places/Place.java
  // Only one place_type, or one place_id, or one place_alias, or one
  // place_chain_name can be set.
  repeated int32 place_type = 3;

  // List of place ids.  This field will not be filled in for the
  // SCREEN_ON_CHANGE trigger type.
  // See Places.getId()
  // https://cs.corp.google.com/piper///depot/google3/java/com/google/android/gmscore/dev/client/placefencing/src/com/google/android/gms/location/places/Place.java
  // Only one place_type, or one place_id, or one place_alias, or one
  // place_chain_name can be set.
  repeated string place_id = 4;

  // Used for trigger type IN.
  // For trigger type IN, it indicates the minimum dwell time in a place
  // before triggering the Place fence.
  optional int64 dwell_time_millis = 5;

  // List of place aliases.  This field will not be filled in for the
  // SCREEN_ON_CHANGE trigger type.
  // See PlaceAlias.getAlias()
  // https://cs.corp.google.com/piper///depot/google3/java/com/google/android/gmscore/dev/client/places/src/com/google/android/gms/location/places/personalized/PlaceAlias.java
  // Only one place_type, or one place_id, or one place_alias, or one
  // place_chain_name can be set.
  repeated string place_alias = 6;

  // Name of the place chain like Walmart, AMC etc,.
  // Only one place_type, or one place_id, or one place_alias, or one
  // place_chain_name can be set.
  optional string place_chain_name = 7;

  // Optional field to set the timestamp for this fence.
  // This is ignored by contextmanager, but can be used to force (AGSA) client
  // into treating this fence as logically different, even if other fields are
  // identical.
  optional int64 creation_timestamp = 8;
}

// This message encapsulates the context specific data.
message ContextExtension {
  // Context specific data is attached as an extension.
  extensions 1000 to max;
}

message DetectedActivity {
  extend ContextExtension { optional DetectedActivity data = 77815057; }

  message ActivityRecord {
    // NextId: 22
    // Note: This enum must be kept in sync (including tag numbers) with
    // google3/java/com/google/geo/sidekick/proto/detected_activity.proto
    // google3/location/unified/proto/location_descriptor.proto
    enum Type {
      // LINT.IfChange
      IN_VEHICLE = 0;
      ON_BICYCLE = 1;
      ON_FOOT = 2;
      STILL = 3;
      UNKNOWN = 4;
      TILTING = 5;
      EXITING_VEHICLE = 6;
      WALKING = 7;
      RUNNING = 8;
      OFF_BODY = 9;
      TRUSTED_GAIT = 10;
      FLOOR_CHANGE = 11;
      ON_STAIRS = 12;
      ON_ESCALATOR = 13;
      IN_ELEVATOR = 14;
      SLEEPING = 15;
      IN_ROAD_VEHICLE = 16;
      IN_RAIL_VEHICLE = 17;
      IN_TWO_WHEELER_VEHICLE = 18;
      IN_FOUR_WHEELER_VEHICLE = 19;
      IN_CAR = 20;
      IN_BUS = 21;

      // This is to support EXPERIMENTAL_EXTRA_PERSONAL_VEHICLE until
      // Activity Recognition team figures out their API.
      EXPERIMENTAL_EXTRA_PERSONAL_VEHICLE = -1000;
      // LINT.ThenChange(
      //     //depot/google3/java/com/google/geo/sidekick/proto/detected_activity.proto,
      //     //depot/google3/location/unified/proto/location_descriptor.proto
      // )
    }

    // The type of activity.
    optional Type type = 1;
    // The confidence of the detection. Range is [0, 100].
    optional int32 confidence = 2;
  }
  repeated ActivityRecord activity_record = 2;
}

// Represents the parameters for an activity-based fence.
message ActivityFence {
  enum TriggerType {
    UKNOWN_ACTIVITY_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence which is triggered when the user's activity
    // is one of the specified activity types.
    DURING = 1;

    // Represents a fence which is triggered when the user starts
    // one of the specified activity types from some other activity type.
    STARTING = 2;

    // Represents a fence which is triggered when the user is
    // currently in one of the specified activity types but transitions
    // to some other activity type.
    STOPPING = 3;
  }

  optional TriggerType trigger_type = 1;

  // Unused for trigger type DURING.
  // For trigger types STARTING and STOPPING, this is window of time
  // in millis after detecting that the user has started or stopped the
  // activity types, during which this fence is considered triggered.
  // This parameter is needed to account for the async nature of context
  // data collection.
  optional int64 delta_time_millis = 2;

  // List of activity types that are considered part of this fence.
  repeated DetectedActivity.ActivityRecord.Type activity_type = 3;
}

// This represents the state of the device screen.
message Screen {
  extend ContextExtension { optional Screen data = 79284926; }

  enum State {
    // Unknown screen state.  All discrete states
    // like this should have an UNKNOWN enum set to 0.
    UNKNOWN = 0;

    // Screen is off.
    OFF = 1;

    // Screen is on.
    ON = 2;
  }

  // Screen state
  optional State state = 1;
}

// Represents the parameters for a fence based on screen on/off state
message ScreenFence {
  enum TriggerType {
    UNKNOWN_SCREEN_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence which is triggered when the screen is either
    // on or off
    DURING = 1;

    // Represents a fence which is triggered when the screen is turning
    // on.
    TURNING_ON = 2;

    // Represents a fence which is triggered when the screen it turning
    // off.
    TURNING_OFF = 3;
  }

  optional TriggerType trigger_type = 1;

  // Unused for trigger type DURING.
  // For trigger types TURNING_ON and TURNING_OFF, this is the window of
  // time in millis after detecting that the device's screen has turned
  // on or off.  This parameter is needed to account for the async nature
  // of context data collection.
  optional int64 delta_time_millis = 2;

  // Used only for trigger type DURING.  This indicates whether the screen is
  // on or off.
  optional Screen.State screen_state = 3;
}

// This represents the state of the headphones.
message AudioState {
  extend ContextExtension { optional AudioState data = 91925232; }

  enum HeadPhoneState {
    UNKNOWN_HEADPHONE_STATE = 0;

    // Headphone is plugged.
    PLUGGED = 1;

    // Headphone is unplugged.
    UNPLUGGED = 2;
  }

  // Deprecated. Results may not be valid
  enum BluetoothA2DPState {
    UNKNOWN_BLUETOOTH_A2DP_STATE = 0;
    // State when A2DP audio routing to the Bluetooth headset is
    // on.
    BLUETOOTH_A2DP_ON = 1;

    // State when A2DP audio routing to the Bluetooth headset is
    // off.
    BLUETOOTH_A2DP_OFF = 2;
  }

  enum BluetoothSCOState {
    UNKNOWN_BLUETOOTH_SCO_STATE = 0;
    // State when SCO audio routing to the Bluetooth headset is
    // on.
    BLUETOOTH_SCO_ON = 1;

    // State when SCO audio routing to the Bluetooth headset is
    // off.
    BLUETOOTH_SCO_OFF = 2;
  }

  enum MicrophoneState {
    UNKNOWN_MICROPHONE_STATE = 0;
    // State indicating if the microphone mute is on.
    MICROPHONE_MUTE_ON = 1;

    // State indicating if the microphone mute is off.
    MICROPHONE_MUTE_OFF = 2;
  }

  enum MusicState {
    UNKNOWN_MUSIC_STATE = 0;
    // State indicating when some music is playing.
    MUSIC_ACTIVE = 1;

    // State indicating when music is not active.
    MUSIC_INACTIVE = 2;
  }

  enum SpeakerPhoneState {
    UNKNOWN_SPEAKERPHONE_STATE = 0;
    // State indicating if the speakerphone is on.
    SPEAKER_PHONE_ON = 1;

    // State indicating if the speakerphone is off.
    SPEAKER_PHONE_OFF = 2;
  }

  optional HeadPhoneState headphone_state = 1;
  optional BluetoothA2DPState bluetooth_a2dp_state = 2 [deprecated = true];
  optional BluetoothSCOState bluetooth_sco_state = 3 [deprecated = true];
  optional MicrophoneState microphone_state = 4;
  optional MusicState music_state = 5;
  optional SpeakerPhoneState speakerphone_state = 6;
}

// Represents the parameters for a fence based on audio state.
// This audio state is derived from Android's AudioManager
// For More details about AudioManager API refer here -
// http://developer.android.com/reference/android/media/AudioManager.html
message AudioStateFence {
  enum TriggerType {
    UNKNOWN_AUDIO_STATE_FENCE_TRIGGER_TYPE = 0;
    HEADPHONE_DURING = 1;
    HEADPHONE_PLUGGING = 2;
    HEADPHONE_UNPLUGGING = 3;

    BLUETOOTH_A2DP_DURING = 4 [deprecated = true];
    BLUETOOTH_A2DP_TURNING_ON = 5 [deprecated = true];
    BLUETOOTH_A2DP_TURNING_OFF = 6 [deprecated = true];

    BLUETOOTH_SCO_DURING = 7 [deprecated = true];
    BLUETOOTH_SCO_TURNING_ON = 8 [deprecated = true];
    BLUETOOTH_SCO_TURNING_OFF = 9 [deprecated = true];

    MICROPHONE_DURING = 10;
    MICROPHONE_MUTING = 11;
    MICROPHONE_UNMUTING = 12;

    MUSIC_DURING = 13;
    MUSIC_ACTIVATING = 14;
    MUSIC_DEACTIVATING = 15;

    SPEAKER_PHONE_DURING = 16;
    SPEAKER_PHONE_TURNING_ON = 17;
    SPEAKER_PHONE_TURNING_OFF = 18;
  }

  optional TriggerType trigger_type = 1;

  // Unused for trigger types *_DURING. Required for all others.
  // This is the window of time in millis after detecting that the audio state
  // has changed during which the context fence will still trigger. This
  // parameter is needed to account for the async nature of context data
  // collection. A non-zero value must be specified, otherwise the fence will
  // never trigger.
  optional int64 delta_time_millis = 2;

  // Used only for trigger types during.
  // Any give time at most one of these states will be set depending upon the
  // During trigger type.
  optional AudioState.HeadPhoneState headphone_state = 3;
  optional AudioState.BluetoothA2DPState bluetooth_a2dp_state = 4
      [deprecated = true];
  optional AudioState.BluetoothSCOState bluetooth_sco_state = 5
      [deprecated = true];
  optional AudioState.MicrophoneState microphone_state = 6;
  optional AudioState.MusicState music_state = 7;
  optional AudioState.SpeakerPhoneState speakerphone_state = 8;
}

// This represents the state of the phone if it is locked or not.
message PhoneLock {
  extend ContextExtension { optional PhoneLock data = 91835270; }

  enum State {
    // Unknown state.  All discrete states
    // like this should have an UNKNOWN enum set to 0.
    UNKNOWN = 0;

    // Phone is unlocked.
    UNLOCKED = 1;

    // Phone is locked.
    LOCKED = 2;
  }

  optional State state = 1;
}

// Represents the parameters for a fence based on phone lock/unlock state
message PhoneLockFence {
  enum TriggerType {
    UNKNOWN_PHONE_LOCK_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence which is triggered when the screen is either
    // on or off
    DURING = 1;

    // Represents a fence which is triggered when the phone is unlocked.
    UNLOCKING = 2;

    // Represents a fence which is triggered when the phone is locked.
    LOCKING = 3;
  }

  optional TriggerType trigger_type = 1;

  // Unused for trigger type DURING. Required for UNLOCKING and LOCKING.
  // This is the window of time in millis after detecting that the device has
  // been locked or unlocked during which the context fence will still trigger.
  // This parameter is needed to account for the async nature of context data
  // collection. A non-zero value must be specified, otherwise the fence will
  // never trigger.
  optional int64 delta_time_millis = 2;

  // Used only for trigger type DURING.  This indicates whether the phone is
  // locked or unlocked.
  optional PhoneLock.State phone_lock_state = 3;
}

// This represents whether the device is connected to power.
message PowerConnection {
  extend ContextExtension { optional PowerConnection data = 87654321; }

  enum State {
    // Unknown power connection state.  All discrete states
    // like this should have an UNKNOWN enum set to 0.
    UNKNOWN = 0;

    // Device is not connected to a power source.
    DISCONNECTED = 1;

    // Device is connected to USB power.
    CONNECTED_USB = 2;

    // Device is connected to AC power.
    CONNECTED_AC = 3;

    // Device is connected to wireless power.
    CONNECTED_WIRELESS = 4;
  }

  // Power connection state
  optional State state = 1;
  // The battery level of the device (0.0-1.0).
  optional double battery_level = 2;
}

// Represents the parameters for a fence based on battery level or
// plugged in state.
message PowerConnectionFence {
  enum TriggerType {
    UNKNOWN_POWER_CONNECTION_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence for which the battery level is within an
    // interval.  For example, battery level between 30% and 80% is
    // represented by battery_level_lower_bound=.3 and
    // battery_level_upper_bound=.8.  Because the battery level
    // can only range from 0.0 to 1.0, you can represent battery level
    // greater than a threshold, say 70%, by setting
    // battery_level_lower_bound=.7 and
    // battery_level_upper_bound=1.0.  To represent battery level less
    // than a threshold, say 20%, you can set
    // battery_level_lower_bound=0.0 and battery_level_upper_bound=0.2.
    BATTERY_LEVEL_IN = 1;

    // Represents a fence when the battery level enters the interval.
    BATTERY_LEVEL_ENTERING = 2;

    // Represents a fence when the battery level exits the interval.
    BATTERY_LEVEL_EXITING = 3;

    // Represents a fence when the plugged in state is one of the
    // specified states.
    PLUGGED_IN_STATE_DURING = 4;

    // Represents a fence when the plugged in state transitions to one
    // of the specified states.
    PLUGGED_IN_STATE_STARTING = 5;

    // Represents a fence when the plugged in state transitions out
    // of one of the specified states.
    PLUGGED_IN_STATE_STOPPING = 6;
  }

  optional TriggerType trigger_type = 1;

  // Used for BATTERY_LEVEL_IN, BATTERY_LEVEL_ENTERING, and
  // BATTERY_LEVEL_EXITING.  This is the lower bound of the
  // battery level interval.  This ranges in value from 0.0 to 1.0.
  optional double battery_level_lower_bound = 2;

  // Used for BATTERY_LEVEL_IN, BATTERY_LEVEL_ENTERING, and
  // BATTERY_LEVEL_EXITING.  This is the upper bound of the
  // battery level interval.  This ranges in value from 0.0 to 1.0.
  // This value must be greater than or equal to
  // battery_level_lower_bound.
  optional double battery_level_upper_bound = 3;

  // Required for trigger types BATTERY_LEVEL_ENTERING, BATTERY_LEVEL_EXITING,
  // PLUGGED_IN_STATE_STARTING, and PLUGGED_IN_STATE_STOPPING.
  // This is the window of time in millis after detecting that the device's
  // state has changed during which the context fence will still trigger. This
  // parameter is needed to account for the async nature of context data
  // collection. A non-zero value must be specified, otherwise the fence will
  // never trigger.
  optional int64 delta_time_millis = 4;

  // Used for DURING_PLUGGED_IN_STATE, STARTING_PLUGGED_IN_STATE, and
  // STOPPING_PLUGGED_IN_STATE.
  repeated PowerConnection.State plugged_in_state = 5;
}

// Represents a fence that is triggered when detecting a beacon
// that contains a beacon attachment of the given types.
message BeaconFence {
  enum TriggerType {
    UNKNOWN_BEACON_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence that is triggered when a beacon is
    // detected.  The fence is triggered every time a unique
    // beacon is found that matches the set of beacon_type_filters.
    // Uniqueness for a beacon means that the (namespace,type,content)
    // triple is unique.
    FOUND = 1;

    // Represents a fence that is triggered when a beacon is
    // no longer detectable.  The fence is triggered every time
    // a unique beacon is lost that matches the set of
    // beacon_type_filters.  Uniqueness for a beacon means that the
    // (namespace,type,content) triple is unique.
    LOST = 2;

    // Represents a fence that is triggered when a beacon has been
    // found and is not lost.
    NEAR = 3;
  }

  optional TriggerType trigger_type = 1;

  // Represents the set of beacon types (i.e., namespace/type pairs)
  // that encompass this beacon fence.  If none is set, then this
  // beacon fence will never trigger.
  // DEPRECATED, fill in beacon_type_filter instead.
  // repeated detected_beacon.DetectedBeacon.Type beacon_type = 2;
  // NOTE: do not reuse field number 2

  // Used for FOUND and LOST.  This is the window of time in millis
  // after detecting that a beacon was either found or lost that
  // the transition is considered true.  This is needed to account
  // for the async nature of context data collection.
  optional int64 delta_time_millis = 3;

  message BeaconTypeFilter {
    // REQUIRED
    // Namespace of the beacon attachment to match against.
    // e.g., "com.google.location.beaconservice"
    optional string namespace = 1;

    // REQUIRED
    // Type of the beacon attachment to match against.
    // e.g., "geo-message-dogfood"
    optional string type = 2;

    // OPTIONAL
    // Indicates the content to match against in terms of
    // a byte array equals.  Do not set this if you do not
    // want to match against specific content.
    optional bytes content = 3;
  }

  repeated BeaconTypeFilter beacon_type_filter = 4;

  // Deprecated fields
  reserved 2;
}

// This represents the state of the phone's network connection,
// i.e. whether the phone is connected to a network and if connected,
// whether it is on WiFi or Cellular.
message NetworkState {
  extend ContextExtension { optional NetworkState data = 95555291; }

  enum ConnectionState {
    // Unknown state.  All discrete states
    // like this should have an UNKNOWN enum set to 0.
    UNKNOWN_STATE = 0;

    // Phone is not connected to network.
    DISCONNECTED = 1;

    // Phone is connected to network via WiFi
    ON_WIFI = 2;

    // Phone is connected to network via Cellular
    ON_CELLULAR = 3;
  }

  // connection_state is a REQUIRED field
  optional ConnectionState connection_state = 1;

  enum MeterState {
    // Unknown meter state
    UNKNOWN_METER_TYPE = 0;

    // Metered network connection
    METERED = 1;

    // Unmetered network connection
    UNMETERED = 2;
  }

  // meter_state field is omitted when connection_state is UNKNOWN_STATE
  // or DISCONNECTED; it is required when state is ON_CELLULAR or ON_WIFI
  optional MeterState meter_state = 2;

  message WifiInfo {
    // bssid of the currently connected Wifi connection
    optional string bssid = 1;

    // ssid of the currently connected Wifi connection
    optional string ssid = 2;
  }

  // connected_wifi_info is only populated when connection_state is connected
  optional WifiInfo connected_wifi_info = 3;
}

// Represents the parameters for a fence pertaining to network state
// (disconnected, connected to network via WiFi, or Cellular.
message NetworkStateFence {
  enum TriggerType {
    UNKNOWN_NETWORK_STATE_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence which is triggered when the connection state of the
    // device
    // is one of the specified states in the connection_state field below.
    CONNECTION_DURING = 1;

    // Represents a fence which is triggered when the device gets into
    // one of the specified connection states from some other connection state.
    CONNECTION_STARTING = 2;

    // Represents a fence which is triggered when the device is
    // currently in one of the specified connection states but transitions
    // to some other connection state.
    CONNECTION_STOPPING = 3;

    // Represents a fence which is triggered when the meter state of the device
    // is one of the specified states in the connection_state field below.
    METER_DURING = 4;

    // Represents a fence which is triggered when the device gets into
    // one of the specified meter states from some other meter state.
    METER_STARTING = 5;

    // Represents a fence which is triggered when the device is
    // currently in one of the specified meter states but transitions
    // to some other meter state.
    METER_STOPPING = 6;
  }

  optional TriggerType trigger_type = 1;

  // Unused for trigger types DURING. Required for STARTING and STOPPING.
  // This is the window of time in millis after detecting that the network state
  // has changed during which the context fence will still trigger. This
  // parameter is needed to account for the async nature of context data
  // collection. A non-zero value must be specified, otherwise the fence will
  // never trigger.
  optional int64 delta_time_millis = 2;

  // A valid NetworkStateFence proto should have only one of the following two
  // fields set. i.e. the fence can be over a subset of either connection
  // states or meter states but not both.
  // connection_state indicates the list of connection states that are
  // considered part of this fence.
  // connection_state is set in the proto only if the trigger_type is set to
  // CONNECTION_DURING, CONNECTION_STARTING, or CONNECTION_STOPPING.
  repeated NetworkState.ConnectionState connection_state = 3;

  // meter_state indicates the list of meter states that are considered part of
  // this fence.
  // meter_state is set in the proto only if the trigger_type is set to
  // METER_DURING, METER_STARTING, or METER_STOPPING.
  repeated NetworkState.MeterState meter_state = 4;
}

// The fence defines a device to be 'IN wandering' state if it has moved more
// than 'wander_distance_meters' in past interval 'wander_time_interval_hours'.
message WanderStateFence {
  enum TriggerType {
    UNKNOWN_WANDER_STATE_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence which is triggered when the device is in a state
    // where it is moving by at least 'wander_distance_meters' in a time
    // interval of 'wander_time_millis'
    IS_WANDERING = 1;

    // Represents a fence which is triggered when the device is entering a
    // wander state specified by the device moving by at least
    // 'wander_distance_meters' in a time interval of 'wander_time_millis'
    STARTING_WANDER = 2;

    // Represents a fence which is triggered when the device is leaving a
    // wander state specified by the device moving by at least
    // 'wander_distance_meters' in a time interval of 'wander_time_millis'
    STOPPING_WANDER = 3;
  }

  optional TriggerType trigger_type = 1;

  // Unused for trigger type IS_WANDERING.
  // For trigger types STARTING and STOPPING, this is window of time
  // in millis after detecting that the wander state has changed,
  // during which this fence is considered triggered.
  // This parameter is needed to account for the async nature of context
  // data collection.
  optional int64 delta_time_millis = 2;

  // the minimum distance that the phone needs to move for it to be evaluated
  // to be in wander state for this fence
  optional float wander_distance_meters = 3;

  // the time interval in hours during which the device should have covered
  // 'wander_distance_meters' for it to be evaluated to be in wander state
  // for this fence. This must be an integer number of hours between 1 and 20.
  // There is a 20 hour limit because the maximum period of location history
  // available on the phone is only 20 hours.
  optional int32 wander_time_interval_hours = 4;
}

// Represents the attributes of the day corresponding to the
// current time and locale.
// As examples, some attributes are: MORNING, AFTERNOON, EVENING,
// WEEKDAY, WEEKEND, HOLIDAY.
message DayAttributes {
  extend ContextExtension { optional DayAttributes data = 121436786; }

  enum DayAttributeType {
    // Unknown attribute type.  All discrete types
    // like this should have an UNKNOWN enum set to 0.
    UNKNOWN = 0;

    // Denotes a weekday for the device locale at the current time
    WEEKDAY = 1;

    // Denotes a weekend for the device locale at the current time
    WEEKEND = 2;

    // Denotes a government-sanctioned holiday for the device locale
    // at the current time
    HOLIDAY = 3;

    // Denotes the period of a day that is classified as morning
    MORNING = 4;

    // Denotes the period of a day that is classified as afternoon
    AFTERNOON = 5;

    // Denotes the period of a day that is classified as evening
    EVENING = 6;

    // Denotes the period of a day that is classified as night
    NIGHT = 7;
  }

  repeated DayAttributeType day_attribute_types = 1;
}

// Represents the parameters for a time-based fence.
message TimeIntervalFence {
  enum TriggerType {
    UNKNOWN_TIME_INTERVAL_FENCE_TRIGGER_TYPE = 0;

    // Represents a fence which is triggered when one of the attributes for
    // the local time for the device is the attribute specified for the fence
    // in 'day_attribute' parameter
    IN = 1;

    // Represents a fence which is triggered when one of the attributes for
    // the local time for the device transitions into being equal to the
    // attribute specified for the fence in 'day_attribute' parameter,
    // and the previous attribute before the transition was not equal
    // to the 'day_attribute' parameter
    STARTING = 2;

    // Represents a fence which is triggered when one of the attributes for
    // the local time for the device transitions to being not equal to the
    // attribute specified for the fence in 'day_attribute' parameter,
    // and the previous attribute before the transition was equal
    // to the 'day_attribute' parameter
    STOPPING = 3;
  }

  optional TriggerType trigger_type = 1;

  // Used to specify one of the DAY_ATTRIBUTE related triggers
  optional DayAttributes.DayAttributeType time_interval_type = 2;
}

// Represents the installed apps fence
message InstalledAppsFence {
  enum TriggerType {
    UNKNOWN_INSTALLED_APPS_TRIGGER_TYPE = 0;

    // Used for the fence which is triggered when the app is installed.
    INSTALLED = 1;

    // Used for the fence which is triggered when the app is not installed.
    NOT_INSTALLED = 2;
  }

  optional TriggerType trigger_type = 1;

  // The package to check for the installed status
  optional string package_name = 2;
}

// Represents the phone call fence
message PhoneCallFence {
  enum TriggerType {
    UNKNOWN_PHONE_CALL_TRIGGER_TYPE = 0;

    // Used for the fence which is triggered when the user is in a phone call.
    IN_CALL = 1;

    // Used for the fence which is triggered when the user is not in a phone
    // call.
    NOT_IN_CALL = 2;
  }

  optional TriggerType trigger_type = 1;
}

// Represents the proximity distance fence
message ProximityDistanceFence {
  enum TriggerType {
    UNKNOWN_PROXIMITY_DISTANCE_TRIGGER_TYPE = 0;

    // Used for the fence which is triggered when the proximity sensor is far
    // from an object.
    FAR_AWAY = 1;

    // Used for the fence which is triggered when the proximity sensor is near
    // to an object.
    NEAR = 2;
  }

  optional TriggerType trigger_type = 1;
}

// Represents a time fence expressed in terms of moments of the day
message SunStateFence {
  enum TriggerType {
    UNKNOWN_MOMENT_FENCE_TRIGGER_TYPE = 0;

    // Time triggers specified based on sunrise times
    AROUND_SUNRISE = 1;

    // Time triggers specified based on sunset times
    AROUND_SUNSET = 2;
  }

  optional TriggerType trigger_type = 1;

  // Absolute value of begin_relative_to_sun_state_millis
  // cannot exceed total millis in a day.
  // begin_relative_to_sun_state_millis cannot be later than
  // end_relative_to_sun_state_millis.
  optional int64 begin_relative_to_sun_state_millis = 3;

  // Absolute value of end_relative_to_sun_state_millis
  // cannot exceed total millis in a day.
  // end_relative_to_sun_state_millis cannot be earlier
  // than begin_relative_to_sun_state_millis.
  optional int64 end_relative_to_sun_state_millis = 4;
}

// Represents a weather fence that triggers when specified criteria
// on weather connditions, temperatures or humidity is met
message WeatherFence {
  enum TriggerType {
    UNKNOWN_WEATHER_FENCE_TRIGGER_TYPE = 0;

    // Fence that triggers when the temperature in the device's location
    // is in a specified range.
    IN_TEMPERATURE_RANGE = 1;

    // Fence that triggers when the feels-like temperature in the device's
    // location is in a specified range.
    IN_FEELS_LIKE_TEMPERATURE_RANGE = 2;

    // Fence that triggers when the dew point in the device's location
    // is in a specified range.
    IN_DEW_POINT_RANGE = 3;

    // Fence that triggers when the humidity in the device's location
    // is in a specified range.
    IN_HUMIDITY_RANGE = 4;

    // Fence that triggers when the weather condition in the device's location
    // is the specified condition
    IN_CONDITION = 5;
  }

  optional TriggerType trigger_type = 1;

  // Low value of the temperature range of the weather fence.
  // Used only for trigger types IN_TEMPERATURE_RANGE,
  // IN_FEELS_LIKE_TEMPERATURE_RANGE, IN_DEW_POINT_RANGE.
  // Note: low_temp_f < high_temp_f for a valid fence.
  optional float low_temp_f = 2;

  // High value of the temperature range of the weather fence.
  // Used only for trigger types IN_TEMPERATURE_RANGE,
  // IN_FEELS_LIKE_TEMPERATURE_RANGE, IN_DEW_POINT_RANGE.
  // Note: low_temp_f < high_temp_f for a valid fence.
  optional float high_temp_f = 3;

  // Low value of the humidity range of the weather fence.
  // Used only for trigger type IN_HUMIDITY_RANGE.
  // Note: low_humidity < high_temp_f for a valid fence.
  optional int32 low_humidity = 4;

  // High value of the temperature range of the weather fence.
  // Used only for trigger type IN_HUMIDITY_RANGE.
  // Note: low_humidity < high_humidity for a valid fence.
  optional int32 high_humidity = 5;

  // Desired type of weather condition for the fence.
  // Used only for trigger types IN_CONDITION
  // This should be set to one of the values in:
  // Weather.WeatherCondition.Type or
  // com.google.android.gms.awareness.state.Weather.WeatherCondition
  optional int32 condition_type = 6;
}

// Represents the parameters for a shush state fence
message ShushStateFence {}

// Represents the parameters for a wifi state fence
message WifiStateFence {
  enum TriggerType {
    UNKNOWN_WIFI_FENCE_TRIGGER_TYPE = 0;

    // Fence triggers when a matching access point is connected
    CONNECTED = 1;
    // Fence triggers when a matching access point is detectable
    FOUND = 2;
  }
  optional TriggerType trigger_type = 1;
  // If provided, matches when an access point has given bssid
  optional string bssid = 2;
  // If provided, matches when an access point has given ssid
  optional string ssid = 3;
}

// Names of the different contexts.  The enum here is meant to grow as more
// contexts are defined. Names are loosely organized (and corresponding proto
// tag numbers) by family. See ContextFamily for description of what families
// entail.  It is understood that some context names may fall under multiple
// families but should be tagged with whatever is deemed the more prominent
// family grouping.
//
// The ContextName directly maps to a proto (if one exists) that is put in
// the extension of a Context object.  These protos are stored
// in subdirectories under //personalization/context/proto according to the
// name.  (E.g., for SCREEN and POWER_CONNECTION, the corresponding protos
// are stored in //personalization/context/proto/screen/screen.proto and
// //personalization/context/proto/power_connection/power_connection.proto.
//
// A ContextName can also be mapped to a model that may be used to generate
// a context for a particular type. Each model name should strictly be suffixed
// with '_MODEL' to indicate that it is a Model. It is also fine if multiple
// contexts share the same model.
//
// Namespaces of 1 - 10000 is reserved for Contexts.
// For any clarification, always contact context-team@
enum ContextName {
  // The context name is unknown.
  UNKNOWN_CONTEXT_NAME = 0;
  // The user's current location.
  USER_LOCATION = 1;
  // How familiar the user is with their current location (tourist vs. local).
  USER_LOCATION_FAMILIARITY = 2 [deprecated = true];
  // Predicted future locations that the user will be at.
  USER_LOCATION_FORECAST = 3 [deprecated = true];
  // The Maps viewport that the user is currently looking at.
  MAPS_VIEWPORT = 4;
  // How familiar the user is with the Maps viewport they are currently looking
  // at (tourist vs. local).
  MAPS_VIEWPORT_FAMILIARITY = 5;
  // Detected activity of the user.
  DETECTED_ACTIVITY = 6;
  // Device screen state: on/off
  SCREEN = 7;
  // Device power connection state: connected/disconnected
  POWER_CONNECTION = 8;
  // Signal related to current trust state of the device (ex. Connection state
  // of devices, signals from facial recognition, user activity or location
  // affinity.
  TRUST_SIGNAL = 9;
  // A decision evaluated by a decision engine about how much the device is
  // currently secure.
  TRUST_DECISION = 10;
  // Use these context names if experimenting with the Context Manager for the
  // first time.  In order to query for experimental context types, be sure
  // to include keys in the Key field when inserting Context objects into
  // Context Manager. For more information see go/experimental-context-name

  // EXPERIMENTAL1_UPLOAD_RESTRICTED is an upload restricted context name,
  // meaning it will not be uploaded to the backend context manager server.
  // Use this for experimental contexts that are prohibited from syncing.
  EXPERIMENTAL1_UPLOAD_RESTRICTED = 11;
  // The 2 and 3 are not upload restricted. These will be synced to the
  // backend.
  EXPERIMENTAL2_UPLOAD_OK = 12;
  EXPERIMENTAL3_UPLOAD_OK = 13;
  // Snapped-to-road locations as provided by GMM in navigation mode.
  SNAPPED_TO_ROAD_LOCATION = 14;
  // High-level semantic time, location and activity state of the user.
  SEMANTIC_STATE = 15;
  // User's travel context, e.g., trips, locations, travel modes, etc.
  TRAVEL = 16;
  // User's device wifi scan results.
  WIFI_SCAN = 17;
  // Places context. See android places api.
  PLACES = 18;
  // Calendar events for the user.
  CALENDAR_EVENT = 19;
  // APPS that are running at a given time interval. This is obtained via the
  // UsageStatsManager for Lollipop+ platform versions, and via ActivityManager
  // for pre Lollipop.
  // Deprecated. consider using UsageStatsManager API directly.
  RUNNING_APPS = 20 [deprecated = true];
  // The topics about which the user will be interested in consuming content.
  CONTENT_INTERESTS = 21;
  // Cast events.
  CAST_EVENT = 22;
  // Places that are of interest to the user.
  PLACE_INTERESTS = 23 [deprecated = true];
  // Audio state for the device provided by Android's audio manager.
  AUDIO_STATE = 24;
  // State of the User's phone, whether it is locked or unlocked.
  PHONE_LOCK = 25;
  // Detected beacon attachments from scanned BLE beacons.
  DETECTED_BEACON = 26;
  // State of the network connection, if connected whether it is on WiFi or
  // Cellular
  NETWORK_STATE = 27;
  // Locations the user recently visited.
  RECENT_VISITS = 28;
  // Snapped place location  of the user. Obtained from Hulk STP backend
  // based on user's lat/lng location, detected activity, nearby Wifi signals,
  // BLE beacons, etc.
  SNAPPED_PLACES = 29;
  // Snapped city location of the user. Obtained by reverse geocoding
  // the user's lat/lng location.
  SNAPPED_CITY = 30 [deprecated = true];
  // Context for the weather information.
  WEATHER = 31;
  // User's wandering state context, i.e. distance spanned by a device in
  // a given time interval
  WANDER_STATE = 32;
  // User's affinities with service providers.
  PROVIDER_AFFINITIES = 34;
  // User's detected routines
  ROUTINES = 35 [deprecated = true];
  // Attributes of the day corresponding to the current time and locale
  // As examples, some attributes are: MORNING, EVENING, WEEKDAY,
  // WEEKEND, HOLIDAY.
  DAY_ATTRIBUTES = 36;
  // Phone call state
  PHONE_CALL = 37 [deprecated = true];
  // Proximity distance reported by the proximity sensor
  PROXIMITY_DISTANCE = 38;
  // Installed applications on the device
  INSTALLED_APPS = 39;
  // Shopping related contexts (e.g. Shopping product profiles from
  // web and Chrome)
  SHOPPING = 40;
  // Users Personas. go/persona
  PERSONAS = 41 [deprecated = true];
  // Users language preferences. go/now-u-languages-design
  LANGUAGES = 42;
  // Sunrise and sunset times of the day at the device's location
  SUN_STATE = 43;
  // User demographics (e.g. age, gender, income bracket)
  DEMOGRAPHICS = 44;
  // Properties of time (such as time zone at device's locale). This is similar
  // to LOCALE_BASED_TIME_MODEL but does not need a network call. The guiding
  // principle has been to have flat organization for contexts despite possible
  // overlap. The alternative of having the same context being produced from
  // client or server introduces code complexity that gets unmaintainable.
  // This context is part of the same SEMANTIC_TIME family.
  TIME_PROPERTY = 45;
  // Predicted future locations the user will go to.
  // This context will eventually replace USER_LOCATION_FORECAST
  DESTINATION_PREDICTION = 46;
  // Where the user has a vehicle parked and related information such as how
  // long they can park there, how to find the parking spot, etc.
  PARKING_LOCATIONS = 47;
  // User's current direction and speed
  USER_VELOCITY = 48;
  // Context from user's Gmail, e.g. movie tickets, flight information,
  // restaurant reservation, etc.
  PERSONAL_INTELLIGENCE = 49;
  // The contextual pivot for a search query, e.g. a KG mid, a location, etc.
  // This is provided as part of search requests to describe the thing that a
  // query is pivoted around.
  QUERY_PIVOT = 50;
  // Intents predicted by the intent system (go/pips).
  // Deprecated. This context is currently not supported. Please email to
  // user-model-clients@google.com before use it.
  PROACTIVE_INTENTS = 51 [deprecated = true];
  // XGeo header
  XGEO_HEADER = 52 [deprecated = true];
  // User's location history and location habits. See go/distill
  DISTILL_LOCATION_PROFILE = 53 [deprecated = true];
  // Trained user embeddings.
  USER_EMBEDDING = 54;
  // Weather context for internal (first-party) clients
  WEATHER_INTERNAL = 55;
  // Trained entity embeddings for user interests.
  INTEREST_ENTITY_EMBEDDINGS = 56;
  // Prediction for whether the device is indoors or outdoors
  // automatic read/write permissions
  INDOOR_OUTDOOR = 57;
  // User's inferred task and task related suggestions.
  VASCO_TASK_SUGGESTIONS = 58;
  // Probability of user in DND mode
  DND_MODE = 59;
  // Filtered CurrentPlaces context, based on filtered PlaceUpdates.
  CURRENT_PLACES = 60;
  // Aware profile (go/search-aware).
  AWARE_PROFILE = 61;
  // The language (ISO 639-1) and country (ISO 3166-1) codes, such as "en_US",
  // of the device that made the request. It belongs to the DEVICE_STATE family.
  DEVICE_LOCALE = 62;
  // All activity in a timeline (go/unified-activity-overview).
  ACTIVITY_TIMELINE = 63;

  // Current Maps turn-by-turn navigation state.  See
  // go/gmm-guided-navigation-state-export.
  MAPS_NAVIGATION_STATE = 67;
  // The user's device information as gathered in Search. Uses
  // superroot/impls/web/proto/device.proto as representation.
  SEARCH_DEVICE = 68;
  // Scores related to sending geo notifications computed from internal ML
  // models. (go/ml-for-ugc-notifications).
  GEO_NOTIFICATION_SCORES = 70;
  // Interest similarity. A list of related entity interests with support for
  // different types and verticals.
  INTEREST_ENTITY_SIMILARITY = 71;
  // Entities consumed by a user and related metadata. (It covers use cases
  // like metadata about watching a movie / tv show or buying a book etc).
  CONTENT_CONSUMPTION = 73;
  // User's semantic location state for at-home, at-work, and traveling.
  SEMANTIC_LOCATION = 74 [deprecated = true];
  // Set of locations (IP location, device location, historic location, etc)
  LOCATION_CONTEXT = 75;
  // The input method of the query, e.g. typed or voice.
  SEARCH_INPUT_METHOD = 76;
  // Knowledge-specific params.
  KE_PARAMS = 77;
  // State of the user w.r.t Product. This is intended to serve
  // lightweight product specific information about a user e.g opt-in age,
  // activity levels, etc.
  PRODUCT_USER_STATE = 78;
  // `ACTIVITY_TRANSPOSE` is deprecated.
  ACTIVITY_TRANSPOSE = 79 [deprecated = true];
  // Search ugc interests, contains entity-level and user-level aggregated
  // signals about user's activities with Search UGC features.
  SEARCH_UGC_INTERESTS = 80;
  // Context indicating user is currently on commute.
  ON_COMMUTE = 81;
  // Relations (Caretaker, Owner, Employee) users have to places
  // go/user-relation-to-place-anima.
  USER_RELATION_TO_PLACES = 82;

  // State capturing user interactions in Discover sliced by card category,
  // content topic etc. which will be used by interest exploration efforts
  // (go/exploration-state-design).
  DISCOVER_ACTIONS_PROFILE = 84;

  // Returns user's related activities given a set of input activities.
  // (go/related-activity-api-proto-proposal).
  RELATED_ACTIVITY = 85;

  // Stateful Task APIs: go/stateful-task-apis
  STATEFUL_ACTIVITY_RECOMMENDED = 86;
  STATEFUL_ACTIVITY_RELATED = 87;
  STATEFUL_ACTIVITY_RENDERABLE = 88;
  STATEFUL_TASK_ACTIVE = 89;
  STATEFUL_TASK_RELATED = 90;

  // Stateful API v2 (go/stateful-api-v2)
  STATEFUL_TASK = 128;
  STATEFUL_TASK_ACTIVITY_CARD = 130;
  STATEFUL_TASK_DISCOVER = 131;
  STATEFUL_TASK_TASK_HUB = 137;
  STATEFUL_TASK_NOTIFICATIONS = 142;

  // State of the currently connected wifi connection
  WIFI_CONNECTION_STATE = 91;

  // User contribution data for geo UGC. go/ugc-motivation.
  GEO_UGC_MOTIVATION = 92;

  // User's search suggestion state, such as previous query and suggested
  // queries from recent queries (go/suggest-context).
  SEARCH_SUGGEST_STATE = 93;

  // User's predicted Geo Merchant Identification state (go/mid-anima).
  GEO_MERCHANT_IDENTIFICATION_STATE = 94;

  // Affinity signals from Sherlock.
  SHERLOCK_AFFINITY = 95;

  // User Activity Counts (go/user-activity-counts).
  USER_ACTIVITY_COUNTS = 96;

  // Shopping preferences model
  SHOPPING_PREFERENCE_PROFILE = 97;

  // Users contribution data for Get-on-Google (go/gog). Includes stats about
  // previous contributions, contribution views, topic interests, and topic
  // tasks.
  GOG_CONTRIBUTOR_PROFILE = 98;

  // Crosspath representative items.
  CROSSPATH_REPRESENTATIVE_ITEMS = 99;

  // Entity History Model which holds entities the user might want to re-engage
  // with in evergreen verticals like Books and Video Games. go/ehm
  ENTITY_HISTORY = 100;

  // Discover User Actions Profile which holds personalized aggregate counts of
  // actions sliced by custom dimensions over longer term time windows.
  // go/discover-uap-redesign
  DISCOVER_USER_ACTIONS_PROFILE = 101;

  // LOCAL_ADS_ENTITY_PREFERENCES represents the serving analog for the local
  // ads entity preference model (go/anima-local-ads-entity-model). The model
  // represents KG entities which the user has shown a preference for based on
  // the Ads-approved activities across Google products.
  LOCAL_ADS_ENTITY_PREFERENCES = 102;

  // Aggregated clicks on merchant websites. See go/scaling-merchant-reviews.
  MERCHANT_CLICK_COUNTS = 103;

  // Model containing aggregated views of Get on Google Cameos across platforms
  // (assistant, SRP, Discover, Topic Feed)
  GOG_CAMEO_VIEWS = 104;

  // Single-day aggregate counts of distinct Semantic User Needs (SUNs) in
  // the user's activity timeline. (See: go/nash-pre-suns)
  DAILY_SUN_COUNTS = 105;

  // Representation Assistant Recipe Embeddings.
  ASSISTANT_RECIPE_USER_EMBEDDINGS = 106;

  // Representation of Assistant Recipe Embeddings inferred during request-time.
  ASSISTANT_RECIPE_ONLINE_USER_EMBEDDINGS = 145;

  // Representation of Core Interest Embeddings.
  CORE_INTEREST_EMBEDDINGS = 107;

  // Representation of Event User Embedding.
  EVENT_USER_EMBEDDINGS = 108;

  // Representation of Podcast User Embedding.
  PODCAST_USER_EMBEDDINGS = 109;

  // Representation of Long term interest embeddings.
  LONG_TERM_INTEREST_EMBEDDINGS = 110;

  // Representation of Horizontal User Embeddings.
  HORIZONTAL_USER_EMBEDDINGS = 135;

  // Monet online embeddings.
  MONET_ONLINE_EMBEDDINGS = 138;

  // Representation of Tvn Timeline Signals.
  TVM_TIMELINE_SIGNALS_FEATURES = 111;

  // Representation of qualia profile for Discover feed.
  DISCOVER_QUALIA_PROFILE = 112;

  // Representation of qualia profile for GNews.
  NEWS_QUALIA_PROFILE = 127;

  // Representation of monet embeddings model input features.
  DISCOVER_MONET_EMBEDDINGS_FEATURES = 113;

  // Representation of monet pilot embeddings model input features.
  DISCOVER_MONET_PILOT_EMBEDDINGS_FEATURES = 144;

  // Representation of monet holdback embeddings model input features.
  DISCOVER_MONET_HOLDBACK_EMBEDDINGS_FEATURES = 148;

  // TVM items click counts, within what-to-watch. Includes item clicks (W2W)
  // and clicks on 'watch now' button (W2W and Amati).
  W2W_CLICKS = 114;

  // Aggregated TVM items clicks, impressions and other relevant signals in W2W,
  // Amati and other surfaces. go/recomedia-freshness
  W2W_STATEFULNESS = 132;

  // Representation of user embeddings for recomedia TVM vertical.
  RECOMEDIA_TVM_USER_EMBEDDINGS = 115;

  // Representation of user embeddings for books vertical.
  RECOMEDIA_BOOKS_USER_EMBEDDINGS = 136;

  // User's implicit watch state across products, i.e. Search, Amati, and
  // Primetime. go/ump-implicit-watch
  UMP_IMPLICIT_WATCH = 116;

  // Representation of Hobbes DeepTrends IDLE user embeddings.
  HOBBES_DEEP_TRENDS_IDLE_USER_EMBEDDINGS = 117;

  // Representation of Hobbes DeepTrends FaBLE user embeddings.
  HOBBES_DEEP_TRENDS_FABLE_USER_EMBEDDINGS = 118;

  // Representation of signals needed to determine churn probability of a user.
  // go/aga-churn-notif-design
  AGA_CHURN_PREVENTION_MODEL = 119;

  // User Activity Store on Evergreen Content (a.k.a., RoutinesMemory Redesign).
  // go/user-activity-store-on-evergreen-content
  USER_ACTIVITY_STORE_ON_EVERGREEN_CONTENT = 120;

  // Url view demotion PSM, containing counts of docids from Chrome, Search,
  // and Discover per time ranges.
  // go/psm-view-demotion-aggregates
  VIEW_DEMOTION_AGGREGATES = 125;

  // Representation of user embeddings model for Shopping Property user
  // timeline.
  SHOPPING_PROPERTY_USER_TIMELINE = 121;

  // Representation of the signals needed to determine churn probability in
  // opa for a user.
  GROWTH_FACTORS_OPA_CHURN_MODEL = 122;

  // LOCAL_ADS_CHAIN_ENTITY_PREFERENCES represents the serving analog for the
  // local ads chain entity preference model. The model scores KG entities
  // pertaining to business chains which the user has shown a preference for
  // based on the Ads-approved activities across Google products.
  LOCAL_ADS_CHAIN_ENTITY_PREFERENCES = 123;

  // Representation of the user profile generated by Qualia model during serving
  // time based on features extracted from both LTAT and STAT.
  QUALIA_ONLINE_PROFILE = 126;

  // Representation of Books Timeline Signals.
  BOOKS_TIMELINE_SIGNALS_FEATURES = 129;

  // Representation of Handbag Personalized entities.
  HANDBAG_PERSONALIZED_ENTITIES = 133;

  // Represents the backfill analog for the local
  // ads entity preference model (go/anima-local-ads-entity-model). The model
  // represents KG entities which the user has shown a preference for based on
  // the Ads-approved activities across Google products.
  LOCAL_ADS_HISTORICAL_ENTITY_PREFERENCES = 134;

  // Representation of Deep Now `ContextFeatures` signals. Note that this is a
  // temporary solution and should not be used for other external use cases.
  // TODO(b/187311600): Clean up DEEP_NOW_CONTEXT_FEATURES
  DEEP_NOW_CONTEXT_FEATURES = 139;

  // Represents the Hobbes user embeddings model for Hotels Ranking.
  HOTEL_HOBBES_USER_EMBEDDINGS = 140;

  // Representation of the petacat profile generated by Petacat model during
  // serving time.
  PETACAT_ONLINE_PROFILE = 143;

  // Represents user's recent actions on documents.
  RECENT_URL_ACTIONS = 146;

  // Represents user's recent activity signals that is local related.
  LOCAL_RELATED_RECENT_ACTIVITY_SIGNALS = 147;

  // Profile of documents by domain visited by the user across google e.g.
  // Search and Chrome (go/wind-rose-data).
  WIND_ROSE_PROFILE = 149;

  // Represents the user's U-SERP profile, i.e. how much they like/dislike
  // certain OneNamespace types (go/u-serp).
  USERP = 150;

  // Next Context Id: 151

  //---------------------------------------------------------------------------
  // Context Manager Internal Contexts. These are usually contexts such as
  // models that are used by the first party apps for synchronization from
  // cloud, or used by context manager for creating other higher level
  // contexts.
  // A range of [10000 - 19999] is reserved.
  // Next Id: 10010
  //---------------------------------------------------------------------------

  // Model for the USER_LOCATION_FAMILIARITY context.
  USER_LOCATION_FAMILIARITY_MODEL = 10000;

  // Model that is trained for a user based upon the hotword detection.
  // Hotword detection is also known as Keyword Spotting and is the task
  // of detecting a pre-defined Hotword like “Ok Google” in a continuous
  // audio stream.
  // These already trained models can be pushed from cloud to device where
  // they can be used as preconfigured for voice search on a new or resetted
  // device.
  HOTWORD_SPEAKER_MODEL = 10001;

  // Model representing the UDC settings.
  UDC_FOOTPRINTS_SETTINGS_MODEL = 10002;

  // Model that is used for predicting safe locations for a user.
  // These locations can be marked as trusted locations on the device,
  // used for creating an overall trust/confidence score etc.
  SAFE_LOCATION_MODEL = 10003;

  // A set of places for which we have personal data for ELSA to use for place
  // inference. This includes the user's home and work, and places for which
  // they have interactions in the GeoJournalSummary. See
  // http://go/elsa-geojournal.
  PERSONALIZED_PLACES = 10004;

  // A set of places which user has set aliases, such as HOME/WORK
  ALIASED_PLACES = 10005;

  // A special type of Context Manager's internal context that represents the
  // encoded bytes of a differential context.
  CONTEXT_DELTA = 10006;

  // Model that represents information about time that is expressed
  // semantically and dependent on locale. For example, notions of weekday,
  // weekend, holiday refer to time but are dependent on country.
  // In addition this includes personalized day parts such as start of day,
  // morning, evening which is user dependent.
  LOCALE_BASED_TIME_MODEL = 10007;

  // Representation for the feedback to be collected about the fence states
  FENCE_FEEDBACK = 10008;

  // Information about the fence state. This includes the fence key, the event
  // related to the fence and the condition of the fence
  FENCE_STATE = 10009;

  // Representation of domain interests
  DOMAIN_INTERESTS = 10011;

  reserved 33, 64, 65, 66, 69, 72, 83, 124, 141, 10010;

  // Next Model Id: 10012

  //---------------------------------------------------------------------------
  // The following block is reserved by Context Manager for generic local
  // contexts, that are produced by a local app or process.
  // UNSPECIFIED_LOCAL_CONTEXTx tags are left in as placeholders so proto
  // parsing does not eliminate them. Each tag should be renamed appropriately
  // once claimed.
  //---------------------------------------------------------------------------

  // Marker for start of the block; default length is 100, expandable to 1000
  LOCALLY_PRODUCED_BLOCK_START_MARKER = 10999;

  // Next locally-produce Context Id: 11000 (claim the name below)
  UNSPECIFIED_LOCAL_CONTEXT0 = 11000;
  UNSPECIFIED_LOCAL_CONTEXT1 = 11001;
  UNSPECIFIED_LOCAL_CONTEXT2 = 11002;
  UNSPECIFIED_LOCAL_CONTEXT3 = 11003;
  UNSPECIFIED_LOCAL_CONTEXT4 = 11004;
  UNSPECIFIED_LOCAL_CONTEXT5 = 11005;
  UNSPECIFIED_LOCAL_CONTEXT6 = 11006;
  UNSPECIFIED_LOCAL_CONTEXT7 = 11007;
  UNSPECIFIED_LOCAL_CONTEXT8 = 11008;
  UNSPECIFIED_LOCAL_CONTEXT9 = 11009;

  //---------------------------------------------------------------------------
  // This block is reserved by Context Manager for generic remote
  // contexts, that are produced on-demand via CMFE. The
  // UNSPECIFIED_BACKEND_CONTEXTx tags are left in as placeholders so proto
  // parsing does not eliminate them. Each tag should be renamed appropriately
  // once claimed.
  //---------------------------------------------------------------------------

  // Marker for start of the block; default length is 100, expandable to 1000
  BACKEND_PRODUCED_BLOCK_START_MARKER = 11999;

  // Next Backend-produce Context Id: 12000 (claim the name below)
  UNSPECIFIED_BACKEND_CONTEXT0 = 12000;
  UNSPECIFIED_BACKEND_CONTEXT1 = 12001;
  UNSPECIFIED_BACKEND_CONTEXT2 = 12002;
  UNSPECIFIED_BACKEND_CONTEXT3 = 12003;
  UNSPECIFIED_BACKEND_CONTEXT4 = 12004;
  UNSPECIFIED_BACKEND_CONTEXT5 = 12005;
  UNSPECIFIED_BACKEND_CONTEXT6 = 12006;
  UNSPECIFIED_BACKEND_CONTEXT7 = 12007;
  UNSPECIFIED_BACKEND_CONTEXT8 = 12008;
  UNSPECIFIED_BACKEND_CONTEXT9 = 12009;

  //---------------------------------------------------------------------------
  // Context names > 100_000 are reserved for experimentation by various teams,
  // These contexts will have automatic read/write permission for everyone, but
  // should NOT be submitted!
  // Next Id: 100001
  //---------------------------------------------------------------------------

  // Dummy context, used to mark beginning of range
  DUMMY_EXPERIMENTAL_AUTO_RW_MARKER = 99999;

  DUMMY_EXPERIMENTAL_AUTO_RW_1 = 100000;
}

// Represents a context fence, which can either be an AND,
// OR, or NOT of other context fences.  Or, one of the fences for
// a particular context name.
message ContextFence {
  // WARNING!  This protocol buffer has a unique equals() method in its nano
  // implementation.  See cl/209825626 and b/112847166.  The default nano
  // equals method somehow causes pathological performance in dex2oat in
  // Lollipop devices, so bad that GMS Core can never start.  This is dependent
  // also on which member messages are in different dex files dependent on
  // which bytecode ProGuard generates.  Instead, the equals() method generated
  // for this just delegates to MessageNano.messageNanoEquals which is slower.

  enum Type {
    UNKNOWN_CONTEXT_FENCE_TYPE = 0;
    AND = 1;                        // AND expression
    OR = 2;                         // OR expression
    NOT = 3;                        // NOT expression
    TIME_FENCE = 4;                 // Time-based fence
    LOCATION_FENCE = 5;             // Location-based fence
    PLACE_FENCE = 6;                // Place-based fence
    ACTIVITY_FENCE = 7;             // Activity-based fence
    SCREEN_FENCE = 8;               // Screen-based fence
    POWER_CONNECTION_FENCE = 9;     // Power connection-based fence
    PHONE_LOCK_FENCE = 10;          // Phone lock fence
    AUDIO_STATE_FENCE = 11;         // Audio state fence
    BEACON_FENCE = 12;              // Beacon fence
    NETWORK_STATE_FENCE = 13;       // Network state fence
    WANDER_STATE_FENCE = 14;        // Wander state fence
    TIME_INTERVAL_FENCE = 15;       // Time fence specified using day attributes
    INSTALLED_APPS_FENCE = 16;      // Installed apps fence
    PHONE_CALL_FENCE = 17;          // Phone call based fence
    PROXIMITY_DISTANCE_FENCE = 18;  // Proximity distance based fence
    SUN_STATE_FENCE = 19;           // Sun-state based fence
    LOCAL_TIME_FENCE = 20;          // Local-time-based fence
    WEATHER_FENCE = 21;             // Weather-based fence
    PREDICTIVE = 22;                // Predictive fence
    SHUSH_STATE_FENCE = 23;         // Shush state fence
    WIFI_STATE_FENCE = 24;          // Wifi state fence
  }

  optional Type type = 1;

  // For AND and OR types, this is the list of ContextFence messages
  // that should be ANDed or ORed together.  For NOT type, this
  // should contain a single element.
  repeated ContextFence fence_list = 2;

  // Should be set only when type is TIME_FENCE.
  optional TimeFence time_fence = 3;

  // Should be set only when type is LOCATION_FENCE.
  optional LocationFence location_fence = 4;

  // Should be set only when type is PLACE_FENCE.
  optional PlaceFence place_fence = 5;

  // Should be set only when type is ACTIVITY_FENCE.
  optional ActivityFence activity_fence = 6;

  // Should be set only when type is SCREEN_FENCE.
  optional ScreenFence screen_fence = 7;

  // Should be set only when type is POWER_CONNECTION_FENCE.
  optional PowerConnectionFence power_connection_fence = 8;

  // Should be set only when the type is PHONE_LOCK_FENCE.
  optional PhoneLockFence phone_lock_fence = 9;

  // Should be set only when the type if AUDIO_STATE_FENCE.
  optional AudioStateFence audio_state_fence = 10;

  // Should be set only when the type is BEACON_FENCE.
  optional BeaconFence beacon_fence = 11;

  // Should be set only when the type is NETWORK_STATE_FENCE.
  optional NetworkStateFence network_state_fence = 12;

  // Encapsulates the source that evaluates this fence.
  optional Source source = 13;

  // Should be set only when the type is WANDER_STATE_FENCE.
  optional WanderStateFence wander_state_fence = 14;

  // Should be set only when the type is TIME_INTERVAL_FENCE.
  optional TimeIntervalFence time_interval_fence = 15;

  // Should be set only when the type is INSTALLED_APPS_FENCE.
  optional InstalledAppsFence installed_apps_fence = 16;

  // Should be set only when the type is PHONE_CALL_FENCE.
  optional PhoneCallFence phone_call_fence = 17;

  // Should be set only when the type is PROXIMITY_DISTANCE_FENCE.
  optional ProximityDistanceFence proximity_distance_fence = 18;

  // Should be set only when the type is SUN_STATE_FENCE.
  optional SunStateFence sun_state_fence = 19;

  // Should be set only when type is LOCAL_TIME_FENCE.
  optional TimeFence local_time_fence = 20;

  // Should be set only when type is WEATHER_FENCE.
  optional WeatherFence weather_fence = 21;

  // Contexts to be snapshot when fence triggers.
  repeated ContextName requested_snapshot = 22;

  // Contain parameters for predictive fences,
  // null if the fence is not predictive
  optional PredictiveParameters predictive_parameters = 23;

  // Should be set only when type is SHUSH_STATE_FENCE.
  optional ShushStateFence shush_state_fence = 24;

  // Should be set only when type is WIFI_STATE_FENCE.
  optional WifiStateFence wifi_state_fence = 25;
  // Next Tag: 26
}

// Encapsulates the source metadata associated with a context fence.
// This is useful for the distributed fences, when a particular context fence
// can be remotely evaluated on a different device.
message Source {
  // TODO(b112847166): Re-migrate to lite after we understand how to avoid this
  // from getting pulled into the main dex and causing catastrophic failures.

  // [REQUIRED]
  optional string account_name = 1;
}

// Represents an expression for representing the date time.
message DateTime {
  // TODO(b112847166): Re-migrate to lite after we understand how to avoid this
  // from getting pulled into the main dex and causing catastrophic failures.

  // Represents the year for the date time.
  // For example: 2015
  optional int32 year = 1;

  // Represents the month for the date time with values ranging
  // from 0 to 11. Example, January is represented as 0 and December
  // as 11.
  optional int32 month = 2;

  // Represents the day of the month
  // The first day of the month has a value of 1.
  // Example January 1 will have day as 1, January 2 will
  // have day as 2 respectively.
  optional int32 day = 3;

  // Represents the hour of the day as a 24 hour clock.
  // Range of valid values is 0 - 23, example for 10:04:15 PM
  // the HOUR_OF_DAY is 22
  optional int32 hour = 4;

  // Represents the minute with in the hour.
  // Range of valid values is 0 - 59, example at 10:04:15 PM
  // the MINUTE is 4
  optional int32 minutes = 5;

  // Represents the seconds with in the minute.
  // Range of valid values is 0 - 59, example at 10:04:15 PM
  // the SECOND is 15
  optional int32 seconds = 6;
}

message PredictiveParameters {
  // Minimum confidence level for a predictive fence to be triggered.
  optional int32 prediction_confidence_level = 1;

  // Time duration within which prediction will be considered.
  optional int64 prediction_time_millis = 2;
  // Next Tag: 25
}