Merge "Enabling plugins on Launcher debug builds" into sc-dev am: 620f53fe30
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13419087 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I7ae2209da18721154811a645c7a34d49e6b235ba
This commit is contained in:
@@ -37,4 +37,9 @@ public interface PluginInitializer {
|
|||||||
* Called from {@link PluginManagerImpl#handleWtfs()}.
|
* Called from {@link PluginManagerImpl#handleWtfs()}.
|
||||||
*/
|
*/
|
||||||
void handleWtfs();
|
void handleWtfs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if pluging manager should run in debug mode.
|
||||||
|
*/
|
||||||
|
boolean isDebuggable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@@ -72,7 +71,7 @@ public class PluginInstanceManager<T extends Plugin> {
|
|||||||
PluginInstanceManager(Context context, String action, PluginListener<T> listener,
|
PluginInstanceManager(Context context, String action, PluginListener<T> listener,
|
||||||
boolean allowMultiple, Looper looper, VersionInfo version, PluginManagerImpl manager) {
|
boolean allowMultiple, Looper looper, VersionInfo version, PluginManagerImpl manager) {
|
||||||
this(context, context.getPackageManager(), action, listener, allowMultiple, looper, version,
|
this(context, context.getPackageManager(), action, listener, allowMultiple, looper, version,
|
||||||
manager, Build.IS_DEBUGGABLE, manager.getWhitelistedPlugins());
|
manager, manager.isDebuggable(), manager.getWhitelistedPlugins());
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
|||||||
private static final String TAG = PluginManagerImpl.class.getSimpleName();
|
private static final String TAG = PluginManagerImpl.class.getSimpleName();
|
||||||
static final String DISABLE_PLUGIN = "com.android.systemui.action.DISABLE_PLUGIN";
|
static final String DISABLE_PLUGIN = "com.android.systemui.action.DISABLE_PLUGIN";
|
||||||
|
|
||||||
private static PluginManager sInstance;
|
|
||||||
|
|
||||||
private final ArrayMap<PluginListener<?>, PluginInstanceManager> mPluginMap
|
private final ArrayMap<PluginListener<?>, PluginInstanceManager> mPluginMap
|
||||||
= new ArrayMap<>();
|
= new ArrayMap<>();
|
||||||
private final Map<String, ClassLoader> mClassLoaders = 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 ArraySet<String> mWhitelistedPlugins = new ArraySet<>();
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final PluginInstanceManagerFactory mFactory;
|
private final PluginInstanceManagerFactory mFactory;
|
||||||
private final boolean isDebuggable;
|
private final boolean mIsDebuggable;
|
||||||
private final PluginPrefs mPluginPrefs;
|
private final PluginPrefs mPluginPrefs;
|
||||||
private final PluginEnabler mPluginEnabler;
|
private final PluginEnabler mPluginEnabler;
|
||||||
private final PluginInitializer mPluginInitializer;
|
private final PluginInitializer mPluginInitializer;
|
||||||
@@ -83,7 +81,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
|||||||
private Looper mLooper;
|
private Looper mLooper;
|
||||||
|
|
||||||
public PluginManagerImpl(Context context, PluginInitializer initializer) {
|
public PluginManagerImpl(Context context, PluginInitializer initializer) {
|
||||||
this(context, new PluginInstanceManagerFactory(), Build.IS_DEBUGGABLE,
|
this(context, new PluginInstanceManagerFactory(), initializer.isDebuggable(),
|
||||||
Thread.getUncaughtExceptionPreHandler(), initializer);
|
Thread.getUncaughtExceptionPreHandler(), initializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +91,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mFactory = factory;
|
mFactory = factory;
|
||||||
mLooper = initializer.getBgLooper();
|
mLooper = initializer.getBgLooper();
|
||||||
isDebuggable = debuggable;
|
mIsDebuggable = debuggable;
|
||||||
mWhitelistedPlugins.addAll(Arrays.asList(initializer.getWhitelistedPlugins(mContext)));
|
mWhitelistedPlugins.addAll(Arrays.asList(initializer.getWhitelistedPlugins(mContext)));
|
||||||
mPluginPrefs = new PluginPrefs(mContext);
|
mPluginPrefs = new PluginPrefs(mContext);
|
||||||
mPluginEnabler = initializer.getPluginEnabler(mContext);
|
mPluginEnabler = initializer.getPluginEnabler(mContext);
|
||||||
@@ -111,6 +109,10 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDebuggable() {
|
||||||
|
return mIsDebuggable;
|
||||||
|
}
|
||||||
|
|
||||||
public String[] getWhitelistedPlugins() {
|
public String[] getWhitelistedPlugins() {
|
||||||
return mWhitelistedPlugins.toArray(new String[0]);
|
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. */
|
/** Returns class loader specific for the given plugin. */
|
||||||
public ClassLoader getClassLoader(ApplicationInfo appInfo) {
|
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:"
|
Log.w(TAG, "Cannot get class loader for non-whitelisted plugin. Src:"
|
||||||
+ appInfo.sourceDir + ", pkg: " + appInfo.packageName);
|
+ appInfo.sourceDir + ", pkg: " + appInfo.packageName);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package com.android.systemui.plugins;
|
package com.android.systemui.plugins;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -67,4 +68,9 @@ public class PluginInitializerImpl implements PluginInitializer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebuggable() {
|
||||||
|
return Build.IS_DEBUGGABLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user