19439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly/*
29439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * Copyright (c) 2008-2009, Motorola, Inc.
39439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
49439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * All rights reserved.
59439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
69439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * Redistribution and use in source and binary forms, with or without
79439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * modification, are permitted provided that the following conditions are met:
89439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
99439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * - Redistributions of source code must retain the above copyright notice,
109439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * this list of conditions and the following disclaimer.
119439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
129439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * - Redistributions in binary form must reproduce the above copyright notice,
139439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * this list of conditions and the following disclaimer in the documentation
149439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * and/or other materials provided with the distribution.
159439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
169439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * - Neither the name of the Motorola, Inc. nor the names of its contributors
179439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * may be used to endorse or promote products derived from this software
189439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * without specific prior written permission.
199439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
209439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
219439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
229439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
239439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
249439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
259439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
269439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
279439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
289439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
299439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
309439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * POSSIBILITY OF SUCH DAMAGE.
319439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly */
329439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
339439a7fe517b858bc5e5c654b459315e4722feb2Nick Pellypackage javax.obex;
349439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
352e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly/**
362e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly * @hide
372e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly */
382e0da96e757a977154063f980d3f4e1abd41cf09Nick Pellypublic final class ApplicationParameter {
399439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
403998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    private byte[] mArray;
413998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun
423998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    private int mLength;
433998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun
443998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    private int mMaxLength = 1000;
459439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
469439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public static class TRIPLET_TAGID {
479439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte ORDER_TAGID = 0x01;
489439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
499439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte SEARCH_VALUE_TAGID = 0x02;
509439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
519439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte SEARCH_ATTRIBUTE_TAGID = 0x03;
529439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
532e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly        // if equals to "0", PSE only reply number of contacts
542e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly        public static final byte MAXLISTCOUNT_TAGID = 0x04;
559439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
569439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte LISTSTARTOFFSET_TAGID = 0x05;
579439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
589439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte FILTER_TAGID = 0x06;
599439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
609439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte FORMAT_TAGID = 0x07;
619439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
622e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly        // only used if max list count = 0
632e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly        public static final byte PHONEBOOKSIZE_TAGID = 0x08;
649439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
652e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly        // only used in "mch" in response
662e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly        public static final byte NEWMISSEDCALLS_TAGID = 0x09;
679439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
689439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
699439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public static class TRIPLET_VALUE {
709439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static class ORDER {
719439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            public static final byte ORDER_BY_INDEX = 0x00;
729439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
739439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            public static final byte ORDER_BY_ALPHANUMERIC = 0x01;
749439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
759439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            public static final byte ORDER_BY_PHONETIC = 0x02;
769439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        }
779439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
789439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static class SEARCHATTRIBUTE {
799439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            public static final byte SEARCH_BY_NAME = 0x00;
809439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
819439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            public static final byte SEARCH_BY_NUMBER = 0x01;
829439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
839439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            public static final byte SEARCH_BY_SOUND = 0x02;
849439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        }
859439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
869439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static class FORMAT {
879439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            public static final byte VCARD_VERSION_21 = 0x00;
889439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
899439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            public static final byte VCARD_VERSION_30 = 0x01;
909439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        }
919439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
929439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
939439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public static class TRIPLET_LENGTH {
949439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte ORDER_LENGTH = 1;
959439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
969439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte SEARCH_ATTRIBUTE_LENGTH = 1;
979439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
989439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte MAXLISTCOUNT_LENGTH = 2;
999439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1009439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte LISTSTARTOFFSET_LENGTH = 2;
1019439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1029439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte FILTER_LENGTH = 8;
1039439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1049439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte FORMAT_LENGTH = 1;
1059439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1069439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte PHONEBOOKSIZE_LENGTH = 2;
1079439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1089439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        public static final byte NEWMISSEDCALLS_LENGTH = 1;
1099439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
1109439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1119439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public ApplicationParameter() {
1123998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        mArray = new byte[mMaxLength];
1133998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        mLength = 0;
1149439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
1159439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1169439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public void addAPPHeader(byte tag, byte len, byte[] value) {
1173998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        if ((mLength + len + 2) > mMaxLength) {
1183998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun            byte[] array_tmp = new byte[mLength + 4 * len];
1193998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun            System.arraycopy(mArray, 0, array_tmp, 0, mLength);
1203998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun            mArray = array_tmp;
1213998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun            mMaxLength = mLength + 4 * len;
1229439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        }
1233998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        mArray[mLength++] = tag;
1243998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        mArray[mLength++] = len;
1253998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        System.arraycopy(value, 0, mArray, mLength, len);
1263998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        mLength += len;
1279439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
1289439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1299439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public byte[] getAPPparam() {
1303998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        byte[] para = new byte[mLength];
1313998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        System.arraycopy(mArray, 0, para, 0, mLength);
1329439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        return para;
1339439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
1349439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly}
135