OSDN Git Service

Fixed ANR associated with SecureStorage
authorherriojr <jherriott@cyngn.com>
Tue, 4 Aug 2015 22:01:02 +0000 (15:01 -0700)
committerherriojr <jherriott@cyngn.com>
Wed, 5 Aug 2015 23:58:20 +0000 (16:58 -0700)
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

src/com/cyanogenmod/filemanager/activities/NavigationActivity.java
src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java

index d65568f..9ca3602 100755 (executable)
@@ -2345,27 +2345,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);
@@ -2374,17 +2361,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();
index 6713f1d..de4cf75 100755 (executable)
@@ -282,7 +282,7 @@ public final class CopyMoveActionPolicy extends ActionsPolicy {
             }
             @Override
             public boolean isDialogCancellable() {
-                return true;
+                return false;
             }
 
             @Override