Search in sources :

Example 61 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class TelephonyRegistry method systemReady.

public void systemReady() {
    // Watch for interesting updates
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_USER_SWITCHED);
    filter.addAction(Intent.ACTION_USER_REMOVED);
    mContext.registerReceiver(mBroadcastReceiver, filter);
}
Also used : IntentFilter(android.content.IntentFilter)

Example 62 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class NetworkTimeUpdateService method registerForTelephonyIntents.

private void registerForTelephonyIntents() {
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(TelephonyIntents.ACTION_NETWORK_SET_TIME);
    intentFilter.addAction(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE);
    mContext.registerReceiver(mNitzReceiver, intentFilter);
}
Also used : IntentFilter(android.content.IntentFilter)

Example 63 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class ActivityManagerService method finishBooting.

final void finishBooting() {
    IntentFilter pkgFilter = new IntentFilter();
    pkgFilter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
    pkgFilter.addDataScheme("package");
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String[] pkgs = intent.getStringArrayExtra(Intent.EXTRA_PACKAGES);
            if (pkgs != null) {
                for (String pkg : pkgs) {
                    synchronized (ActivityManagerService.this) {
                        if (forceStopPackageLocked(pkg, -1, false, false, false, false, 0)) {
                            setResultCode(Activity.RESULT_OK);
                            return;
                        }
                    }
                }
            }
        }
    }, pkgFilter);
    ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            mUiContext = null;
        }
    });
    synchronized (this) {
        // Ensure that any processes we had put on hold are now started
        // up.
        final int NP = mProcessesOnHold.size();
        if (NP > 0) {
            ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(mProcessesOnHold);
            for (int ip = 0; ip < NP; ip++) {
                if (DEBUG_PROCESSES)
                    Slog.v(TAG, "Starting process on hold: " + procs.get(ip));
                startProcessLocked(procs.get(ip), "on-hold", null);
            }
        }
        if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
            // Start looking for apps that are abusing wake locks.
            Message nmsg = mHandler.obtainMessage(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
            mHandler.sendMessageDelayed(nmsg, POWER_CHECK_DELAY);
            // Tell anyone interested that we are done booting!
            SystemProperties.set("sys.boot_completed", "1");
            SystemProperties.set("dev.bootcomplete", "1");
            for (int i = 0; i < mStartedUsers.size(); i++) {
                UserStartedState uss = mStartedUsers.valueAt(i);
                if (uss.mState == UserStartedState.STATE_BOOTING) {
                    uss.mState = UserStartedState.STATE_RUNNING;
                    final int userId = mStartedUsers.keyAt(i);
                    Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED, null);
                    intent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
                    broadcastIntentLocked(null, null, intent, null, null, 0, null, null, android.Manifest.permission.RECEIVE_BOOT_COMPLETED, AppOpsManager.OP_NONE, false, false, MY_PID, Process.SYSTEM_UID, userId);
                }
            }
        }
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Message(android.os.Message) ArrayList(java.util.ArrayList) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 64 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityManagerService method registerBroadcastReceivers.

