Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64bdf5de authored by Myles Watson's avatar Myles Watson Committed by android-build-merger
Browse files

Merge "OPP: Remove dead code and update Constants.java" am: 8a13e527

am: 81aa8faf

Change-Id: Idae12cf4f000e09d16c82da6271f3d3b3ad35a75
parents cdc6b6aa 81aa8faf
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -363,9 +363,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                            } catch (IOException e) {
                                Log.e(TAG, "close tranport error");
                            }
                        } else if (Constants.USE_TCP_DEBUG && !Constants.USE_TCP_SIMPLE_SERVER) {
                            Log.i(TAG, "Start Obex Server in TCP DEBUG mode");
                            createServerSession(transport);
                        } else {
                            Log.i(TAG, "OPP busy! Retry after 1 second");
                            mIncomingRetries = mIncomingRetries + 1;
@@ -790,19 +787,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                        Log.v(TAG,
                                "Service add new Batch " + newBatch.mId + " for info " + info.mId);
                    }
                    if (Constants.USE_TCP_DEBUG && !Constants.USE_TCP_SIMPLE_SERVER) {
                        // only allow  concurrent serverTransfer in debug mode
                        if (info.mDirection == BluetoothShare.DIRECTION_INBOUND) {
                            if (V) {
                                Log.v(TAG,
                                        "TCP_DEBUG start server transfer new Batch " + newBatch.mId
                                                + " for info " + info.mId);
                            }
                            mServerTransfer =
                                    new BluetoothOppTransfer(this, newBatch, mServerSession);
                            mServerTransfer.start();
                        }
                    }
                }
            }
        }
+69 −127
Original line number Diff line number Diff line
@@ -44,164 +44,138 @@ import java.util.regex.Pattern;
import javax.obex.HeaderSet;

/**
 * Bluetooth OPP internal constants definition
 * Bluetooth OPP internal constant definitions
 */
public class Constants {
    /** Tag used for debugging/logging */
    public static final String TAG = "BluetoothOpp";

    /**
     * The intent that gets sent when the service must wake up for a retry Note:
     * only retry Outbound transfer
     * The intent that gets sent when the service must wake up for a retry
     * Note: Only retry Outbound transfers
     */
    public static final String ACTION_RETRY = "android.btopp.intent.action.RETRY";
    static final String ACTION_RETRY = "android.btopp.intent.action.RETRY";

    /** the intent that gets sent when clicking a successful transfer */
    public static final String ACTION_OPEN = "android.btopp.intent.action.OPEN";
    static final String ACTION_OPEN = "android.btopp.intent.action.OPEN";

    /** the intent that gets sent when clicking outbound transfer notification */
    public static final String ACTION_OPEN_OUTBOUND_TRANSFER =
            "android.btopp.intent.action.OPEN_OUTBOUND";
    static final String ACTION_OPEN_OUTBOUND_TRANSFER = "android.btopp.intent.action.OPEN_OUTBOUND";

    /** the intent that gets sent when clicking a inbound transfer notification */
    public static final String ACTION_OPEN_INBOUND_TRANSFER =
            "android.btopp.intent.action.OPEN_INBOUND";
    static final String ACTION_OPEN_INBOUND_TRANSFER = "android.btopp.intent.action.OPEN_INBOUND";

    /** the intent that gets sent from the Settings app to show the received files */
    public static final String ACTION_OPEN_RECEIVED_FILES =
    static final String ACTION_OPEN_RECEIVED_FILES =
            "android.btopp.intent.action.OPEN_RECEIVED_FILES";

    /** the intent that whitelists a remote bluetooth device for auto-receive confirmation (NFC) */
    public static final String ACTION_WHITELIST_DEVICE =
            "android.btopp.intent.action.WHITELIST_DEVICE";
    static final String ACTION_WHITELIST_DEVICE = "android.btopp.intent.action.WHITELIST_DEVICE";

    /** the intent that can be sent by handover requesters to stop a BTOPP transfer */
    public static final String ACTION_STOP_HANDOVER =
            "android.btopp.intent.action.STOP_HANDOVER_TRANSFER";
    static final String ACTION_STOP_HANDOVER = "android.btopp.intent.action.STOP_HANDOVER_TRANSFER";

    /** the intent extra to show all received files in the transfer history */
    public static final String EXTRA_SHOW_ALL_FILES = "android.btopp.intent.extra.SHOW_ALL";
    static final String EXTRA_SHOW_ALL_FILES = "android.btopp.intent.extra.SHOW_ALL";

