Search in sources :

Example 21 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by crdroidandroid.

the class BaseStatusBar method createIcon.

public StatusBarIconView createIcon(StatusBarNotification sbn) {
    // Construct the icon.
    Notification n = sbn.getNotification();
    final StatusBarIconView iconView = new StatusBarIconView(mContext, sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()), n);
    iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    final Icon smallIcon = n.getSmallIcon();
    if (smallIcon == null) {
        handleNotificationError(sbn, "No small icon in notification from " + sbn.getPackageName());
        return null;
    }
    final StatusBarIcon ic = new StatusBarIcon(sbn.getUser(), sbn.getPackageName(), smallIcon, n.iconLevel, n.number, StatusBarIconView.contentDescForNotification(mContext, n));
    if (!iconView.set(ic)) {
        handleNotificationError(sbn, "Couldn't create icon: " + ic);
        return null;
    }
    return iconView;
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) Icon(android.graphics.drawable.Icon) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 22 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by crdroidandroid.

the class StatusBarManagerService method setIcon.

@Override
public void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription) {
    enforceStatusBar();
    synchronized (mIcons) {
        StatusBarIcon icon = new StatusBarIcon(iconPackage, UserHandle.SYSTEM, iconId, iconLevel, 0, contentDescription);
        //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon);
        mIcons.put(slot, icon);
        if (mBar != null) {
            try {
                mBar.setIcon(slot, icon);
            } catch (RemoteException ex) {
            }
        }
    }
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) RemoteException(android.os.RemoteException)

Example 23 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by crdroidandroid.

the class Ticker method addEntry.

public void addEntry(StatusBarNotification n, boolean isMusic, MediaMetadata mediaMetaData) {
    int initialCount = mSegments.size();
    ContentResolver resolver = mContext.getContentResolver();
    if (isMusic) {
        CharSequence artist = mediaMetaData.getText(MediaMetadata.METADATA_KEY_ARTIST);
        CharSequence album = mediaMetaData.getText(MediaMetadata.METADATA_KEY_ALBUM);
        CharSequence title = mediaMetaData.getText(MediaMetadata.METADATA_KEY_TITLE);
        if (artist != null && album != null && title != null) {
            n.getNotification().tickerText = artist.toString() + " - " + album.toString() + " - " + title.toString();
        } else {
            return;
        }
    }
    // a notification storm).
    if (initialCount > 0) {
        final Segment seg = mSegments.get(0);
        if (n.getPackageName().equals(seg.notification.getPackageName()) && n.getNotification().icon == seg.notification.getNotification().icon && n.getNotification().iconLevel == seg.notification.getNotification().iconLevel && charSequencesEqual(seg.notification.getNotification().tickerText, n.getNotification().tickerText)) {
            return;
        }
    }
    final Drawable icon = StatusBarIconView.getIcon(mContext, new StatusBarIcon(n.getPackageName(), n.getUser(), n.getNotification().icon, n.getNotification().iconLevel, 0, n.getNotification().tickerText));
    final CharSequence text = n.getNotification().tickerText;
    final Segment newSegment = new Segment(n, icon, text);
    final ColorStateList tickerIconColor = TickerColorHelper.getTickerIconColorList(mContext, mDefaultColor);
    // If there's already a notification schedule for this package and id, remove it.
    for (int i = 0; i < mSegments.size(); i++) {
        Segment seg = mSegments.get(i);
        if (n.getId() == seg.notification.getId() && n.getPackageName().equals(seg.notification.getPackageName())) {
            // just update that one to use this new data instead
            // restart iteration here
            mSegments.remove(i--);
        }
    }
    mSegments.add(newSegment);
    if (initialCount == 0 && mSegments.size() > 0) {
        Segment seg = mSegments.get(0);
        seg.first = false;
        mIconSwitcher.setAnimateFirstView(false);
        mIconSwitcher.reset();
        mIconSwitcher.setColoredImageDrawable(seg.icon, tickerIconColor);
        mTextSwitcher.setAnimateFirstView(false);
        mTextSwitcher.reset();
        mTextSwitcher.setText(seg.getText());
        updateTickerSize();
        updateTextColor();
        updateTickerFontStyle();
        setTextSwitcherColor();
        mTextSwitcher.setTextSize(mTickerFontSize);
        mTextSwitcher.setTypeface(mFontStyle);
        tickerStarting();
        scheduleAdvance();
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) ColorStateList(android.content.res.ColorStateList) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) TextPaint(android.text.TextPaint) ContentResolver(android.content.ContentResolver)

Example 24 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by crdroidandroid.

the class StatusBarIconController method setIconVisibility.

