NotificationManagerService( Context context, StatusBarManagerService statusBar, LightsService lights) { super(); mContext = context; mAm = ActivityManagerNative.getDefault(); mSound = new NotificationPlayer(TAG); mSound.setUsesWakeLock(context); mToastQueue = new ArrayList<ToastRecord>(); mHandler = new WorkerHandler(); mStatusBar = statusBar; statusBar.setNotificationCallbacks(mNotificationCallbacks); mNotificationLight = lights.getLight(LightsService.LIGHT_ID_NOTIFICATIONS); mAttentionLight = lights.getLight(LightsService.LIGHT_ID_ATTENTION); Resources resources = mContext.getResources(); mDefaultNotificationColor = resources.getColor(com.android.internal.R.color.config_defaultNotificationColor); mDefaultNotificationLedOn = resources.getInteger(com.android.internal.R.integer.config_defaultNotificationLedOn); mDefaultNotificationLedOff = resources.getInteger(com.android.internal.R.integer.config_defaultNotificationLedOff); // Don't start allowing notifications until the setup wizard has run once. // After that, including subsequent boots, init with notifications turned on. // This works on the first boot because the setup wizard will toggle this // flag at least once and we'll go back to 0 after that. if (0 == Settings.Secure.getInt( mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0)) { mDisabledNotifications = StatusBarManager.DISABLE_NOTIFICATION_ALERTS; } // register for various Intents IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED); filter.addAction(Intent.ACTION_USER_PRESENT); mContext.registerReceiver(mIntentReceiver, filter); IntentFilter pkgFilter = new IntentFilter(); pkgFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); pkgFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); pkgFilter.addAction(Intent.ACTION_PACKAGE_RESTARTED); pkgFilter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART); pkgFilter.addDataScheme("package"); mContext.registerReceiver(mIntentReceiver, pkgFilter); IntentFilter sdFilter = new IntentFilter(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE); mContext.registerReceiver(mIntentReceiver, sdFilter); SettingsObserver observer = new SettingsObserver(mHandler); observer.observe(); }
Led(Context context, LightsService lights) { mLightsService = lights; mBatteryLight = lights.getLight(LightsService.LIGHT_ID_BATTERY); mBatteryLowARGB = mContext .getResources() .getInteger(com.android.internal.R.integer.config_notificationsBatteryLowARGB); mBatteryMediumARGB = mContext .getResources() .getInteger(com.android.internal.R.integer.config_notificationsBatteryMediumARGB); mBatteryFullARGB = mContext .getResources() .getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB); mBatteryLedOn = mContext .getResources() .getInteger(com.android.internal.R.integer.config_notificationsBatteryLedOn); mBatteryLedOff = mContext .getResources() .getInteger(com.android.internal.R.integer.config_notificationsBatteryLedOff); }