diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java')
-rwxr-xr-x | packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java | 116 |
1 files changed, 96 insertions, 20 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 7b608bb..e958ee1 100755 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -45,6 +45,7 @@ import android.database.ContentObserver; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; +import android.media.session.MediaController; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; @@ -117,6 +118,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import cyanogenmod.providers.CMSettings; + import static com.android.keyguard.KeyguardHostView.OnDismissAction; public abstract class BaseStatusBar extends SystemUI implements @@ -154,6 +157,8 @@ public abstract class BaseStatusBar extends SystemUI implements private static final String BANNER_ACTION_SETUP = "com.android.systemui.statusbar.banner_action_setup"; + protected static final int SYSTEM_UI_VISIBILITY_MASK = 0xffffffff; + private static final Uri SPAM_MESSAGE_URI = new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) .authority(SpamMessageProvider.AUTHORITY) @@ -221,6 +226,8 @@ public abstract class BaseStatusBar extends SystemUI implements protected WindowManager mWindowManager; protected IWindowManager mWindowManagerService; + private NotificationManager mNoMan; + protected abstract void refreshLayout(int layoutDirection); protected Display mDisplay; @@ -263,8 +270,8 @@ public abstract class BaseStatusBar extends SystemUI implements protected final ContentObserver mSettingsObserver = new ContentObserver(mHandler) { @Override public void onChange(boolean selfChange) { - final boolean provisioned = 0 != Settings.Global.getInt( - mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0); + final boolean provisioned = 0 != CMSettings.Secure.getInt( + mContext.getContentResolver(), CMSettings.Secure.CM_SETUP_WIZARD_COMPLETED, 0); if (provisioned != mDeviceProvisioned) { mDeviceProvisioned = provisioned; updateNotifications(); @@ -427,9 +434,7 @@ public abstract class BaseStatusBar extends SystemUI implements } } } else if (BANNER_ACTION_CANCEL.equals(action) || BANNER_ACTION_SETUP.equals(action)) { - NotificationManager noMan = (NotificationManager) - mContext.getSystemService(Context.NOTIFICATION_SERVICE); - noMan.cancel(R.id.notification_hidden); + mNoMan.cancel(R.id.notification_hidden); Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0); @@ -558,6 +563,9 @@ public abstract class BaseStatusBar extends SystemUI implements public void start() { mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); + + mNoMan = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); + mDisplay = mWindowManager.getDefaultDisplay(); mDevicePolicyManager = (DevicePolicyManager)mContext.getSystemService( Context.DEVICE_POLICY_SERVICE); @@ -574,8 +582,8 @@ public abstract class BaseStatusBar extends SystemUI implements mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mContext.getContentResolver().registerContentObserver( - Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, - mSettingsObserver); + CMSettings.Secure.getUriFor(CMSettings.Secure.CM_SETUP_WIZARD_COMPLETED), false, + mSettingsObserver, UserHandle.USER_ALL); mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.ZEN_MODE), false, mSettingsObserver); @@ -624,7 +632,7 @@ public abstract class BaseStatusBar extends SystemUI implements mSettingsObserver.onChange(false); // set up disable(switches[0], switches[6], false /* animate */); - setSystemUiVisibility(switches[1], 0xffffffff); + setSystemUiVisibility(switches[1], SYSTEM_UI_VISIBILITY_MASK); 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); @@ -723,9 +731,7 @@ public abstract class BaseStatusBar extends SystemUI implements mContext.getString(R.string.hidden_notifications_setup), setupIntent); - NotificationManager noMan = - (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); - noMan.notify(R.id.notification_hidden, note.build()); + mNoMan.notify(R.id.notification_hidden, note.build()); } } @@ -769,6 +775,10 @@ public abstract class BaseStatusBar extends SystemUI implements return null; } + protected MediaController getCurrentMediaController() { + return null; + } + @Override public NotificationGroupManager getGroupManager() { return mGroupManager; @@ -947,7 +957,9 @@ public abstract class BaseStatusBar extends SystemUI implements } }); - filterButton.setVisibility(View.VISIBLE); + Notification notification = sbn.getNotification(); + filterButton.setVisibility(SpamFilter.hasFilterableContent(notification) + ? View.VISIBLE : View.GONE); filterButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AsyncTask.execute(new Runnable() { @@ -1014,6 +1026,10 @@ public abstract class BaseStatusBar extends SystemUI implements } ExpandableNotificationRow row = (ExpandableNotificationRow) v; + if (v instanceof MediaExpandableNotificationRow + && !((MediaExpandableNotificationRow) v).inflateGuts()) { + return false; + } bindGuts(row); // Assume we are a status_bar_notification_row @@ -1280,6 +1296,20 @@ public abstract class BaseStatusBar extends SystemUI implements } protected boolean inflateViews(Entry entry, ViewGroup parent) { + final StatusBarNotification sbn = entry.notification; + String themePackageName = mCurrentTheme != null + ? mCurrentTheme.getOverlayPkgNameForApp(sbn.getPackageName()) : null; + boolean inflated = inflateViews(entry, parent, true); + if (!inflated && themePackageName != null + && !ThemeConfig.SYSTEM_DEFAULT.equals(themePackageName)) { + Log.w(TAG, "Couldn't expand themed RemoteViews, trying unthemed for: " + sbn); + inflated = inflateViews(entry, mStackScroller, false); + } + + return inflated; + } + + protected boolean inflateViews(Entry entry, ViewGroup parent, boolean isThemeable) { PackageManager pmUser = getPackageManagerForUser( entry.notification.getUser().getIdentifier()); @@ -1320,8 +1350,19 @@ public abstract class BaseStatusBar extends SystemUI implements // create the row view LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE); - row = (ExpandableNotificationRow) inflater.inflate(R.layout.status_bar_notification_row, - parent, false); + + // cannot use isMediaNotification() + if (sbn.getNotification().category != null + && sbn.getNotification().category.equals(Notification.CATEGORY_TRANSPORT)) { + row = (MediaExpandableNotificationRow) inflater.inflate( + R.layout.status_bar_notification_row_media, parent, false); + ((MediaExpandableNotificationRow)row).setMediaController( + getCurrentMediaController()); + } else { + row = (ExpandableNotificationRow) inflater.inflate( + R.layout.status_bar_notification_row, + parent, false); + } row.setExpansionLogger(this, entry.notification.getKey()); row.setGroupManager(mGroupManager); } @@ -1345,10 +1386,12 @@ public abstract class BaseStatusBar extends SystemUI implements View contentViewLocal = null; View bigContentViewLocal = null; View headsUpContentViewLocal = null; - String themePackageName = mCurrentTheme != null - ? mCurrentTheme.getOverlayPkgNameForApp(sbn.getPackageName()) : null; - String statusBarThemePackageName = mCurrentTheme != null - ? mCurrentTheme.getOverlayForStatusBar() : null; + String themePackageName = (isThemeable && mCurrentTheme != null) + ? mCurrentTheme.getOverlayPkgNameForApp(sbn.getPackageName()) + : ThemeConfig.SYSTEM_DEFAULT; + String statusBarThemePackageName = (isThemeable && mCurrentTheme != null) + ? mCurrentTheme.getOverlayForStatusBar() + : ThemeConfig.SYSTEM_DEFAULT; try { contentViewLocal = contentView.apply( @@ -1439,8 +1482,10 @@ public abstract class BaseStatusBar extends SystemUI implements } if (publicViewLocal == null) { + final Context layoutContext = isThemeable ? mContext + : maybeGetThemedContext(mContext, ThemeConfig.SYSTEM_DEFAULT); // Add a basic notification template - publicViewLocal = LayoutInflater.from(mContext).inflate( + publicViewLocal = LayoutInflater.from(layoutContext).inflate( R.layout.notification_public_default, contentContainerPublic, false); publicViewLocal.setIsRootNamespace(true); @@ -1875,7 +1920,18 @@ public abstract class BaseStatusBar extends SystemUI implements } private boolean shouldShowOnKeyguard(StatusBarNotification sbn) { - return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey()); + if (!mShowLockscreenNotifications || mNotificationData.isAmbient(sbn.getKey())) { + return false; + } + final int showOnKeyguard = mNoMan.getShowNotificationForPackageOnKeyguard( + sbn.getPackageName(), sbn.getUid()); + boolean isKeyguardAllowedForApp = + (showOnKeyguard & Notification.SHOW_ALL_NOTI_ON_KEYGUARD) != 0; + if (isKeyguardAllowedForApp && sbn.isOngoing()) { + isKeyguardAllowedForApp = + (showOnKeyguard & Notification.SHOW_NO_ONGOING_NOTI_ON_KEYGUARD) == 0; + } + return isKeyguardAllowedForApp; } protected void setZenMode(int mode) { @@ -2286,4 +2342,24 @@ public abstract class BaseStatusBar extends SystemUI implements mAssistManager.startAssist(args); } } + + /** + * Returns a context with the given theme applied or the original context if we fail to get a + * themed context. + */ + private Context maybeGetThemedContext(Context context, String themePkg) { + Context themedContext; + try { + ApplicationInfo ai = context.getPackageManager().getApplicationInfo( + context.getPackageName(), 0); + themedContext = context.createApplicationContext(ai, themePkg, + 0); + } catch (PackageManager.NameNotFoundException e) { + themedContext = null; + } + if (themedContext == null) { + themedContext = context; + } + return themedContext; + } } |