    /** the intent that gets sent when clicking an incomplete/failed transfer */
    public static final String ACTION_LIST = "android.btopp.intent.action.LIST";
    static final String ACTION_LIST = "android.btopp.intent.action.LIST";

    /** the intent that is used for initiating a handover transfer */
    public static final String ACTION_HANDOVER_SEND =
            "android.nfc.handover.intent.action.HANDOVER_SEND";
    static final String ACTION_HANDOVER_SEND = "android.nfc.handover.intent.action.HANDOVER_SEND";

    /** the intent that is used for initiating a multi-uri handover transfer */
    public static final String ACTION_HANDOVER_SEND_MULTIPLE =
    static final String ACTION_HANDOVER_SEND_MULTIPLE =
            "android.nfc.handover.intent.action.HANDOVER_SEND_MULTIPLE";

    /** the intent that is used for indicating an incoming transfer*/
    public static final String ACTION_HANDOVER_STARTED =
    static final String ACTION_HANDOVER_STARTED =
            "android.nfc.handover.intent.action.HANDOVER_STARTED";

    /** intent action used to indicate the progress of a handover transfer */
    public static final String ACTION_BT_OPP_TRANSFER_PROGRESS =
    static final String ACTION_BT_OPP_TRANSFER_PROGRESS =
            "android.nfc.handover.intent.action.TRANSFER_PROGRESS";

    /** intent action used to indicate the completion of a handover transfer */
    public static final String ACTION_BT_OPP_TRANSFER_DONE =
    static final String ACTION_BT_OPP_TRANSFER_DONE =
            "android.nfc.handover.intent.action.TRANSFER_DONE";

    /** intent extra used to indicate the success of a handover transfer */
    public static final String EXTRA_BT_OPP_TRANSFER_STATUS =
    static final String EXTRA_BT_OPP_TRANSFER_STATUS =
            "android.nfc.handover.intent.extra.TRANSFER_STATUS";

    /** intent extra used to indicate the address associated with the transfer */
    public static final String EXTRA_BT_OPP_ADDRESS = "android.nfc.handover.intent.extra.ADDRESS";
    static final String EXTRA_BT_OPP_ADDRESS = "android.nfc.handover.intent.extra.ADDRESS";

    public static final String EXTRA_BT_OPP_OBJECT_COUNT =
    static final String EXTRA_BT_OPP_OBJECT_COUNT =
            "android.nfc.handover.intent.extra.OBJECT_COUNT";

    public static final int COUNT_HEADER_UNAVAILABLE = -1;
    public static final int HANDOVER_TRANSFER_STATUS_SUCCESS = 0;
    static final int COUNT_HEADER_UNAVAILABLE = -1;
    static final int HANDOVER_TRANSFER_STATUS_SUCCESS = 0;

    public static final int HANDOVER_TRANSFER_STATUS_FAILURE = 1;
    static final int HANDOVER_TRANSFER_STATUS_FAILURE = 1;

    /** intent extra used to indicate the direction of a handover transfer */
    public static final String EXTRA_BT_OPP_TRANSFER_DIRECTION =
    static final String EXTRA_BT_OPP_TRANSFER_DIRECTION =
            "android.nfc.handover.intent.extra.TRANSFER_DIRECTION";

    public static final int DIRECTION_BLUETOOTH_INCOMING = 0;
    static final int DIRECTION_BLUETOOTH_INCOMING = 0;

    public static final int DIRECTION_BLUETOOTH_OUTGOING = 1;
    static final int DIRECTION_BLUETOOTH_OUTGOING = 1;

    /** intent extra used to provide a unique ID for the transfer */
    public static final String EXTRA_BT_OPP_TRANSFER_ID =
            "android.nfc.handover.intent.extra.TRANSFER_ID";
    static final String EXTRA_BT_OPP_TRANSFER_ID = "android.nfc.handover.intent.extra.TRANSFER_ID";

    /** intent extra used to provide progress of the transfer */
    public static final String EXTRA_BT_OPP_TRANSFER_PROGRESS =
    static final String EXTRA_BT_OPP_TRANSFER_PROGRESS =
            "android.nfc.handover.intent.extra.TRANSFER_PROGRESS";

    /** intent extra used to provide the Uri where the data was stored
     * by the handover transfer */
    public static final String EXTRA_BT_OPP_TRANSFER_URI =
    /** intent extra used to provide the Uri where the data was stored by the handover transfer */
    static final String EXTRA_BT_OPP_TRANSFER_URI =
            "android.nfc.handover.intent.extra.TRANSFER_URI";

