Search in sources :

Example 41 with IntentFilter

use of android.content.IntentFilter in project platform_frameworks_base by android.

the class KeyguardViewMediator method setupLocked.

private void setupLocked() {
    mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    mWM = WindowManagerGlobal.getWindowManagerService();
    mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);
    mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
    mShowKeyguardWakeLock.setReferenceCounted(false);
    mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION));
    mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_LOCK_PROFILE_ACTION));
    mKeyguardDisplayManager = new KeyguardDisplayManager(mContext);
    mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
    mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
    mLockPatternUtils = new LockPatternUtils(mContext);
    KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser());
    // Assume keyguard is showing (unless it's disabled) until we know for sure...
    setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled(KeyguardUpdateMonitor.getCurrentUser()));
    updateInputRestrictedLocked();
    mTrustManager.reportKeyguardShowingChanged();
    mStatusBarKeyguardViewManager = SystemUIFactory.getInstance().createStatusBarKeyguardViewManager(mContext, mViewMediatorCallback, mLockPatternUtils);
    final ContentResolver cr = mContext.getContentResolver();
    mDeviceInteractive = mPM.isInteractive();
    mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
    String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND);
    if (soundPath != null) {
        mLockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mLockSoundId == 0) {
        Log.w(TAG, "failed to load lock sound from " + soundPath);
    }
    soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND);
    if (soundPath != null) {
        mUnlockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mUnlockSoundId == 0) {
        Log.w(TAG, "failed to load unlock sound from " + soundPath);
    }
    soundPath = Settings.Global.getString(cr, Settings.Global.TRUSTED_SOUND);
    if (soundPath != null) {
        mTrustedSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mTrustedSoundId == 0) {
        Log.w(TAG, "failed to load trusted sound from " + soundPath);
    }
    int lockSoundDefaultAttenuation = mContext.getResources().getInteger(com.android.internal.R.integer.config_lockSoundVolumeDb);
    mLockSoundVolume = (float) Math.pow(10, (float) lockSoundDefaultAttenuation / 20);
    mHideAnimation = AnimationUtils.loadAnimation(mContext, com.android.internal.R.anim.lock_screen_behind_enter);
}
Also used : IntentFilter(android.content.IntentFilter) KeyguardDisplayManager(com.android.keyguard.KeyguardDisplayManager) LockPatternUtils(com.android.internal.widget.LockPatternUtils) SoundPool(android.media.SoundPool) ContentResolver(android.content.ContentResolver)

Example 42 with IntentFilter

use of android.content.IntentFilter in project platform_frameworks_base by android.

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));
}
Also used : IntentFilter(android.content.IntentFilter) Rect(android.graphics.Rect) Recents(com.android.systemui.recents.Recents) Configuration(android.content.res.Configuration) LockPatternUtils(com.android.internal.widget.LockPatternUtils) ArrayList(java.util.ArrayList) IBinder(android.os.IBinder) ComponentName(android.content.ComponentName) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) RemoteException(android.os.RemoteException) IVrManager(android.service.vr.IVrManager)

Example 43 with IntentFilter

use of android.content.IntentFilter in project platform_frameworks_base by android.

the class ServiceMonitor method start.

public void start() {
    // listen for setting changes
    ContentResolver cr = mContext.getContentResolver();
    cr.registerContentObserver(Settings.Secure.getUriFor(mSettingKey), false, /*notifyForDescendents*/
    mSettingObserver, UserHandle.USER_ALL);
    // listen for package/component changes
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addDataScheme("package");
    mContext.registerReceiver(mBroadcastReceiver, filter);
    mHandler.sendEmptyMessage(MSG_START_SERVICE);
}
Also used : IntentFilter(android.content.IntentFilter) ContentResolver(android.content.ContentResolver)

Example 44 with IntentFilter

use of android.content.IntentFilter in project platform_frameworks_base by android.

the class NetworkActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Register BroadcastReceiver to track connection changes.
    IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    receiver = new NetworkReceiver();
    this.registerReceiver(receiver, filter);
}
Also used : IntentFilter(android.content.IntentFilter)

Example 45 with IntentFilter

use of android.content.IntentFilter in project platform_frameworks_base by android.

