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 android.companion.datatransfer; 18 19 import android.annotation.NonNull; 20 import android.annotation.UserIdInt; 21 import android.os.Parcel; 22 23 /** 24 * A request for users to allow the companion app to transfer system data to the companion devices. 25 * 26 * @hide 27 */ 28 public abstract class SystemDataTransferRequest { 29 30 /** @hide */ 31 public static final int DATA_TYPE_PERMISSION_SYNC = 1; 32 33 final int mAssociationId; 34 35 final int mDataType; 36 37 /** 38 * User id that the request belongs to. 39 * Populated by the system. 40 */ 41 @UserIdInt 42 int mUserId; 43 44 /** 45 * Whether the request is consented by the user. 46 * Populated by the system 47 */ 48 boolean mUserConsented = false; 49 50 /** @hide */ SystemDataTransferRequest(int associationId, int dataType)51 SystemDataTransferRequest(int associationId, int dataType) { 52 mAssociationId = associationId; 53 mDataType = dataType; 54 } 55 56 /** @hide */ getAssociationId()57 public int getAssociationId() { 58 return mAssociationId; 59 } 60 61 /** @hide */ getDataType()62 public int getDataType() { 63 return mDataType; 64 } 65 66 /** @hide */ getUserId()67 public int getUserId() { 68 return mUserId; 69 } 70 71 /** @hide */ isUserConsented()72 public boolean isUserConsented() { 73 return mUserConsented; 74 } 75 76 /** @hide */ setUserId(@serIdInt int userId)77 public void setUserId(@UserIdInt int userId) { 78 mUserId = userId; 79 } 80 81 /** @hide */ setUserConsented(boolean isUserConsented)82 public void setUserConsented(boolean isUserConsented) { 83 mUserConsented = isUserConsented; 84 } 85 86 /** @hide */ SystemDataTransferRequest(Parcel in)87 SystemDataTransferRequest(Parcel in) { 88 mAssociationId = in.readInt(); 89 mDataType = in.readInt(); 90 mUserId = in.readInt(); 91 mUserConsented = in.readBoolean(); 92 } 93 94 /** @hide */ writeToParcel(@onNull Parcel dest, int flags)95 public void writeToParcel(@NonNull Parcel dest, int flags) { 96 dest.writeInt(mAssociationId); 97 dest.writeInt(mDataType); 98 dest.writeInt(mUserId); 99 dest.writeBoolean(mUserConsented); 100 } 101 102 /** @hide */ describeContents()103 public int describeContents() { 104 return 0; 105 } 106 } 107