From 86efb31b8bde6894f0ca0ac5e57c35807755ba79 Mon Sep 17 00:00:00 2001 From: herriojr Date: Tue, 4 Aug 2015 15:01:02 -0700 Subject: Fixed ANR associated with SecureStorage An ANR was happening on SecureConsole when a very large item was added, canceled, and click the parent in the Secure folder. This is caused by the locking mechanism used by SecureConsole. Consoles, long-term, need to be refactored to not synchronize on the SecureConsole object itself during execute. The only fix we can do without full refactoring is to not allow cancelling the operation because the Console doesn't support the cancel operation. Change-Id: I845372567b8656d63192bfde27952240915ecfe6 Ticket: QRDL-971 (cherry picked from commit ddb22bba80ce56ca77eca2faeace1d33aff85cc1) --- .../filemanager/activities/NavigationActivity.java | 37 ++++++++++------------ .../ui/policy/CopyMoveActionPolicy.java | 2 +- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java index 0751c2e9..100330bf 100644 --- a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java +++ b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java @@ -2323,27 +2323,14 @@ public class NavigationActivity extends Activity return false; } - /** - * Method that opens the actions dialog - * - * @param item The path or the {@link FileSystemObject} - * @param global If the menu to display is the one with global actions - */ - private void openActionsDialog(Object item, boolean global) { - // Resolve the full path - String path = String.valueOf(item); - if (item instanceof FileSystemObject) { - path = ((FileSystemObject)item).getFullPath(); - } - - // Prior to show the dialog, refresh the item reference + private void openActionsDialog(String path, boolean global) { FileSystemObject fso = null; try { fso = CommandHelper.getFileInfo(this, path, false, null); if (fso == null) { throw new NoSuchFileOrDirectory(path); } - + openActionsDialog(fso, global); } catch (Exception e) { // Notify the user ExceptionUtil.translateException(this, e); @@ -2352,17 +2339,25 @@ public class NavigationActivity extends Activity if (e instanceof FileNotFoundException || e instanceof NoSuchFileOrDirectory) { // If have a FileSystemObject reference then there is no need to search // the path (less resources used) - if (item instanceof FileSystemObject) { - getCurrentNavigationView().removeItem((FileSystemObject)item); - } else { - getCurrentNavigationView().removeItem((String)item); - } + getCurrentNavigationView().removeItem(path); } return; } + } + + /** + * Method that opens the actions dialog + * + * @param item The path or the {@link FileSystemObject} + * @param global If the menu to display is the one with global actions + */ + private void openActionsDialog(FileSystemObject item, boolean global) { + // We used to refresh the item reference here, but the access to the SecureConsole is synchronized, + // which can/will cause on ANR in certain scenarios. We don't care if it doesn't exist anymore really + // For this to work, SecureConsole NEEDS to be refactored. // Show the dialog - ActionsDialog dialog = new ActionsDialog(this, this, fso, global, false); + ActionsDialog dialog = new ActionsDialog(this, this, item, global, false); dialog.setOnRequestRefreshListener(this); dialog.setOnSelectionListener(getCurrentNavigationView()); dialog.show(); diff --git a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java index 6713f1d5..de4cf75f 100755 --- a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java +++ b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java @@ -282,7 +282,7 @@ public final class CopyMoveActionPolicy extends ActionsPolicy { } @Override public boolean isDialogCancellable() { - return true; + return false; } @Override -- cgit v1.2.3