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

Commit 944f8d07 authored by Jack He's avatar Jack He
Browse files

[Script] Fix checkstyle errors (1/2)

Format code using Intellij to conform to CheckStyle requirements

Bug: 63597465
Test: make checkbuild, no manual changes, no functional changes
Change-Id: I70cd2ab8e5e6d5428ab1556658735b0d83f4fb15
parent edef9483
Loading
Loading
Loading
Loading
+140 −134
Original line number Diff line number Diff line
@@ -162,8 +162,11 @@ public final class BluetoothMapContract {
     */
    public static Uri buildAccountUri(String authority) {
        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority).appendPath(TABLE_ACCOUNT).build();
                .authority(authority)
                .appendPath(TABLE_ACCOUNT)
                .build();
    }

    /**
     * Build URI representing the given Account data-set with specific Id in a
     * Bluetooth provider. When queried, the direct URI for the account
@@ -176,6 +179,7 @@ public final class BluetoothMapContract {
                .appendPath(accountId)
                .build();
    }

    /**
     * Build URI representing the entire Message table in a
     * Bluetooth provider.
@@ -186,6 +190,7 @@ public final class BluetoothMapContract {
                .appendPath(TABLE_MESSAGE)
                .build();
    }

    /**
     * Build URI representing the given Message data-set in a
     * Bluetooth provider. When queried, the URI for the Messages
@@ -198,6 +203,7 @@ public final class BluetoothMapContract {
                .appendPath(TABLE_MESSAGE)
                .build();
    }

    /**
     * Build URI representing the given Message data-set with specific messageId in a
     * Bluetooth provider. When queried, the direct URI for the account
@@ -211,6 +217,7 @@ public final class BluetoothMapContract {
                .appendPath(messageId)
                .build();
    }

    /**
     * Build URI representing the given Message data-set in a
     * Bluetooth provider. When queried, the direct URI for the folder
@@ -261,6 +268,7 @@ public final class BluetoothMapContract {
                .appendPath(TABLE_CONVOCONTACT)
                .build();
    }

    /**
     * Build URI representing the given Contact data-set in a
     * Bluetooth provider. When queried, the direct URI for the contact
@@ -275,6 +283,7 @@ public final class BluetoothMapContract {
                .appendPath(contactId)
                .build();
    }

    /**
     *  @hide
     */
