• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 
17 package com.android.internal.telephony.metrics;
18 
19 import com.android.internal.telephony.PhoneFactory;
20 import com.android.internal.telephony.nano.PersistAtomsProto.SatelliteController;
21 import com.android.internal.telephony.nano.PersistAtomsProto.SatelliteIncomingDatagram;
22 import com.android.internal.telephony.nano.PersistAtomsProto.SatelliteOutgoingDatagram;
23 import com.android.internal.telephony.nano.PersistAtomsProto.SatelliteProvision;
24 import com.android.internal.telephony.nano.PersistAtomsProto.SatelliteSession;
25 import com.android.internal.telephony.nano.PersistAtomsProto.SatelliteSosMessageRecommender;
26 import com.android.telephony.Rlog;
27 
28 /** Tracks Satellite metrics for each phone */
29 public class SatelliteStats {
30     private static final String TAG = SatelliteStats.class.getSimpleName();
31 
32     private final PersistAtomsStorage mAtomsStorage =
33             PhoneFactory.getMetricsCollector().getAtomsStorage();
34 
35     private static SatelliteStats sInstance = null;
36 
37     /** Gets the instance of SatelliteStats */
getInstance()38     public static SatelliteStats getInstance() {
39         if (sInstance == null) {
40             Rlog.d(TAG, "SatelliteStats created.");
41             synchronized (SatelliteStats.class) {
42                 sInstance = new SatelliteStats();
43             }
44         }
45         return sInstance;
46     }
47 
48     /**
49      * A data class to contain whole component of {@link SatelliteController) atom.
50      * Refer to {@link #onSatelliteControllerMetrics(SatelliteControllerParams)}.
51      */
52     public class SatelliteControllerParams {
53         private final int mCountOfSatelliteServiceEnablementsSuccess;
54         private final int mCountOfSatelliteServiceEnablementsFail;
55         private final int mCountOfOutgoingDatagramSuccess;
56         private final int mCountOfOutgoingDatagramFail;
57         private final int mCountOfIncomingDatagramSuccess;
58         private final int mCountOfIncomingDatagramFail;
59         private final int mCountOfDatagramTypeSosSmsSuccess;
60         private final int mCountOfDatagramTypeSosSmsFail;
61         private final int mCountOfDatagramTypeLocationSharingSuccess;
62         private final int mCountOfDatagramTypeLocationSharingFail;
63         private final int mCountOfProvisionSuccess;
64         private final int mCountOfProvisionFail;
65         private final int mCountOfDeprovisionSuccess;
66         private final int mCountOfDeprovisionFail;
67         private final int mTotalServiceUptimeSec;
68         private final int mTotalBatteryConsumptionPercent;
69         private final int mTotalBatteryChargedTimeSec;
70 
SatelliteControllerParams(Builder builder)71         private SatelliteControllerParams(Builder builder) {
72             this.mCountOfSatelliteServiceEnablementsSuccess =
73                     builder.mCountOfSatelliteServiceEnablementsSuccess;
74             this.mCountOfSatelliteServiceEnablementsFail =
75                     builder.mCountOfSatelliteServiceEnablementsFail;
76             this.mCountOfOutgoingDatagramSuccess = builder.mCountOfOutgoingDatagramSuccess;
77             this.mCountOfOutgoingDatagramFail = builder.mCountOfOutgoingDatagramFail;
78             this.mCountOfIncomingDatagramSuccess = builder.mCountOfIncomingDatagramSuccess;
79             this.mCountOfIncomingDatagramFail = builder.mCountOfIncomingDatagramFail;
80             this.mCountOfDatagramTypeSosSmsSuccess = builder.mCountOfDatagramTypeSosSmsSuccess;
81             this.mCountOfDatagramTypeSosSmsFail = builder.mCountOfDatagramTypeSosSmsFail;
82             this.mCountOfDatagramTypeLocationSharingSuccess =
83                     builder.mCountOfDatagramTypeLocationSharingSuccess;
84             this.mCountOfDatagramTypeLocationSharingFail =
85                     builder.mCountOfDatagramTypeLocationSharingFail;
86             this.mCountOfProvisionSuccess = builder.mCountOfProvisionSuccess;
87             this.mCountOfProvisionFail = builder.mCountOfProvisionFail;
88             this.mCountOfDeprovisionSuccess = builder.mCountOfDeprovisionSuccess;
89             this.mCountOfDeprovisionFail = builder.mCountOfDeprovisionFail;
90             this.mTotalServiceUptimeSec = builder.mTotalServiceUptimeSec;
91             this.mTotalBatteryConsumptionPercent = builder.mTotalBatteryConsumptionPercent;
92             this.mTotalBatteryChargedTimeSec = builder.mTotalBatteryChargedTimeSec;
93         }
94 
getCountOfSatelliteServiceEnablementsSuccess()95         public int getCountOfSatelliteServiceEnablementsSuccess() {
96             return mCountOfSatelliteServiceEnablementsSuccess;
97         }
98 
getCountOfSatelliteServiceEnablementsFail()99         public int getCountOfSatelliteServiceEnablementsFail() {
100             return mCountOfSatelliteServiceEnablementsFail;
101         }
102 
getCountOfOutgoingDatagramSuccess()103         public int getCountOfOutgoingDatagramSuccess() {
104             return mCountOfOutgoingDatagramSuccess;
105         }
106 
getCountOfOutgoingDatagramFail()107         public int getCountOfOutgoingDatagramFail() {
108             return mCountOfOutgoingDatagramFail;
109         }
110 
getCountOfIncomingDatagramSuccess()111         public int getCountOfIncomingDatagramSuccess() {
112             return mCountOfIncomingDatagramSuccess;
113         }
114 
getCountOfIncomingDatagramFail()115         public int getCountOfIncomingDatagramFail() {
116             return mCountOfIncomingDatagramFail;
117         }
118 
getCountOfDatagramTypeSosSmsSuccess()119         public int getCountOfDatagramTypeSosSmsSuccess() {
120             return mCountOfDatagramTypeSosSmsSuccess;
121         }
122 
getCountOfDatagramTypeSosSmsFail()123         public int getCountOfDatagramTypeSosSmsFail() {
124             return mCountOfDatagramTypeSosSmsFail;
125         }
126 
getCountOfDatagramTypeLocationSharingSuccess()127         public int getCountOfDatagramTypeLocationSharingSuccess() {
128             return mCountOfDatagramTypeLocationSharingSuccess;
129         }
130 
getCountOfDatagramTypeLocationSharingFail()131         public int getCountOfDatagramTypeLocationSharingFail() {
132             return mCountOfDatagramTypeLocationSharingFail;
133         }
134 
getCountOfProvisionSuccess()135         public int getCountOfProvisionSuccess() {
136             return mCountOfProvisionSuccess;
137         }
138 
getCountOfProvisionFail()139         public int getCountOfProvisionFail() {
140             return mCountOfProvisionFail;
141         }
142 
getCountOfDeprovisionSuccess()143         public int getCountOfDeprovisionSuccess() {
144             return mCountOfDeprovisionSuccess;
145         }
146 
getCountOfDeprovisionFail()147         public int getCountOfDeprovisionFail() {
148             return mCountOfDeprovisionFail;
149         }
150 
getTotalServiceUptimeSec()151         public int getTotalServiceUptimeSec() {
152             return mTotalServiceUptimeSec;
153         }
154 
getTotalBatteryConsumptionPercent()155         public int getTotalBatteryConsumptionPercent() {
156             return mTotalBatteryConsumptionPercent;
157         }
158 
getTotalBatteryChargedTimeSec()159         public int getTotalBatteryChargedTimeSec() {
160             return mTotalBatteryChargedTimeSec;
161         }
162 
163         /**
164          * A builder class to create {@link SatelliteControllerParams} data structure class
165          */
166         public static class Builder {
167             private int mCountOfSatelliteServiceEnablementsSuccess = 0;
168             private int mCountOfSatelliteServiceEnablementsFail = 0;
169             private int mCountOfOutgoingDatagramSuccess = 0;
170             private int mCountOfOutgoingDatagramFail = 0;
171             private int mCountOfIncomingDatagramSuccess = 0;
172             private int mCountOfIncomingDatagramFail = 0;
173             private int mCountOfDatagramTypeSosSmsSuccess = 0;
174             private int mCountOfDatagramTypeSosSmsFail = 0;
175             private int mCountOfDatagramTypeLocationSharingSuccess = 0;
176             private int mCountOfDatagramTypeLocationSharingFail = 0;
177             private int mCountOfProvisionSuccess;
178             private int mCountOfProvisionFail;
179             private int mCountOfDeprovisionSuccess;
180             private int mCountOfDeprovisionFail;
181             private int mTotalServiceUptimeSec = 0;
182             private int mTotalBatteryConsumptionPercent = 0;
183             private int mTotalBatteryChargedTimeSec = 0;
184 
185             /**
186              * Sets countOfSatelliteServiceEnablementsSuccess value of {@link SatelliteController}
187              * atom then returns Builder class
188              */
setCountOfSatelliteServiceEnablementsSuccess( int countOfSatelliteServiceEnablementsSuccess)189             public Builder setCountOfSatelliteServiceEnablementsSuccess(
190                     int countOfSatelliteServiceEnablementsSuccess) {
191                 this.mCountOfSatelliteServiceEnablementsSuccess =
192                         countOfSatelliteServiceEnablementsSuccess;
193                 return this;
194             }
195 
196             /**
197              * Sets countOfSatelliteServiceEnablementsFail value of {@link SatelliteController} atom
198              * then returns Builder class
199              */
setCountOfSatelliteServiceEnablementsFail( int countOfSatelliteServiceEnablementsFail)200             public Builder setCountOfSatelliteServiceEnablementsFail(
201                     int countOfSatelliteServiceEnablementsFail) {
202                 this.mCountOfSatelliteServiceEnablementsFail =
203                         countOfSatelliteServiceEnablementsFail;
204                 return this;
205             }
206 
207             /**
208              * Sets countOfOutgoingDatagramSuccess value of {@link SatelliteController} atom then
209              * returns Builder class
210              */
setCountOfOutgoingDatagramSuccess(int countOfOutgoingDatagramSuccess)211             public Builder setCountOfOutgoingDatagramSuccess(int countOfOutgoingDatagramSuccess) {
212                 this.mCountOfOutgoingDatagramSuccess = countOfOutgoingDatagramSuccess;
213                 return this;
214             }
215 
216             /**
217              * Sets countOfOutgoingDatagramFail value of {@link SatelliteController} atom then
218              * returns Builder class
219              */
setCountOfOutgoingDatagramFail(int countOfOutgoingDatagramFail)220             public Builder setCountOfOutgoingDatagramFail(int countOfOutgoingDatagramFail) {
221                 this.mCountOfOutgoingDatagramFail = countOfOutgoingDatagramFail;
222                 return this;
223             }
224 
225             /**
226              * Sets countOfIncomingDatagramSuccess value of {@link SatelliteController} atom then
227              * returns Builder class
228              */
setCountOfIncomingDatagramSuccess(int countOfIncomingDatagramSuccess)229             public Builder setCountOfIncomingDatagramSuccess(int countOfIncomingDatagramSuccess) {
230                 this.mCountOfIncomingDatagramSuccess = countOfIncomingDatagramSuccess;
231                 return this;
232             }
233 
234             /**
235              * Sets countOfIncomingDatagramFail value of {@link SatelliteController} atom then
236              * returns Builder class
237              */
setCountOfIncomingDatagramFail(int countOfIncomingDatagramFail)238             public Builder setCountOfIncomingDatagramFail(int countOfIncomingDatagramFail) {
239                 this.mCountOfIncomingDatagramFail = countOfIncomingDatagramFail;
240                 return this;
241             }
242 
243             /**
244              * Sets countOfDatagramTypeSosSmsSuccess value of {@link SatelliteController} atom then
245              * returns Builder class
246              */
setCountOfDatagramTypeSosSmsSuccess( int countOfDatagramTypeSosSmsSuccess)247             public Builder setCountOfDatagramTypeSosSmsSuccess(
248                     int countOfDatagramTypeSosSmsSuccess) {
249                 this.mCountOfDatagramTypeSosSmsSuccess = countOfDatagramTypeSosSmsSuccess;
250                 return this;
251             }
252 
253             /**
254              * Sets countOfDatagramTypeSosSmsFail value of {@link SatelliteController} atom then
255              * returns Builder class
256              */
setCountOfDatagramTypeSosSmsFail(int countOfDatagramTypeSosSmsFail)257             public Builder setCountOfDatagramTypeSosSmsFail(int countOfDatagramTypeSosSmsFail) {
258                 this.mCountOfDatagramTypeSosSmsFail = countOfDatagramTypeSosSmsFail;
259                 return this;
260             }
261 
262             /**
263              * Sets countOfDatagramTypeLocationSharingSuccess value of {@link SatelliteController}
264              * atom then returns Builder class
265              */
setCountOfDatagramTypeLocationSharingSuccess( int countOfDatagramTypeLocationSharingSuccess)266             public Builder setCountOfDatagramTypeLocationSharingSuccess(
267                     int countOfDatagramTypeLocationSharingSuccess) {
268                 this.mCountOfDatagramTypeLocationSharingSuccess =
269                         countOfDatagramTypeLocationSharingSuccess;
270                 return this;
271             }
272 
273             /**
274              * Sets countOfDatagramTypeLocationSharingFail value of {@link SatelliteController}
275              * atom then returns Builder class
276              */
setCountOfDatagramTypeLocationSharingFail( int countOfDatagramTypeLocationSharingFail)277             public Builder setCountOfDatagramTypeLocationSharingFail(
278                     int countOfDatagramTypeLocationSharingFail) {
279                 this.mCountOfDatagramTypeLocationSharingFail =
280                         countOfDatagramTypeLocationSharingFail;
281                 return this;
282             }
283 
284             /**
285              * Sets countOfProvisionSuccess value of {@link SatelliteController}
286              * atom then returns Builder class
287              */
setCountOfProvisionSuccess(int countOfProvisionSuccess)288             public Builder setCountOfProvisionSuccess(int countOfProvisionSuccess) {
289                 this.mCountOfProvisionSuccess = countOfProvisionSuccess;
290                 return this;
291             }
292 
293             /**
294              * Sets countOfProvisionFail value of {@link SatelliteController}
295              * atom then returns Builder class
296              */
setCountOfProvisionFail(int countOfProvisionFail)297             public Builder setCountOfProvisionFail(int countOfProvisionFail) {
298                 this.mCountOfProvisionFail = countOfProvisionFail;
299                 return this;
300             }
301 
302             /**
303              * Sets countOfDeprovisionSuccess value of {@link SatelliteController}
304              * atom then returns Builder class
305              */
setCountOfDeprovisionSuccess(int countOfDeprovisionSuccess)306             public Builder setCountOfDeprovisionSuccess(int countOfDeprovisionSuccess) {
307                 this.mCountOfDeprovisionSuccess = countOfDeprovisionSuccess;
308                 return this;
309             }
310 
311             /**
312              * Sets countOfDeprovisionSuccess value of {@link SatelliteController}
313              * atom then returns Builder class
314              */
setCountOfDeprovisionFail(int countOfDeprovisionFail)315             public Builder setCountOfDeprovisionFail(int countOfDeprovisionFail) {
316                 this.mCountOfDeprovisionFail = countOfDeprovisionFail;
317                 return this;
318             }
319 
320             /**
321              * Sets totalServiceUptimeSec value of {@link SatelliteController} atom then
322              * returns Builder class
323              */
setTotalServiceUptimeSec(int totalServiceUptimeSec)324             public Builder setTotalServiceUptimeSec(int totalServiceUptimeSec) {
325                 this.mTotalServiceUptimeSec = totalServiceUptimeSec;
326                 return this;
327             }
328 
329             /**
330              * Sets totalBatteryConsumptionPercent value of {@link SatelliteController} atom then
331              * returns Builder class
332              */
setTotalBatteryConsumptionPercent(int totalBatteryConsumptionPercent)333             public Builder setTotalBatteryConsumptionPercent(int totalBatteryConsumptionPercent) {
334                 this.mTotalBatteryConsumptionPercent = totalBatteryConsumptionPercent;
335                 return this;
336             }
337 
338             /**
339              * Sets totalBatteryChargedTimeSec value of {@link SatelliteController} atom then
340              * returns Builder class
341              */
setTotalBatteryChargedTimeSec(int totalBatteryChargedTimeSec)342             public Builder setTotalBatteryChargedTimeSec(int totalBatteryChargedTimeSec) {
343                 this.mTotalBatteryChargedTimeSec = totalBatteryChargedTimeSec;
344                 return this;
345             }
346 
347             /**
348              * Returns ControllerParams, which contains whole component of
349              * {@link SatelliteController} atom
350              */
build()351             public SatelliteControllerParams build() {
352                 return new SatelliteStats()
353                         .new SatelliteControllerParams(this);
354             }
355         }
356 
357         @Override
toString()358         public String toString() {
359             return "ControllerParams("
360                     + ", countOfSatelliteServiceEnablementsSuccess="
361                     + mCountOfSatelliteServiceEnablementsSuccess
362                     + ", countOfSatelliteServiceEnablementsFail="
363                     + mCountOfSatelliteServiceEnablementsFail
364                     + ", countOfOutgoingDatagramSuccess=" + mCountOfOutgoingDatagramSuccess
365                     + ", countOfOutgoingDatagramFail=" + mCountOfOutgoingDatagramFail
366                     + ", countOfIncomingDatagramSuccess=" + mCountOfIncomingDatagramSuccess
367                     + ", countOfIncomingDatagramFail=" + mCountOfIncomingDatagramFail
368                     + ", countOfDatagramTypeSosSms=" + mCountOfDatagramTypeSosSmsSuccess
369                     + ", countOfDatagramTypeSosSms=" + mCountOfDatagramTypeSosSmsFail
370                     + ", countOfDatagramTypeLocationSharing="
371                     + mCountOfDatagramTypeLocationSharingSuccess
372                     + ", countOfDatagramTypeLocationSharing="
373                     + mCountOfDatagramTypeLocationSharingFail
374                     + ", serviceUptimeSec=" + mTotalServiceUptimeSec
375                     + ", batteryConsumptionPercent=" + mTotalBatteryConsumptionPercent
376                     + ", batteryChargedTimeSec=" + mTotalBatteryChargedTimeSec
377                     + ")";
378         }
379     }
380 
381     /**
382      * A data class to contain whole component of {@link SatelliteSession) atom.
383      * Refer to {@link #onSatelliteSessionMetrics(SatelliteSessionParams)}.
384      */
385     public class SatelliteSessionParams {
386         private final int mSatelliteServiceInitializationResult;
387         private final int mSatelliteTechnology;
388 
SatelliteSessionParams(Builder builder)389         private SatelliteSessionParams(Builder builder) {
390             this.mSatelliteServiceInitializationResult =
391                     builder.mSatelliteServiceInitializationResult;
392             this.mSatelliteTechnology = builder.mSatelliteTechnology;
393         }
394 
getSatelliteServiceInitializationResult()395         public int getSatelliteServiceInitializationResult() {
396             return mSatelliteServiceInitializationResult;
397         }
398 
getSatelliteTechnology()399         public int getSatelliteTechnology() {
400             return mSatelliteTechnology;
401         }
402 
403         /**
404          * A builder class to create {@link SatelliteSessionParams} data structure class
405          */
406         public static class Builder {
407             private int mSatelliteServiceInitializationResult = -1;
408             private int mSatelliteTechnology = -1;
409 
410             /**
411              * Sets satelliteServiceInitializationResult value of {@link SatelliteSession}
412              * atom then returns Builder class
413              */
setSatelliteServiceInitializationResult( int satelliteServiceInitializationResult)414             public Builder setSatelliteServiceInitializationResult(
415                     int satelliteServiceInitializationResult) {
416                 this.mSatelliteServiceInitializationResult = satelliteServiceInitializationResult;
417                 return this;
418             }
419 
420             /**
421              * Sets satelliteTechnology value of {@link SatelliteSession} atoms then
422              * returns Builder class
423              */
setSatelliteTechnology(int satelliteTechnology)424             public Builder setSatelliteTechnology(int satelliteTechnology) {
425                 this.mSatelliteTechnology = satelliteTechnology;
426                 return this;
427             }
428 
429             /**
430              * Returns SessionParams, which contains whole component of
431              * {@link SatelliteSession} atom
432              */
build()433             public SatelliteSessionParams build() {
434                 return new SatelliteStats()
435                         .new SatelliteSessionParams(this);
436             }
437         }
438 
439         @Override
toString()440         public String toString() {
441             return "SessionParams("
442                     + ", satelliteServiceInitializationResult="
443                     + mSatelliteServiceInitializationResult
444                     + ", satelliteTechnology=" + mSatelliteTechnology
445                     + ")";
446         }
447     }
448 
449     /**
450      * A data class to contain whole component of {@link SatelliteIncomingDatagram} atom.
451      * Refer to {@link #onSatelliteIncomingDatagramMetrics(SatelliteIncomingDatagramParams)}.
452      */
453     public class SatelliteIncomingDatagramParams {
454         private final int mResultCode;
455         private final int mDatagramSizeBytes;
456         private final long mDatagramTransferTimeMillis;
457 
SatelliteIncomingDatagramParams(Builder builder)458         private SatelliteIncomingDatagramParams(Builder builder) {
459             this.mResultCode = builder.mResultCode;
460             this.mDatagramSizeBytes = builder.mDatagramSizeBytes;
461             this.mDatagramTransferTimeMillis = builder.mDatagramTransferTimeMillis;
462         }
463 
getResultCode()464         public int getResultCode() {
465             return mResultCode;
466         }
467 
getDatagramSizeBytes()468         public int getDatagramSizeBytes() {
469             return mDatagramSizeBytes;
470         }
471 
getDatagramTransferTimeMillis()472         public long getDatagramTransferTimeMillis() {
473             return mDatagramTransferTimeMillis;
474         }
475 
476         /**
477          * A builder class to create {@link SatelliteIncomingDatagramParams} data structure class
478          */
479         public static class Builder {
480             private int mResultCode = -1;
481             private int mDatagramSizeBytes = -1;
482             private long mDatagramTransferTimeMillis = -1;
483 
484             /**
485              * Sets resultCode value of {@link SatelliteIncomingDatagram} atom
486              * then returns Builder class
487              */
setResultCode(int resultCode)488             public Builder setResultCode(int resultCode) {
489                 this.mResultCode = resultCode;
490                 return this;
491             }
492 
493             /**
494              * Sets datagramSizeBytes value of {@link SatelliteIncomingDatagram} atom
495              * then returns Builder class
496              */
setDatagramSizeBytes(int datagramSizeBytes)497             public Builder setDatagramSizeBytes(int datagramSizeBytes) {
498                 this.mDatagramSizeBytes = datagramSizeBytes;
499                 return this;
500             }
501 
502             /**
503              * Sets datagramTransferTimeMillis value of {@link SatelliteIncomingDatagram} atom
504              * then returns Builder class
505              */
setDatagramTransferTimeMillis(long datagramTransferTimeMillis)506             public Builder setDatagramTransferTimeMillis(long datagramTransferTimeMillis) {
507                 this.mDatagramTransferTimeMillis = datagramTransferTimeMillis;
508                 return this;
509             }
510 
511             /**
512              * Returns IncomingDatagramParams, which contains whole component of
513              * {@link SatelliteIncomingDatagram} atom
514              */
build()515             public SatelliteIncomingDatagramParams build() {
516                 return new SatelliteStats()
517                         .new SatelliteIncomingDatagramParams(Builder.this);
518             }
519         }
520 
521         @Override
toString()522         public String toString() {
523             return "IncomingDatagramParams("
524                     + ", resultCode=" + mResultCode
525                     + ", datagramSizeBytes=" + mDatagramSizeBytes
526                     + ", datagramTransferTimeMillis=" + mDatagramTransferTimeMillis + ")";
527         }
528     }
529 
530     /**
531      * A data class to contain whole component of {@link SatelliteOutgoingDatagram} atom.
532      * Refer to {@link #onSatelliteOutgoingDatagramMetrics(SatelliteOutgoingDatagramParams)}.
533      */
534     public class SatelliteOutgoingDatagramParams {
535         private final int mDatagramType;
536         private final int mResultCode;
537         private final int mDatagramSizeBytes;
538         private final long mDatagramTransferTimeMillis;
539 
SatelliteOutgoingDatagramParams(Builder builder)540         private SatelliteOutgoingDatagramParams(Builder builder) {
541             this.mDatagramType = builder.mDatagramType;
542             this.mResultCode = builder.mResultCode;
543             this.mDatagramSizeBytes = builder.mDatagramSizeBytes;
544             this.mDatagramTransferTimeMillis = builder.mDatagramTransferTimeMillis;
545         }
546 
getDatagramType()547         public int getDatagramType() {
548             return mDatagramType;
549         }
550 
getResultCode()551         public int getResultCode() {
552             return mResultCode;
553         }
554 
getDatagramSizeBytes()555         public int getDatagramSizeBytes() {
556             return mDatagramSizeBytes;
557         }
558 
getDatagramTransferTimeMillis()559         public long getDatagramTransferTimeMillis() {
560             return mDatagramTransferTimeMillis;
561         }
562 
563         /**
564          * A builder class to create {@link SatelliteOutgoingDatagramParams} data structure class
565          */
566         public static class Builder {
567             private int mDatagramType = -1;
568             private int mResultCode = -1;
569             private int mDatagramSizeBytes = -1;
570             private long mDatagramTransferTimeMillis = -1;
571 
572             /**
573              * Sets datagramType value of {@link SatelliteOutgoingDatagram} atom
574              * then returns Builder class
575              */
setDatagramType(int datagramType)576             public Builder setDatagramType(int datagramType) {
577                 this.mDatagramType = datagramType;
578                 return this;
579             }
580 
581             /**
582              * Sets resultCode value of {@link SatelliteOutgoingDatagram} atom
583              * then returns Builder class
584              */
setResultCode(int resultCode)585             public Builder setResultCode(int resultCode) {
586                 this.mResultCode = resultCode;
587                 return this;
588             }
589 
590             /**
591              * Sets datagramSizeBytes value of {@link SatelliteOutgoingDatagram} atom
592              * then returns Builder class
593              */
setDatagramSizeBytes(int datagramSizeBytes)594             public Builder setDatagramSizeBytes(int datagramSizeBytes) {
595                 this.mDatagramSizeBytes = datagramSizeBytes;
596                 return this;
597             }
598 
599             /**
600              * Sets datagramTransferTimeMillis value of {@link SatelliteOutgoingDatagram} atom
601              * then returns Builder class
602              */
setDatagramTransferTimeMillis(long datagramTransferTimeMillis)603             public Builder setDatagramTransferTimeMillis(long datagramTransferTimeMillis) {
604                 this.mDatagramTransferTimeMillis = datagramTransferTimeMillis;
605                 return this;
606             }
607 
608             /**
609              * Returns OutgoingDatagramParams, which contains whole component of
610              * {@link SatelliteOutgoingDatagram} atom
611              */
build()612             public SatelliteOutgoingDatagramParams build() {
613                 return new SatelliteStats()
614                         .new SatelliteOutgoingDatagramParams(Builder.this);
615             }
616         }
617 
618         @Override
toString()619         public String toString() {
620             return "OutgoingDatagramParams("
621                     + "datagramType=" + mDatagramType
622                     + ", resultCode=" + mResultCode
623                     + ", datagramSizeBytes=" + mDatagramSizeBytes
624                     + ", datagramTransferTimeMillis=" + mDatagramTransferTimeMillis + ")";
625         }
626     }
627 
628     /**
629      * A data class to contain whole component of {@link SatelliteProvision} atom.
630      * Refer to {@link #onSatelliteProvisionMetrics(SatelliteProvisionParams)}.
631      */
632     public class SatelliteProvisionParams {
633         private final int mResultCode;
634         private final int mProvisioningTimeSec;
635         private final boolean mIsProvisionRequest;
636         private final boolean mIsCanceled;
637 
SatelliteProvisionParams(Builder builder)638         private SatelliteProvisionParams(Builder builder) {
639             this.mResultCode = builder.mResultCode;
640             this.mProvisioningTimeSec = builder.mProvisioningTimeSec;
641             this.mIsProvisionRequest = builder.mIsProvisionRequest;
642             this.mIsCanceled = builder.mIsCanceled;
643         }
644 
getResultCode()645         public int getResultCode() {
646             return mResultCode;
647         }
648 
getProvisioningTimeSec()649         public int getProvisioningTimeSec() {
650             return mProvisioningTimeSec;
651         }
652 
getIsProvisionRequest()653         public boolean getIsProvisionRequest() {
654             return mIsProvisionRequest;
655         }
656 
getIsCanceled()657         public boolean getIsCanceled() {
658             return mIsCanceled;
659         }
660 
661         /**
662          * A builder class to create {@link SatelliteProvisionParams} data structure class
663          */
664         public static class Builder {
665             private int mResultCode = -1;
666             private int mProvisioningTimeSec = -1;
667             private boolean mIsProvisionRequest = false;
668             private boolean mIsCanceled = false;
669 
670             /**
671              * Sets resultCode value of {@link SatelliteProvision} atom
672              * then returns Builder class
673              */
setResultCode(int resultCode)674             public Builder setResultCode(int resultCode) {
675                 this.mResultCode = resultCode;
676                 return this;
677             }
678 
679             /**
680              * Sets provisioningTimeSec value of {@link SatelliteProvision} atom
681              * then returns Builder class
682              */
setProvisioningTimeSec(int provisioningTimeSec)683             public Builder setProvisioningTimeSec(int provisioningTimeSec) {
684                 this.mProvisioningTimeSec = provisioningTimeSec;
685                 return this;
686             }
687 
688             /**
689              * Sets isProvisionRequest value of {@link SatelliteProvision} atom
690              * then returns Builder class
691              */
setIsProvisionRequest(boolean isProvisionRequest)692             public Builder setIsProvisionRequest(boolean isProvisionRequest) {
693                 this.mIsProvisionRequest = isProvisionRequest;
694                 return this;
695             }
696 
697             /**
698              * Sets isCanceled value of {@link SatelliteProvision} atom
699              * then returns Builder class
700              */
setIsCanceled(boolean isCanceled)701             public Builder setIsCanceled(boolean isCanceled) {
702                 this.mIsCanceled = isCanceled;
703                 return this;
704             }
705 
706             /**
707              * Returns ProvisionParams, which contains whole component of
708              * {@link SatelliteProvision} atom
709              */
build()710             public SatelliteProvisionParams build() {
711                 return new SatelliteStats()
712                         .new SatelliteProvisionParams(Builder.this);
713             }
714         }
715 
716         @Override
toString()717         public String toString() {
718             return "ProvisionParams("
719                     + "resultCode=" + mResultCode
720                     + ", provisioningTimeSec=" + mProvisioningTimeSec
721                     + ", isProvisionRequest=" + mIsProvisionRequest
722                     + ", isCanceled" + mIsCanceled + ")";
723         }
724     }
725 
726     /**
727      * A data class to contain whole component of {@link SatelliteSosMessageRecommender} atom.
728      * Refer to {@link #onSatelliteSosMessageRecommender(SatelliteSosMessageRecommenderParams)}.
729      */
730     public class SatelliteSosMessageRecommenderParams {
731         private final boolean mIsDisplaySosMessageSent;
732         private final int mCountOfTimerStarted;
733         private final boolean mIsImsRegistered;
734         private final int mCellularServiceState;
735 
SatelliteSosMessageRecommenderParams(Builder builder)736         private SatelliteSosMessageRecommenderParams(Builder builder) {
737             this.mIsDisplaySosMessageSent = builder.mIsDisplaySosMessageSent;
738             this.mCountOfTimerStarted = builder.mCountOfTimerStarted;
739             this.mIsImsRegistered = builder.mIsImsRegistered;
740             this.mCellularServiceState = builder.mCellularServiceState;
741         }
742 
isDisplaySosMessageSent()743         public boolean isDisplaySosMessageSent() {
744             return mIsDisplaySosMessageSent;
745         }
746 
getCountOfTimerStarted()747         public int getCountOfTimerStarted() {
748             return mCountOfTimerStarted;
749         }
750 
isImsRegistered()751         public boolean isImsRegistered() {
752             return mIsImsRegistered;
753         }
754 
getCellularServiceState()755         public int getCellularServiceState() {
756             return mCellularServiceState;
757         }
758 
759         /**
760          * A builder class to create {@link SatelliteProvisionParams} data structure class
761          */
762         public static class Builder {
763             private boolean mIsDisplaySosMessageSent = false;
764             private int mCountOfTimerStarted = -1;
765             private boolean mIsImsRegistered = false;
766             private int mCellularServiceState = -1;
767 
768             /**
769              * Sets resultCode value of {@link SatelliteSosMessageRecommender} atom
770              * then returns Builder class
771              */
setDisplaySosMessageSent( boolean isDisplaySosMessageSent)772             public Builder setDisplaySosMessageSent(
773                     boolean isDisplaySosMessageSent) {
774                 this.mIsDisplaySosMessageSent = isDisplaySosMessageSent;
775                 return this;
776             }
777 
778             /**
779              * Sets countOfTimerIsStarted value of {@link SatelliteSosMessageRecommender} atom
780              * then returns Builder class
781              */
setCountOfTimerStarted(int countOfTimerStarted)782             public Builder setCountOfTimerStarted(int countOfTimerStarted) {
783                 this.mCountOfTimerStarted = countOfTimerStarted;
784                 return this;
785             }
786 
787             /**
788              * Sets isImsRegistered value of {@link SatelliteSosMessageRecommender} atom
789              * then returns Builder class
790              */
setImsRegistered(boolean isImsRegistered)791             public Builder setImsRegistered(boolean isImsRegistered) {
792                 this.mIsImsRegistered = isImsRegistered;
793                 return this;
794             }
795 
796             /**
797              * Sets cellularServiceState value of {@link SatelliteSosMessageRecommender} atom
798              * then returns Builder class
799              */
setCellularServiceState(int cellularServiceState)800             public Builder setCellularServiceState(int cellularServiceState) {
801                 this.mCellularServiceState = cellularServiceState;
802                 return this;
803             }
804 
805             /**
806              * Returns SosMessageRecommenderParams, which contains whole component of
807              * {@link SatelliteSosMessageRecommenderParams} atom
808              */
build()809             public SatelliteSosMessageRecommenderParams build() {
810                 return new SatelliteStats()
811                         .new SatelliteSosMessageRecommenderParams(Builder.this);
812             }
813         }
814 
815         @Override
toString()816         public String toString() {
817             return "SosMessageRecommenderParams("
818                     + "isDisplaySosMessageSent=" + mIsDisplaySosMessageSent
819                     + ", countOfTimerStarted=" + mCountOfTimerStarted
820                     + ", isImsRegistered=" + mIsImsRegistered
821                     + ", cellularServiceState=" + mCellularServiceState + ")";
822         }
823     }
824 
825     /**  Create a new atom or update an existing atom for SatelliteController metrics */
onSatelliteControllerMetrics(SatelliteControllerParams param)826     public synchronized void onSatelliteControllerMetrics(SatelliteControllerParams param) {
827         SatelliteController proto = new SatelliteController();
828         proto.countOfSatelliteServiceEnablementsSuccess =
829                 param.getCountOfSatelliteServiceEnablementsSuccess();
830         proto.countOfSatelliteServiceEnablementsFail =
831                 param.getCountOfSatelliteServiceEnablementsFail();
832         proto.countOfOutgoingDatagramSuccess = param.getCountOfOutgoingDatagramSuccess();
833         proto.countOfOutgoingDatagramFail = param.getCountOfOutgoingDatagramFail();
834         proto.countOfIncomingDatagramSuccess = param.getCountOfIncomingDatagramSuccess();
835         proto.countOfIncomingDatagramFail = param.getCountOfIncomingDatagramFail();
836         proto.countOfDatagramTypeSosSmsSuccess = param.getCountOfDatagramTypeSosSmsSuccess();
837         proto.countOfDatagramTypeSosSmsFail = param.getCountOfDatagramTypeSosSmsFail();
838         proto.countOfDatagramTypeLocationSharingSuccess =
839                 param.getCountOfDatagramTypeLocationSharingSuccess();
840         proto.countOfDatagramTypeLocationSharingFail =
841                 param.getCountOfDatagramTypeLocationSharingFail();
842         proto.countOfProvisionSuccess = param.getCountOfProvisionSuccess();
843         proto.countOfProvisionFail = param.getCountOfProvisionFail();
844         proto.countOfDeprovisionSuccess = param.getCountOfDeprovisionSuccess();
845         proto.countOfDeprovisionFail = param.getCountOfDeprovisionFail();
846         proto.totalServiceUptimeSec = param.getTotalServiceUptimeSec();
847         proto.totalBatteryConsumptionPercent = param.getTotalBatteryConsumptionPercent();
848         proto.totalBatteryChargedTimeSec = param.getTotalBatteryChargedTimeSec();
849 
850         mAtomsStorage.addSatelliteControllerStats(proto);
851     }
852 
853     /**  Create a new atom or update an existing atom for SatelliteSession metrics */
onSatelliteSessionMetrics(SatelliteSessionParams param)854     public synchronized void onSatelliteSessionMetrics(SatelliteSessionParams param) {
855         SatelliteSession proto = new SatelliteSession();
856         proto.satelliteServiceInitializationResult =
857                 param.getSatelliteServiceInitializationResult();
858         proto.satelliteTechnology = param.getSatelliteTechnology();
859         proto.count = 1;
860         mAtomsStorage.addSatelliteSessionStats(proto);
861     }
862 
863     /**  Create a new atom for SatelliteIncomingDatagram metrics */
onSatelliteIncomingDatagramMetrics( SatelliteIncomingDatagramParams param)864     public synchronized void onSatelliteIncomingDatagramMetrics(
865             SatelliteIncomingDatagramParams param) {
866         SatelliteIncomingDatagram proto = new SatelliteIncomingDatagram();
867         proto.resultCode = param.getResultCode();
868         proto.datagramSizeBytes = param.getDatagramSizeBytes();
869         proto.datagramTransferTimeMillis = param.getDatagramTransferTimeMillis();
870         mAtomsStorage.addSatelliteIncomingDatagramStats(proto);
871     }
872 
873     /**  Create a new atom for SatelliteOutgoingDatagram metrics */
onSatelliteOutgoingDatagramMetrics( SatelliteOutgoingDatagramParams param)874     public synchronized void onSatelliteOutgoingDatagramMetrics(
875             SatelliteOutgoingDatagramParams param) {
876         SatelliteOutgoingDatagram proto = new SatelliteOutgoingDatagram();
877         proto.datagramType = param.getDatagramType();
878         proto.resultCode = param.getResultCode();
879         proto.datagramSizeBytes = param.getDatagramSizeBytes();
880         proto.datagramTransferTimeMillis = param.getDatagramTransferTimeMillis();
881         mAtomsStorage.addSatelliteOutgoingDatagramStats(proto);
882     }
883 
884     /**  Create a new atom for SatelliteProvision metrics */
onSatelliteProvisionMetrics(SatelliteProvisionParams param)885     public synchronized void onSatelliteProvisionMetrics(SatelliteProvisionParams param) {
886         SatelliteProvision proto = new SatelliteProvision();
887         proto.resultCode = param.getResultCode();
888         proto.provisioningTimeSec = param.getProvisioningTimeSec();
889         proto.isProvisionRequest = param.getIsProvisionRequest();
890         proto.isCanceled = param.getIsCanceled();
891         mAtomsStorage.addSatelliteProvisionStats(proto);
892     }
893 
894     /**  Create a new atom or update an existing atom for SatelliteSosMessageRecommender metrics */
onSatelliteSosMessageRecommender( SatelliteSosMessageRecommenderParams param)895     public synchronized void onSatelliteSosMessageRecommender(
896             SatelliteSosMessageRecommenderParams param) {
897         SatelliteSosMessageRecommender proto = new SatelliteSosMessageRecommender();
898         proto.isDisplaySosMessageSent = param.isDisplaySosMessageSent();
899         proto.countOfTimerStarted = param.getCountOfTimerStarted();
900         proto.isImsRegistered = param.isImsRegistered();
901         proto.cellularServiceState = param.getCellularServiceState();
902         proto.count = 1;
903         mAtomsStorage.addSatelliteSosMessageRecommenderStats(proto);
904     }
905 }
906