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;
}
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) {
}
}
}
}
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();
}
}
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);
}
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));
}
Aggregations