diff options
author | 2019-03-29 17:59:02 +0800 | |
---|---|---|
committer | 2019-04-01 15:37:54 +0800 | |
commit | 96f886be7ec7d4ff40e8186108ecec16f32d7e11 (patch) | |
tree | 43f4a5cdcd47f93f354a91522277a90da16e1845 | |
parent | f4de7ac6f26c05bfc48192d5bc090a0a30801f52 (diff) |
Optimize for debug log coding style.
Optimize for debug log coding style to following coding guideline.
Change-Id: I7077356b41f11914d4654285ab0959b943e47612
Fix: 123164197
Test: atest DocumentsUITests
27 files changed, 275 insertions, 95 deletions
diff --git a/src/com/android/documentsui/AbstractActionHandler.java b/src/com/android/documentsui/AbstractActionHandler.java index 86bd0a190..a01f3b08b 100644 --- a/src/com/android/documentsui/AbstractActionHandler.java +++ b/src/com/android/documentsui/AbstractActionHandler.java @@ -616,9 +616,11 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA contentsUri = DocumentsContract.setManageMode(contentsUri); } - if (DEBUG) Log.d(TAG, + if (DEBUG) { + Log.d(TAG, "Creating new directory loader for: " - + DocumentInfo.debugString(mState.stack.peek())); + + DocumentInfo.debugString(mState.stack.peek())); + } return new DirectoryLoader( mInjector.features, @@ -633,8 +635,10 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA @Override public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) { - if (DEBUG) Log.d(TAG, "Loader has finished for: " + if (DEBUG) { + Log.d(TAG, "Loader has finished for: " + DocumentInfo.debugString(mState.stack.peek())); + } assert(result != null); mInjector.getModel().update(result); diff --git a/src/com/android/documentsui/ActionModeController.java b/src/com/android/documentsui/ActionModeController.java index cec5fe848..754825006 100644 --- a/src/com/android/documentsui/ActionModeController.java +++ b/src/com/android/documentsui/ActionModeController.java @@ -75,13 +75,17 @@ public class ActionModeController extends SelectionObserver<String> mSelectionMgr.copySelection(mSelected); if (mSelected.size() > 0) { if (mActionMode == null) { - if (DEBUG) Log.d(TAG, "Starting action mode."); + if (DEBUG) { + Log.d(TAG, "Starting action mode."); + } mActionMode = mActivity.startActionMode(this); } updateActionMenu(); } else { if (mActionMode != null) { - if (DEBUG) Log.d(TAG, "Finishing action mode."); + if (DEBUG) { + Log.d(TAG, "Finishing action mode."); + } mActionMode.finish(); } } @@ -104,12 +108,16 @@ public class ActionModeController extends SelectionObserver<String> @Override public void onDestroyActionMode(ActionMode mode) { if (mActionMode == null) { - if (DEBUG) Log.w(TAG, "Received call to destroy action mode on alien mode object."); + if (DEBUG) { + Log.w(TAG, "Received call to destroy action mode on alien mode object."); + } } assert(mActionMode.equals(mode)); - if (DEBUG) Log.d(TAG, "Handling action mode destroyed."); + if (DEBUG) { + Log.d(TAG, "Handling action mode destroyed."); + } mActionMode = null; mMenu = null; diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java index f7d4fe0f6..fcdd02901 100644 --- a/src/com/android/documentsui/BaseActivity.java +++ b/src/com/android/documentsui/BaseActivity.java @@ -334,7 +334,9 @@ public abstract class BaseActivity private State getState(@Nullable Bundle icicle) { if (icicle != null) { State state = icicle.<State>getParcelable(Shared.EXTRA_STATE); - if (DEBUG) Log.d(mTag, "Recovered existing state object: " + state); + if (DEBUG) { + Log.d(mTag, "Recovered existing state object: " + state); + } return state; } @@ -354,7 +356,9 @@ public abstract class BaseActivity // Only show the toggle if advanced isn't forced enabled. state.showDeviceStorageOption = !Shared.mustShowDeviceRoot(intent); - if (DEBUG) Log.d(mTag, "Created new state object: " + state); + if (DEBUG) { + Log.d(mTag, "Created new state object: " + state); + } return state; } diff --git a/src/com/android/documentsui/FocusManager.java b/src/com/android/documentsui/FocusManager.java index 7a228ffe3..9d9f4c75b 100644 --- a/src/com/android/documentsui/FocusManager.java +++ b/src/com/android/documentsui/FocusManager.java @@ -143,7 +143,9 @@ public final class FocusManager extends FocusDelegate<String> implements FocusHa @Override public boolean focusDirectoryList() { if (!mScope.isValid() || mScope.adapter.getItemCount() == 0) { - if (DEBUG) Log.v(TAG, "Nothing to focus."); + if (DEBUG) { + Log.v(TAG, "Nothing to focus."); + } return false; } @@ -152,7 +154,9 @@ public final class FocusManager extends FocusDelegate<String> implements FocusHa // vs. Cut focused // item) if (mSelectionMgr.hasSelection()) { - if (DEBUG) Log.v(TAG, "Existing selection found. No focus will be done."); + if (DEBUG) { + Log.v(TAG, "Existing selection found. No focus will be done."); + } return false; } @@ -199,7 +203,9 @@ public final class FocusManager extends FocusDelegate<String> implements FocusHa @Override public void focusDocument(String modelId) { if (!mScope.isValid()) { - if (DEBUG) Log.v(TAG, "Invalid mScope. No focus will be done."); + if (DEBUG) { + Log.v(TAG, "Invalid mScope. No focus will be done."); + } return; } int pos = mScope.adapter.getAdapterPosition(modelId); diff --git a/src/com/android/documentsui/Model.java b/src/com/android/documentsui/Model.java index 9e258056a..b9c3d1d4d 100644 --- a/src/com/android/documentsui/Model.java +++ b/src/com/android/documentsui/Model.java @@ -113,7 +113,9 @@ public class Model { @VisibleForTesting public void update(DirectoryResult result) { assert(result != null); - if (DEBUG) Log.i(TAG, "Updating model with new result set."); + if (DEBUG) { + Log.i(TAG, "Updating model with new result set."); + } if (result.exception != null) { Log.e(TAG, "Error while loading directory contents", result.exception); @@ -177,13 +179,17 @@ public class Model { public @Nullable Cursor getItem(String modelId) { Integer pos = mPositions.get(modelId); if (pos == null) { - if (DEBUG) Log.d(TAG, "Unabled to find cursor position for modelId: " + modelId); + if (DEBUG) { + Log.d(TAG, "Unabled to find cursor position for modelId: " + modelId); + } return null; } if (!mCursor.moveToPosition(pos)) { - if (DEBUG) Log.d(TAG, + if (DEBUG) { + Log.d(TAG, "Unabled to move cursor to position " + pos + " for modelId: " + modelId); + } return null; } diff --git a/src/com/android/documentsui/SharedInputHandler.java b/src/com/android/documentsui/SharedInputHandler.java index b9a5b92c3..28eba70c9 100644 --- a/src/com/android/documentsui/SharedInputHandler.java +++ b/src/com/android/documentsui/SharedInputHandler.java @@ -116,7 +116,9 @@ public class SharedInputHandler { } if (mSelectionMgr.hasSelection()) { - if (DEBUG) Log.d(TAG, "Back pressed. Clearing existing selection."); + if (DEBUG) { + Log.d(TAG, "Back pressed. Clearing existing selection."); + } mSelectionMgr.clearSelection(); return true; } @@ -130,7 +132,9 @@ public class SharedInputHandler { } if (mSelectionMgr.hasSelection()) { - if (DEBUG) Log.d(TAG, "ESC pressed. Clearing existing selection."); + if (DEBUG) { + Log.d(TAG, "ESC pressed. Clearing existing selection."); + } mSelectionMgr.clearSelection(); return true; } diff --git a/src/com/android/documentsui/base/DocumentStack.java b/src/com/android/documentsui/base/DocumentStack.java index fee6ee3be..7f57ef8e3 100644 --- a/src/com/android/documentsui/base/DocumentStack.java +++ b/src/com/android/documentsui/base/DocumentStack.java @@ -125,13 +125,17 @@ public class DocumentStack implements Durable, Parcelable { public void push(DocumentInfo info) { checkArgument(!mList.contains(info)); - if (DEBUG) Log.d(TAG, "Adding doc to stack: " + info); + if (DEBUG) { + Log.d(TAG, "Adding doc to stack: " + info); + } mList.addLast(info); mStackTouched = true; } public DocumentInfo pop() { - if (DEBUG) Log.d(TAG, "Popping doc off stack."); + if (DEBUG) { + Log.d(TAG, "Popping doc off stack."); + } final DocumentInfo result = mList.removeLast(); mStackTouched = true; @@ -139,7 +143,9 @@ public class DocumentStack implements Durable, Parcelable { } public void popToRootDocument() { - if (DEBUG) Log.d(TAG, "Popping docs to root folder."); + if (DEBUG) { + Log.d(TAG, "Popping docs to root folder."); + } while (mList.size() > 1) { mList.removeLast(); } @@ -147,7 +153,9 @@ public class DocumentStack implements Durable, Parcelable { } public void changeRoot(RootInfo root) { - if (DEBUG) Log.d(TAG, "Root changed to: " + root); + if (DEBUG) { + Log.d(TAG, "Root changed to: " + root); + } reset(); mRoot = root; } @@ -178,7 +186,9 @@ public class DocumentStack implements Durable, Parcelable { * {@link #mRoot} instead of making a copy. */ public void reset(DocumentStack stack) { - if (DEBUG) Log.d(TAG, "Resetting the whole darn stack to: " + stack); + if (DEBUG) { + Log.d(TAG, "Resetting the whole darn stack to: " + stack); + } mList = stack.mList; mRoot = stack.mRoot; diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java index 205f696a3..748b0ae01 100644 --- a/src/com/android/documentsui/dirlist/DirectoryFragment.java +++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java @@ -573,13 +573,17 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On "Next scale " + nextScale + ", Min/max scale " + minScale + "/" + maxScale); if (nextScale > minScale && nextScale < maxScale) { - if (DEBUG) Log.d(TAG, "Updating grid scale: " + scale); + if (DEBUG) { + Log.d(TAG, "Updating grid scale: " + scale); + } mLiveScale = nextScale; updateLayout(mMode); } } else { - if (DEBUG) Log.d(TAG, "List mode, ignoring scale: " + scale); + if (DEBUG) { + Log.d(TAG, "List mode, ignoring scale: " + scale); + } mLiveScale = 1.0f; } } @@ -752,7 +756,9 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On return true; default: - if (DEBUG) Log.d(TAG, "Unhandled menu item selected: " + item); + if (DEBUG) { + Log.d(TAG, "Unhandled menu item selected: " + item); + } return false; } } @@ -1020,7 +1026,9 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On public static void showDirectory( FragmentManager fm, RootInfo root, DocumentInfo doc, int anim) { - if (DEBUG) Log.d(TAG, "Showing directory: " + DocumentInfo.debugString(doc)); + if (DEBUG) { + Log.d(TAG, "Showing directory: " + DocumentInfo.debugString(doc)); + } create(fm, root, doc, anim); } @@ -1095,7 +1103,9 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On @Override public void accept(Model.Update update) { - if (DEBUG) Log.d(TAG, "Received model update. Loading=" + mModel.isLoading()); + if (DEBUG) { + Log.d(TAG, "Received model update. Loading=" + mModel.isLoading()); + } mProgressBar.setVisibility(mModel.isLoading() ? View.VISIBLE : View.GONE); diff --git a/src/com/android/documentsui/dirlist/DragHost.java b/src/com/android/documentsui/dirlist/DragHost.java index c1f9c8cb0..b08637b2b 100644 --- a/src/com/android/documentsui/dirlist/DragHost.java +++ b/src/com/android/documentsui/dirlist/DragHost.java @@ -118,7 +118,9 @@ class DragHost<T extends Activity & AbstractActionHandler.CommonAddons> extends DocumentInfo dst = mDestinationLookup.lookup(v); if (dst == null) { - if (DEBUG) Log.d(TAG, "Invalid destination. Ignoring."); + if (DEBUG) { + Log.d(TAG, "Invalid destination. Ignoring."); + } return false; } diff --git a/src/com/android/documentsui/dirlist/DragStartListener.java b/src/com/android/documentsui/dirlist/DragStartListener.java index e88967573..8fe087229 100644 --- a/src/com/android/documentsui/dirlist/DragStartListener.java +++ b/src/com/android/documentsui/dirlist/DragStartListener.java @@ -105,13 +105,17 @@ interface DragStartListener { private boolean startDrag(@Nullable View view, MotionEvent event) { if (view == null) { - if (DEBUG) Log.d(TAG, "Ignoring drag event, null view."); + if (DEBUG) { + Log.d(TAG, "Ignoring drag event, null view."); + } return false; } @Nullable String modelId = mIdFinder.apply(view); if (modelId == null) { - if (DEBUG) Log.d(TAG, "Ignoring drag on view not represented in model."); + if (DEBUG) { + Log.d(TAG, "Ignoring drag on view not represented in model."); + } return false; } diff --git a/src/com/android/documentsui/files/ActionHandler.java b/src/com/android/documentsui/files/ActionHandler.java index 7e90000b3..b563b7ead 100644 --- a/src/com/android/documentsui/files/ActionHandler.java +++ b/src/com/android/documentsui/files/ActionHandler.java @@ -412,32 +412,44 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract // stack is initialized if it's restored from bundle, which means we're restoring a // previously stored state. if (mState.stack.isInitialized()) { - if (DEBUG) Log.d(TAG, "Stack already resolved for uri: " + intent.getData()); + if (DEBUG) { + Log.d(TAG, "Stack already resolved for uri: " + intent.getData()); + } restoreRootAndDirectory(); return; } if (launchToStackLocation(intent)) { - if (DEBUG) Log.d(TAG, "Launched to location from stack."); + if (DEBUG) { + Log.d(TAG, "Launched to location from stack."); + } return; } if (launchToRoot(intent)) { - if (DEBUG) Log.d(TAG, "Launched to root for browsing."); + if (DEBUG) { + Log.d(TAG, "Launched to root for browsing."); + } return; } if (launchToDocument(intent)) { - if (DEBUG) Log.d(TAG, "Launched to a document."); + if (DEBUG) { + Log.d(TAG, "Launched to a document."); + } return; } if (launchToDownloads(intent)) { - if (DEBUG) Log.d(TAG, "Launched to a downloads."); + if (DEBUG) { + Log.d(TAG, "Launched to a downloads."); + } return; } - if (DEBUG) Log.d(TAG, "Launching directly into Home directory."); + if (DEBUG) { + Log.d(TAG, "Launching directly into Home directory."); + } launchToDefaultLocation(); } @@ -481,13 +493,17 @@ public class ActionHandler<T extends FragmentActivity & Addons> extends Abstract if (Intent.ACTION_VIEW.equals(action)) { Uri uri = intent.getData(); if (DocumentsContract.isRootUri(mActivity, uri)) { - if (DEBUG) Log.d(TAG, "Launching with root URI."); + if (DEBUG) { + Log.d(TAG, "Launching with root URI."); + } // If we've got a specific root to display, restore that root using a dedicated // authority. That way a misbehaving provider won't result in an ANR. loadRoot(uri); return true; } else if (DocumentsContract.isRootsUri(mActivity, uri)) { - if (DEBUG) Log.d(TAG, "Launching first root with roots URI."); + if (DEBUG) { + Log.d(TAG, "Launching first root with roots URI."); + } // TODO: b/116760996 Let the user can disambiguate between roots if there are // multiple from DocumentsProvider instead of launching the first root in default loadFirstRoot(uri); diff --git a/src/com/android/documentsui/files/LauncherActivity.java b/src/com/android/documentsui/files/LauncherActivity.java index 6376094ee..8cd7dcbb8 100644 --- a/src/com/android/documentsui/files/LauncherActivity.java +++ b/src/com/android/documentsui/files/LauncherActivity.java @@ -103,12 +103,16 @@ public class LauncherActivity extends Activity { // Forward any flags from the original intent. intent.setFlags(getIntent().getFlags()); - if (DEBUG) Log.d(TAG, "Starting new task > " + intent.getData()); + if (DEBUG) { + Log.d(TAG, "Starting new task > " + intent.getData()); + } startActivity(intent); } private boolean restoreTask(Intent intent) { - if (DEBUG) Log.d(TAG, "Restoring existing task > " + intent.getData()); + if (DEBUG) { + Log.d(TAG, "Restoring existing task > " + intent.getData()); + } try { // TODO: This doesn't appear to restore a task once it has stopped running. startActivity(intent); diff --git a/src/com/android/documentsui/files/QuickViewIntentBuilder.java b/src/com/android/documentsui/files/QuickViewIntentBuilder.java index f7d757117..236a36c97 100644 --- a/src/com/android/documentsui/files/QuickViewIntentBuilder.java +++ b/src/com/android/documentsui/files/QuickViewIntentBuilder.java @@ -103,7 +103,9 @@ public final class QuickViewIntentBuilder { * be resolved; in this case {@code null} is returned. */ @Nullable public Intent build() { - if (DEBUG) Log.d(TAG, "Preparing intent for doc:" + mDocument.documentId); + if (DEBUG) { + Log.d(TAG, "Preparing intent for doc:" + mDocument.documentId); + } String trustedPkg = getQuickViewPackage(); @@ -126,7 +128,9 @@ public final class QuickViewIntentBuilder { for (int i = range.getLower(); i <= range.getUpper(); i++) { uri = uris.get(i); item = new ClipData.Item(uri); - if (DEBUG) Log.d(TAG, "Including file: " + uri); + if (DEBUG) { + Log.d(TAG, "Including file: " + uri); + } if (clipData == null) { clipData = new ClipData( "URIs", new String[] { ClipDescription.MIMETYPE_TEXT_URILIST }, @@ -186,17 +190,21 @@ public final class QuickViewIntentBuilder { cursor = mModel.getItem(siblingIds[i]); if (cursor == null) { - if (DEBUG) Log.d(TAG, + if (DEBUG) { + Log.d(TAG, "Unable to obtain cursor for sibling document, modelId: " - + siblingIds[i]); + + siblingIds[i]); + } continue; } mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE); if (Document.MIME_TYPE_DIR.equals(mimeType)) { - if (DEBUG) Log.d(TAG, + if (DEBUG) { + Log.d(TAG, "Skipping directory, not supported by quick view. modelId: " - + siblingIds[i]); + + siblingIds[i]); + } continue; } @@ -208,7 +216,9 @@ public final class QuickViewIntentBuilder { if (id.equals(mDocument.documentId)) { documentLocation = uris.size() - 1; // Position in "uris", not in the model. - if (DEBUG) Log.d(TAG, "Found starting point for QV. " + documentLocation); + if (DEBUG) { + Log.d(TAG, "Found starting point for QV. " + documentLocation); + } } } @@ -242,8 +252,10 @@ public final class QuickViewIntentBuilder { firstSibling = Math.max(0, lastSibling - MAX_DOCS_IN_INTENT + 1); } - if (DEBUG) Log.d(TAG, "Copmuted siblings from index: " + firstSibling + if (DEBUG) { + Log.d(TAG, "Copmuted siblings from index: " + firstSibling + " to: " + lastSibling); + } return new Range(firstSibling, lastSibling); } diff --git a/src/com/android/documentsui/picker/ActionHandler.java b/src/com/android/documentsui/picker/ActionHandler.java index ecac93a05..7318d5bc5 100644 --- a/src/com/android/documentsui/picker/ActionHandler.java +++ b/src/com/android/documentsui/picker/ActionHandler.java @@ -110,7 +110,9 @@ class ActionHandler<T extends FragmentActivity & Addons> extends AbstractActionH // stack is initialized if it's restored from bundle, which means we're restoring a // previously stored state. if (mState.stack.isInitialized()) { - if (DEBUG) Log.d(TAG, "Stack already resolved for uri: " + intent.getData()); + if (DEBUG) { + Log.d(TAG, "Stack already resolved for uri: " + intent.getData()); + } restoreRootAndDirectory(); return; } @@ -120,16 +122,22 @@ class ActionHandler<T extends FragmentActivity & Addons> extends AbstractActionH mActivity.setTitle(""); if (launchHomeForCopyDestination(intent)) { - if (DEBUG) Log.d(TAG, "Launching directly into Home directory for copy destination."); + if (DEBUG) { + Log.d(TAG, "Launching directly into Home directory for copy destination."); + } return; } if (mFeatures.isLaunchToDocumentEnabled() && launchToInitialUri(intent)) { - if (DEBUG) Log.d(TAG, "Launched to initial uri."); + if (DEBUG) { + Log.d(TAG, "Launched to initial uri."); + } return; } - if (DEBUG) Log.d(TAG, "Load last accessed stack."); + if (DEBUG) { + Log.d(TAG, "Load last accessed stack."); + } loadLastAccessedStack(); } @@ -167,7 +175,9 @@ class ActionHandler<T extends FragmentActivity & Addons> extends AbstractActionH } private void loadLastAccessedStack() { - if (DEBUG) Log.d(TAG, "Attempting to load last used stack for calling package."); + if (DEBUG) { + Log.d(TAG, "Attempting to load last used stack for calling package."); + } new LoadLastAccessedStackTask<>( mActivity, mLastAccessed, mState, mProviders, this::onLastAccessedStackLoaded) .execute(); @@ -237,7 +247,9 @@ class ActionHandler<T extends FragmentActivity & Addons> extends AbstractActionH @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (DEBUG) Log.d(TAG, "onActivityResult() code=" + resultCode); + if (DEBUG) { + Log.d(TAG, "onActivityResult() code=" + resultCode); + } // Only relay back results when not canceled; otherwise stick around to // let the user pick another app/backend. @@ -411,7 +423,9 @@ class ActionHandler<T extends FragmentActivity & Addons> extends AbstractActionH } private void onPickFinished(Uri... uris) { - if (DEBUG) Log.d(TAG, "onFinished() " + Arrays.toString(uris)); + if (DEBUG) { + Log.d(TAG, "onFinished() " + Arrays.toString(uris)); + } final Intent intent = new Intent(); if (uris.length == 1) { diff --git a/src/com/android/documentsui/queries/CommandInterceptor.java b/src/com/android/documentsui/queries/CommandInterceptor.java index 211333059..4119f14b6 100644 --- a/src/com/android/documentsui/queries/CommandInterceptor.java +++ b/src/com/android/documentsui/queries/CommandInterceptor.java @@ -63,7 +63,9 @@ public final class CommandInterceptor implements EventHandler<String> { } if (!mFeatures.isCommandInterceptorEnabled()) { - if (DEBUG) Log.v(TAG, "Skipping input, command interceptor disabled."); + if (DEBUG) { + Log.v(TAG, "Skipping input, command interceptor disabled."); + } return false; } diff --git a/src/com/android/documentsui/queries/SearchViewManager.java b/src/com/android/documentsui/queries/SearchViewManager.java index 1763fbf0c..fd6499c5c 100644 --- a/src/com/android/documentsui/queries/SearchViewManager.java +++ b/src/com/android/documentsui/queries/SearchViewManager.java @@ -245,7 +245,9 @@ public class SearchViewManager implements */ public void update(DocumentStack stack) { if (mMenuItem == null) { - if (DEBUG) Log.d(TAG, "update called before Search MenuItem installed."); + if (DEBUG) { + Log.d(TAG, "update called before Search MenuItem installed."); + } return; } @@ -287,7 +289,9 @@ public class SearchViewManager implements } if (mMenuItem == null) { - if (DEBUG) Log.d(TAG, "showMenu called before Search MenuItem installed."); + if (DEBUG) { + Log.d(TAG, "showMenu called before Search MenuItem installed."); + } return; } diff --git a/src/com/android/documentsui/roots/LoadRootTask.java b/src/com/android/documentsui/roots/LoadRootTask.java index 8e2479e79..a146090b2 100644 --- a/src/com/android/documentsui/roots/LoadRootTask.java +++ b/src/com/android/documentsui/roots/LoadRootTask.java @@ -46,7 +46,9 @@ public class LoadRootTask<T extends Activity & CommonAddons> @Override protected RootInfo run(Void... params) { - if (DEBUG) Log.d(TAG, "Loading root: " + mRootUri); + if (DEBUG) { + Log.d(TAG, "Loading root: " + mRootUri); + } return mProviders.getRootOneshot(mRootUri.getAuthority(), getRootId(mRootUri)); } @@ -54,7 +56,9 @@ public class LoadRootTask<T extends Activity & CommonAddons> @Override protected void finish(RootInfo root) { if (root != null) { - if (DEBUG) Log.d(TAG, "Loaded root: " + root); + if (DEBUG) { + Log.d(TAG, "Loaded root: " + root); + } mOwner.onRootPicked(root); } else { Log.w(TAG, "Failed to find root: " + mRootUri); diff --git a/src/com/android/documentsui/roots/ProvidersAccess.java b/src/com/android/documentsui/roots/ProvidersAccess.java index 3b6ebc887..aa4b530d9 100644 --- a/src/com/android/documentsui/roots/ProvidersAccess.java +++ b/src/com/android/documentsui/roots/ProvidersAccess.java @@ -139,7 +139,9 @@ public interface ProvidersAccess { matching.add(root); } - if (DEBUG) Log.d(tag, "Matched roots: " + matching); + if (DEBUG) { + Log.d(tag, "Matched roots: " + matching); + } return matching; } } diff --git a/src/com/android/documentsui/roots/ProvidersCache.java b/src/com/android/documentsui/roots/ProvidersCache.java index 243c2cf28..bd3ca1f44 100644 --- a/src/com/android/documentsui/roots/ProvidersCache.java +++ b/src/com/android/documentsui/roots/ProvidersCache.java @@ -130,7 +130,9 @@ public class ProvidersCache implements ProvidersAccess { Log.w(TAG, "Received onChange event for null uri. Skipping."); return; } - if (DEBUG) Log.i(TAG, "Updating roots due to change at " + uri); + if (DEBUG) { + Log.i(TAG, "Updating roots due to change at " + uri); + } updateAuthorityAsync(uri.getAuthority()); } } @@ -229,7 +231,9 @@ public class ProvidersCache implements ProvidersAccess { if (!mStoppedAuthorities.contains(authority)) { return; } - if (DEBUG) Log.d(TAG, "Loading stopped authority " + authority); + if (DEBUG) { + Log.d(TAG, "Loading stopped authority " + authority); + } mRoots.replaceValues(authority, loadRootsForAuthority(resolver, authority, true)); mStoppedAuthorities.remove(authority); } diff --git a/src/com/android/documentsui/services/CopyJob.java b/src/com/android/documentsui/services/CopyJob.java index 47f926278..5502e0a5a 100644 --- a/src/com/android/documentsui/services/CopyJob.java +++ b/src/com/android/documentsui/services/CopyJob.java @@ -215,9 +215,11 @@ class CopyJob extends ResolvedResourcesJob { for (int i = 0; i < mResolvedDocs.size() && !isCanceled(); ++i) { srcInfo = mResolvedDocs.get(i); - if (DEBUG) Log.d(TAG, + if (DEBUG) { + Log.d(TAG, "Copying " + srcInfo.displayName + " (" + srcInfo.derivedUri + ")" - + " to " + mDstInfo.displayName + " (" + mDstInfo.derivedUri + ")"); + + " to " + mDstInfo.displayName + " (" + mDstInfo.derivedUri + ")"); + } try { // Copying recursively to itself or one of descendants is not allowed. @@ -242,9 +244,11 @@ class CopyJob extends ResolvedResourcesJob { */ boolean checkSpace() { if (!mProgressTracker.hasRequiredBytes()) { - if (DEBUG) Log.w(TAG, + if (DEBUG) { + Log.w(TAG, "Proceeding copy without knowing required space, files or directories may " - + "empty or failed to compute required bytes."); + + "empty or failed to compute required bytes."); + } return true; } return verifySpaceAvailable(mProgressTracker.getRequiredBytes()); @@ -336,7 +340,9 @@ class CopyJob extends ResolvedResourcesJob { } // If optimized copy fails, then fallback to byte-by-byte copy. - if (DEBUG) Log.d(TAG, "Fallback to byte-by-byte copy for: " + src.derivedUri); + if (DEBUG) { + Log.d(TAG, "Fallback to byte-by-byte copy for: " + src.derivedUri); + } } } @@ -354,7 +360,9 @@ class CopyJob extends ResolvedResourcesJob { final String dstMimeType; final String dstDisplayName; - if (DEBUG) Log.d(TAG, "Doing byte copy of document: " + src); + if (DEBUG) { + Log.d(TAG, "Doing byte copy of document: " + src); + } // If the file is virtual, but can be converted to another format, then try to copy it // as such format. Also, append an extension for the target mime type (if known). if (src.isVirtual()) { @@ -569,7 +577,9 @@ class CopyJob extends ResolvedResourcesJob { makeCopyProgress(delta); }); } catch (OperationCanceledException e) { - if (DEBUG) Log.d(TAG, "Canceled copy mid-copy of: " + src.derivedUri); + if (DEBUG) { + Log.d(TAG, "Canceled copy mid-copy of: " + src.derivedUri); + } return; } @@ -616,7 +626,9 @@ class CopyJob extends ResolvedResourcesJob { } } - if (DEBUG) Log.d(TAG, "Cleaning up failed operation leftovers."); + if (DEBUG) { + Log.d(TAG, "Cleaning up failed operation leftovers."); + } mSignal.cancel(); try { deleteDocument(dest, destParent); diff --git a/src/com/android/documentsui/services/DeleteJob.java b/src/com/android/documentsui/services/DeleteJob.java index b918ab73a..38b8288cd 100644 --- a/src/com/android/documentsui/services/DeleteJob.java +++ b/src/com/android/documentsui/services/DeleteJob.java @@ -112,7 +112,9 @@ final class DeleteJob extends ResolvedResourcesJob { } for (DocumentInfo doc : mResolvedDocs) { - if (DEBUG) Log.d(TAG, "Deleting document @ " + doc.derivedUri); + if (DEBUG) { + Log.d(TAG, "Deleting document @ " + doc.derivedUri); + } try { deleteDocument(doc, parentDoc); } catch (ResourceException e) { diff --git a/src/com/android/documentsui/services/FileOperationService.java b/src/com/android/documentsui/services/FileOperationService.java index b70c0d1a7..ca6166a7c 100644 --- a/src/com/android/documentsui/services/FileOperationService.java +++ b/src/com/android/documentsui/services/FileOperationService.java @@ -163,7 +163,9 @@ public class FileOperationService extends Service implements Job.Listener { features = new Features.RuntimeFeatures(getResources(), userManager); setUpNotificationChannel(); - if (DEBUG) Log.d(TAG, "Created."); + if (DEBUG) { + Log.d(TAG, "Created."); + } mPowerManager = getSystemService(PowerManager.class); } @@ -179,7 +181,9 @@ public class FileOperationService extends Service implements Job.Listener { @Override public void onDestroy() { - if (DEBUG) Log.d(TAG, "Shutting down executor."); + if (DEBUG) { + Log.d(TAG, "Shutting down executor."); + } List<Runnable> unfinishedCopies = executor.shutdownNow(); List<Runnable> unfinishedDeletions = deletionExecutor.shutdownNow(); @@ -195,7 +199,9 @@ public class FileOperationService extends Service implements Job.Listener { deletionExecutor = null; handler = null; - if (DEBUG) Log.d(TAG, "Destroyed."); + if (DEBUG) { + Log.d(TAG, "Destroyed."); + } } @Override @@ -206,7 +212,9 @@ public class FileOperationService extends Service implements Job.Listener { String jobId = intent.getStringExtra(EXTRA_JOB_ID); assert(jobId != null); - if (DEBUG) Log.d(TAG, "onStartCommand: " + jobId + " with serviceId " + serviceId); + if (DEBUG) { + Log.d(TAG, "onStartCommand: " + jobId + " with serviceId " + serviceId); + } if (intent.hasExtra(EXTRA_CANCEL)) { handleCancel(intent); @@ -240,7 +248,9 @@ public class FileOperationService extends Service implements Job.Listener { } assert (job != null); - if (DEBUG) Log.d(TAG, "Scheduling job " + job.id + "."); + if (DEBUG) { + Log.d(TAG, "Scheduling job " + job.id + "."); + } Future<?> future = getExecutorService(operation.getOpType()).submit(job); mJobs.put(jobId, new JobRecord(job, future)); @@ -262,7 +272,9 @@ public class FileOperationService extends Service implements Job.Listener { String jobId = intent.getStringExtra(EXTRA_JOB_ID); - if (DEBUG) Log.d(TAG, "handleCancel: " + jobId); + if (DEBUG) { + Log.d(TAG, "handleCancel: " + jobId); + } synchronized (mJobs) { // Do nothing if the cancelled ID doesn't match the current job ID. This prevents racey @@ -301,7 +313,9 @@ public class FileOperationService extends Service implements Job.Listener { @GuardedBy("mJobs") private void deleteJob(Job job) { - if (DEBUG) Log.d(TAG, "deleteJob: " + job.id); + if (DEBUG) { + Log.d(TAG, "deleteJob: " + job.id); + } // Release wake lock before clearing jobs just in case we fail to clean them up. mWakeLock.release(); @@ -322,14 +336,18 @@ public class FileOperationService extends Service implements Job.Listener { * message. Thread pool is deal with in onDestroy. */ private void shutdown() { - if (DEBUG) Log.d(TAG, "Shutting down. Last serviceId was " + mLastServiceId); + if (DEBUG) { + Log.d(TAG, "Shutting down. Last serviceId was " + mLastServiceId); + } assert(mWakeLock == null); // Turns out, for us, stopSelfResult always returns false in tests, // so we can't guard executor shutdown. For this reason we move // executor shutdown to #onDestroy. boolean gonnaStop = stopSelfResult(mLastServiceId); - if (DEBUG) Log.d(TAG, "Stopping service: " + gonnaStop); + if (DEBUG) { + Log.d(TAG, "Stopping service: " + gonnaStop); + } if (!gonnaStop) { Log.w(TAG, "Service should be stopping, but reports otherwise."); } @@ -342,18 +360,24 @@ public class FileOperationService extends Service implements Job.Listener { @Override public void onStart(Job job) { - if (DEBUG) Log.d(TAG, "onStart: " + job.id); + if (DEBUG) { + Log.d(TAG, "onStart: " + job.id); + } Notification notification = job.getSetupNotification(); // If there is no foreground job yet, set this job to foreground job. synchronized (mJobs) { if (mForegroundJob == null) { - if (DEBUG) Log.d(TAG, "Set foreground job to " + job.id); + if (DEBUG) { + Log.d(TAG, "Set foreground job to " + job.id); + } mForegroundJob = job; foregroundManager.startForeground(NOTIFICATION_ID_PROGRESS, notification); } else { // Show start up notification - if (DEBUG) Log.d(TAG, "Posting notification for " + job.id); + if (DEBUG) { + Log.d(TAG, "Posting notification for " + job.id); + } notificationManager.notify( mForegroundJob == job ? null : job.id, NOTIFICATION_ID_PROGRESS, @@ -369,7 +393,9 @@ public class FileOperationService extends Service implements Job.Listener { @Override public void onFinished(Job job) { assert(job.isFinished()); - if (DEBUG) Log.d(TAG, "onFinished: " + job.id); + if (DEBUG) { + Log.d(TAG, "onFinished: " + job.id); + } synchronized (mJobs) { // Delete the job from mJobs first to avoid this job being selected as the foreground @@ -403,12 +429,16 @@ public class FileOperationService extends Service implements Job.Listener { if (mForegroundJob == job) { mForegroundJob = candidate; if (candidate == null) { - if (DEBUG) Log.d(TAG, "Stop foreground"); + if (DEBUG) { + Log.d(TAG, "Stop foreground"); + } // Remove the notification here just in case we're torn down before we have the // chance to clean up notifications. foregroundManager.stopForeground(true); } else { - if (DEBUG) Log.d(TAG, "Switch foreground job to " + candidate.id); + if (DEBUG) { + Log.d(TAG, "Switch foreground job to " + candidate.id); + } notificationManager.cancel(candidate.id, NOTIFICATION_ID_PROGRESS); Notification notification = (candidate.getState() == Job.STATE_STARTED) @@ -421,7 +451,9 @@ public class FileOperationService extends Service implements Job.Listener { private void cleanUpNotification(Job job) { - if (DEBUG) Log.d(TAG, "Canceling notification for " + job.id); + if (DEBUG) { + Log.d(TAG, "Canceling notification for " + job.id); + } // Dismiss the ongoing copy notification when the copy is done. notificationManager.cancel(job.id, NOTIFICATION_ID_PROGRESS); @@ -437,7 +469,9 @@ public class FileOperationService extends Service implements Job.Listener { } if (job.hasWarnings()) { - if (DEBUG) Log.d(TAG, "Job finished with warnings."); + if (DEBUG) { + Log.d(TAG, "Job finished with warnings."); + } notificationManager.notify( job.id, NOTIFICATION_ID_WARNING, job.getWarningNotification()); } diff --git a/src/com/android/documentsui/services/FileOperations.java b/src/com/android/documentsui/services/FileOperations.java index 5c9c62b37..e8a2c354f 100644 --- a/src/com/android/documentsui/services/FileOperations.java +++ b/src/com/android/documentsui/services/FileOperations.java @@ -58,7 +58,9 @@ public final class FileOperations { public static String start(Context context, FileOperation operation, Callback callback, @Nullable String jobId) { - if (DEBUG) Log.d(TAG, "Handling generic 'start' call."); + if (DEBUG) { + Log.d(TAG, "Handling generic 'start' call."); + } String newJobId = jobId != null ? jobId : createJobId(); Intent intent = createBaseIntent(context, newJobId, operation); @@ -74,7 +76,9 @@ public final class FileOperations { @VisibleForTesting public static void cancel(Activity activity, String jobId) { - if (DEBUG) Log.d(TAG, "Attempting to canceling operation: " + jobId); + if (DEBUG) { + Log.d(TAG, "Attempting to canceling operation: " + jobId); + } Intent intent = new Intent(activity, FileOperationService.class); intent.putExtra(EXTRA_CANCEL, true); diff --git a/src/com/android/documentsui/services/MoveJob.java b/src/com/android/documentsui/services/MoveJob.java index 36887e02c..faccedb51 100644 --- a/src/com/android/documentsui/services/MoveJob.java +++ b/src/com/android/documentsui/services/MoveJob.java @@ -162,7 +162,9 @@ final class MoveJob extends CopyJob { + " due to an exception: ", e); } // If optimized move fails, then fallback to byte-by-byte copy. - if (DEBUG) Log.d(TAG, "Fallback to byte-by-byte move for: " + src.derivedUri); + if (DEBUG) { + Log.d(TAG, "Fallback to byte-by-byte move for: " + src.derivedUri); + } } } diff --git a/src/com/android/documentsui/sidebar/RootsFragment.java b/src/com/android/documentsui/sidebar/RootsFragment.java index 4b7274725..e438b3c2e 100644 --- a/src/com/android/documentsui/sidebar/RootsFragment.java +++ b/src/com/android/documentsui/sidebar/RootsFragment.java @@ -497,7 +497,9 @@ public class RootsFragment extends Fragment { mActionHandler.openSettings(rootItem.root); return true; default: - if (DEBUG) Log.d(TAG, "Unhandled menu item selected: " + item); + if (DEBUG) { + Log.d(TAG, "Unhandled menu item selected: " + item); + } return false; } } diff --git a/src/com/android/documentsui/sidebar/SpacerItem.java b/src/com/android/documentsui/sidebar/SpacerItem.java index 66c814db5..4ca466e57 100644 --- a/src/com/android/documentsui/sidebar/SpacerItem.java +++ b/src/com/android/documentsui/sidebar/SpacerItem.java @@ -48,6 +48,8 @@ class SpacerItem extends Item { @Override void open() { - if (DEBUG) Log.d(TAG, "Ignoring click/hover on spacer item."); + if (DEBUG) { + Log.d(TAG, "Ignoring click/hover on spacer item."); + } } } diff --git a/src/com/android/documentsui/sorting/SortModel.java b/src/com/android/documentsui/sorting/SortModel.java index 48084ece4..09a027c82 100644 --- a/src/com/android/documentsui/sorting/SortModel.java +++ b/src/com/android/documentsui/sorting/SortModel.java @@ -356,7 +356,9 @@ public class SortModel implements Parcelable { if (!mIsUserSpecified) { SortDimension dimension = mDimensions.get(mDefaultDimensionId); if (dimension == null) { - if (DEBUG) Log.d(TAG, "No default sort dimension."); + if (DEBUG) { + Log.d(TAG, "No default sort dimension."); + } return; } |