private void registerBroadcastReceivers() {
    PackageMonitor monitor = new PackageMonitor() {

        @Override
        public void onSomePackagesChanged() {
            synchronized (mLock) {
                if (getChangingUserId() != mCurrentUserId) {
                    return;
                }
                // We will update when the automation service dies.
                UserState userState = getCurrentUserStateLocked();
                // We have to reload the installed services since some services may
                // have different attributes, resolve info (does not support equals),
                // etc. Remove them then to force reload. Do it even if automation is
                // running since when it goes away, we will have to reload as well.
                userState.mInstalledServices.clear();
                if (userState.mUiAutomationService == null) {
                    if (readConfigurationForUserStateLocked(userState)) {
                        onUserStateChangedLocked(userState);
                    }
                }
            }
        }

        @Override
        public void onPackageRemoved(String packageName, int uid) {
            synchronized (mLock) {
                final int userId = getChangingUserId();
                if (userId != mCurrentUserId) {
                    return;
                }
                UserState userState = getUserStateLocked(userId);
                Iterator<ComponentName> it = userState.mEnabledServices.iterator();
                while (it.hasNext()) {
                    ComponentName comp = it.next();
                    String compPkg = comp.getPackageName();
                    if (compPkg.equals(packageName)) {
                        it.remove();
                        // Update the enabled services setting.
                        persistComponentNamesToSettingLocked(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, userState.mEnabledServices, userId);
                        // Update the touch exploration granted services setting.
                        userState.mTouchExplorationGrantedServices.remove(comp);
                        persistComponentNamesToSettingLocked(Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, userState.mTouchExplorationGrantedServices, userId);
                        // We will update when the automation service dies.
                        if (userState.mUiAutomationService == null) {
                            onUserStateChangedLocked(userState);
                        }
                        return;
                    }
                }
            }
        }

        @Override
        public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) {
            synchronized (mLock) {
                final int userId = getChangingUserId();
                if (userId != mCurrentUserId) {
                    return false;
                }
                UserState userState = getUserStateLocked(userId);
                Iterator<ComponentName> it = userState.mEnabledServices.iterator();
                while (it.hasNext()) {
                    ComponentName comp = it.next();
                    String compPkg = comp.getPackageName();
                    for (String pkg : packages) {
                        if (compPkg.equals(pkg)) {
                            if (!doit) {
                                return true;
                            }
                            it.remove();
                            persistComponentNamesToSettingLocked(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, userState.mEnabledServices, userId);
                            // We will update when the automation service dies.
                            if (userState.mUiAutomationService == null) {
                                onUserStateChangedLocked(userState);
                            }
                        }
                    }
                }
                return false;
            }
        }
    };
    // package changes
    monitor.register(mContext, null, UserHandle.ALL, true);
    // user change and unlock
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
    intentFilter.addAction(Intent.ACTION_USER_REMOVED);
    intentFilter.addAction(Intent.ACTION_USER_PRESENT);
    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_USER_REMOVED.equals(action)) {
                removeUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
            } else if (Intent.ACTION_USER_PRESENT.equals(action)) {
                // We will update when the automation service dies.
                UserState userState = getCurrentUserStateLocked();
                if (userState.mUiAutomationService == null) {
                    if (readConfigurationForUserStateLocked(userState)) {
                        onUserStateChangedLocked(userState);
                    }
                }
            }
        }
    }, UserHandle.ALL, intentFilter, null, null);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) ComponentName(android.content.ComponentName) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) PackageMonitor(com.android.internal.content.PackageMonitor) Point(android.graphics.Point)

Example 65 with IntentFilter

use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.

the class Watchdog method init.

public void init(Context context, BatteryService battery, PowerManagerService power, AlarmManagerService alarm, ActivityManagerService activity) {
    mResolver = context.getContentResolver();
    mBattery = battery;
    mPower = power;
    mAlarm = alarm;
    mActivity = activity;
    context.registerReceiver(new RebootReceiver(), new IntentFilter(REBOOT_ACTION));
    mRebootIntent = PendingIntent.getBroadcast(context, 0, new Intent(REBOOT_ACTION), 0);
    context.registerReceiver(new RebootRequestReceiver(), new IntentFilter(Intent.ACTION_REBOOT), android.Manifest.permission.REBOOT, null);
    mBootTime = System.currentTimeMillis();
}
Also used : IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Aggregations

IntentFilter (android.content.IntentFilter)1441 Intent (android.content.Intent)493 Context (android.content.Context)292 BroadcastReceiver (android.content.BroadcastReceiver)274 PendingIntent (android.app.PendingIntent)148 RemoteException (android.os.RemoteException)80 ComponentName (android.content.ComponentName)54 Handler (android.os.Handler)53 View (android.view.View)45 Test (org.junit.Test)41 Uri (android.net.Uri)40 PowerManager (android.os.PowerManager)38 ArrayList (java.util.ArrayList)37 TextView (android.widget.TextView)36 ResolveInfo (android.content.pm.ResolveInfo)30 File (java.io.File)29 Point (android.graphics.Point)28 PackageManager (android.content.pm.PackageManager)27 IOException (java.io.IOException)25 HandlerThread (android.os.HandlerThread)24