Home | History | Annotate | Download | only in os
      1 /*
      2  * Copyright (C) 2011 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.os;
     18 import android.os.RemoteException;
     19 
     20 /**
     21  * The Binder transaction failed because it was too large.
     22  * <p>
     23  * During a remote procedure call, the arguments and the return value of the call
     24  * are transferred as {@link Parcel} objects stored in the Binder transaction buffer.
     25  * If the arguments or the return value are too large to fit in the transaction buffer,
     26  * then the call will fail and {@link TransactionTooLargeException} will be thrown.
     27  * </p><p>
     28  * The Binder transaction buffer has a limited fixed size, currently 1Mb, which
     29  * is shared by all transactions in progress for the process.  Consequently this
     30  * exception can be thrown when there are many transactions in progress even when
     31  * most of the individual transactions are of moderate size.
     32  * </p><p>
     33  * There are two possible outcomes when a remote procedure call throws
     34  * {@link TransactionTooLargeException}.  Either the client was unable to send
     35  * its request to the service (most likely if the arguments were too large to fit in
     36  * the transaction buffer), or the service was unable to send its response back
     37  * to the client (most likely if the return value was too large to fit
     38  * in the transaction buffer).  It is not possible to tell which of these outcomes
     39  * actually occurred.  The client should assume that a partial failure occurred.
     40  * </p><p>
     41  * The key to avoiding {@link TransactionTooLargeException} is to keep all
     42  * transactions relatively small.  Try to minimize the amount of memory needed to create
     43  * a {@link Parcel} for the arguments and the return value of the remote procedure call.
     44  * Avoid transferring huge arrays of strings or large bitmaps.
     45  * If possible, try to break up big requests into smaller pieces.
     46  * </p><p>
     47  * If you are implementing a service, it may help to impose size or complexity
     48  * contraints on the queries that clients can perform.  For example, if the result set
     49  * could become large, then don't allow the client to request more than a few records
     50  * at a time.  Alternately, instead of returning all of the available data all at once,
     51  * return the essential information first and make the client ask for additional information
     52  * later as needed.
     53  * </p>
     54  */
     55 public class TransactionTooLargeException extends RemoteException {
     56     public TransactionTooLargeException() {
     57         super();
     58     }
     59 
     60     public TransactionTooLargeException(String msg) {
     61         super(msg);
     62     }
     63 }
     64