Search in sources :

Example 6 with LightsManager

use of com.android.server.lights.LightsManager in project android_frameworks_base by ResurrectionRemix.

the class NotificationManagerService method onStart.

@Override
public void onStart() {
    Resources resources = getContext().getResources();
    mMaxPackageEnqueueRate = Settings.Global.getFloat(getContext().getContentResolver(), Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE);
    mAm = ActivityManagerNative.getDefault();
    mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
    mVibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
    mAppUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
    mKeyguardManager = (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE);
    // This is the package that contains the AOSP framework update.
    mRankerServicePackageName = getContext().getPackageManager().getServicesSystemSharedLibraryPackageName();
    mHandler = new WorkerHandler();
    mRankingThread.start();
    String[] extractorNames;
    try {
        extractorNames = resources.getStringArray(R.array.config_notificationSignalExtractors);
    } catch (Resources.NotFoundException e) {
        extractorNames = new String[0];
    }
    mUsageStats = new NotificationUsageStats(getContext());
    mRankingHandler = new RankingHandlerWorker(mRankingThread.getLooper());
    mRankingHelper = new RankingHelper(getContext(), mRankingHandler, mUsageStats, extractorNames);
    mConditionProviders = new ConditionProviders(getContext(), mHandler, mUserProfiles);
    mZenModeHelper = new ZenModeHelper(getContext(), mHandler.getLooper(), mConditionProviders);
    mZenModeHelper.addCallback(new ZenModeHelper.Callback() {

        @Override
        public void onConfigChanged() {
            savePolicyFile();
        }

        @Override
        void onZenModeChanged() {
            sendRegisteredOnlyBroadcast(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED);
            getContext().sendBroadcastAsUser(new Intent(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL).addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT), UserHandle.ALL, android.Manifest.permission.MANAGE_NOTIFICATIONS);
            synchronized (mNotificationList) {
                updateInterruptionFilterLocked();
            }
        }

        @Override
        void onPolicyChanged() {
            sendRegisteredOnlyBroadcast(NotificationManager.ACTION_NOTIFICATION_POLICY_CHANGED);
        }
    });
    final File systemDir = new File(Environment.getDataDirectory(), "system");
    mPolicyFile = new AtomicFile(new File(systemDir, "notification_policy.xml"));
    syncBlockDb();
    // This is a MangedServices object that keeps track of the listeners.
    mListeners = new NotificationListeners();
    // This is a MangedServices object that keeps track of the ranker.
    mRankerServices = new NotificationRankers();
    // Find the updatable ranker and register it.
    mRankerServices.registerRanker();
    mStatusBar = getLocalService(StatusBarManagerInternal.class);
    if (mStatusBar != null) {
        mStatusBar.setNotificationDelegate(mNotificationDelegate);
    }
    final LightsManager lights = getLocalService(LightsManager.class);
    mNotificationLight = lights.getLight(LightsManager.LIGHT_ID_NOTIFICATIONS);
    mAttentionLight = lights.getLight(LightsManager.LIGHT_ID_ATTENTION);
    mDefaultNotificationColor = resources.getColor(R.color.config_defaultNotificationColor);
    mDefaultNotificationLedOn = resources.getInteger(R.integer.config_defaultNotificationLedOn);
    mDefaultNotificationLedOff = resources.getInteger(R.integer.config_defaultNotificationLedOff);
    mMultiColorNotificationLed = doLightsSupport(NotificationManager.LIGHTS_RGB_NOTIFICATION_LED);
    mNotificationPulseCustomLedValues = new ArrayMap<String, NotificationLedValues>();
    mPackageNameMappings = new ArrayMap<String, String>();
    final String[] defaultMapping = resources.getStringArray(com.android.internal.R.array.notification_light_package_mapping);
    for (String mapping : defaultMapping) {
        String[] map = mapping.split("\\|");
        mPackageNameMappings.put(map[0], map[1]);
    }
    mDefaultVibrationPattern = getLongArray(resources, R.array.config_defaultNotificationVibePattern, VIBRATE_PATTERN_MAXLEN, DEFAULT_VIBRATE_PATTERN);
    mFallbackVibrationPattern = getLongArray(resources, R.array.config_notificationFallbackVibePattern, VIBRATE_PATTERN_MAXLEN, DEFAULT_VIBRATE_PATTERN);
    mAdjustableNotificationLedBrightness = doLightsSupport(NotificationManager.LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS);
    mMultipleNotificationLeds = doLightsSupport(NotificationManager.LIGHTS_MULTIPLE_NOTIFICATION_LED);
    mUseAttentionLight = resources.getBoolean(R.bool.config_useAttentionLight);
    // flag at least once and we'll go back to 0 after that.
    if (0 == Settings.Global.getInt(getContext().getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0)) {
        mDisableNotificationEffects = true;
    }
    mZenModeHelper.initZenMode();
    mZenModeHelper.readAllowLightsFromSettings();
    mZenModeHelper.readVibrationModeFromSettings();
    mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter();
    mUserProfiles.updateCache(getContext());
    listenForCallState();
    // 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);
    filter.addAction(Intent.ACTION_USER_STOPPED);
    filter.addAction(Intent.ACTION_USER_SWITCHED);
    filter.addAction(Intent.ACTION_USER_ADDED);
    filter.addAction(Intent.ACTION_USER_REMOVED);
    filter.addAction(Intent.ACTION_USER_UNLOCKED);
    filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE);
    getContext().registerReceiver(mIntentReceiver, filter);
    IntentFilter pkgFilter = new IntentFilter();
    pkgFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    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");
    getContext().registerReceiverAsUser(mPackageIntentReceiver, UserHandle.ALL, pkgFilter, null, null);
    IntentFilter suspendedPkgFilter = new IntentFilter();
    suspendedPkgFilter.addAction(Intent.ACTION_PACKAGES_SUSPENDED);
    getContext().registerReceiverAsUser(mPackageIntentReceiver, UserHandle.ALL, suspendedPkgFilter, null, null);
    IntentFilter sdFilter = new IntentFilter(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    getContext().registerReceiverAsUser(mPackageIntentReceiver, UserHandle.ALL, sdFilter, null, null);
    mSettingsObserver = new LEDSettingsObserver(mHandler);
    mSettingsObserver.observe();
    mArchive = new Archive(resources.getInteger(R.integer.config_notificationServiceArchiveSize));
    publishBinderService(Context.NOTIFICATION_SERVICE, mService);
    publishLocalService(NotificationManagerInternal.class, mInternalService);
}
Also used : UsageStatsManagerInternal(android.app.usage.UsageStatsManagerInternal) IntentFilter(android.content.IntentFilter) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) StatusBarManagerInternal(com.android.server.statusbar.StatusBarManagerInternal) AtomicFile(android.util.AtomicFile) LightsManager(com.android.server.lights.LightsManager) Resources(android.content.res.Resources) File(java.io.File) AtomicFile(android.util.AtomicFile)

