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

Commit da08f546 authored by Jason Monk's avatar Jason Monk
Browse files

Don't manage whitelisted plugins

Add sysui to the plugin whitelist and don't manage whitelisted plugins.
This will prevent sysui getting all its components disabled when it
crashes if we have a plugin compiled into the APK, which we now support.

Bug: 118403466
Test: added test
Change-Id: I1f65ae44db686e718e23bf1d9f4c06d0ba16056a
parent 9b74c075
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -461,5 +461,7 @@
    <bool name="config_pipEnableDismissDragToEdge">true</bool>

    <!-- SystemUI Plugins that can be loaded on user builds. -->
    <string-array name="config_pluginWhitelist" translatable="false" />
    <string-array name="config_pluginWhitelist" translatable="false">
        <item>com.android.systemui</item>
    </string-array>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -158,6 +158,10 @@ public class PluginInstanceManager<T extends Plugin> {
        // If a plugin is detected in the stack of a crash then this will be called for that
        // plugin, if the plugin causing a crash cannot be identified, they are all disabled
        // assuming one of them must be bad.
        if (mWhitelistedPlugins.contains(info.mPackage)) {
            // Don't disable whitelisted plugins as they are a part of the OS.
            return;
        }
        Log.w(TAG, "Disabling plugin " + info.mPackage + "/" + info.mClass);
        mManager.getPluginEnabler().setEnabled(new ComponentName(info.mPackage, info.mClass),
                false);
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ public interface PluginManager {
    // must be one of the channels created in NotificationChannels.java
    String NOTIFICATION_CHANNEL_ID = "ALR";

    String[] getWhitelistedPlugins();

    <T extends Plugin> T getOneShotPlugin(Class<T> cls);
    <T extends Plugin> T getOneShotPlugin(String action, Class<?> cls);

+4 −0
Original line number Diff line number Diff line
@@ -210,6 +210,10 @@ public class PluginManagerImpl extends BroadcastReceiver implements PluginManage
            Uri uri = intent.getData();
            ComponentName component = ComponentName.unflattenFromString(
                    uri.toString().substring(10));
            if (mWhitelistedPlugins.contains(component.getPackageName())) {
                // Don't disable whitelisted plugins as they are a part of the OS.
                return;
            }
            getPluginEnabler().setEnabled(component, false);
            mContext.getSystemService(NotificationManager.class).cancel(component.getClassName(),
                    SystemMessage.NOTE_PLUGIN);
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.view.View;

import com.android.internal.util.ArrayUtils;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.PluginEnablerImpl;
import com.android.systemui.shared.plugins.PluginEnabler;
@@ -77,6 +79,7 @@ public class PluginFragment extends PreferenceFragment {
    }

    private void loadPrefs() {
        PluginManager manager = Dependency.get(PluginManager.class);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getContext());
        screen.setOrderingAsAdded(false);
        Context prefContext = getPreferenceManager().getContext();
@@ -103,6 +106,10 @@ public class PluginFragment extends PreferenceFragment {
                PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.GET_SERVICES);
        apps.forEach(app -> {
            if (!plugins.containsKey(app.packageName)) return;
            if (ArrayUtils.contains(manager.getWhitelistedPlugins(), app.packageName)) {
                // Don't manage whitelisted plugins, they are part of the OS.
                return;
            }
            SwitchPreference pref = new PluginPreference(prefContext, app, mPluginEnabler);
            pref.setSummary("Plugins: " + toString(plugins.get(app.packageName)));
            screen.addPreference(pref);
Loading