Search in sources :

Example 1 with LightsManager

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

the class WindowManagerService method performEnableScreen.

public void performEnableScreen() {
    synchronized (mWindowMap) {
        if (DEBUG_BOOT)
            Slog.i(TAG_WM, "performEnableScreen: mDisplayEnabled=" + mDisplayEnabled + " mForceDisplayEnabled=" + mForceDisplayEnabled + " mShowingBootMessages=" + mShowingBootMessages + " mSystemBooted=" + mSystemBooted + " mOnlyCore=" + mOnlyCore, new RuntimeException("here").fillInStackTrace());
        if (mDisplayEnabled) {
            return;
        }
        if (!mSystemBooted && !mShowingBootMessages) {
            return;
        }
        // Don't enable the screen until all existing windows have been drawn.
        if (!mForceDisplayEnabled && checkWaitingForWindowsLocked()) {
            return;
        }
        if (!mBootAnimationStopped) {
            // Do this one time.
            Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "Stop bootanim", 0);
            try {
                IBinder surfaceFlinger = ServiceManager.getService("SurfaceFlinger");
                if (surfaceFlinger != null) {
                    //Slog.i(TAG_WM, "******* TELLING SURFACE FLINGER WE ARE BOOTED!");
                    Parcel data = Parcel.obtain();
                    data.writeInterfaceToken("android.ui.ISurfaceComposer");
                    // BOOT_FINISHED
                    surfaceFlinger.transact(// BOOT_FINISHED
                    IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
                    data.recycle();
                }
            } catch (RemoteException ex) {
                Slog.e(TAG_WM, "Boot completed: SurfaceFlinger is dead!");
            }
            mBootAnimationStopped = true;
        }
        if (!mForceDisplayEnabled && !checkBootAnimationCompleteLocked()) {
            if (DEBUG_BOOT)
                Slog.i(TAG_WM, "performEnableScreen: Waiting for anim complete");
            return;
        }
        EventLog.writeEvent(EventLogTags.WM_BOOT_ANIMATION_DONE, SystemClock.uptimeMillis());
        Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "Stop bootanim", 0);
        mDisplayEnabled = true;
        if (DEBUG_SCREEN_ON || DEBUG_BOOT)
            Slog.i(TAG_WM, "******************** ENABLING SCREEN!");
        // Enable input dispatch.
        mInputMonitor.setEventDispatchingLw(mEventDispatchingEnabled);
    }
    try {
        mActivityManager.bootAnimationComplete();
    } catch (RemoteException e) {
    }
    mPolicy.enableScreenAfterBoot();
    // clear any intrusive lighting which may still be on from the
    // crypto landing ui
    LightsManager lm = LocalServices.getService(LightsManager.class);
    Light batteryLight = lm.getLight(LightsManager.LIGHT_ID_BATTERY);
    Light notifLight = lm.getLight(LightsManager.LIGHT_ID_NOTIFICATIONS);
    if (batteryLight != null) {
        batteryLight.turnOff();
    }
    if (notifLight != null) {
        notifLight.turnOff();
    }
    // Make sure the last requested orientation has been applied.
    updateRotationUnchecked(false, false);
}
Also used : IBinder(android.os.IBinder) Parcel(android.os.Parcel) Light(com.android.server.lights.Light) LightsManager(com.android.server.lights.LightsManager) RemoteException(android.os.RemoteException)

Example 2 with LightsManager

use of com.android.server.lights.LightsManager in project platform_frameworks_base by android.

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);
    // 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);
    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);
    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();
    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 SettingsObserver(mHandler);
    mArchive = new Archive(resources.getInteger(R.integer.config_notificationServiceArchiveSize));
    publishBinderService(Context.NOTIFICATION_SERVICE, mService);
    publishLocalService(NotificationManagerInternal.class, mInternalService);
}
Also used : 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) UsageStatsManagerInternal(android.app.usage.UsageStatsManagerInternal) File(java.io.File) AtomicFile(android.util.AtomicFile)

Example 3 with LightsManager

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

the class WindowManagerService method performEnableScreen.

public void performEnableScreen() {
    synchronized (mWindowMap) {
        if (DEBUG_BOOT)
            Slog.i(TAG_WM, "performEnableScreen: mDisplayEnabled=" + mDisplayEnabled + " mForceDisplayEnabled=" + mForceDisplayEnabled + " mShowingBootMessages=" + mShowingBootMessages + " mSystemBooted=" + mSystemBooted + " mOnlyCore=" + mOnlyCore, new RuntimeException("here").fillInStackTrace());
        if (mDisplayEnabled) {
            return;
        }
        if (!mSystemBooted && !mShowingBootMessages) {
            return;
        }
        // Don't enable the screen until all existing windows have been drawn.
        if (!mForceDisplayEnabled && checkWaitingForWindowsLocked()) {
            return;
        }
        if (!mBootAnimationStopped) {
            // Do this one time.
            Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "Stop bootanim", 0);
            try {
                IBinder surfaceFlinger = ServiceManager.getService("SurfaceFlinger");
                if (surfaceFlinger != null) {
                    //Slog.i(TAG_WM, "******* TELLING SURFACE FLINGER WE ARE BOOTED!");
                    Parcel data = Parcel.obtain();
                    data.writeInterfaceToken("android.ui.ISurfaceComposer");
                    // BOOT_FINISHED
                    surfaceFlinger.transact(// BOOT_FINISHED
                    IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
                    data.recycle();
                }
            } catch (RemoteException ex) {
                Slog.e(TAG_WM, "Boot completed: SurfaceFlinger is dead!");
            }
            mBootAnimationStopped = true;
        }
        if (!mForceDisplayEnabled && !checkBootAnimationCompleteLocked()) {
            if (DEBUG_BOOT)
                Slog.i(TAG_WM, "performEnableScreen: Waiting for anim complete");
            return;
        }
        EventLog.writeEvent(EventLogTags.WM_BOOT_ANIMATION_DONE, SystemClock.uptimeMillis());
        Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "Stop bootanim", 0);
        mDisplayEnabled = true;
        if (DEBUG_SCREEN_ON || DEBUG_BOOT)
            Slog.i(TAG_WM, "******************** ENABLING SCREEN!");
        // Enable input dispatch.
        mInputMonitor.setEventDispatchingLw(mEventDispatchingEnabled);
    }
    try {
        mActivityManager.bootAnimationComplete();
    } catch (RemoteException e) {
    }
    mPolicy.enableScreenAfterBoot();
    // clear any intrusive lighting which may still be on from the
    // crypto landing ui
    LightsManager lm = LocalServices.getService(LightsManager.class);
    Light batteryLight = lm.getLight(LightsManager.LIGHT_ID_BATTERY);
    Light notifLight = lm.getLight(LightsManager.LIGHT_ID_NOTIFICATIONS);
    if (batteryLight != null) {
        batteryLight.turnOff();
    }
    if (notifLight != null) {
        notifLight.turnOff();
    }
    // Make sure the last requested orientation has been applied.
    updateRotationUnchecked(false, false);
}
Also used : IBinder(android.os.IBinder) Parcel(android.os.Parcel) Light(com.android.server.lights.Light) LightsManager(com.android.server.lights.LightsManager) RemoteException(android.os.RemoteException)

Example 4 with LightsManager

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

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);
    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);
    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.readLightsAllowedModeFromSetting();
    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 5 with LightsManager

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

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);
    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);
    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.readLightsAllowedModeFromSetting();
    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);
    filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
    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);
    mConfigManager = (CarrierConfigManager) getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
}
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