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

Commit a9ac86f6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow specifying full component names in sysui plugin whitelist" into qt-dev

parents 87b7e3d4 02bbaaa4
Loading
Loading
Loading
Loading
+27 −5
Original line number Original line Diff line number Diff line
@@ -151,19 +151,34 @@ public class PluginInstanceManager<T extends Plugin> {
        return plugins.size() != 0;
        return plugins.size() != 0;
    }
    }


    private void disable(PluginInfo info,
    private boolean isPluginWhitelisted(ComponentName pluginName) {
            @PluginEnabler.DisableReason int reason) {
        for (String componentNameOrPackage : mWhitelistedPlugins) {
            ComponentName componentName = ComponentName.unflattenFromString(componentNameOrPackage);
            if (componentName == null) {
                if (componentNameOrPackage.equals(pluginName.getPackageName())) {
                    return true;
                }
            } else {
                if (componentName.equals(pluginName)) {
                    return true;
                }
            }
        }
        return false;
    }

    private void disable(PluginInfo info, @PluginEnabler.DisableReason int reason) {
        // Live by the sword, die by the sword.
        // Live by the sword, die by the sword.
        // Misbehaving plugins get disabled and won't come back until uninstall/reinstall.
        // Misbehaving plugins get disabled and won't come back until uninstall/reinstall.


        ComponentName pluginComponent = new ComponentName(info.mPackage, info.mClass);
        // If a plugin is detected in the stack of a crash then this will be called for that
        // 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
        // plugin, if the plugin causing a crash cannot be identified, they are all disabled
        // assuming one of them must be bad.
        // assuming one of them must be bad.
        if (mWhitelistedPlugins.contains(info.mPackage)) {
        if (isPluginWhitelisted(pluginComponent)) {
            // Don't disable whitelisted plugins as they are a part of the OS.
            // Don't disable whitelisted plugins as they are a part of the OS.
            return;
            return;
        }
        }
        ComponentName pluginComponent = new ComponentName(info.mPackage, info.mClass);
        Log.w(TAG, "Disabling plugin " + pluginComponent.flattenToShortString());
        Log.w(TAG, "Disabling plugin " + pluginComponent.flattenToShortString());
        mManager.getPluginEnabler().setDisabled(pluginComponent, reason);
        mManager.getPluginEnabler().setDisabled(pluginComponent, reason);
    }
    }
@@ -288,6 +303,13 @@ public class PluginInstanceManager<T extends Plugin> {
            if (result.size() > 1 && !mAllowMultiple) {
            if (result.size() > 1 && !mAllowMultiple) {
                // TODO: Show warning.
                // TODO: Show warning.
                Log.w(TAG, "Multiple plugins found for " + mAction);
                Log.w(TAG, "Multiple plugins found for " + mAction);
                if (DEBUG) {
                    for (ResolveInfo info : result) {
                        ComponentName name = new ComponentName(info.serviceInfo.packageName,
                                info.serviceInfo.name);
                        Log.w(TAG, "  " + name);
                    }
                }
                return;
                return;
            }
            }
            for (ResolveInfo info : result) {
            for (ResolveInfo info : result) {
@@ -305,7 +327,7 @@ public class PluginInstanceManager<T extends Plugin> {
        protected PluginInfo<T> handleLoadPlugin(ComponentName component) {
        protected PluginInfo<T> handleLoadPlugin(ComponentName component) {
            // This was already checked, but do it again here to make extra extra sure, we don't
            // This was already checked, but do it again here to make extra extra sure, we don't
            // use these on production builds.
            // use these on production builds.
            if (!isDebuggable && !mWhitelistedPlugins.contains(component.getPackageName())) {
            if (!isDebuggable && !isPluginWhitelisted(component)) {
                // Never ever ever allow these on production builds, they are only for prototyping.
                // Never ever ever allow these on production builds, they are only for prototyping.
                Log.w(TAG, "Plugin cannot be loaded on production build: " + component);
                Log.w(TAG, "Plugin cannot be loaded on production build: " + component);
                return null;
                return null;
+1 −0
Original line number Original line Diff line number Diff line
@@ -413,6 +413,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
                                },
                                },
                                mKeyguardManager.isDeviceLocked())
                                mKeyguardManager.isDeviceLocked())
                        : null;
                        : null;

        ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, panelViewController);
        ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, panelViewController);
        dialog.setCanceledOnTouchOutside(false); // Handled by the custom class.
        dialog.setCanceledOnTouchOutside(false); // Handled by the custom class.
        dialog.setKeyguardShowing(mKeyguardShowing);
        dialog.setKeyguardShowing(mKeyguardShowing);