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

Commit 58f9d475 authored by jruesga's avatar jruesga
Browse files

Extract destroy method of console. Remove :main from process name.

parent 1c696439
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,6 @@
    android:description="@string/app_description"
    android:description="@string/app_description"
    android:icon="@drawable/ic_launcher"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:label="@string/app_name"
    android:process=":main"
    android:largeHeap="true"
    android:largeHeap="true"
    android:theme="@style/Explorer.Theme.Holo.Ligth" >
    android:theme="@style/Explorer.Theme.Holo.Ligth" >


+50 −13
Original line number Original line Diff line number Diff line
@@ -51,7 +51,7 @@ public final class ExplorerApplication extends Application {
     * A constant that contains the main process name.
     * A constant that contains the main process name.
     * @hide
     * @hide
     */
     */
    public static final String MAIN_PROCESS = "com.cyanogenmod.explorer:main"; //$NON-NLS-1$
    public static final String MAIN_PROCESS = "com.cyanogenmod.explorer"; //$NON-NLS-1$


    //Static resources
    //Static resources
    private static ExplorerApplication sApp;
    private static ExplorerApplication sApp;
@@ -153,7 +153,7 @@ public final class ExplorerApplication extends Application {
            /**NON BLOCK**/
            /**NON BLOCK**/
        }
        }
        try {
        try {
            sBackgroundConsole.dispose();
            destroyBackgroundConsole();
        } catch (Throwable ex) {
        } catch (Throwable ex) {
            /**NON BLOCK**/
            /**NON BLOCK**/
        }
        }
@@ -186,17 +186,8 @@ public final class ExplorerApplication extends Application {
        FileHelper.ROOT_DIRECTORY = getString(R.string.root_dir);
        FileHelper.ROOT_DIRECTORY = getString(R.string.root_dir);
        Preferences.loadDefaults();
        Preferences.loadDefaults();


        //Create a non-privileged console for background non-privileged tasks
        //Create a console for background tasks
        try {
        allocBackgroundConsole(getApplicationContext());
            sBackgroundConsole =
                    new ConsoleHolder(
                            ConsoleBuilder.createNonPrivilegedConsole(
                                    getApplicationContext(), FileHelper.ROOT_DIRECTORY));
        } catch (Exception e) {
            Log.e(TAG,
                    "Background console creation failed. " +  //$NON-NLS-1$
                    "This probably will cause a force close.", e); //$NON-NLS-1$
        }


        //Force the load of mime types
        //Force the load of mime types
        try {
        try {
@@ -222,9 +213,55 @@ public final class ExplorerApplication extends Application {
     * @return Console The background console
     * @return Console The background console
     */
     */
    public static Console getBackgroundConsole() {
    public static Console getBackgroundConsole() {
        if (!sBackgroundConsole.getConsole().isActive()) {
            allocBackgroundConsole(getInstance().getApplicationContext());
        }
        return sBackgroundConsole.getConsole();
        return sBackgroundConsole.getConsole();
    }
    }


    /**
     * Method that destroy the background console
     */
    public static void destroyBackgroundConsole() {
        try {
            sBackgroundConsole.dispose();
        } catch (Throwable ex) {
            /**NON BLOCK**/
        }
    }

    /**
     * Method that allocate a new background console
     * 
     * @param ctx The current context
     */
    private static synchronized void allocBackgroundConsole(Context ctx) {
        try {
            // Dispose the current console
            if (sBackgroundConsole != null) {
                sBackgroundConsole.dispose();
                sBackgroundConsole = null;
            }

            //Create a console for background tasks
            if (ConsoleBuilder.isPrivileged()) {
                sBackgroundConsole =
                        new ConsoleHolder(
                                ConsoleBuilder.createPrivilegedConsole(
                                        ctx, FileHelper.ROOT_DIRECTORY));
            } else {
                sBackgroundConsole =
                        new ConsoleHolder(
                                ConsoleBuilder.createNonPrivilegedConsole(
                                        ctx, FileHelper.ROOT_DIRECTORY));
            }
        } catch (Exception e) {
            Log.e(TAG,
                    "Background console creation failed. " +  //$NON-NLS-1$
                    "This probably will cause a force close.", e); //$NON-NLS-1$
        }
    }

    /**
    /**
     * Method that changes the background console to a privileged console
     * Method that changes the background console to a privileged console
     *
     *