    /** intent extra used to provide the mime-type of the data in
     *  the handover transfer */
    public static final String EXTRA_BT_OPP_TRANSFER_MIMETYPE =
    /** intent extra used to provide the mime-type of the data in the handover transfer */
    static final String EXTRA_BT_OPP_TRANSFER_MIMETYPE =
            "android.nfc.handover.intent.extra.TRANSFER_MIME_TYPE";

    /** permission needed to be able to receive handover status requests */
    public static final String HANDOVER_STATUS_PERMISSION =
            "android.permission.NFC_HANDOVER_STATUS";
    static final String HANDOVER_STATUS_PERMISSION = "android.permission.NFC_HANDOVER_STATUS";

    /** intent extra that indicates this transfer is a handover from another
     * transport (NFC, WIFI)
     */
    public static final String EXTRA_CONNECTION_HANDOVER =
            "com.android.intent.extra.CONNECTION_HANDOVER";
    /** the intent that gets sent when deleting the incoming file confirmation notification */
    static final String ACTION_HIDE = "android.btopp.intent.action.HIDE";

    /**
     * the intent that gets sent when deleting the incoming file confirmation notification
     */
    public static final String ACTION_HIDE = "android.btopp.intent.action.HIDE";
    /** the intent that gets sent when accepting the incoming file confirmation notification */
    static final String ACTION_ACCEPT = "android.btopp.intent.action.ACCEPT";

    /**
     * the intent that gets sent when accepting the incoming file confirmation notification
     */
    public static final String ACTION_ACCEPT = "android.btopp.intent.action.ACCEPT";

    /**
     * the intent that gets sent when declining the incoming file confirmation notification
     */
    public static final String ACTION_DECLINE = "android.btopp.intent.action.DECLINE";
    /** the intent that gets sent when declining the incoming file confirmation notification */
    static final String ACTION_DECLINE = "android.btopp.intent.action.DECLINE";

    /**
     * the intent that gets sent when deleting the notifications of outbound and
     * inbound completed transfer
     */
    public static final String ACTION_COMPLETE_HIDE = "android.btopp.intent.action.HIDE_COMPLETE";
    static final String ACTION_COMPLETE_HIDE = "android.btopp.intent.action.HIDE_COMPLETE";

    /**
     * the intent that gets sent when clicking a incoming file confirm
     * notification
     */
    public static final String ACTION_INCOMING_FILE_CONFIRM = "android.btopp.intent.action.CONFIRM";
    /** the intent that gets sent when clicking a incoming file confirm notification */
    static final String ACTION_INCOMING_FILE_CONFIRM = "android.btopp.intent.action.CONFIRM";

    public static final String THIS_PACKAGE_NAME = "com.android.bluetooth";
    static final String THIS_PACKAGE_NAME = "com.android.bluetooth";

    /**
     * The column that is used to remember whether the media scanner was invoked
     */
    public static final String MEDIA_SCANNED = "scanned";
    /** The column that is used to remember whether the media scanner was invoked */
    static final String MEDIA_SCANNED = "scanned";

    public static final int MEDIA_SCANNED_NOT_SCANNED = 0;
    static final int MEDIA_SCANNED_NOT_SCANNED = 0;

    public static final int MEDIA_SCANNED_SCANNED_OK = 1;
    static final int MEDIA_SCANNED_SCANNED_OK = 1;

    public static final int MEDIA_SCANNED_SCANNED_FAILED = 2;
    static final int MEDIA_SCANNED_SCANNED_FAILED = 2;