@@ -510,6 +519,7 @@ public final class BluetoothMapContract {
        String RAW_DATA = "raw_data";

    }

    /**
     * The actual message table containing all messages.
     * Content that must support filtering using WHERE clauses:
@@ -665,7 +675,6 @@ public final class BluetoothMapContract {
    public interface EmailMessageColumns {



        /**
         * A comma-delimited list of CC addresses in RFC2822 format.
         * The list must be compatible with Rfc822Tokenizer.tokenize();
@@ -1117,9 +1126,7 @@ public final class BluetoothMapContract {
     * A projection of all the columns in the Account table
     */
    public static final String[] BT_ACCOUNT_PROJECTION = new String[]{
        AccountColumns._ID,
        AccountColumns.ACCOUNT_DISPLAY_NAME,
        AccountColumns.FLAG_EXPOSE,
            AccountColumns._ID, AccountColumns.ACCOUNT_DISPLAY_NAME, AccountColumns.FLAG_EXPOSE,
    };

    /**
@@ -1201,8 +1208,7 @@ public final class BluetoothMapContract {
     * A projection of all the columns in the Chat Status table
     */
    public static final String[] BT_CHATSTATUS_PROJECTION = new String[]{
        ChatStatusColumns.CHAT_STATE,
        ChatStatusColumns.LAST_ACTIVE,
            ChatStatusColumns.CHAT_STATE, ChatStatusColumns.LAST_ACTIVE,
    };

    /**
+129 −96
Original line number Diff line number Diff line
@@ -73,8 +73,7 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
     * @throws IOException
     */
    protected abstract void WriteMessageToStream(long accountId, long messageId,
            boolean includeAttachment, boolean download, FileOutputStream out)
        throws IOException;
            boolean includeAttachment, boolean download, FileOutputStream out) throws IOException;

    /**
     * @return the CONTENT_URI exposed. This will be used to send out notifications.
@@ -99,8 +98,8 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
        }
        // Enforce correct permissions are used
        if (!android.Manifest.permission.BLUETOOTH_MAP.equals(info.writePermission)) {
           throw new SecurityException("Provider must be protected by " +
                   android.Manifest.permission.BLUETOOTH_MAP);
            throw new SecurityException(
                    "Provider must be protected by " + android.Manifest.permission.BLUETOOTH_MAP);
        }
        mResolver = context.getContentResolver();
        super.attachInfo(context, info);
@@ -135,8 +134,8 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
         * Use the message to do an update of the message specified by the URI.
         */
        @Override
        public void readDataFromPipe(ParcelFileDescriptor input, Uri uri,
                String mimeType, Bundle opts, Cursor args) {
        public void readDataFromPipe(ParcelFileDescriptor input, Uri uri, String mimeType,
                Bundle opts, Cursor args) {
            Log.v(TAG, "readDataFromPipe(): uri=" + uri.toString());
            FileInputStream fIn = null;
            try {
@@ -146,13 +145,15 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
                UpdateMimeMessageFromStream(fIn, accountId, messageId);
            } catch (IOException e) {
                Log.w(TAG, "IOException: ", e);
                /* TODO: How to signal the error to the calling entity? Had expected readDataFromPipe
                /* TODO: How to signal the error to the calling entity? Had expected
                readDataFromPipe
                 *       to throw IOException?
                 */
            } finally {
                try {
                    if(fIn != null)
                    if (fIn != null) {
                        fIn.close();
                    }
                } catch (IOException e) {
                    Log.w(TAG, e);
                }
@@ -181,8 +182,10 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
        @Override
        public void writeDataToPipe(ParcelFileDescriptor output, Uri uri, String mimeType,
                Bundle opts, Cursor c) {
            if (D) Log.d(TAG, "writeDataToPipe(): uri=" + uri.toString() +
                    " - getLastPathSegment() = " + uri.getLastPathSegment());
            if (D) {
                Log.d(TAG, "writeDataToPipe(): uri=" + uri.toString() + " - getLastPathSegment() = "
                        + uri.getLastPathSegment());
            }

            FileOutputStream fout = null;

@@ -198,7 +201,8 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
                    String format = segments.get(3);
                    if (format.equalsIgnoreCase(BluetoothMapContract.FILE_MSG_NO_ATTACHMENTS)) {
                        includeAttachments = false;
                    } else if(format.equalsIgnoreCase(BluetoothMapContract.FILE_MSG_DOWNLOAD_NO_ATTACHMENTS)) {
                    } else if (format.equalsIgnoreCase(
                            BluetoothMapContract.FILE_MSG_DOWNLOAD_NO_ATTACHMENTS)) {
                        includeAttachments = false;
                        download = true;
                    } else if (format.equalsIgnoreCase(BluetoothMapContract.FILE_MSG_DOWNLOAD)) {
@@ -244,7 +248,9 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
        } else {
            newUri = BluetoothMapContract.buildAccountUriwithId(mAuthority, accountId);
        }
        if(D) Log.d(TAG,"onAccountChanged() accountId = " + accountId + " URI: " + newUri);
        if (D) {
            Log.d(TAG, "onAccountChanged() accountId = " + accountId + " URI: " + newUri);
        }
        mResolver.notifyChange(newUri, null);
    }

@@ -266,14 +272,17 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
        if (accountId == null) {
            newUri = BluetoothMapContract.buildMessageUri(mAuthority);
        } else {
            if(messageId == null)
            {
            if (messageId == null) {
                newUri = BluetoothMapContract.buildMessageUri(mAuthority, accountId);
            } else {
                newUri = BluetoothMapContract.buildMessageUriWithId(mAuthority,accountId, messageId);
                newUri = BluetoothMapContract.buildMessageUriWithId(mAuthority, accountId,
                        messageId);
            }
        }
        if (D) {
            Log.d(TAG, "onMessageChanged() accountId = " + accountId + " messageId = " + messageId
                    + " URI: " + newUri);
        }
        if(D) Log.d(TAG,"onMessageChanged() accountId = " + accountId + " messageId = " + messageId + " URI: " + newUri);
        mResolver.notifyChange(newUri, null);
    }

@@ -318,8 +327,10 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
    @Override
    public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
        long callingId = Binder.clearCallingIdentity();
        if(D)Log.d(TAG, "openFile(): uri=" + uri.toString() + " - getLastPathSegment() = " +
                uri.getLastPathSegment());
        if (D) {
            Log.d(TAG, "openFile(): uri=" + uri.toString() + " - getLastPathSegment() = "
                    + uri.getLastPathSegment());
        }
        try {
            /* To be able to do abstraction of the file IO, we simply ignore the URI at this
             * point and let the read/write function implementations parse the URI. */
@@ -387,28 +398,35 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
     */
    @Override
    public int delete(Uri uri, String where, String[] selectionArgs) {
        if (D) Log.d(TAG, "delete(): uri=" + uri.toString() );
        if (D) {
            Log.d(TAG, "delete(): uri=" + uri.toString());
        }
        int result = 0;

        String table = uri.getPathSegments().get(1);
        if(table == null)
        if (table == null) {
            throw new IllegalArgumentException("Table missing in URI");
        }
        // the id of the entry to be deleted from the database
        String messageId = uri.getLastPathSegment();
        if (messageId == null)
        if (messageId == null) {
            throw new IllegalArgumentException("Message ID missing in update values!");
        }


        String accountId = getAccountId(uri);
        if (accountId == null)
        if (accountId == null) {
            throw new IllegalArgumentException("Account ID missing in update values!");
        }

        long callingId = Binder.clearCallingIdentity();
        try {
            if (table.equals(BluetoothMapContract.TABLE_MESSAGE)) {
                return deleteMessage(accountId, messageId);
            } else {
                if (D) Log.w(TAG, "Unknown table name: " + table);
                if (D) {
                    Log.w(TAG, "Unknown table name: " + table);
                }
                return result;
            }
        } finally {
@@ -446,12 +464,14 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {

        String id; // the id of the entry inserted into the database
        long callingId = Binder.clearCallingIdentity();
        Log.d(TAG, "insert(): uri=" + uri.toString() + " - getLastPathSegment() = " +
                uri.getLastPathSegment());
        Log.d(TAG, "insert(): uri=" + uri.toString() + " - getLastPathSegment() = "
                + uri.getLastPathSegment());
        try {
            if (table.equals(BluetoothMapContract.TABLE_MESSAGE)) {
                id = insertMessage(accountId, folderId.toString());
                if(D) Log.i(TAG, "insert() ID: " + id);
                if (D) {
                    Log.i(TAG, "insert() ID: " + id);
                }
                return Uri.parse(uri.toString() + "/" + id);
            } else {
                Log.w(TAG, "Unknown table name: " + table);
@@ -491,7 +511,8 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
    }

    /**
     * This query needs to map from the data used in the e-mail client to BluetoothMapContract type of data.
     * This query needs to map from the data used in the e-mail client to BluetoothMapContract
     * type of data.
     */
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
@@ -526,8 +547,8 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
     * @param sortOrder
     * @return a cursor to the accounts that are subject to exposure over BT.
     */
    protected abstract Cursor queryAccount(String[] projection, String selection, String[] selectionArgs,
            String sortOrder);
    protected abstract Cursor queryAccount(String[] projection, String selection,
            String[] selectionArgs, String sortOrder);

    /**
     * Filter out the non usable folders and ensure to name the mandatory folders
@@ -539,8 +560,9 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
     * @param sortOrder
     * @return
     */
    protected abstract Cursor queryFolder(String accountId, String[] projection, String selection, String[] selectionArgs,
            String sortOrder);
    protected abstract Cursor queryFolder(String accountId, String[] projection, String selection,
            String[] selectionArgs, String sortOrder);

    /**
     * For the message table the selection (where clause) can only include the following columns:
     *    date: less than, greater than and equals
@@ -559,8 +581,8 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
     * @param sortOrder
     * @return a cursor to query result
     */
    protected abstract Cursor queryMessage(String accountId, String[] projection, String selection, String[] selectionArgs,
            String sortOrder);
    protected abstract Cursor queryMessage(String accountId, String[] projection, String selection,
            String[] selectionArgs, String sortOrder);

    /**
     * update()
@@ -580,19 +602,23 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
            throw new IllegalArgumentException("Table missing in URI");
        }
        if (selection != null) {
            throw new IllegalArgumentException("selection shall not be used, ContentValues shall contain the data");
            throw new IllegalArgumentException(
                    "selection shall not be used, ContentValues shall contain the data");
        }

        long callingId = Binder.clearCallingIdentity();
        if(D)Log.w(TAG, "update(): uri=" + uri.toString() + " - getLastPathSegment() = " +
                uri.getLastPathSegment());
        if (D) {
            Log.w(TAG, "update(): uri=" + uri.toString() + " - getLastPathSegment() = "
                    + uri.getLastPathSegment());
        }
        try {
            if (table.equals(BluetoothMapContract.TABLE_ACCOUNT)) {
                String accountId = values.getAsString(BluetoothMapContract.AccountColumns._ID);
                if (accountId == null) {
                    throw new IllegalArgumentException("Account ID missing in update values!");
                }
                Integer exposeFlag = values.getAsInteger(BluetoothMapContract.AccountColumns.FLAG_EXPOSE);
                Integer exposeFlag =
                        values.getAsInteger(BluetoothMapContract.AccountColumns.FLAG_EXPOSE);
                if (exposeFlag == null) {
                    throw new IllegalArgumentException("Expose flag missing in update values!");
                }
@@ -606,10 +632,13 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
                    throw new IllegalArgumentException("Message ID missing in update values!");
                }
                Long folderId = values.getAsLong(BluetoothMapContract.MessageColumns.FOLDER_ID);
                Boolean flagRead = values.getAsBoolean(BluetoothMapContract.MessageColumns.FLAG_READ);
                Boolean flagRead =
                        values.getAsBoolean(BluetoothMapContract.MessageColumns.FLAG_READ);
                return updateMessage(accountId, messageId, folderId, flagRead);
            } else {
                if(D)Log.w(TAG, "Unknown table name: " + table);
                if (D) {
                    Log.w(TAG, "Unknown table name: " + table);
                }
                return 0;
            }
        } finally {
@@ -634,13 +663,17 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
     * @param flagRead the new flagRead value to set - ignore if null.
     * @return
     */
    protected abstract int updateMessage(String accountId, Long messageId, Long folderId, Boolean flagRead);
    protected abstract int updateMessage(String accountId, Long messageId, Long folderId,
            Boolean flagRead);


    @Override
    public Bundle call(String method, String arg, Bundle extras) {
        long callingId = Binder.clearCallingIdentity();
        if(D)Log.d(TAG, "call(): method=" + method + " arg=" + arg + "ThreadId: " + Thread.currentThread().getId());
        if (D) {
            Log.d(TAG, "call(): method=" + method + " arg=" + arg + "ThreadId: "
                    + Thread.currentThread().getId());
        }

        try {
            if (method.equals(BluetoothMapContract.METHOD_UPDATE_FOLDER)) {
+134 −110

File changed.

Preview size limit exceeded, changes collapsed.

+4 −3
Original line number Diff line number Diff line
@@ -98,8 +98,9 @@ public class BluetoothObexTransport implements ObexTransport {
    }

    public String getRemoteAddress() {
        if (mSocket == null)
        if (mSocket == null) {
            return null;
        }
        return mSocket.getRemoteDevice().getAddress();
    }

+27 −23
Original line number Diff line number Diff line
@@ -15,11 +15,6 @@

package com.android.bluetooth;

import java.io.IOException;

import javax.obex.HeaderSet;
import javax.obex.ServerRequestHandler;

import android.bluetooth.BluetoothSocket;
import android.os.Handler;
import android.os.Handler.Callback;
@@ -28,6 +23,11 @@ import android.os.Looper;
import android.os.Message;
import android.util.Log;

import java.io.IOException;

import javax.obex.HeaderSet;
import javax.obex.ServerRequestHandler;

/**
 * A simple ObexServer used to handle connection rejection in two cases:
 *  - A profile cannot handle a new connection, as it is already connected to another device.
@@ -65,7 +65,9 @@ public class ObexRejectServer extends ServerRequestHandler implements Callback {
    // OBEX operation handlers
    @Override
    public int onConnect(HeaderSet request, HeaderSet reply) {
        if(V) Log.i(TAG,"onConnect() returning error");
        if (V) {
            Log.i(TAG, "onConnect() returning error");
        }
        return mResult;
    }

@@ -82,7 +84,9 @@ public class ObexRejectServer extends ServerRequestHandler implements Callback {

    @Override
    public boolean handleMessage(Message msg) {
        if(V) Log.i(TAG,"Handling message ID: " + msg.what);
        if (V) {
            Log.i(TAG, "Handling message ID: " + msg.what);
        }
        switch (msg.what) {
            case MSG_ID_TIMEOUT:
                shutdown();
Loading