@Override protected VJobSchedulerService create() { return new VJobSchedulerService(); } };
IBinder binder = mirror.android.app.job.JobParameters.callback.get(jobParams); IJobCallback callback = IJobCallback.Stub.asInterface(binder); Map.Entry<JobId, JobConfig> entry = get().findJobByVirtualJobId(jobId); if (entry == null) { emptyCallback(callback, jobId); emptyCallback(callback, jobId); mScheduler.cancel(jobId); get().cancel(jobId);
private VJobSchedulerService() { mJobProxyComponent = new ComponentName(VirtualCore.get().getHostPkg(), VASettings.STUB_JOB); readJobs(); }
@Override public void cancel(int jobId) throws RemoteException { int vuid = VBinder.getCallingUid(); synchronized (mJobStore) { boolean changed = false; Iterator<Map.Entry<JobId, JobConfig>> iterator = mJobStore.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<JobId, JobConfig> entry = iterator.next(); JobId job = entry.getKey(); JobConfig config = entry.getValue(); if (job.vuid == vuid && job.clientJobId == jobId) { changed = true; mScheduler.cancel(config.virtualJobId); iterator.remove(); break; } } if (changed) { saveJobs(); } } }
@Override public boolean onCreate() { Context context = getContext(); DaemonService.startup(context); if (!VirtualCore.get().isStartup()) { return true; } VPackageManagerService.systemReady(); addService(ServiceManagerNative.PACKAGE, VPackageManagerService.get()); VActivityManagerService.systemReady(context); addService(ServiceManagerNative.ACTIVITY, VActivityManagerService.get()); addService(ServiceManagerNative.USER, VUserManagerService.get()); VAppManagerService.systemReady(); addService(ServiceManagerNative.APP, VAppManagerService.get()); BroadcastSystem.attach(VActivityManagerService.get(), VAppManagerService.get()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { addService(ServiceManagerNative.JOB, VJobSchedulerService.get()); } VNotificationManagerService.systemReady(context); addService(ServiceManagerNative.NOTIFICATION, VNotificationManagerService.get()); VAppManagerService.get().scanApps(); VAccountManagerService.systemReady(); addService(ServiceManagerNative.ACCOUNT, VAccountManagerService.get()); addService(ServiceManagerNative.VS, VirtualStorageService.get()); addService(ServiceManagerNative.DEVICE, VDeviceManagerService.get()); addService(ServiceManagerNative.VIRTUAL_LOC, VirtualLocationService.get()); return true; }
@Override public List<JobInfo> getAllPendingJobs() throws RemoteException { int vuid = VBinder.getCallingUid(); List<JobInfo> jobs = mScheduler.getAllPendingJobs(); synchronized (mJobStore) { Iterator<JobInfo> iterator = jobs.listIterator(); while (iterator.hasNext()) { JobInfo job = iterator.next(); if (!VASettings.STUB_JOB.equals(job.getService().getClassName())) { // Schedule by Host, invisible in VA. iterator.remove(); continue; } Map.Entry<JobId, JobConfig> jobEntry = findJobByVirtualJobId(job.getId()); if (jobEntry == null) { iterator.remove(); continue; } JobId jobId = jobEntry.getKey(); JobConfig config = jobEntry.getValue(); if (jobId.vuid != vuid) { iterator.remove(); continue; } mirror.android.app.job.JobInfo.jobId.set(job, jobId.clientJobId); mirror.android.app.job.JobInfo.service.set(job, new ComponentName(jobId.packageName, config.serviceName)); } } return jobs; }
@Override public void cancelAll() throws RemoteException { int vuid = VBinder.getCallingUid(); synchronized (mJobStore) { boolean changed = false; Iterator<Map.Entry<JobId, JobConfig>> iterator = mJobStore.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<JobId, JobConfig> entry = iterator.next(); JobId job = entry.getKey(); if (job.vuid == vuid) { JobConfig config = entry.getValue(); mScheduler.cancel(config.virtualJobId); changed = true; iterator.remove(); break; } } if (changed) { saveJobs(); } } }
@Override public boolean onCreate() { Context context = getContext(); DaemonService.startup(context); if (!VirtualCore.get().isStartup()) { return true; } VPackageManagerService.systemReady(); addService(ServiceManagerNative.PACKAGE, VPackageManagerService.get()); VActivityManagerService.systemReady(context); addService(ServiceManagerNative.ACTIVITY, VActivityManagerService.get()); addService(ServiceManagerNative.USER, VUserManagerService.get()); VAppManagerService.systemReady(); addService(ServiceManagerNative.APP, VAppManagerService.get()); BroadcastSystem.attach(VActivityManagerService.get(), VAppManagerService.get()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { addService(ServiceManagerNative.JOB, VJobSchedulerService.get()); } VNotificationManagerService.systemReady(context); addService(ServiceManagerNative.NOTIFICATION, VNotificationManagerService.get()); VAppManagerService.get().scanApps(); VAccountManagerService.systemReady(); addService(ServiceManagerNative.ACCOUNT, VAccountManagerService.get()); addService(ServiceManagerNative.VS, VirtualStorageService.get()); addService(ServiceManagerNative.DEVICE, VDeviceManagerService.get()); addService(ServiceManagerNative.VIRTUAL_LOC, VirtualLocationService.get()); return true; }
@Override public List<JobInfo> getAllPendingJobs() throws RemoteException { int vuid = VBinder.getCallingUid(); List<JobInfo> jobs = mScheduler.getAllPendingJobs(); synchronized (mJobStore) { Iterator<JobInfo> iterator = jobs.listIterator(); while (iterator.hasNext()) { JobInfo job = iterator.next(); if (!VASettings.STUB_JOB.equals(job.getService().getClassName())) { // Schedule by Host, invisible in VA. iterator.remove(); continue; } Map.Entry<JobId, JobConfig> jobEntry = findJobByVirtualJobId(job.getId()); if (jobEntry == null) { iterator.remove(); continue; } JobId jobId = jobEntry.getKey(); JobConfig config = jobEntry.getValue(); if (jobId.vuid != vuid) { iterator.remove(); continue; } mirror.android.app.job.JobInfo.jobId.set(job, jobId.clientJobId); mirror.android.app.job.JobInfo.service.set(job, new ComponentName(jobId.packageName, config.serviceName)); } } return jobs; }
IBinder binder = mirror.android.app.job.JobParameters.callback.get(jobParams); IJobCallback callback = IJobCallback.Stub.asInterface(binder); Map.Entry<JobId, JobConfig> entry = get().findJobByVirtualJobId(jobId); if (entry == null) { emptyCallback(callback, jobId); emptyCallback(callback, jobId); mScheduler.cancel(jobId); get().cancel(jobId);
@Override public int schedule(JobInfo job) throws RemoteException { int vuid = VBinder.getCallingUid(); int id = job.getId(); ComponentName service = job.getService(); JobId jobId = new JobId(vuid, service.getPackageName(), id); JobConfig config = mJobStore.get(jobId); if (config == null) { config = new JobConfig(mGlobalJobId++, service.getClassName(), job.getExtras()); mJobStore.put(jobId, config); } else { config.serviceName = service.getClassName(); config.extras = job.getExtras(); } saveJobs(); mirror.android.app.job.JobInfo.jobId.set(job, config.virtualJobId); mirror.android.app.job.JobInfo.service.set(job, mJobProxyComponent); return mScheduler.schedule(job); }
@Override protected VJobSchedulerService create() { return new VJobSchedulerService(); } };
private VJobSchedulerService() { mJobProxyComponent = new ComponentName(VirtualCore.get().getHostPkg(), VASettings.STUB_JOB); readJobs(); }
@Override public boolean onCreate() { Context context = getContext(); DaemonService.startup(context); if (!VirtualCore.get().isStartup()) { return true; } VPackageManagerService.systemReady(); IPCBus.register(IPackageManager.class, VPackageManagerService.get()); VActivityManagerService.systemReady(context); IPCBus.register(IActivityManager.class, VActivityManagerService.get()); IPCBus.register(IUserManager.class, VUserManagerService.get()); VAppManagerService.systemReady(); IPCBus.register(IAppManager.class, VAppManagerService.get()); BroadcastSystem.attach(VActivityManagerService.get(), VAppManagerService.get()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { IPCBus.register(IJobScheduler.class, VJobSchedulerService.get()); } VNotificationManagerService.systemReady(context); IPCBus.register(INotificationManager.class, VNotificationManagerService.get()); VAppManagerService.get().scanApps(); VAccountManagerService.systemReady(); IPCBus.register(IAccountManager.class, VAccountManagerService.get()); IPCBus.register(IVirtualStorageService.class, VirtualStorageService.get()); IPCBus.register(IDeviceInfoManager.class, VDeviceManagerService.get()); IPCBus.register(IVirtualLocationManager.class, VirtualLocationService.get()); return true; }
@Override public List<JobInfo> getAllPendingJobs() { int vuid = VBinder.getCallingUid(); List<JobInfo> jobs = mScheduler.getAllPendingJobs(); synchronized (mJobStore) { Iterator<JobInfo> iterator = jobs.listIterator(); while (iterator.hasNext()) { JobInfo job = iterator.next(); if (!VASettings.STUB_JOB.equals(job.getService().getClassName())) { // Schedule by Host, invisible in VA. iterator.remove(); continue; } Map.Entry<JobId, JobConfig> jobEntry = findJobByVirtualJobId(job.getId()); if (jobEntry == null) { iterator.remove(); continue; } JobId jobId = jobEntry.getKey(); JobConfig config = jobEntry.getValue(); if (jobId.vuid != vuid) { iterator.remove(); continue; } mirror.android.app.job.JobInfo.jobId.set(job, jobId.clientJobId); mirror.android.app.job.JobInfo.service.set(job, new ComponentName(jobId.packageName, config.serviceName)); } } return jobs; }
IBinder binder = mirror.android.app.job.JobParameters.callback.get(jobParams); IJobCallback callback = IJobCallback.Stub.asInterface(binder); Map.Entry<JobId, JobConfig> entry = get().findJobByVirtualJobId(jobId); if (entry == null) { emptyCallback(callback, jobId); emptyCallback(callback, jobId); mScheduler.cancel(jobId); get().cancel(jobId);
@Override public void cancelAll() { int vuid = VBinder.getCallingUid(); synchronized (mJobStore) { boolean changed = false; Iterator<Map.Entry<JobId, JobConfig>> iterator = mJobStore.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<JobId, JobConfig> entry = iterator.next(); JobId job = entry.getKey(); if (job.vuid == vuid) { JobConfig config = entry.getValue(); mScheduler.cancel(config.virtualJobId); changed = true; iterator.remove(); break; } } if (changed) { saveJobs(); } } }
@Override protected VJobSchedulerService create() { return new VJobSchedulerService(); } };
private VJobSchedulerService() { mJobProxyComponent = new ComponentName(VirtualCore.get().getHostPkg(), VASettings.STUB_JOB); readJobs(); }
@Override public void cancel(int jobId) throws RemoteException { int vuid = VBinder.getCallingUid(); synchronized (mJobStore) { boolean changed = false; Iterator<Map.Entry<JobId, JobConfig>> iterator = mJobStore.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<JobId, JobConfig> entry = iterator.next(); JobId job = entry.getKey(); JobConfig config = entry.getValue(); if (job.vuid == vuid && job.clientJobId == jobId) { changed = true; mScheduler.cancel(config.virtualJobId); iterator.remove(); break; } } if (changed) { saveJobs(); } } }