Search in sources :

Example 1 with JobStatusFunctor

use of com.android.server.job.JobStore.JobStatusFunctor in project android_frameworks_base by crdroidandroid.

the class JobSchedulerService method onBootPhase.

@Override
public void onBootPhase(int phase) {
    if (PHASE_SYSTEM_SERVICES_READY == phase) {
        mConstants.start(getContext().getContentResolver());
        // Register br for package removals and user removals.
        final IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
        filter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
        filter.addDataScheme("package");
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
        final IntentFilter userFilter = new IntentFilter(Intent.ACTION_USER_REMOVED);
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, userFilter, null, null);
        mPowerManager = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
        try {
            ActivityManagerNative.getDefault().registerUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE | ActivityManager.UID_OBSERVER_IDLE);
        } catch (RemoteException e) {
        // ignored; both services live in system_server
        }
    } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
        synchronized (mLock) {
            // Let's go!
            mReadyToRock = true;
            mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(BatteryStats.SERVICE_NAME));
            mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class);
            // Create the "runners".
            for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) {
                mActiveServices.add(new JobServiceContext(this, mBatteryStats, mJobPackageTracker, getContext().getMainLooper()));
            }
            // Attach jobs to their controllers.
            mJobs.forEachJob(new JobStatusFunctor() {

                @Override
                public void process(JobStatus job) {
                    for (int controller = 0; controller < mControllers.size(); controller++) {
                        final StateController sc = mControllers.get(controller);
                        sc.maybeStartTrackingJobLocked(job, null);
                    }
                }
            });
            // GO GO GO!
            mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
        }
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) IntentFilter(android.content.IntentFilter) DeviceIdleController(com.android.server.DeviceIdleController) JobStatusFunctor(com.android.server.job.JobStore.JobStatusFunctor) RemoteException(android.os.RemoteException) StateController(com.android.server.job.controllers.StateController)

Example 2 with JobStatusFunctor

use of com.android.server.job.JobStore.JobStatusFunctor in project platform_frameworks_base by android.

the class JobSchedulerService method onBootPhase.

@Override
public void onBootPhase(int phase) {
    if (PHASE_SYSTEM_SERVICES_READY == phase) {
        mConstants.start(getContext().getContentResolver());
        // Register br for package removals and user removals.
        final IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
        filter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
        filter.addDataScheme("package");
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
        final IntentFilter userFilter = new IntentFilter(Intent.ACTION_USER_REMOVED);
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, userFilter, null, null);
        mPowerManager = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
        try {
            ActivityManagerNative.getDefault().registerUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE | ActivityManager.UID_OBSERVER_IDLE);
        } catch (RemoteException e) {
        // ignored; both services live in system_server
        }
    } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
        synchronized (mLock) {
            // Let's go!
            mReadyToRock = true;
            mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(BatteryStats.SERVICE_NAME));
            mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class);
            // Create the "runners".
            for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) {
                mActiveServices.add(new JobServiceContext(this, mBatteryStats, mJobPackageTracker, getContext().getMainLooper()));
            }
            // Attach jobs to their controllers.
            mJobs.forEachJob(new JobStatusFunctor() {

                @Override
                public void process(JobStatus job) {
                    for (int controller = 0; controller < mControllers.size(); controller++) {
                        final StateController sc = mControllers.get(controller);
                        sc.maybeStartTrackingJobLocked(job, null);
                    }
                }
            });
            // GO GO GO!
            mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
        }
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) IntentFilter(android.content.IntentFilter) DeviceIdleController(com.android.server.DeviceIdleController) JobStatusFunctor(com.android.server.job.JobStore.JobStatusFunctor) RemoteException(android.os.RemoteException) StateController(com.android.server.job.controllers.StateController)

Example 3 with JobStatusFunctor

use of com.android.server.job.JobStore.JobStatusFunctor in project android_frameworks_base by DirtyUnicorns.

the class JobSchedulerService method onBootPhase.

@Override
public void onBootPhase(int phase) {
    if (PHASE_SYSTEM_SERVICES_READY == phase) {
        mConstants.start(getContext().getContentResolver());
        // Register br for package removals and user removals.
        final IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
        filter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
        filter.addDataScheme("package");
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
        final IntentFilter userFilter = new IntentFilter(Intent.ACTION_USER_REMOVED);
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, userFilter, null, null);
        mPowerManager = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
        try {
            ActivityManagerNative.getDefault().registerUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE | ActivityManager.UID_OBSERVER_IDLE);
        } catch (RemoteException e) {
        // ignored; both services live in system_server
        }
    } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
        synchronized (mLock) {
            // Let's go!
            mReadyToRock = true;
            mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(BatteryStats.SERVICE_NAME));
            mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class);
            // Create the "runners".
            for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) {
                mActiveServices.add(new JobServiceContext(this, mBatteryStats, mJobPackageTracker, getContext().getMainLooper()));
            }
            // Attach jobs to their controllers.
            mJobs.forEachJob(new JobStatusFunctor() {

                @Override
                public void process(JobStatus job) {
                    for (int controller = 0; controller < mControllers.size(); controller++) {
                        final StateController sc = mControllers.get(controller);
                        sc.maybeStartTrackingJobLocked(job, null);
                    }
                }
            });
            // GO GO GO!
            mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
        }
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) IntentFilter(android.content.IntentFilter) DeviceIdleController(com.android.server.DeviceIdleController) JobStatusFunctor(com.android.server.job.JobStore.JobStatusFunctor) RemoteException(android.os.RemoteException) StateController(com.android.server.job.controllers.StateController)

