109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly/*
209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * Copyright (c) 2008-2009, Motorola, Inc.
309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly *
409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * All rights reserved.
509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly *
609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * Redistribution and use in source and binary forms, with or without
709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * modification, are permitted provided that the following conditions are met:
809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly *
909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * - Redistributions of source code must retain the above copyright notice,
1009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * this list of conditions and the following disclaimer.
1109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly *
1209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * - Redistributions in binary form must reproduce the above copyright notice,
1309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * this list of conditions and the following disclaimer in the documentation
1409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * and/or other materials provided with the distribution.
1509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly *
1609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * - Neither the name of the Motorola, Inc. nor the names of its contributors
1709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * may be used to endorse or promote products derived from this software
1809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * without specific prior written permission.
1909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly *
2009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * POSSIBILITY OF SUCH DAMAGE.
3109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly */
3209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
3309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pellypackage com.android.bluetooth.opp;
3409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
3509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pellyimport java.io.File;
3609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pellyimport java.util.ArrayList;
3709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
3841ef8d494511c040451f2f887cb31c3100746b61Nick Pellyimport android.bluetooth.BluetoothAdapter;
3941ef8d494511c040451f2f887cb31c3100746b61Nick Pellyimport android.bluetooth.BluetoothDevice;
4009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pellyimport android.content.Context;
4109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pellyimport android.util.Log;
4209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
4309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pellyimport com.google.android.collect.Lists;
4409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
4509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly/**
4609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * This class stores information about a batch of OPP shares that should be
4709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * transferred in one session.
4809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly */
4909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly/*There are a few cases: 1. create a batch for a single file to send
5009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * 2. create a batch for multiple files to send
5109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * 3. add additional file(s) to existing batch to send
5209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * 4. create a batch for receive single file
5309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * 5. add additional file to existing batch to receive (this only happens as the server
5409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * session notify more files to receive)
5509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * 6. Cancel sending a single file
5609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * 7. Cancel sending a file from multiple files (implies cancel the transfer, rest of
5709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * the unsent files are also canceled)
5809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * 8. Cancel receiving a single file
5909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly * 9. Cancel receiving a file (implies cancel the transfer, no additional files will be received)
6009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly */
6141ef8d494511c040451f2f887cb31c3100746b61Nick Pelly
6209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pellypublic class BluetoothOppBatch {
63ce4d93666275df294cb073fe41de5b85932570a8Nick Pelly    private static final String TAG = "BtOppBatch";
64ce4d93666275df294cb073fe41de5b85932570a8Nick Pelly    private static final boolean V = Constants.VERBOSE;
6509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
6609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public int mId;
6709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public int mStatus;
6809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
6941ef8d494511c040451f2f887cb31c3100746b61Nick Pelly    public final long mTimestamp;
7041ef8d494511c040451f2f887cb31c3100746b61Nick Pelly    public final int mDirection;
7141ef8d494511c040451f2f887cb31c3100746b61Nick Pelly    public final BluetoothDevice mDestination;
7241ef8d494511c040451f2f887cb31c3100746b61Nick Pelly
7309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    private BluetoothOppBatchListener mListener;
7409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
7541ef8d494511c040451f2f887cb31c3100746b61Nick Pelly    private final ArrayList<BluetoothOppShareInfo> mShares;
7641ef8d494511c040451f2f887cb31c3100746b61Nick Pelly    private final Context mContext;
7709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
7809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /**
7909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * An interface for notifying when BluetoothOppTransferBatch is changed
8009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
8109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public interface BluetoothOppBatchListener {
8209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        /**
8309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly         * Called to notify when a share is added into the batch
8409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly         * @param id , BluetoothOppShareInfo.id
8509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly         */
8609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        public void onShareAdded(int id);
8709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
8809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        /**
8909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly         * Called to notify when a share is deleted from the batch
9009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly         * @param id , BluetoothOppShareInfo.id
9109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly         */
9209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        public void onShareDeleted(int id);
9309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
9409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        /**
9509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly         * Called to notify when the batch is canceled
9609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly         */
9709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        public void onBatchCanceled();
9809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
9909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
10009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /**
10109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * A batch is always created with at least one ShareInfo
10209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * @param context, Context
10309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * @param info, BluetoothOppShareInfo
10409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
10509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public BluetoothOppBatch(Context context, BluetoothOppShareInfo info) {
1063a88b20fcd71e42451e402d27374b19eeb2ff0daNick Pelly        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
10709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mContext = context;
10809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mShares = Lists.newArrayList();
10909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mTimestamp = info.mTimestamp;
11009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mDirection = info.mDirection;
11141ef8d494511c040451f2f887cb31c3100746b61Nick Pelly        mDestination = adapter.getRemoteDevice(info.mDestination);
11209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mStatus = Constants.BATCH_STATUS_PENDING;
11309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mShares.add(info);
114ce4d93666275df294cb073fe41de5b85932570a8Nick Pelly
115ce4d93666275df294cb073fe41de5b85932570a8Nick Pelly        if (V) Log.v(TAG, "New Batch created for info " + info.mId);
11609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
11709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
11809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /**
11909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * Add one share into the batch.
12009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
12109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /* There are 2 cases: Service scans the databases and it's multiple send
12209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * Service receives database update and know additional file should be received
12309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
12409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
12509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public void addShare(BluetoothOppShareInfo info) {
12609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mShares.add(info);
12709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        if (mListener != null) {
12809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            mListener.onShareAdded(info.mId);
12909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        }
13009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
13109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
13209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /**
133888485a3f5fe991116c5536bb6d6903d47b63a70Tao Liejun     * Delete one share from the batch. Not used now.
13409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
13509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /*It should only be called under requirement that cancel one single share, but not to
13609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * cancel the whole batch. Currently we assume "cancel" is to cancel whole batch.
13709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
13809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public void deleteShare(BluetoothOppShareInfo info) {
13909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        if (info.mStatus == BluetoothShare.STATUS_RUNNING) {
14009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            info.mStatus = BluetoothShare.STATUS_CANCELED;
14109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            if (info.mDirection == BluetoothShare.DIRECTION_INBOUND && info.mFilename != null) {
14209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly                new File(info.mFilename).delete();
14309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            }
14409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        }
14509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
14609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        if (mListener != null) {
14709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            mListener.onShareDeleted(info.mId);
14809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        }
14909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
15009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
15109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /**
15209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * Cancel the whole batch.
15309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
15409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /* 1) If the batch is running, stop the transfer
15509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * 2) Go through mShares list and mark all incomplete share as CANCELED status
15609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * 3) update ContentProvider for these canceled transfer
15709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
15809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public void cancelBatch() {
159ce4d93666275df294cb073fe41de5b85932570a8Nick Pelly        if (V) Log.v(TAG, "batch " + this.mId + " is canceled");
160ce4d93666275df294cb073fe41de5b85932570a8Nick Pelly
16109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        if (mListener != null) {
16209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            mListener.onBatchCanceled();
16309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        }
16409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        //TODO investigate if below code is redundant
16509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        for (int i = mShares.size() - 1; i >= 0; i--) {
16609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            BluetoothOppShareInfo info = mShares.get(i);
16709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
16809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            if (info.mStatus < 200) {
16909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly                if (info.mDirection == BluetoothShare.DIRECTION_INBOUND && info.mFilename != null) {
17009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly                    new File(info.mFilename).delete();
17109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly                }
172ce4d93666275df294cb073fe41de5b85932570a8Nick Pelly                if (V) Log.v(TAG, "Cancel batch for info " + info.mId);
17309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
17409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly                Constants.updateShareStatus(mContext, info.mId, BluetoothShare.STATUS_CANCELED);
17509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            }
17609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        }
17709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mShares.clear();
17809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
17909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
18009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /** check if a specific share is in this batch */
18109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public boolean hasShare(BluetoothOppShareInfo info) {
18209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        return mShares.contains(info);
18309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
18409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
18509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /** if this batch is empty */
18609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public boolean isEmpty() {
18709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        return (mShares.size() == 0);
18809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
18909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
19009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /**
19109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * Get the running status of the batch
19209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * @return
19309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
19409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
19509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /** register a listener for the batch change */
19609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public void registerListern(BluetoothOppBatchListener listener) {
19709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        mListener = listener;
19809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
19909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly
20009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    /**
20109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     * Get the first pending ShareInfo of the batch
2026769b59d715ea98bd72eafcfea9acd2714a887daTao Liejun     * @return BluetoothOppShareInfo, for the first pending share, or null if
2036769b59d715ea98bd72eafcfea9acd2714a887daTao Liejun     *         none exists
20409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly     */
20509e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    public BluetoothOppShareInfo getPendingShare() {
20609e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        for (int i = 0; i < mShares.size(); i++) {
20709e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            BluetoothOppShareInfo share = mShares.get(i);
20809e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            if (share.mStatus == BluetoothShare.STATUS_PENDING) {
20909e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly                return share;
21009e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly            }
21109e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        }
21209e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly        return null;
21309e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly    }
21409e9cba205af60b3f42e7a4d891a7d1392e1f2a5Nick Pelly}
215