Search in sources :

Example 86 with BroadcastReceiver

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

the class UserManagerService method finishRemoveUser.

void finishRemoveUser(final int userHandle) {
    if (DBG)
        Slog.i(LOG_TAG, "finishRemoveUser " + userHandle);
    // Let other services shutdown any activity and clean up their state before completely
    // wiping the user's system directory and removing from the user list
    long ident = Binder.clearCallingIdentity();
    try {
        Intent addedIntent = new Intent(Intent.ACTION_USER_REMOVED);
        addedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userHandle);
        mContext.sendOrderedBroadcastAsUser(addedIntent, UserHandle.ALL, android.Manifest.permission.MANAGE_USERS, new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                if (DBG) {
                    Slog.i(LOG_TAG, "USER_REMOVED broadcast sent, cleaning up user data " + userHandle);
                }
                new Thread() {

                    @Override
                    public void run() {
                        // Clean up any ActivityManager state
                        LocalServices.getService(ActivityManagerInternal.class).onUserRemoved(userHandle);
                        removeUserState(userHandle);
                    }
                }.start();
            }
        }, null, Activity.RESULT_OK, null, null);
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
Also used : Context(android.content.Context) ActivityManagerInternal(android.app.ActivityManagerInternal) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 87 with BroadcastReceiver

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

the class ServiceWatcher method start.

/**
     * Start this watcher, including binding to the current best match and
     * re-binding to any better matches down the road.
     * <p>
     * Note that if there are no matching encryption-aware services, we may not
     * bind to a real service until after the current user is unlocked.
     *
     * @returns {@code true} if a potential service implementation was found.
     */
public boolean start() {
    if (isServiceMissing())
        return false;
    synchronized (mLock) {
        bindBestPackageLocked(mServicePackageName, false);
    }
    // listen for user change
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
    intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
    mContext.registerReceiverAsUser(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
            if (Intent.ACTION_USER_SWITCHED.equals(action)) {
                switchUser(userId);
            } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
                unlockUser(userId);
            }
        }
    }, UserHandle.ALL, intentFilter, null, mHandler);
    // listen for relevant package changes if service overlay is enabled.
    if (mServicePackageName == null) {
        mPackageMonitor.register(mContext, null, UserHandle.ALL, true);
    }
    return true;
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 88 with BroadcastReceiver

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

the class VibratorService method systemReady.

public void systemReady() {
    mIm = mContext.getSystemService(InputManager.class);
    mSettingObserver = new SettingsObserver(mH);
    mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);
    mPowerManagerInternal.registerLowPowerModeObserver(new PowerManagerInternal.LowPowerModeListener() {

        @Override
        public void onLowPowerModeChanged(boolean enabled) {
            updateInputDeviceVibrators();
        }
    });
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.VIBRATE_INPUT_DEVICES), true, mSettingObserver, UserHandle.USER_ALL);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            updateInputDeviceVibrators();
        }
    }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mH);
    updateInputDeviceVibrators();
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PowerManagerInternal(android.os.PowerManagerInternal) Intent(android.content.Intent) InputManager(android.hardware.input.InputManager) BroadcastReceiver(android.content.BroadcastReceiver)

Example 89 with BroadcastReceiver

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

the class InputManagerService method start.

public void start() {
    Slog.i(TAG, "Starting input manager");
    nativeStart(mPtr);
    // Add ourself to the Watchdog monitors.
    Watchdog.getInstance().addMonitor(this);
    registerPointerSpeedSettingObserver();
    registerShowTouchesSettingObserver();
    registerAccessibilityLargePointerSettingObserver();
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            updatePointerSpeedFromSettings();
            updateShowTouchesFromSettings();
            updateAccessibilityLargePointerFromSettings();
        }
    }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
    updatePointerSpeedFromSettings();
    updateShowTouchesFromSettings();
    updateAccessibilityLargePointerFromSettings();
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 90 with BroadcastReceiver

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

the class InputManagerService method systemRunning.

// TODO(BT) Pass in paramter for bluetooth system
public void systemRunning() {
    if (DEBUG) {
        Slog.d(TAG, "System ready.");
    }
    mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    mSystemReady = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    filter.addDataScheme("package");
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            updateKeyboardLayouts();
        }
    }, filter, null, mHandler);
    filter = new IntentFilter(BluetoothDevice.ACTION_ALIAS_CHANGED);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            reloadDeviceAliases();
        }
    }, filter, null, mHandler);
    mHandler.sendEmptyMessage(MSG_RELOAD_DEVICE_ALIASES);
    mHandler.sendEmptyMessage(MSG_UPDATE_KEYBOARD_LAYOUTS);
    if (mWiredAccessoryCallbacks != null) {
        mWiredAccessoryCallbacks.systemReady();
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Aggregations

BroadcastReceiver (android.content.BroadcastReceiver)637 Intent (android.content.Intent)564 Context (android.content.Context)493 IntentFilter (android.content.IntentFilter)441 PendingIntent (android.app.PendingIntent)120 Test (org.junit.Test)109 ArrayList (java.util.ArrayList)34 RemoteException (android.os.RemoteException)29 Bundle (android.os.Bundle)24 IOException (java.io.IOException)23 Point (android.graphics.Point)20 Semaphore (java.util.concurrent.Semaphore)20 View (android.view.View)19 Handler (android.os.Handler)18 LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)17 ComponentName (android.content.ComponentName)16 TextView (android.widget.TextView)16 PackageMonitor (com.android.internal.content.PackageMonitor)15 ApplicationInfo (android.content.pm.ApplicationInfo)14 AndroidRuntimeException (android.util.AndroidRuntimeException)14