Example 4 with JobStatusFunctor

use of com.android.server.job.JobStore.JobStatusFunctor in project android_frameworks_base by AOSPA.

the class JobSchedulerService method onBootPhase.

@Override
public void onBootPhase(int phase) {
    if (PHASE_SYSTEM_SERVICES_READY == phase) {
        mConstants.start(getContext().getContentResolver());
        // Register br for package removals and user removals.
        final IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
        filter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
        filter.addDataScheme("package");
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
        final IntentFilter userFilter = new IntentFilter(Intent.ACTION_USER_REMOVED);
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, userFilter, null, null);
        mPowerManager = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
        try {
            ActivityManagerNative.getDefault().registerUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE | ActivityManager.UID_OBSERVER_IDLE);
        } catch (RemoteException e) {
        // ignored; both services live in system_server
        }
    } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
        synchronized (mLock) {
            // Let's go!
            mReadyToRock = true;
            mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(BatteryStats.SERVICE_NAME));
            mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class);
            // Create the "runners".
            for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) {
                mActiveServices.add(new JobServiceContext(this, mBatteryStats, mJobPackageTracker, getContext().getMainLooper()));
            }
            // Attach jobs to their controllers.
            mJobs.forEachJob(new JobStatusFunctor() {

                @Override
                public void process(JobStatus job) {
                    for (int controller = 0; controller < mControllers.size(); controller++) {
                        final StateController sc = mControllers.get(controller);
                        sc.maybeStartTrackingJobLocked(job, null);
                    }
                }
            });
            // GO GO GO!
            mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
        }
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) IntentFilter(android.content.IntentFilter) DeviceIdleController(com.android.server.DeviceIdleController) JobStatusFunctor(com.android.server.job.JobStore.JobStatusFunctor) RemoteException(android.os.RemoteException) StateController(com.android.server.job.controllers.StateController)

Example 5 with JobStatusFunctor

use of com.android.server.job.JobStore.JobStatusFunctor in project android_frameworks_base by ResurrectionRemix.

the class JobSchedulerService method onBootPhase.

@Override
public void onBootPhase(int phase) {
    if (PHASE_SYSTEM_SERVICES_READY == phase) {
        mConstants.start(getContext().getContentResolver());
        // Register br for package removals and user removals.
        final IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
        filter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
        filter.addDataScheme("package");
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
        final IntentFilter userFilter = new IntentFilter(Intent.ACTION_USER_REMOVED);
        getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, userFilter, null, null);
        mPowerManager = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
        try {
            ActivityManagerNative.getDefault().registerUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE | ActivityManager.UID_OBSERVER_IDLE);
        } catch (RemoteException e) {
        // ignored; both services live in system_server
        }
    } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
        synchronized (mLock) {
            // Let's go!
            mReadyToRock = true;
            mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(BatteryStats.SERVICE_NAME));
            mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class);
            // Create the "runners".
            for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) {
                mActiveServices.add(new JobServiceContext(this, mBatteryStats, mJobPackageTracker, getContext().getMainLooper()));
            }
            // Attach jobs to their controllers.
            mJobs.forEachJob(new JobStatusFunctor() {

                @Override
                public void process(JobStatus job) {
                    for (int controller = 0; controller < mControllers.size(); controller++) {
                        final StateController sc = mControllers.get(controller);
                        sc.maybeStartTrackingJobLocked(job, null);
                    }
                }
            });
            // GO GO GO!
            mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
        }
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) IntentFilter(android.content.IntentFilter) DeviceIdleController(com.android.server.DeviceIdleController) JobStatusFunctor(com.android.server.job.JobStore.JobStatusFunctor) RemoteException(android.os.RemoteException) StateController(com.android.server.job.controllers.StateController)

Aggregations

IntentFilter (android.content.IntentFilter)5 RemoteException (android.os.RemoteException)5 DeviceIdleController (com.android.server.DeviceIdleController)5 JobStatusFunctor (com.android.server.job.JobStore.JobStatusFunctor)5 JobStatus (com.android.server.job.controllers.JobStatus)5 StateController (com.android.server.job.controllers.StateController)5