Search in sources :

Example 46 with IntentFilter

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

the class DropBoxManagerService method onStart.

@Override
public void onStart() {
    // Set up intent receivers
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
    getContext().registerReceiver(mReceiver, filter);
    mContentResolver.registerContentObserver(Settings.Global.CONTENT_URI, true, new ContentObserver(new Handler()) {

        @Override
        public void onChange(boolean selfChange) {
            mReceiver.onReceive(getContext(), (Intent) null);
        }
    });
    publishBinderService(Context.DROPBOX_SERVICE, mStub);
// The real work gets done lazily in init() -- that way service creation always
// succeeds, and things like disk problems cause individual method failures.
}
Also used : IntentFilter(android.content.IntentFilter) Handler(android.os.Handler) Intent(android.content.Intent) ContentObserver(android.database.ContentObserver)

Example 47 with IntentFilter

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

the class ActivityManagerService method finishBooting.

final void finishBooting() {
    synchronized (this) {
        if (!mBootAnimationComplete) {
            mCallFinishBooting = true;
            return;
        }
        mCallFinishBooting = false;
    }
    ArraySet<String> completedIsas = new ArraySet<String>();
    for (String abi : Build.SUPPORTED_ABIS) {
        Process.zygoteProcess.establishZygoteConnectionForAbi(abi);
        final String instructionSet = VMRuntime.getInstructionSet(abi);
        if (!completedIsas.contains(instructionSet)) {
            try {
                mInstaller.markBootComplete(VMRuntime.getInstructionSet(abi));
            } catch (InstallerException e) {
                Slog.w(TAG, "Unable to mark boot complete for abi: " + abi + " (" + e.getMessage() + ")");
            }
            completedIsas.add(instructionSet);
        }
    }
    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, false, 0, "query restart")) {
                            setResultCode(Activity.RESULT_OK);
                            return;
                        }
                    }
                }
            }
        }
    }, pkgFilter);
    IntentFilter dumpheapFilter = new IntentFilter();
    dumpheapFilter.addAction(DumpHeapActivity.ACTION_DELETE_DUMPHEAP);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getBooleanExtra(DumpHeapActivity.EXTRA_DELAY_DELETE, false)) {
                mHandler.sendEmptyMessageDelayed(POST_DUMP_HEAP_NOTIFICATION_MSG, 5 * 60 * 1000);
            } else {
                mHandler.sendEmptyMessage(POST_DUMP_HEAP_NOTIFICATION_MSG);
            }
        }
    }, dumpheapFilter);
    // Let system services know.
    mSystemServiceManager.startBootPhase(SystemService.PHASE_BOOT_COMPLETED);
    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_PROCESSES, "Starting process on hold: " + procs.get(ip));
                startProcessLocked(procs.get(ip), "on-hold", null);
            }
        }
        if (mFactoryTest != FactoryTest.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");
            // And trigger dev.bootcomplete if we are not showing encryption progress
            if (!"trigger_restart_min_framework".equals(SystemProperties.get("vold.decrypt")) || "".equals(SystemProperties.get("vold.encrypt_progress"))) {
                SystemProperties.set("dev.bootcomplete", "1");
            }
            mUserController.sendBootCompletedLocked(new IIntentReceiver.Stub() {

                @Override
                public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
                    synchronized (ActivityManagerService.this) {
                        requestPssAllProcsLocked(SystemClock.uptimeMillis(), true, false);
                    }
                }
            });
            scheduleStartProfilesLocked();
        }
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) ArraySet(android.util.ArraySet) Message(android.os.Message) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) ArrayList(java.util.ArrayList) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) Point(android.graphics.Point) IIntentReceiver(android.content.IIntentReceiver) InstallerException(com.android.server.pm.Installer.InstallerException)

Example 48 with IntentFilter

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

the class DreamManagerService method onBootPhase.

@Override
public void onBootPhase(int phase) {
    if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
        if (Build.IS_DEBUGGABLE) {
            SystemProperties.addChangeCallback(mSystemPropertiesChanged);
        }
        mContext.registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                writePulseGestureEnabled();
                synchronized (mLock) {
                    stopDreamLocked(false);
                }
            }
        }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
        mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.DOZE_ENABLED), false, mDozeEnabledObserver, UserHandle.USER_ALL);
        writePulseGestureEnabled();
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 49 with IntentFilter

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

the class NetworkPolicyManagerService method systemReady.

