10bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown/* 20bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * Copyright (C) 2011 The Android Open Source Project 30bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * 40bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * Licensed under the Apache License, Version 2.0 (the "License"); 50bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * you may not use this file except in compliance with the License. 60bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * You may obtain a copy of the License at 70bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * 80bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * http://www.apache.org/licenses/LICENSE-2.0 90bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * 100bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * Unless required by applicable law or agreed to in writing, software 110bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * distributed under the License is distributed on an "AS IS" BASIS, 120bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * See the License for the specific language governing permissions and 140bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * limitations under the License. 150bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown */ 160bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown 170bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brownpackage android.os; 180bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brownimport android.os.RemoteException; 190bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown 200bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown/** 210bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * The Binder transaction failed because it was too large. 220bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * <p> 230bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * During a remote procedure call, the arguments and the return value of the call 240bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * are transferred as {@link Parcel} objects stored in the Binder transaction buffer. 250bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * If the arguments or the return value are too large to fit in the transaction buffer, 260bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * then the call will fail and {@link TransactionTooLargeException} will be thrown. 270bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * </p><p> 280bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * The Binder transaction buffer has a limited fixed size, currently 1Mb, which 290bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * is shared by all transactions in progress for the process. Consequently this 300bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * exception can be thrown when there are many transactions in progress even when 310bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * most of the individual transactions are of moderate size. 320bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * </p><p> 330bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * There are two possible outcomes when a remote procedure call throws 340bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * {@link TransactionTooLargeException}. Either the client was unable to send 350bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * its request to the service (most likely if the arguments were too large to fit in 360bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * the transaction buffer), or the service was unable to send its response back 370bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * to the client (most likely if the return value was too large to fit 380bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * in the transaction buffer). It is not possible to tell which of these outcomes 390bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * actually occurred. The client should assume that a partial failure occurred. 400bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * </p><p> 410bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * The key to avoiding {@link TransactionTooLargeException} is to keep all 420bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * transactions relatively small. Try to minimize the amount of memory needed to create 430bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * a {@link Parcel} for the arguments and the return value of the remote procedure call. 440bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * Avoid transferring huge arrays of strings or large bitmaps. 450bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * If possible, try to break up big requests into smaller pieces. 460bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * </p><p> 470bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * If you are implementing a service, it may help to impose size or complexity 480bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * contraints on the queries that clients can perform. For example, if the result set 490bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * could become large, then don't allow the client to request more than a few records 500bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * at a time. Alternately, instead of returning all of the available data all at once, 510bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * return the essential information first and make the client ask for additional information 520bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * later as needed. 530bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown * </p> 540bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown */ 550bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brownpublic class TransactionTooLargeException extends RemoteException { 560bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown public TransactionTooLargeException() { 570bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown super(); 580bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown } 590bde66a837542e5bd901d8b8e47c5bd7c4c99fe4Jeff Brown} 60