    /**
     * The MIME type(s) of we could accept from other device.
     * This is in essence a "white list" of acceptable types.
     * Today, restricted to images, audio, video and certain text types.
     */
    public static final String[] ACCEPTABLE_SHARE_INBOUND_TYPES = new String[]{
    static final String[] ACCEPTABLE_SHARE_INBOUND_TYPES = new String[]{
            "image/*",
            "video/*",
            "audio/*",
@@ -222,61 +196,33 @@ public class Constants {
            "application/x-hwp",
    };

    /**
     * The MIME type(s) of we could not accept from other device. TODO: define
     * correct type list
     */
    public static final String[] UNACCEPTABLE_SHARE_INBOUND_TYPES = new String[]{};

    /** Where we store Bluetooth received files on the external storage */
    public static final String DEFAULT_STORE_SUBDIR = "/bluetooth";

    /**
     * Notify NFC of the transfer progress per this period
     * to NFC Handover still consider this transfer to be "alive"
     * This value is taken into account the timeout value 20sec in NFC and delaying broadcast
     */
    public static final int NFC_ALIVE_CHECK_MS = 10000;

    /**
     * Debug level logging
     */
    public static final boolean DEBUG = true;

    /**
     * Verbose level logging
     */
    public static final boolean VERBOSE = false;

    /** use TCP socket instead of Rfcomm Socket to develop */
    public static final boolean USE_TCP_DEBUG = false;
    /** Where we store received files */
    static final String DEFAULT_STORE_SUBDIR = "/bluetooth";

    /** use simple TCP server started from TestActivity */
    public static final boolean USE_TCP_SIMPLE_SERVER = false;
    /** Notify NFC of the transfer progress periodically, or it will timeout after 20sec. */
    static final int NFC_ALIVE_CHECK_MS = 10000;

    /** Test TCP socket port */
    public static final int TCP_DEBUG_PORT = 6500;
    static final boolean DEBUG = true;

    /** use emulator to debug */
    public static final boolean USE_EMULATOR_DEBUG = false;
    static final boolean VERBOSE = false;

    public static final int MAX_RECORDS_IN_DATABASE = 50;
    static final int MAX_RECORDS_IN_DATABASE = 50;

    public static final int BATCH_STATUS_PENDING = 0;
    static final int BATCH_STATUS_PENDING = 0;

    public static final int BATCH_STATUS_RUNNING = 1;
    static final int BATCH_STATUS_RUNNING = 1;

    public static final int BATCH_STATUS_FINISHED = 2;
    static final int BATCH_STATUS_FINISHED = 2;

    public static final int BATCH_STATUS_FAILED = 3;
    static final int BATCH_STATUS_FAILED = 3;

    public static final String BLUETOOTHOPP_NAME_PREFERENCE = "btopp_names";
    static final String BLUETOOTHOPP_NAME_PREFERENCE = "btopp_names";

    public static final String BLUETOOTHOPP_CHANNEL_PREFERENCE = "btopp_channels";
    static final String BLUETOOTHOPP_CHANNEL_PREFERENCE = "btopp_channels";

    public static final String FILENAME_SEQUENCE_SEPARATOR = "-";
    static final String FILENAME_SEQUENCE_SEPARATOR = "-";

    public static void updateShareStatus(Context context, int id, int status) {
    static void updateShareStatus(Context context, int id, int status) {
        Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + id);
        ContentValues updateValues = new ContentValues();
        updateValues.put(BluetoothShare.STATUS, status);
@@ -284,11 +230,8 @@ public class Constants {
        Constants.sendIntentIfCompleted(context, contentUri, status);
    }

    /*
     * This function should be called whenever transfer status change to
     * completed.
     */
    public static void sendIntentIfCompleted(Context context, Uri contentUri, int status) {
    /** This function should be called whenever the transfer status changes to completed. */
    static void sendIntentIfCompleted(Context context, Uri contentUri, int status) {
        if (BluetoothShare.isStatusCompleted(status)) {
            Intent intent = new Intent(BluetoothShare.TRANSFER_COMPLETED_ACTION);
            intent.setClassName(THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
@@ -297,7 +240,7 @@ public class Constants {
        }
    }

    public static boolean mimeTypeMatches(String mimeType, String[] matchAgainst) {
    static boolean mimeTypeMatches(String mimeType, String[] matchAgainst) {
        for (String matchType : matchAgainst) {
            if (mimeTypeMatches(mimeType, matchType)) {
                return true;
@@ -306,16 +249,15 @@ public class Constants {
        return false;
    }

    public static boolean mimeTypeMatches(String mimeType, String matchAgainst) {
    private static boolean mimeTypeMatches(String mimeType, String matchAgainst) {
        Pattern p =
                Pattern.compile(matchAgainst.replaceAll("\\*", "\\.\\*"), Pattern.CASE_INSENSITIVE);
        return p.matcher(mimeType).matches();
    }

    public static void logHeader(HeaderSet hs) {
    static void logHeader(HeaderSet hs) {
        Log.v(TAG, "Dumping HeaderSet " + hs.toString());
        try {

            Log.v(TAG, "COUNT : " + hs.getHeader(HeaderSet.COUNT));
            Log.v(TAG, "NAME : " + hs.getHeader(HeaderSet.NAME));
            Log.v(TAG, "TYPE : " + hs.getHeader(HeaderSet.TYPE));