1 /* 2 * Copyright (C) 2006 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.cat; 18 19 /** 20 * {@hide} 21 */ 22 public class ImageDescriptor { 23 // members 24 int mWidth; 25 int mHeight; 26 int mCodingScheme; 27 int mImageId; 28 int mHighOffset; 29 int mLowOffset; 30 int mLength; 31 32 // constants 33 static final int CODING_SCHEME_BASIC = 0x11; 34 static final int CODING_SCHEME_COLOUR = 0x21; 35 36 // public static final int ID_LENGTH = 9; 37 // ID_LENGTH substituted by IccFileHandlerBase.GET_RESPONSE_EF_IMG_SIZE_BYTES 38 ImageDescriptor()39 ImageDescriptor() { 40 mWidth = 0; 41 mHeight = 0; 42 mCodingScheme = 0; 43 mImageId = 0; 44 mHighOffset = 0; 45 mLowOffset = 0; 46 mLength = 0; 47 } 48 49 /** 50 * Extract descriptor information about image instance. 51 * 52 * @param rawData 53 * @param valueIndex 54 * @return ImageDescriptor 55 */ parse(byte[] rawData, int valueIndex)56 static ImageDescriptor parse(byte[] rawData, int valueIndex) { 57 ImageDescriptor d = new ImageDescriptor(); 58 try { 59 d.mWidth = rawData[valueIndex++] & 0xff; 60 d.mHeight = rawData[valueIndex++] & 0xff; 61 d.mCodingScheme = rawData[valueIndex++] & 0xff; 62 63 // parse image id 64 d.mImageId = (rawData[valueIndex++] & 0xff) << 8; 65 d.mImageId |= rawData[valueIndex++] & 0xff; 66 // parse offset 67 d.mHighOffset = (rawData[valueIndex++] & 0xff); // high byte offset 68 d.mLowOffset = rawData[valueIndex++] & 0xff; // low byte offset 69 70 d.mLength = ((rawData[valueIndex++] & 0xff) << 8 | (rawData[valueIndex++] & 0xff)); 71 CatLog.d("ImageDescriptor", "parse; Descriptor : " + d.mWidth + ", " + d.mHeight + 72 ", " + d.mCodingScheme + ", 0x" + Integer.toHexString(d.mImageId) + ", " + 73 d.mHighOffset + ", " + d.mLowOffset + ", " + d.mLength); 74 } catch (IndexOutOfBoundsException e) { 75 CatLog.d("ImageDescriptor", "parse; failed parsing image descriptor"); 76 d = null; 77 } 78 return d; 79 } 80 } 81