Search in sources :

Example 11 with StatusBarIcon

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

the class PhoneStatusBar method recreateStatusBar.

private void recreateStatusBar() {
    mRecreating = true;
    mStatusBarContainer.removeAllViews();
    // extract icons from the soon-to-be recreated viewgroup.
    int nIcons = mStatusIcons.getChildCount();
    ArrayList<StatusBarIcon> icons = new ArrayList<StatusBarIcon>(nIcons);
    ArrayList<String> iconSlots = new ArrayList<String>(nIcons);
    for (int i = 0; i < nIcons; i++) {
        StatusBarIconView iconView = (StatusBarIconView) mStatusIcons.getChildAt(i);
        icons.add(iconView.getStatusBarIcon());
        iconSlots.add(iconView.getStatusBarSlot());
    }
    // extract notifications.
    int nNotifs = mNotificationData.size();
    ArrayList<Pair<IBinder, StatusBarNotification>> notifications = new ArrayList<Pair<IBinder, StatusBarNotification>>(nNotifs);
    copyNotifications(notifications, mNotificationData);
    mNotificationData.clear();
    makeStatusBarView();
    repositionNavigationBar();
    mNavigationBarView.updateResources();
    // recreate StatusBarIconViews.
    for (int i = 0; i < nIcons; i++) {
        StatusBarIcon icon = icons.get(i);
        String slot = iconSlots.get(i);
        addIcon(slot, i, i, icon);
    }
    // recreate notifications.
    for (int i = 0; i < nNotifs; i++) {
        Pair<IBinder, StatusBarNotification> notifData = notifications.get(i);
        addNotificationViews(notifData.first, notifData.second);
    }
    setAreThereNotifications();
    mStatusBarContainer.addView(mStatusBarWindow);
    updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
    mRecreating = false;
}
Also used : IBinder(android.os.IBinder) StatusBarNotification(android.service.notification.StatusBarNotification) ArrayList(java.util.ArrayList) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) Point(android.graphics.Point) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) Pair(android.util.Pair)

Example 12 with StatusBarIcon

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

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 13 with StatusBarIcon

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

the class StatusBarIconController method setIcon.

public void setIcon(String slot, int resourceId, CharSequence contentDescription) {
    int index = getSlotIndex(slot);
    StatusBarIcon icon = getIcon(index);
    if (icon == null) {
        icon = new StatusBarIcon(UserHandle.SYSTEM, mContext.getPackageName(), Icon.createWithResource(mContext, resourceId), 0, 0, contentDescription);
        setIcon(slot, icon);
    } else {
        icon.icon = Icon.createWithResource(mContext, resourceId);
        icon.contentDescription = contentDescription;
        handleSet(index, icon);
    }
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

Example 14 with StatusBarIcon

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

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);
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.ALWAYS_HEADSUP_DIALER), false, mSettingsObserver, UserHandle.USER_ALL);
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.NAVIGATION_BAR_VISIBLE), false, mSettingsObserver, UserHandle.USER_ALL);
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.HARDWARE_KEYS_DISABLE), false, mSettingsObserver, UserHandle.USER_ALL);
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.NO_NAVIGATION_NOTIFICATION), false, mSettingsObserver, UserHandle.USER_ALL);
    mBarService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    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);
    filter.addAction(ACTION_ENABLE_NAVIGATION_KEY);
    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));
    mPieSettingsObserver.onChange(false);
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.PA_PIE_STATE), false, mPieSettingsObserver);
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.PA_PIE_GRAVITY), false, mPieSettingsObserver);
}
Also used : IntentFilter(android.content.IntentFilter) Rect(android.graphics.Rect) 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)

Example 15 with StatusBarIcon

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

the class StatusBarManagerService method dump.

// ================================================================================
// Always called from UI thread
// ================================================================================
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        pw.println("Permission Denial: can't dump StatusBar from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
        return;
    }
    synchronized (mLock) {
        pw.println("  mDisabled1=0x" + Integer.toHexString(mDisabled1));
        pw.println("  mDisabled2=0x" + Integer.toHexString(mDisabled2));
        final int N = mDisableRecords.size();
        pw.println("  mDisableRecords.size=" + N);
        for (int i = 0; i < N; i++) {
            DisableRecord tok = mDisableRecords.get(i);
            pw.println("    [" + i + "] userId=" + tok.userId + " what1=0x" + Integer.toHexString(tok.what1) + " what2=0x" + Integer.toHexString(tok.what2) + " pkg=" + tok.pkg + " token=" + tok.token);
        }
        pw.println("  mCurrentUserId=" + mCurrentUserId);
        pw.println("  mIcons=");
        for (String slot : mIcons.keySet()) {
            pw.println("    ");
            pw.print(slot);
            pw.print(" -> ");
            final StatusBarIcon icon = mIcons.get(slot);
            pw.print(icon);
            if (!TextUtils.isEmpty(icon.contentDescription)) {
                pw.print(" \"");
                pw.print(icon.contentDescription);
                pw.print("\"");
            }
            pw.println();
        }
    }
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

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