Example 7 with LightsManager

use of com.android.server.lights.LightsManager in project android_frameworks_base by crdroidandroid.

the class NotificationManagerService method onStart.

@Override
public void onStart() {
    Resources resources = getContext().getResources();
    mMaxPackageEnqueueRate = Settings.Global.getFloat(getContext().getContentResolver(), Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE);
    mAm = ActivityManagerNative.getDefault();
    mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
    mVibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
    mAppUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
    mKeyguardManager = (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE);
    // This is the package that contains the AOSP framework update.
    mRankerServicePackageName = getContext().getPackageManager().getServicesSystemSharedLibraryPackageName();
    mHandler = new WorkerHandler();
    mRankingThread.start();
    String[] extractorNames;
    try {
        extractorNames = resources.getStringArray(R.array.config_notificationSignalExtractors);
    } catch (Resources.NotFoundException e) {
        extractorNames = new String[0];
    }
    mUsageStats = new NotificationUsageStats(getContext());
    mRankingHandler = new RankingHandlerWorker(mRankingThread.getLooper());
    mRankingHelper = new RankingHelper(getContext(), mRankingHandler, mUsageStats, extractorNames);
    mConditionProviders = new ConditionProviders(getContext(), mHandler, mUserProfiles);
    mZenModeHelper = new ZenModeHelper(getContext(), mHandler.getLooper(), mConditionProviders);
    mZenModeHelper.addCallback(new ZenModeHelper.Callback() {

        @Override
        public void onConfigChanged() {
            savePolicyFile();
        }

        @Override
        void onZenModeChanged() {
            sendRegisteredOnlyBroadcast(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED);
            getContext().sendBroadcastAsUser(new Intent(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL).addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT), UserHandle.ALL, android.Manifest.permission.MANAGE_NOTIFICATIONS);
            synchronized (mNotificationList) {
                updateInterruptionFilterLocked();
            }
        }

        @Override
        void onPolicyChanged() {
            sendRegisteredOnlyBroadcast(NotificationManager.ACTION_NOTIFICATION_POLICY_CHANGED);
        }
    });
    final File systemDir = new File(Environment.getDataDirectory(), "system");
    mPolicyFile = new AtomicFile(new File(systemDir, "notification_policy.xml"));
    syncBlockDb();
    // This is a MangedServices object that keeps track of the listeners.
    mListeners = new NotificationListeners();
    // This is a MangedServices object that keeps track of the ranker.
    mRankerServices = new NotificationRankers();
    // Find the updatable ranker and register it.
    mRankerServices.registerRanker();
    mStatusBar = getLocalService(StatusBarManagerInternal.class);
    if (mStatusBar != null) {
        mStatusBar.setNotificationDelegate(mNotificationDelegate);
    }
    final LightsManager lights = getLocalService(LightsManager.class);
    mNotificationLight = lights.getLight(LightsManager.LIGHT_ID_NOTIFICATIONS);
    mAttentionLight = lights.getLight(LightsManager.LIGHT_ID_ATTENTION);
    mDefaultNotificationColor = resources.getColor(R.color.config_defaultNotificationColor);
    mDefaultNotificationLedOn = resources.getInteger(R.integer.config_defaultNotificationLedOn);
    mDefaultNotificationLedOff = resources.getInteger(R.integer.config_defaultNotificationLedOff);
    mMultiColorNotificationLed = doLightsSupport(NotificationManager.LIGHTS_RGB_NOTIFICATION_LED);
    mNotificationPulseCustomLedValues = new ArrayMap<String, NotificationLedValues>();
    mPackageNameMappings = new ArrayMap<String, String>();
    final String[] defaultMapping = resources.getStringArray(com.android.internal.R.array.notification_light_package_mapping);
    for (String mapping : defaultMapping) {
        String[] map = mapping.split("\\|");
        mPackageNameMappings.put(map[0], map[1]);
    }
    mDefaultVibrationPattern = getLongArray(resources, R.array.config_defaultNotificationVibePattern, VIBRATE_PATTERN_MAXLEN, DEFAULT_VIBRATE_PATTERN);
    mFallbackVibrationPattern = getLongArray(resources, R.array.config_notificationFallbackVibePattern, VIBRATE_PATTERN_MAXLEN, DEFAULT_VIBRATE_PATTERN);
    mAdjustableNotificationLedBrightness = doLightsSupport(NotificationManager.LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS);
    mMultipleNotificationLeds = doLightsSupport(NotificationManager.LIGHTS_MULTIPLE_NOTIFICATION_LED);
    mUseAttentionLight = resources.getBoolean(R.bool.config_useAttentionLight);
    // flag at least once and we'll go back to 0 after that.
    if (0 == Settings.Global.getInt(getContext().getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0)) {
        mDisableNotificationEffects = true;
    }
    mZenModeHelper.initZenMode();
    mZenModeHelper.readAllowLightsFromSettings();
    mZenModeHelper.readVibrationModeFromSettings();
    mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter();
    mUserProfiles.updateCache(getContext());
    listenForCallState();
    // 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);
    filter.addAction(Intent.ACTION_USER_STOPPED);
    filter.addAction(Intent.ACTION_USER_SWITCHED);
    filter.addAction(Intent.ACTION_USER_ADDED);
    filter.addAction(Intent.ACTION_USER_REMOVED);
    filter.addAction(Intent.ACTION_USER_UNLOCKED);
    filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE);
    getContext().registerReceiver(mIntentReceiver, filter);
    IntentFilter pkgFilter = new IntentFilter();
    pkgFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    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");
    getContext().registerReceiverAsUser(mPackageIntentReceiver, UserHandle.ALL, pkgFilter, null, null);
    IntentFilter suspendedPkgFilter = new IntentFilter();
    suspendedPkgFilter.addAction(Intent.ACTION_PACKAGES_SUSPENDED);
    getContext().registerReceiverAsUser(mPackageIntentReceiver, UserHandle.ALL, suspendedPkgFilter, null, null);
    IntentFilter sdFilter = new IntentFilter(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    getContext().registerReceiverAsUser(mPackageIntentReceiver, UserHandle.ALL, sdFilter, null, null);
    mSettingsObserver = new LEDSettingsObserver(mHandler);
    mSettingsObserver.observe();
    mArchive = new Archive(resources.getInteger(R.integer.config_notificationServiceArchiveSize));
    publishBinderService(Context.NOTIFICATION_SERVICE, mService);
    publishLocalService(NotificationManagerInternal.class, mInternalService);
}
Also used : UsageStatsManagerInternal(android.app.usage.UsageStatsManagerInternal) IntentFilter(android.content.IntentFilter) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) StatusBarManagerInternal(com.android.server.statusbar.StatusBarManagerInternal) AtomicFile(android.util.AtomicFile) LightsManager(com.android.server.lights.LightsManager) Resources(android.content.res.Resources) File(java.io.File) AtomicFile(android.util.AtomicFile)

Aggregations

LightsManager (com.android.server.lights.LightsManager)7 PendingIntent (android.app.PendingIntent)5 UsageStatsManagerInternal (android.app.usage.UsageStatsManagerInternal)5 Intent (android.content.Intent)5 IntentFilter (android.content.IntentFilter)5 Resources (android.content.res.Resources)5 AtomicFile (android.util.AtomicFile)5 StatusBarManagerInternal (com.android.server.statusbar.StatusBarManagerInternal)5 File (java.io.File)5 IBinder (android.os.IBinder)2 Parcel (android.os.Parcel)2 RemoteException (android.os.RemoteException)2 Light (com.android.server.lights.Light)2