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

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

Merge "Don't send PLUGIN_CHANGED broadcast unless something changed"

parents 3ae35297 8ab04d4c
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -169,16 +169,23 @@ public class PluginFragment extends PreferenceFragment {
        protected boolean persistBoolean(boolean value) {
            final int desiredState = value ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                    : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
            boolean shouldSendBroadcast = false;
            for (int i = 0; i < mInfo.services.length; i++) {
                ComponentName componentName = new ComponentName(mInfo.packageName,
                        mInfo.services[i].name);

                if (mPm.getComponentEnabledSetting(componentName) != desiredState) {
                    mPm.setComponentEnabledSetting(componentName, desiredState,
                            PackageManager.DONT_KILL_APP);
                    shouldSendBroadcast = true;
                }
            }
            if (shouldSendBroadcast) {
                final String pkg = mInfo.packageName;
                final Intent intent = new Intent(PluginManager.PLUGIN_CHANGED,
                        pkg != null ? Uri.fromParts("package", pkg, null) : null);
                getContext().sendBroadcast(intent);
            }
            return true;
        }