1 /* 2 * Copyright (C) 2015 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 package com.android.car.vehiclenetwork; 17 18 import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropConfig; 19 import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropValue; 20 21 public class VehicleNetworkProtoUtil { VehiclePropValueToString(VehiclePropValue value)22 public static String VehiclePropValueToString(VehiclePropValue value) { 23 StringBuilder sb = new StringBuilder(); 24 sb.append("prop:0x"); 25 sb.append(Integer.toHexString(value.getProp())); 26 sb.append(" type:0x"); 27 sb.append(Integer.toHexString(value.getValueType())); 28 return sb.toString(); 29 } 30 VehiclePropConfigToString(VehiclePropConfig config)31 public static String VehiclePropConfigToString(VehiclePropConfig config) { 32 StringBuilder sb = new StringBuilder(); 33 sb.append("prop:0x"); 34 sb.append(Integer.toHexString(config.getProp())); 35 sb.append(" access:0x"); 36 sb.append(Integer.toHexString(config.getAccess())); 37 sb.append(" change_mode:0x"); 38 sb.append(Integer.toHexString(config.getChangeMode())); 39 sb.append(" value_type:0x"); 40 sb.append(Integer.toHexString(config.getValueType())); 41 sb.append(" permission_model:0x"); 42 sb.append(Integer.toHexString(config.getPermissionModel())); 43 return sb.toString(); 44 } 45 VehiclePropConfigEquals(VehiclePropConfig l, VehiclePropConfig r)46 public static boolean VehiclePropConfigEquals(VehiclePropConfig l, VehiclePropConfig r) { 47 if (l.getProp() != r.getProp()) { 48 return false; 49 } 50 if (l.getAccess() != r.getAccess()) { 51 return false; 52 } 53 if (l.getChangeMode() != r.getChangeMode()) { 54 return false; 55 } 56 if (l.getValueType() != r.getValueType()) { 57 return false; 58 } 59 if (l.getPermissionModel() != r.getPermissionModel()) { 60 return false; 61 } 62 //TODO add more comparison 63 return true; 64 } 65 } 66