Update systemui shared lib
This commit is contained in:
1 parent
d422bf8991
commit
a0f5e6d5b6
50 files changed
+4955
-878
No files matched your search
@@ -14,50 +14,33 @@
|
||||
|
||||
package com.android.systemui.shared.plugins;
|
||||
|
||||
import android.app.LoadedApk;
|
||||
import android.app.Notification;
|
||||
import android.app.Notification.Action;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemProperties;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.systemui.plugins.Plugin;
|
||||
import com.android.systemui.plugins.PluginListener;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
import com.android.systemui.shared.plugins.PluginInstanceManager.PluginInfo;
|
||||
|
||||
import dalvik.system.PathClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @see Plugin
|
||||
*/
|
||||
@@ -66,113 +49,65 @@ 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 final ArrayMap<PluginListener<?>, PluginInstanceManager> mPluginMap
|
||||
private final ArrayMap<PluginListener<?>, PluginActionManager<?>> mPluginMap
|
||||
= new ArrayMap<>();
|
||||
private final Map<String, ClassLoader> mClassLoaders = new ArrayMap<>();
|
||||
private final ArraySet<String> mOneShotPackages = new ArraySet<>();
|
||||
private final ArraySet<String> mWhitelistedPlugins = new ArraySet<>();
|
||||
private final ArraySet<String> mPrivilegedPlugins = new ArraySet<>();
|
||||
private final Context mContext;
|
||||
private final PluginInstanceManagerFactory mFactory;
|
||||
private final PluginActionManager.Factory mActionManagerFactory;
|
||||
private final boolean mIsDebuggable;
|
||||
private final PluginPrefs mPluginPrefs;
|
||||
private final PluginEnabler mPluginEnabler;
|
||||
private final PluginInitializer mPluginInitializer;
|
||||
private ClassLoaderFilter mParentClassLoader;
|
||||
private boolean mListening;
|
||||
private boolean mHasOneShot;
|
||||
private Looper mLooper;
|
||||
|
||||
public PluginManagerImpl(Context context, PluginInitializer initializer) {
|
||||
this(context, new PluginInstanceManagerFactory(), initializer.isDebuggable(),
|
||||
(UncaughtExceptionHandler) invoke(sGetUncaughtExceptionPreHandler, null), initializer);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
PluginManagerImpl(Context context, PluginInstanceManagerFactory factory, boolean debuggable,
|
||||
UncaughtExceptionHandler defaultHandler, final PluginInitializer initializer) {
|
||||
public PluginManagerImpl(Context context,
|
||||
PluginActionManager.Factory actionManagerFactory,
|
||||
boolean debuggable,
|
||||
Optional<UncaughtExceptionHandler> defaultHandlerOptional,
|
||||
PluginEnabler pluginEnabler,
|
||||
PluginPrefs pluginPrefs,
|
||||
List<String> privilegedPlugins) {
|
||||
mContext = context;
|
||||
mFactory = factory;
|
||||
mLooper = initializer.getBgLooper();
|
||||
mActionManagerFactory = actionManagerFactory;
|
||||
mIsDebuggable = debuggable;
|
||||
mWhitelistedPlugins.addAll(Arrays.asList(initializer.getWhitelistedPlugins(mContext)));
|
||||
mPluginPrefs = new PluginPrefs(mContext);
|
||||
mPluginEnabler = initializer.getPluginEnabler(mContext);
|
||||
mPluginInitializer = initializer;
|
||||
mPrivilegedPlugins.addAll(privilegedPlugins);
|
||||
mPluginPrefs = pluginPrefs;
|
||||
mPluginEnabler = pluginEnabler;
|
||||
|
||||
PluginExceptionHandler uncaughtExceptionHandler = new PluginExceptionHandler(
|
||||
defaultHandler);
|
||||
invoke(sSetUncaughtExceptionPreHandler, null, uncaughtExceptionHandler);
|
||||
|
||||
new Handler(mLooper).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initializer.onPluginManagerInit();
|
||||
}
|
||||
});
|
||||
defaultHandlerOptional);
|
||||
invoke(sSetUncaughtExceptionPreHandler, uncaughtExceptionHandler);
|
||||
}
|
||||
|
||||
public boolean isDebuggable() {
|
||||
return mIsDebuggable;
|
||||
}
|
||||
|
||||
public String[] getWhitelistedPlugins() {
|
||||
return mWhitelistedPlugins.toArray(new String[0]);
|
||||
public String[] getPrivilegedPlugins() {
|
||||
return mPrivilegedPlugins.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public PluginEnabler getPluginEnabler() {
|
||||
return mPluginEnabler;
|
||||
}
|
||||
|
||||
// TODO(mankoff): This appears to be only called from tests. Remove?
|
||||
public <T extends Plugin> T getOneShotPlugin(Class<T> cls) {
|
||||
ProvidesInterface info = cls.getDeclaredAnnotation(ProvidesInterface.class);
|
||||
if (info == null) {
|
||||
throw new RuntimeException(cls + " doesn't provide an interface");
|
||||
}
|
||||
if (TextUtils.isEmpty(info.action())) {
|
||||
throw new RuntimeException(cls + " doesn't provide an action");
|
||||
}
|
||||
return getOneShotPlugin(info.action(), cls);
|
||||
}
|
||||
|
||||
public <T extends Plugin> T getOneShotPlugin(String action, Class<?> cls) {
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
throw new RuntimeException("Must be called from UI thread");
|
||||
}
|
||||
// Passing null causes compiler to complain about incompatible (generic) types.
|
||||
PluginListener<Plugin> dummy = null;
|
||||
PluginInstanceManager<T> p = mFactory.createPluginInstanceManager(mContext, action, dummy,
|
||||
false, mLooper, cls, this);
|
||||
mPluginPrefs.addAction(action);
|
||||
PluginInfo<T> info = p.getPlugin();
|
||||
if (info != null) {
|
||||
mOneShotPackages.add(info.mPackage);
|
||||
mHasOneShot = true;
|
||||
startListening();
|
||||
return info.mPlugin;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T extends Plugin> void addPluginListener(PluginListener<T> listener, Class<?> cls) {
|
||||
/** */
|
||||
public <T extends Plugin> void addPluginListener(PluginListener<T> listener, Class<T> cls) {
|
||||
addPluginListener(listener, cls, false);
|
||||
}
|
||||
|
||||
public <T extends Plugin> void addPluginListener(PluginListener<T> listener, Class<?> cls,
|
||||
/** */
|
||||
public <T extends Plugin> void addPluginListener(PluginListener<T> listener, Class<T> cls,
|
||||
boolean allowMultiple) {
|
||||
addPluginListener(PluginManager.Helper.getAction(cls), listener, cls, allowMultiple);
|
||||
}
|
||||
|
||||
public <T extends Plugin> void addPluginListener(String action, PluginListener<T> listener,
|
||||
Class<?> cls) {
|
||||
Class<T> cls) {
|
||||
addPluginListener(action, listener, cls, false);
|
||||
}
|
||||
|
||||
public <T extends Plugin> void addPluginListener(String action, PluginListener<T> listener,
|
||||
Class cls, boolean allowMultiple) {
|
||||
Class<T> cls, boolean allowMultiple) {
|
||||
mPluginPrefs.addAction(action);
|
||||
PluginInstanceManager p = mFactory.createPluginInstanceManager(mContext, action, listener,
|
||||
allowMultiple, mLooper, cls, this);
|
||||
PluginActionManager<T> p = mActionManagerFactory.create(action, listener, cls,
|
||||
allowMultiple, isDebuggable());
|
||||
p.loadAll();
|
||||
synchronized (this) {
|
||||
mPluginMap.put(listener, p);
|
||||
@@ -204,14 +139,13 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
filter.addAction(PLUGIN_CHANGED);
|
||||
filter.addAction(DISABLE_PLUGIN);
|
||||
filter.addDataScheme("package");
|
||||
mContext.registerReceiver(this, filter, PluginInstanceManager.PLUGIN_PERMISSION, null);
|
||||
mContext.registerReceiver(this, filter, PluginActionManager.PLUGIN_PERMISSION, null);
|
||||
filter = new IntentFilter(Intent.ACTION_USER_UNLOCKED);
|
||||
mContext.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
private void stopListening() {
|
||||
// Never stop listening if a one-shot is present.
|
||||
if (!mListening || mHasOneShot) return;
|
||||
if (!mListening) return;
|
||||
mListening = false;
|
||||
mContext.unregisterReceiver(this);
|
||||
}
|
||||
@@ -220,7 +154,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) {
|
||||
synchronized (this) {
|
||||
for (PluginInstanceManager manager : mPluginMap.values()) {
|
||||
for (PluginActionManager<?> manager : mPluginMap.values()) {
|
||||
manager.loadAll();
|
||||
}
|
||||
}
|
||||
@@ -228,46 +162,17 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
Uri uri = intent.getData();
|
||||
ComponentName component = ComponentName.unflattenFromString(
|
||||
uri.toString().substring(10));
|
||||
if (isPluginWhitelisted(component)) {
|
||||
// Don't disable whitelisted plugins as they are a part of the OS.
|
||||
if (isPluginPrivileged(component)) {
|
||||
// Don't disable privileged plugins as they are a part of the OS.
|
||||
return;
|
||||
}
|
||||
getPluginEnabler().setDisabled(component, PluginEnabler.DISABLED_INVALID_VERSION);
|
||||
mPluginEnabler.setDisabled(component, PluginEnabler.DISABLED_INVALID_VERSION);
|
||||
mContext.getSystemService(NotificationManager.class).cancel(component.getClassName(),
|
||||
SystemMessage.NOTE_PLUGIN);
|
||||
} else {
|
||||
Uri data = intent.getData();
|
||||
String pkg = data.getEncodedSchemeSpecificPart();
|
||||
ComponentName componentName = ComponentName.unflattenFromString(pkg);
|
||||
if (mOneShotPackages.contains(pkg)) {
|
||||
int icon = Resources.getSystem().getIdentifier(
|
||||
"stat_sys_warning", "drawable", "android");
|
||||
int color = Resources.getSystem().getIdentifier(
|
||||
"system_notification_accent_color", "color", "android");
|
||||
String label = pkg;
|
||||
try {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
label = pm.getApplicationInfo(pkg, 0).loadLabel(pm).toString();
|
||||
} catch (NameNotFoundException e) {
|
||||
}
|
||||
// Localization not required as this will never ever appear in a user build.
|
||||
final Notification.Builder nb =
|
||||
new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
|
||||
.setSmallIcon(icon)
|
||||
.setWhen(0)
|
||||
.setShowWhen(false)
|
||||
.setPriority(Notification.PRIORITY_MAX)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setColor(mContext.getColor(color))
|
||||
.setContentTitle("Plugin \"" + label + "\" has updated")
|
||||
.setContentText("Restart SysUI for changes to take effect.");
|
||||
Intent i = new Intent("com.android.systemui.action.RESTART").setData(
|
||||
Uri.parse("package://" + pkg));
|
||||
PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, PendingIntent.FLAG_MUTABLE_UNAUDITED);
|
||||
nb.addAction(new Action.Builder(null, "Restart SysUI", pi).build());
|
||||
mContext.getSystemService(NotificationManager.class)
|
||||
.notify(SystemMessage.NOTE_PLUGIN, nb.build());
|
||||
}
|
||||
if (clearClassLoader(pkg)) {
|
||||
if (Build.IS_ENG) {
|
||||
Toast.makeText(mContext, "Reloading " + pkg, Toast.LENGTH_LONG).show();
|
||||
@@ -278,22 +183,24 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
if (Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())
|
||||
&& componentName != null) {
|
||||
@PluginEnabler.DisableReason int disableReason =
|
||||
getPluginEnabler().getDisableReason(componentName);
|
||||
mPluginEnabler.getDisableReason(componentName);
|
||||
if (disableReason == PluginEnabler.DISABLED_FROM_EXPLICIT_CRASH
|
||||
|| disableReason == PluginEnabler.DISABLED_FROM_SYSTEM_CRASH
|
||||
|| disableReason == PluginEnabler.DISABLED_INVALID_VERSION) {
|
||||
Log.i(TAG, "Re-enabling previously disabled plugin that has been "
|
||||
+ "updated: " + componentName.flattenToShortString());
|
||||
getPluginEnabler().setEnabled(componentName);
|
||||
mPluginEnabler.setEnabled(componentName);
|
||||
}
|
||||
}
|
||||
synchronized (this) {
|
||||
if (!Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
|
||||
for (PluginInstanceManager manager : mPluginMap.values()) {
|
||||
manager.onPackageChange(pkg);
|
||||
if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())
|
||||
|| Intent.ACTION_PACKAGE_CHANGED.equals(intent.getAction())
|
||||
|| Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())) {
|
||||
for (PluginActionManager<?> actionManager : mPluginMap.values()) {
|
||||
actionManager.reloadPackage(pkg);
|
||||
}
|
||||
} else {
|
||||
for (PluginInstanceManager manager : mPluginMap.values()) {
|
||||
for (PluginActionManager<?> manager : mPluginMap.values()) {
|
||||
manager.onPackageRemoved(pkg);
|
||||
}
|
||||
}
|
||||
@@ -301,41 +208,10 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns class loader specific for the given plugin. */
|
||||
public ClassLoader getClassLoader(ApplicationInfo appInfo) {
|
||||
if (!mIsDebuggable && !isPluginPackageWhitelisted(appInfo.packageName)) {
|
||||
Log.w(TAG, "Cannot get class loader for non-whitelisted plugin. Src:"
|
||||
+ appInfo.sourceDir + ", pkg: " + appInfo.packageName);
|
||||
return null;
|
||||
}
|
||||
if (mClassLoaders.containsKey(appInfo.packageName)) {
|
||||
return mClassLoaders.get(appInfo.packageName);
|
||||
}
|
||||
|
||||
List<String> zipPaths = new ArrayList<>();
|
||||
List<String> libPaths = new ArrayList<>();
|
||||
LoadedApk.makePaths(null, true, appInfo, zipPaths, libPaths);
|
||||
ClassLoader classLoader = new PathClassLoader(
|
||||
TextUtils.join(File.pathSeparator, zipPaths),
|
||||
TextUtils.join(File.pathSeparator, libPaths),
|
||||
getParentClassLoader());
|
||||
mClassLoaders.put(appInfo.packageName, classLoader);
|
||||
return classLoader;
|
||||
}
|
||||
|
||||
private boolean clearClassLoader(String pkg) {
|
||||
return mClassLoaders.remove(pkg) != null;
|
||||
}
|
||||
|
||||
ClassLoader getParentClassLoader() {
|
||||
if (mParentClassLoader == null) {
|
||||
// Lazily load this so it doesn't have any effect on devices without plugins.
|
||||
mParentClassLoader = new ClassLoaderFilter(getClass().getClassLoader(),
|
||||
"com.android.systemui.plugin");
|
||||
}
|
||||
return mParentClassLoader;
|
||||
}
|
||||
|
||||
public <T> boolean dependsOn(Plugin p, Class<T> cls) {
|
||||
synchronized (this) {
|
||||
for (int i = 0; i < mPluginMap.size(); i++) {
|
||||
@@ -347,46 +223,18 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleWtfs() {
|
||||
mPluginInitializer.handleWtfs();
|
||||
}
|
||||
|
||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
synchronized (this) {
|
||||
pw.println(String.format(" plugin map (%d):", mPluginMap.size()));
|
||||
for (PluginListener listener : mPluginMap.keySet()) {
|
||||
for (PluginListener<?> listener : mPluginMap.keySet()) {
|
||||
pw.println(String.format(" %s -> %s",
|
||||
listener, mPluginMap.get(listener)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static class PluginInstanceManagerFactory {
|
||||
public <T extends Plugin> PluginInstanceManager createPluginInstanceManager(Context context,
|
||||
String action, PluginListener<T> listener, boolean allowMultiple, Looper looper,
|
||||
Class<?> cls, PluginManagerImpl manager) {
|
||||
return new PluginInstanceManager(context, action, listener, allowMultiple, looper,
|
||||
new VersionInfo().addClass(cls), manager);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPluginPackageWhitelisted(String packageName) {
|
||||
for (String componentNameOrPackage : mWhitelistedPlugins) {
|
||||
ComponentName componentName = ComponentName.unflattenFromString(componentNameOrPackage);
|
||||
if (componentName != null) {
|
||||
if (componentName.getPackageName().equals(packageName)) {
|
||||
return true;
|
||||
}
|
||||
} else if (componentNameOrPackage.equals(packageName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isPluginWhitelisted(ComponentName pluginName) {
|
||||
for (String componentNameOrPackage : mWhitelistedPlugins) {
|
||||
private boolean isPluginPrivileged(ComponentName pluginName) {
|
||||
for (String componentNameOrPackage : mPrivilegedPlugins) {
|
||||
ComponentName componentName = ComponentName.unflattenFromString(componentNameOrPackage);
|
||||
if (componentName != null) {
|
||||
if (componentName.equals(pluginName)) {
|
||||
@@ -401,7 +249,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
|
||||
// This allows plugins to include any libraries or copied code they want by only including
|
||||
// classes from the plugin library.
|
||||
private static class ClassLoaderFilter extends ClassLoader {
|
||||
static class ClassLoaderFilter extends ClassLoader {
|
||||
private final String mPackage;
|
||||
private final ClassLoader mBase;
|
||||
|
||||
@@ -419,16 +267,20 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
}
|
||||
|
||||
private class PluginExceptionHandler implements UncaughtExceptionHandler {
|
||||
private final UncaughtExceptionHandler mHandler;
|
||||
private final Optional<UncaughtExceptionHandler> mExceptionHandlerOptional;
|
||||
|
||||
private PluginExceptionHandler(UncaughtExceptionHandler handler) {
|
||||
mHandler = handler;
|
||||
private PluginExceptionHandler(
|
||||
Optional<UncaughtExceptionHandler> exceptionHandlerOptional) {
|
||||
mExceptionHandlerOptional = exceptionHandlerOptional;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
if (SystemProperties.getBoolean("plugin.debugging", false)) {
|
||||
mHandler.uncaughtException(thread, throwable);
|
||||
Throwable finalThrowable = throwable;
|
||||
mExceptionHandlerOptional.ifPresent(
|
||||
handler -> handler.uncaughtException(thread, finalThrowable));
|
||||
|
||||
return;
|
||||
}
|
||||
// Search for and disable plugins that may have been involved in this crash.
|
||||
@@ -438,7 +290,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
// disable all the plugins, so we can be sure that SysUI is running as
|
||||
// best as possible.
|
||||
synchronized (this) {
|
||||
for (PluginInstanceManager manager : mPluginMap.values()) {
|
||||
for (PluginActionManager<?> manager : mPluginMap.values()) {
|
||||
disabledAny |= manager.disableAll();
|
||||
}
|
||||
}
|
||||
@@ -448,7 +300,9 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
}
|
||||
|
||||
// Run the normal exception handler so we can crash and cleanup our state.
|
||||
mHandler.uncaughtException(thread, throwable);
|
||||
Throwable finalThrowable = throwable;
|
||||
mExceptionHandlerOptional.ifPresent(
|
||||
handler -> handler.uncaughtException(thread, finalThrowable));
|
||||
}
|
||||
|
||||
private boolean checkStack(Throwable throwable) {
|
||||
@@ -456,7 +310,7 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
boolean disabledAny = false;
|
||||
synchronized (this) {
|
||||
for (StackTraceElement element : throwable.getStackTrace()) {
|
||||
for (PluginInstanceManager manager : mPluginMap.values()) {
|
||||
for (PluginActionManager<?> manager : mPluginMap.values()) {
|
||||
disabledAny |= manager.checkAndDisable(element.getClassName());
|
||||
}
|
||||
}
|
||||
@@ -471,13 +325,11 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
|
||||
}
|
||||
}
|
||||
|
||||
private static Method sGetUncaughtExceptionPreHandler;
|
||||
private static Method sSetUncaughtExceptionPreHandler;
|
||||
|
||||
static {
|
||||
try {
|
||||
Method getDeclaredMethod = Class.class.getDeclaredMethod("getDeclaredMethod", String.class, Class[].class);
|
||||
sGetUncaughtExceptionPreHandler = (Method) getDeclaredMethod.invoke(Thread.class, "getUncaughtExceptionPreHandler", new Class[]{});
|
||||
sSetUncaughtExceptionPreHandler = (Method) getDeclaredMethod.invoke(Thread.class, "setUncaughtExceptionPreHandler", new Class[]{UncaughtExceptionHandler.class});
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in new issue
Block a user