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

Commit 3c530ff5 authored by Pinyao Ting's avatar Pinyao Ting
Browse files

allow error notification in plugin framework to be shown in external

process, such as Launcher

Bug: 139823632
Change-Id: Id0307e483e66bd3c396f5355a526e4c728e68335
Test: Manual
parent fb07c6a1
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.UserHandle;
import android.util.ArraySet;
import android.util.Log;
import android.view.LayoutInflater;
@@ -359,8 +358,8 @@ public class PluginInstanceManager<T extends Plugin> {
                    if (DEBUG) Log.d(TAG, "createPlugin");
                    return new PluginInfo(pkg, cls, plugin, pluginContext, version);
                } catch (InvalidVersionException e) {
                    final int icon = mContext.getResources().getIdentifier("tuner", "drawable",
                            mContext.getPackageName());
                    final int icon = Resources.getSystem().getIdentifier(
                            "stat_sys_warning", "drawable", "android");
                    final int color = Resources.getSystem().getIdentifier(
                            "system_notification_accent_color", "color", "android");
                    final Notification.Builder nb = new Notification.Builder(mContext,
@@ -392,8 +391,7 @@ public class PluginInstanceManager<T extends Plugin> {
                    PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, 0);
                    nb.addAction(new Action.Builder(null, "Disable plugin", pi).build());
                    mContext.getSystemService(NotificationManager.class)
                            .notifyAsUser(cls, SystemMessage.NOTE_PLUGIN, nb.build(),
                                    UserHandle.ALL);
                            .notify(SystemMessage.NOTE_PLUGIN, nb.build());
                    // TODO: Warn user.
                    Log.w(TAG, "Plugin has invalid interface version " + plugin.getVersion()
                            + ", expected " + mVersion);
+4 −5
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -235,8 +234,8 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
            String pkg = data.getEncodedSchemeSpecificPart();
            ComponentName componentName = ComponentName.unflattenFromString(pkg);
            if (mOneShotPackages.contains(pkg)) {
                int icon = mContext.getResources().getIdentifier("tuner", "drawable",
                        mContext.getPackageName());
                int icon = Resources.getSystem().getIdentifier(
                        "stat_sys_warning", "drawable", "android");
                int color = Resources.getSystem().getIdentifier(
                        "system_notification_accent_color", "color", "android");
                String label = pkg;
@@ -260,8 +259,8 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
                            Uri.parse("package://" + pkg));
                PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, 0);
                nb.addAction(new Action.Builder(null, "Restart SysUI", pi).build());
                mContext.getSystemService(NotificationManager.class).notifyAsUser(pkg,
                        SystemMessage.NOTE_PLUGIN, nb.build(), UserHandle.ALL);
                mContext.getSystemService(NotificationManager.class)
                        .notify(SystemMessage.NOTE_PLUGIN, nb.build());
            }
            if (clearClassLoader(pkg)) {
                if (Build.IS_ENG) {
+1 −3
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.os.HandlerThread;
import android.os.UserHandle;
import android.test.suitebuilder.annotation.SmallTest;

import androidx.test.annotation.UiThreadTest;
@@ -168,8 +167,7 @@ public class PluginInstanceManagerTest extends SysuiTestCase {

        // Plugin shouldn't be connected because it is the wrong version.
        verify(mMockListener, never()).onPluginConnected(any(), any());
        verify(nm).notifyAsUser(eq(TestPlugin.class.getName()), eq(SystemMessage.NOTE_PLUGIN),
                any(), eq(UserHandle.ALL));
        verify(nm).notify(eq(SystemMessage.NOTE_PLUGIN), any());
    }

    @Test