the class LocationManagerService method systemRunning.

public void systemRunning() {
    synchronized (mLock) {
        if (D)
            Log.d(TAG, "systemRunning()");
        // fetch package manager
        mPackageManager = mContext.getPackageManager();
        // fetch power manager
        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        // prepare worker thread
        mLocationHandler = new LocationWorkerHandler(BackgroundThread.get().getLooper());
        // prepare mLocationHandler's dependents
        mLocationFudger = new LocationFudger(mContext, mLocationHandler);
        mBlacklist = new LocationBlacklist(mContext, mLocationHandler);
        mBlacklist.init();
        mGeofenceManager = new GeofenceManager(mContext, mBlacklist);
        // Monitor for app ops mode changes.
        AppOpsManager.OnOpChangedListener callback = new AppOpsManager.OnOpChangedInternalListener() {

            public void onOpChanged(int op, String packageName) {
                synchronized (mLock) {
                    for (Receiver receiver : mReceivers.values()) {
                        receiver.updateMonitoring(true);
                    }
                    applyAllProviderRequirementsLocked();
                }
            }
        };
        mAppOps.startWatchingMode(AppOpsManager.OP_COARSE_LOCATION, null, callback);
        PackageManager.OnPermissionsChangedListener permissionListener = new PackageManager.OnPermissionsChangedListener() {

            @Override
            public void onPermissionsChanged(final int uid) {
                synchronized (mLock) {
                    applyAllProviderRequirementsLocked();
                }
            }
        };
        mPackageManager.addOnPermissionsChangeListener(permissionListener);
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        updateUserProfiles(mCurrentUserId);
        // prepare providers
        loadProvidersLocked();
        updateProvidersLocked();
    }
    // listen for settings changes
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCATION_PROVIDERS_ALLOWED), true, new ContentObserver(mLocationHandler) {

        @Override
        public void onChange(boolean selfChange) {
            synchronized (mLock) {
                updateProvidersLocked();
            }
        }
    }, UserHandle.USER_ALL);
    mPackageMonitor.register(mContext, mLocationHandler.getLooper(), true);
    // listen for user change
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
    intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED);
    intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED);
    intentFilter.addAction(Intent.ACTION_SHUTDOWN);
    mContext.registerReceiverAsUser(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (Intent.ACTION_USER_SWITCHED.equals(action)) {
                switchUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
            } else if (Intent.ACTION_MANAGED_PROFILE_ADDED.equals(action) || Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) {
                updateUserProfiles(mCurrentUserId);
            } else if (Intent.ACTION_SHUTDOWN.equals(action)) {
                // shutdown only if UserId indicates whole system, not just one user
                if (D)
                    Log.d(TAG, "Shutdown received with UserId: " + getSendingUserId());
                if (getSendingUserId() == UserHandle.USER_ALL) {
                    shutdownComponents();
                }
            }
        }
    }, UserHandle.ALL, intentFilter, null, mLocationHandler);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) LocationBlacklist(com.android.server.location.LocationBlacklist) GeofenceManager(com.android.server.location.GeofenceManager) BroadcastReceiver(android.content.BroadcastReceiver) LocationFudger(com.android.server.location.LocationFudger) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) AppOpsManager(android.app.AppOpsManager) PackageManager(android.content.pm.PackageManager) ContentObserver(android.database.ContentObserver)

Aggregations

IntentFilter (android.content.IntentFilter)1505 Intent (android.content.Intent)516 Context (android.content.Context)305 BroadcastReceiver (android.content.BroadcastReceiver)285 PendingIntent (android.app.PendingIntent)155 RemoteException (android.os.RemoteException)80 Handler (android.os.Handler)65 ComponentName (android.content.ComponentName)55 PowerManager (android.os.PowerManager)50 View (android.view.View)50 Uri (android.net.Uri)42 Test (org.junit.Test)42 ArrayList (java.util.ArrayList)39 TextView (android.widget.TextView)37 HandlerThread (android.os.HandlerThread)34 ResolveInfo (android.content.pm.ResolveInfo)30 File (java.io.File)30 PackageManager (android.content.pm.PackageManager)28 Point (android.graphics.Point)28 IOException (java.io.IOException)28