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

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

Merge "Create a global registry for system message IDs"

parents aedb707a 5e6c0ffd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.util.Log;
import android.view.LayoutInflater;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;

import java.util.ArrayList;
import java.util.List;
@@ -283,8 +284,6 @@ public class PluginInstanceManager<T extends Plugin> {
                Class<?> pluginClass = Class.forName(cls, true, classLoader);
                T plugin = (T) pluginClass.newInstance();
                if (plugin.getVersion() != mVersion) {
                    final int id = mContext.getResources().getIdentifier("notification_plugin",
                            "id", mContext.getPackageName());
                    final int icon = mContext.getResources().getIdentifier("tuner", "drawable",
                            mContext.getPackageName());
                    final int color = Resources.getSystem().getIdentifier(
@@ -320,7 +319,8 @@ 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, id, nb.build(), UserHandle.ALL);
                            .notifyAsUser(cls, SystemMessage.NOTE_PLUGIN, nb.build(),
                                    UserHandle.ALL);
                    // TODO: Warn user.
                    Log.w(TAG, "Plugin has invalid interface version " + plugin.getVersion()
                            + ", expected " + mVersion);
+2 −3
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.SystemProperties;
import android.util.ArrayMap;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.systemui.plugins.PluginInstanceManager.PluginContextWrapper;

import dalvik.system.PathClassLoader;
@@ -141,10 +142,8 @@ public class PluginManager extends BroadcastReceiver {
            mContext.getPackageManager().setComponentEnabledSetting(component,
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                    PackageManager.DONT_KILL_APP);
            int id = mContext.getResources().getIdentifier("notification_plugin", "id",
                    mContext.getPackageName());
            mContext.getSystemService(NotificationManager.class).cancel(component.getClassName(),
                    id);
                    SystemMessage.NOTE_PLUGIN);
        } else {
            Uri data = intent.getData();
            String pkg = data.getEncodedSchemeSpecificPart();
+0 −5
Original line number Diff line number Diff line
@@ -49,12 +49,7 @@
    <item type="id" name="scrim_target"/>
    <item type="id" name="scrim_alpha_start"/>
    <item type="id" name="scrim_alpha_end"/>
    <item type="id" name="notification_power"/>
    <item type="id" name="notification_screenshot"/>
    <item type="id" name="notification_hidden"/>
    <item type="id" name="notification_volumeui"/>
    <item type="id" name="notification_temperature"/>
    <item type="id" name="notification_plugin"/>
    <item type="id" name="transformation_start_x_tag"/>
    <item type="id" name="transformation_start_y_tag"/>
    <item type="id" name="transformation_start_scale_x_tag"/>
+13 −10
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;

import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
@@ -50,8 +51,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
    private static final String TAG = PowerUI.TAG + ".Notification";
    private static final boolean DEBUG = PowerUI.DEBUG;

    private static final String TAG_NOTIFICATION_BATTERY = "low_battery";
    private static final String TAG_NOTIFICATION_TEMPERATURE = "high_temp";
    private static final String TAG_BATTERY = "low_battery";
    private static final String TAG_TEMPERATURE = "high_temp";

    private static final int SHOWING_NOTHING = 0;
    private static final int SHOWING_WARNING = 1;
@@ -136,7 +137,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
            showWarningNotification();
            mShowing = SHOWING_WARNING;
        } else {
            mNoMan.cancelAsUser(TAG_NOTIFICATION_BATTERY, R.id.notification_power, UserHandle.ALL);
            mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, UserHandle.ALL);
            mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, UserHandle.ALL);
            mShowing = SHOWING_NOTHING;
        }
    }
@@ -155,7 +157,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                        com.android.internal.R.color.system_notification_accent_color));
        SystemUI.overrideNotificationAppName(mContext, nb);
        final Notification n = nb.build();
        mNoMan.notifyAsUser(TAG_NOTIFICATION_BATTERY, R.id.notification_power, n, UserHandle.ALL);
        mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, UserHandle.ALL);
        mNoMan.notifyAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, n, UserHandle.ALL);
    }

    private void showWarningNotification() {
@@ -185,8 +188,9 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
            mPlaySound = false;
        }
        SystemUI.overrideNotificationAppName(mContext, nb);
        mNoMan.notifyAsUser(
                TAG_NOTIFICATION_BATTERY, R.id.notification_power, nb.build(), UserHandle.ALL);
        final Notification n = nb.build();
        mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, UserHandle.ALL);
        mNoMan.notifyAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, n, UserHandle.ALL);
    }

    private PendingIntent pendingBroadcast(String action) {
@@ -213,8 +217,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
            return;
        }
        mTempWarning = false;
        mNoMan.cancelAsUser(
                TAG_NOTIFICATION_TEMPERATURE, R.id.notification_temperature, UserHandle.ALL);
        mNoMan.cancelAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP,
                UserHandle.ALL);
    }

    @Override
@@ -237,8 +241,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                        com.android.internal.R.color.battery_saver_mode_color));
        SystemUI.overrideNotificationAppName(mContext, nb);
        final Notification n = nb.build();
        mNoMan.notifyAsUser(
                TAG_NOTIFICATION_TEMPERATURE, R.id.notification_temperature, n, UserHandle.ALL);
        mNoMan.notifyAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP, n, UserHandle.ALL);

    }

+9 −6
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.view.WindowManager;
import android.view.animation.Interpolator;
import android.widget.ImageView;

import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.systemui.R;
import com.android.systemui.SystemUI;

@@ -201,7 +202,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
        mNotificationBuilder.setFlag(Notification.FLAG_NO_CLEAR, true);
        SystemUI.overrideNotificationAppName(context, mNotificationBuilder);

        mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build());
        mNotificationManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT,
                mNotificationBuilder.build());

        /**
         * NOTE: The following code prepares the notification builder for updating the notification
@@ -348,7 +350,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
                .setPublicVersion(mPublicNotificationBuilder.build())
                .setFlag(Notification.FLAG_NO_CLEAR, false);

            mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build());
            mNotificationManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT,
                    mNotificationBuilder.build());
        }
        mParams.finisher.run();
        mParams.clearContext();
@@ -364,7 +367,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
        mParams.clearContext();

        // Cancel the posted notification
        mNotificationManager.cancel(R.id.notification_screenshot);
        mNotificationManager.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT);
    }
}

@@ -866,7 +869,7 @@ class GlobalScreenshot {
        Notification n = new Notification.BigTextStyle(b)
                .bigText(errorMsg)
                .build();
        nManager.notify(R.id.notification_screenshot, n);
        nManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT, n);
    }

    /**
@@ -878,7 +881,7 @@ class GlobalScreenshot {
            // Clear the notification
            final NotificationManager nm =
                    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            nm.cancel(R.id.notification_screenshot);
            nm.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT);
        }
    }

@@ -896,7 +899,7 @@ class GlobalScreenshot {
            final NotificationManager nm =
                    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            final Uri uri = Uri.parse(intent.getStringExtra(SCREENSHOT_URI_ID));
            nm.cancel(R.id.notification_screenshot);
            nm.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT);

            // And delete the image from the media store
            new DeleteImageInBackgroundTask(context).execute(uri);
Loading