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

Commit 1d74166d authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Enabling plugins on Launcher debug builds

Test: Verified on device
Change-Id: I2cecf0a825c41ee8c528c669b0534b09aa16508d
parent 3f08df9f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -37,4 +37,9 @@ public interface PluginInitializer {
     * Called from {@link PluginManagerImpl#handleWtfs()}.
     */
    void handleWtfs();

    /**
     * Returns if pluging manager should run in debug mode.
     */
    boolean isDebuggable();
}
+1 −2
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -72,7 +71,7 @@ public class PluginInstanceManager<T extends Plugin> {
    PluginInstanceManager(Context context, String action, PluginListener<T> listener,
            boolean allowMultiple, Looper looper, VersionInfo version, PluginManagerImpl manager) {
        this(context, context.getPackageManager(), action, listener, allowMultiple, looper, version,
                manager, Build.IS_DEBUGGABLE, manager.getWhitelistedPlugins());
                manager, manager.isDebuggable(), manager.getWhitelistedPlugins());
    }

    @VisibleForTesting
+8 −6
Original line number Diff line number Diff line
@@ -64,8 +64,6 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
    private static final String TAG = PluginManagerImpl.class.getSimpleName();
    static final String DISABLE_PLUGIN = "com.android.systemui.action.DISABLE_PLUGIN";

    private static PluginManager sInstance;

    private final ArrayMap<PluginListener<?>, PluginInstanceManager> mPluginMap
            = new ArrayMap<>();
    private final Map<String, ClassLoader> mClassLoaders = new ArrayMap<>();
@@ -73,7 +71,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
    private final ArraySet<String> mWhitelistedPlugins = new ArraySet<>();
    private final Context mContext;
    private final PluginInstanceManagerFactory mFactory;
    private final boolean isDebuggable;
    private final boolean mIsDebuggable;
    private final PluginPrefs mPluginPrefs;
    private final PluginEnabler mPluginEnabler;
    private final PluginInitializer mPluginInitializer;
@@ -83,7 +81,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
    private Looper mLooper;

    public PluginManagerImpl(Context context, PluginInitializer initializer) {
        this(context, new PluginInstanceManagerFactory(), Build.IS_DEBUGGABLE,
        this(context, new PluginInstanceManagerFactory(), initializer.isDebuggable(),
                Thread.getUncaughtExceptionPreHandler(), initializer);
    }

@@ -93,7 +91,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
        mContext = context;
        mFactory = factory;
        mLooper = initializer.getBgLooper();
        isDebuggable = debuggable;
        mIsDebuggable = debuggable;
        mWhitelistedPlugins.addAll(Arrays.asList(initializer.getWhitelistedPlugins(mContext)));
        mPluginPrefs = new PluginPrefs(mContext);
        mPluginEnabler = initializer.getPluginEnabler(mContext);
@@ -111,6 +109,10 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
        });
    }

    public boolean isDebuggable() {
        return mIsDebuggable;
    }

    public String[] getWhitelistedPlugins() {
        return mWhitelistedPlugins.toArray(new String[0]);
    }
@@ -297,7 +299,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage

    /** Returns class loader specific for the given plugin. */
    public ClassLoader getClassLoader(ApplicationInfo appInfo) {
        if (!isDebuggable && !isPluginPackageWhitelisted(appInfo.packageName)) {
        if (!mIsDebuggable && !isPluginPackageWhitelisted(appInfo.packageName)) {
            Log.w(TAG, "Cannot get class loader for non-whitelisted plugin. Src:"
                    + appInfo.sourceDir + ", pkg: " + appInfo.packageName);
            return null;
+6 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
package com.android.systemui.plugins;

import android.content.Context;
import android.os.Build;
import android.os.Looper;
import android.util.Log;

@@ -67,4 +68,9 @@ public class PluginInitializerImpl implements PluginInitializer {
            });
        }
    }

    @Override
    public boolean isDebuggable() {
        return Build.IS_DEBUGGABLE;
    }
}