public void setIconVisibility(String slot, boolean visibility) {
    int index = getSlotIndex(slot);
    StatusBarIcon icon = getIcon(index);
    if (icon == null || icon.visible == visibility) {
        return;
    }
    icon.visible = visibility;
    handleSet(index, icon);
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

Example 25 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by AOSPA.

the class BaseStatusBar method start.

public void start() {
    mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
    mDisplay = mWindowManager.getDefaultDisplay();
    mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
    mNotificationData = new NotificationData(this);
    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    mDreamManager = IDreamManager.Stub.asInterface(ServiceManager.checkService(DreamService.DREAM_SERVICE));
    mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, mSettingsObserver);
    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.ZEN_MODE), false, mSettingsObserver);
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false, mSettingsObserver, UserHandle.USER_ALL);
    if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) {
        mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT), false, mSettingsObserver, UserHandle.USER_ALL);
    }
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS), true, mLockscreenSettingsObserver, UserHandle.USER_ALL);
    mBarService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    mRecents = getComponent(Recents.class);
    final Configuration currentConfig = mContext.getResources().getConfiguration();
    mLocale = currentConfig.locale;
    mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale);
    mFontScale = currentConfig.fontScale;
    mDensity = currentConfig.densityDpi;
    mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
    mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
    mLockPatternUtils = new LockPatternUtils(mContext);
    // Connect in to the status bar manager service
    mCommandQueue = new CommandQueue(this);
    int[] switches = new int[9];
    ArrayList<IBinder> binders = new ArrayList<IBinder>();
    ArrayList<String> iconSlots = new ArrayList<>();
    ArrayList<StatusBarIcon> icons = new ArrayList<>();
    Rect fullscreenStackBounds = new Rect();
    Rect dockedStackBounds = new Rect();
    try {
        mBarService.registerStatusBar(mCommandQueue, iconSlots, icons, switches, binders, fullscreenStackBounds, dockedStackBounds);
    } catch (RemoteException ex) {
    // If the system process isn't there we're doomed anyway.
    }
    createAndAddWindows();
    // set up
    mSettingsObserver.onChange(false);
    disable(switches[0], switches[6], false);
    setSystemUiVisibility(switches[1], switches[7], switches[8], 0xffffffff, fullscreenStackBounds, dockedStackBounds);
    topAppWindowChanged(switches[2] != 0);
    // StatusBarManagerService has a back up of IME token and it's restored here.
    setImeWindowStatus(binders.get(0), switches[3], switches[4], switches[5] != 0);
    // Set up the initial icon state
    int N = iconSlots.size();
    int viewIndex = 0;
    for (int i = 0; i < N; i++) {
        setIcon(iconSlots.get(i), icons.get(i));
    }
    // Set up the initial notification state.
    try {
        mNotificationListener.registerAsSystemService(mContext, new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()), UserHandle.USER_ALL);
    } catch (RemoteException e) {
        Log.e(TAG, "Unable to register notification listener", e);
    }
    if (DEBUG) {
        Log.d(TAG, String.format("init: icons=%d disabled=0x%08x lights=0x%08x menu=0x%08x imeButton=0x%08x", icons.size(), switches[0], switches[1], switches[2], switches[3]));
    }
    mCurrentUserId = ActivityManager.getCurrentUser();
    setHeadsUpUser(mCurrentUserId);
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_USER_SWITCHED);
    filter.addAction(Intent.ACTION_USER_ADDED);
    filter.addAction(Intent.ACTION_USER_PRESENT);
    mContext.registerReceiver(mBroadcastReceiver, filter);
    IntentFilter internalFilter = new IntentFilter();
    internalFilter.addAction(WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION);
    internalFilter.addAction(BANNER_ACTION_CANCEL);
    internalFilter.addAction(BANNER_ACTION_SETUP);
    mContext.registerReceiver(mBroadcastReceiver, internalFilter, PERMISSION_SELF, null);
    IntentFilter allUsersFilter = new IntentFilter();
    allUsersFilter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
    mContext.registerReceiverAsUser(mAllUsersReceiver, UserHandle.ALL, allUsersFilter, null, null);
    updateCurrentProfilesCache();
    IVrManager vrManager = IVrManager.Stub.asInterface(ServiceManager.getService("vrmanager"));
    try {
        vrManager.registerListener(mVrStateCallbacks);
    } catch (RemoteException e) {
        Slog.e(TAG, "Failed to register VR mode state listener: " + e);
    }
    mNonBlockablePkgs = new ArraySet<String>();
    Collections.addAll(mNonBlockablePkgs, mContext.getResources().getStringArray(com.android.internal.R.array.config_nonBlockableNotificationPackages));
}
Also used : IntentFilter(android.content.IntentFilter) Rect(android.graphics.Rect) Recents(com.android.systemui.recents.Recents) Configuration(android.content.res.Configuration) LockPatternUtils(com.android.internal.widget.LockPatternUtils) ArrayList(java.util.ArrayList) IBinder(android.os.IBinder) ComponentName(android.content.ComponentName) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) RemoteException(android.os.RemoteException) IVrManager(android.service.vr.IVrManager)

Aggregations

StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)56 StatusBarNotification (android.service.notification.StatusBarNotification)16 Notification (android.app.Notification)13 RemoteException (android.os.RemoteException)13 ComponentName (android.content.ComponentName)10 Drawable (android.graphics.drawable.Drawable)8 StatusBarIconView (com.android.systemui.statusbar.StatusBarIconView)8 IBinder (android.os.IBinder)7 ArrayList (java.util.ArrayList)7 IntentFilter (android.content.IntentFilter)6 Rect (android.graphics.Rect)6 PackageInfo (android.content.pm.PackageInfo)5 PackageManager (android.content.pm.PackageManager)5 Configuration (android.content.res.Configuration)5 Icon (android.graphics.drawable.Icon)5 UserHandle (android.os.UserHandle)5 IVrManager (android.service.vr.IVrManager)5 LinearLayout (android.widget.LinearLayout)5 LockPatternUtils (com.android.internal.widget.LockPatternUtils)5 Entry (com.android.systemui.statusbar.NotificationData.Entry)5