public void systemReady() {
    Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "systemReady");
    try {
        if (!isBandwidthControlEnabled()) {
            Slog.w(TAG, "bandwidth controls disabled, unable to enforce policy");
            return;
        }
        mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
        synchronized (mUidRulesFirstLock) {
            synchronized (mNetworkPoliciesSecondLock) {
                updatePowerSaveWhitelistUL();
                mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);
                mPowerManagerInternal.registerLowPowerModeObserver(new PowerManagerInternal.LowPowerModeListener() {

                    @Override
                    public void onLowPowerModeChanged(boolean enabled) {
                        if (LOGD)
                            Slog.d(TAG, "onLowPowerModeChanged(" + enabled + ")");
                        synchronized (mUidRulesFirstLock) {
                            if (mRestrictPower != enabled) {
                                mRestrictPower = enabled;
                                updateRulesForRestrictPowerUL();
                            }
                        }
                    }
                });
                mRestrictPower = mPowerManagerInternal.getLowPowerModeEnabled();
                mSystemReady = true;
                // read policy from disk
                readPolicyAL();
                if (addDefaultRestrictBackgroundWhitelistUidsUL()) {
                    writePolicyAL();
                }
                setRestrictBackgroundUL(mRestrictBackground);
                updateRulesForGlobalChangeAL(false);
                updateNotificationsNL();
            }
        }
        try {
            mActivityManager.registerUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE);
            mNetworkManager.registerObserver(mAlertObserver);
        } catch (RemoteException e) {
        // ignored; both services live in system_server
        }
        // listen for changes to power save whitelist
        final IntentFilter whitelistFilter = new IntentFilter(PowerManager.ACTION_POWER_SAVE_WHITELIST_CHANGED);
        mContext.registerReceiver(mPowerSaveWhitelistReceiver, whitelistFilter, null, mHandler);
        DeviceIdleController.LocalService deviceIdleService = LocalServices.getService(DeviceIdleController.LocalService.class);
        deviceIdleService.setNetworkPolicyTempWhitelistCallback(mTempPowerSaveChangedCallback);
        // watch for network interfaces to be claimed
        final IntentFilter connFilter = new IntentFilter(CONNECTIVITY_ACTION);
        mContext.registerReceiver(mConnReceiver, connFilter, CONNECTIVITY_INTERNAL, mHandler);
        // listen for package changes to update policy
        final IntentFilter packageFilter = new IntentFilter();
        packageFilter.addAction(ACTION_PACKAGE_ADDED);
        packageFilter.addDataScheme("package");
        mContext.registerReceiver(mPackageReceiver, packageFilter, null, mHandler);
        // listen for UID changes to update policy
        mContext.registerReceiver(mUidRemovedReceiver, new IntentFilter(ACTION_UID_REMOVED), null, mHandler);
        // listen for user changes to update policy
        final IntentFilter userFilter = new IntentFilter();
        userFilter.addAction(ACTION_USER_ADDED);
        userFilter.addAction(ACTION_USER_REMOVED);
        mContext.registerReceiver(mUserReceiver, userFilter, null, mHandler);
        // listen for stats update events
        final IntentFilter statsFilter = new IntentFilter(ACTION_NETWORK_STATS_UPDATED);
        mContext.registerReceiver(mStatsReceiver, statsFilter, READ_NETWORK_USAGE_HISTORY, mHandler);
        // listen for restrict background changes from notifications
        final IntentFilter allowFilter = new IntentFilter(ACTION_ALLOW_BACKGROUND);
        mContext.registerReceiver(mAllowReceiver, allowFilter, MANAGE_NETWORK_POLICY, mHandler);
        // listen for snooze warning from notifications
        final IntentFilter snoozeWarningFilter = new IntentFilter(ACTION_SNOOZE_WARNING);
        mContext.registerReceiver(mSnoozeWarningReceiver, snoozeWarningFilter, MANAGE_NETWORK_POLICY, mHandler);
        // listen for configured wifi networks to be removed
        final IntentFilter wifiConfigFilter = new IntentFilter(CONFIGURED_NETWORKS_CHANGED_ACTION);
        mContext.registerReceiver(mWifiConfigReceiver, wifiConfigFilter, null, mHandler);
        // listen for wifi state changes to catch metered hint
        final IntentFilter wifiStateFilter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION);
        mContext.registerReceiver(mWifiStateReceiver, wifiStateFilter, null, mHandler);
        mUsageStats.addAppIdleStateChangeListener(new AppIdleStateChangeListener());
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
    }
}
Also used : IntentFilter(android.content.IntentFilter) DeviceIdleController(com.android.server.DeviceIdleController) IDeviceIdleController(android.os.IDeviceIdleController) PowerManagerInternal(android.os.PowerManagerInternal) UsageStatsManagerInternal(android.app.usage.UsageStatsManagerInternal) RemoteException(android.os.RemoteException)

Example 50 with IntentFilter

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

the class MediaRouterService method systemRunning.

public void systemRunning() {
    IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Intent.ACTION_USER_SWITCHED)) {
                switchUser();
            }
        }
    }, filter);
    switchUser();
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

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