1 /*
2  * Copyright (C) 2022 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.ondevicepersonalization.services.data.user;
18 
19 import android.adservices.ondevicepersonalization.UserData;
20 import android.content.res.Configuration;
21 import android.net.NetworkCapabilities;
22 
23 import java.util.HashSet;
24 import java.util.Set;
25 
26 /** A singleton class that holds all most recent in-memory user signals. */
27 public final class RawUserData {
28 
29     private static RawUserData sUserData = null;
30 
31     // The device time zone +/- offset in minute from UTC.
32     public int utcOffset = 0;
33 
34     // The device orientation.
35     public int orientation = Configuration.ORIENTATION_PORTRAIT;
36 
37     // Available storage in bytes.
38     public long availableStorageBytes = 0;
39 
40     // Battery percentage.
41     public int batteryPercentage = 0;
42 
43     // Mobile carrier.
44     public Carrier carrier = Carrier.UNKNOWN;
45 
46     public NetworkCapabilities networkCapabilities;
47 
48     @UserData.NetworkType public int dataNetworkType;
49 
50     // The list of installed package names in last 30 days.
51     public Set<String> installedApps = new HashSet<>();
52 
RawUserData()53     private RawUserData() {}
54 
55     /** Returns an instance of UserData. */
getInstance()56     public static RawUserData getInstance() {
57         synchronized (RawUserData.class) {
58             if (sUserData == null) {
59                 sUserData = new RawUserData();
60             }
61             return sUserData;
62         }
63     }
64 }
65