1 /* 2 * Copyright (C) 2017 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.location.cts.asn1.supl2.ulp_components; 18 19 /* 20 */ 21 22 23 // 24 // 25 import android.location.cts.asn1.base.Asn1Enumerated; 26 import android.location.cts.asn1.base.Asn1Tag; 27 import android.location.cts.asn1.base.BitStream; 28 import android.location.cts.asn1.base.BitStreamReader; 29 import com.google.common.collect.ImmutableList; 30 import java.util.Collection; 31 import javax.annotation.Nullable; 32 33 34 /** 35 */ 36 public class PosMethod extends Asn1Enumerated { 37 public enum Value implements Asn1Enumerated.Value { 38 agpsSETassisted(0), 39 agpsSETbased(1), 40 agpsSETassistedpref(2), 41 agpsSETbasedpref(3), 42 autonomousGPS(4), 43 aFLT(5), 44 eCID(6), 45 eOTD(7), 46 oTDOA(8), 47 noPosition(9), 48 ; 49 50 Value(int i) { 51 value = i; 52 } 53 54 private int value; 55 public int getAssignedValue() { 56 return value; 57 } 58 59 @Override public boolean isExtensionValue() { 60 return false; 61 } 62 } 63 64 public enum ExtensionValue implements Asn1Enumerated.Value { 65 ver2_historicalDataRetrieval(10), 66 ver2_agnssSETassisted(11), 67 ver2_agnssSETbased(12), 68 ver2_agnssSETassistedpref(13), 69 ver2_agnssSETbasedpref(14), 70 ver2_autonomousGNSS(15), 71 ver2_sessioninfoquery(16), 72 ; 73 74 ExtensionValue(int i) { 75 value = i; 76 } 77 78 private int value; 79 @Override public int getAssignedValue() { 80 return value; 81 } 82 83 @Override public boolean isExtensionValue() { 84 return true; 85 } 86 } 87 88 89 90 private static final Asn1Tag TAG_PosMethod 91 = Asn1Tag.fromClassAndNumber(-1, -1); 92 93 public PosMethod() { 94 super(); 95 } 96 97 @Override 98 @Nullable 99 protected Asn1Tag getTag() { 100 return TAG_PosMethod; 101 } 102 103 @Override 104 protected boolean isTagImplicit() { 105 return true; 106 } 107 108 public static Collection<Asn1Tag> getPossibleFirstTags() { 109 if (TAG_PosMethod != null) { 110 return ImmutableList.of(TAG_PosMethod); 111 } else { 112 return Asn1Enumerated.getPossibleFirstTags(); 113 } 114 } 115 116 @Override protected boolean isExtensible() { 117 return true; 118 } 119 120 @Override protected Asn1Enumerated.Value lookupValue(int ordinal) { 121 return Value.values()[ordinal]; 122 } 123 124 @Override protected Asn1Enumerated.Value lookupExtensionValue(int ordinal) { 125 return ExtensionValue.values()[ordinal]; 126 } 127 128 @Override protected int getValueCount() { 129 return Value.values().length; 130 } 131 132 /** 133 * Creates a new PosMethod from encoded stream. 134 */ 135 public static PosMethod fromPerUnaligned(byte[] encodedBytes) { 136 PosMethod result = new PosMethod(); 137 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 138 return result; 139 } 140 141 /** 142 * Creates a new PosMethod from encoded stream. 143 */ 144 public static PosMethod fromPerAligned(byte[] encodedBytes) { 145 PosMethod result = new PosMethod(); 146 result.decodePerAligned(new BitStreamReader(encodedBytes)); 147 return result; 148 } 149 150 @Override public Iterable<BitStream> encodePerUnaligned() { 151 return super.encodePerUnaligned(); 152 } 153 154 @Override public Iterable<BitStream> encodePerAligned() { 155 return super.encodePerAligned(); 156 } 157 158 @Override public void decodePerUnaligned(BitStreamReader reader) { 159 super.decodePerUnaligned(reader); 160 } 161 162 @Override public void decodePerAligned(BitStreamReader reader) { 163 super.decodePerAligned(reader); 164 } 165 166 @Override public String toString() { 167 return toIndentedString(""); 168 } 169 170 public String toIndentedString(String indent) { 171 return "PosMethod = " + getValue() + ";\n"; 172 } 173 } 174