Home | History | Annotate | Download | only in cat
      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 width;
     25     int height;
     26     int codingScheme;
     27     int imageId;
     28     int highOffset;
     29     int lowOffset;
     30     int length;
     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 
     39     ImageDescriptor() {
     40         width = 0;
     41         height = 0;
     42         codingScheme = 0;
     43         imageId = 0;
     44         highOffset = 0;
     45         lowOffset = 0;
     46         length = 0;
     47     }
     48 
     49     /**
     50      * Extract descriptor information about image instance.
     51      *
     52      * @param rawData
     53      * @param valueIndex
     54      * @return ImageDescriptor
     55      */
     56     static ImageDescriptor parse(byte[] rawData, int valueIndex) {
     57         ImageDescriptor d = new ImageDescriptor();
     58         try {
     59             d.width = rawData[valueIndex++] & 0xff;
     60             d.height = rawData[valueIndex++] & 0xff;
     61             d.codingScheme = rawData[valueIndex++] & 0xff;
     62 
     63             // parse image id
     64             d.imageId = (rawData[valueIndex++] & 0xff) << 8;
     65             d.imageId |= rawData[valueIndex++] & 0xff;
     66             // parse offset
     67             d.highOffset = (rawData[valueIndex++] & 0xff); // high byte offset
     68             d.lowOffset = rawData[valueIndex++] & 0xff; // low byte offset
     69 
     70             d.length = ((rawData[valueIndex++] & 0xff) << 8 | (rawData[valueIndex++] & 0xff));
     71         } catch (IndexOutOfBoundsException e) {
     72             CatLog.d("ImageDescripter", "parse; failed parsing image descriptor");
     73             d = null;
     74         }
     75         return d;
     76     }
     77 }
     78