Java Code Examples for android.os.PersistableBundle#containsKey()
The following examples show how to use
android.os.PersistableBundle#containsKey() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestrictionsManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Called by the Restrictions Provider to deliver a response to an application. * * @param packageName the application to deliver the response to. Cannot be null. * @param response the bundle containing the response status, request ID and other information. * Cannot be null. * * @throws IllegalArgumentException if any of the required parameters are missing. */ public void notifyPermissionResponse(String packageName, PersistableBundle response) { if (packageName == null) { throw new NullPointerException("packageName cannot be null"); } if (response == null) { throw new NullPointerException("request cannot be null"); } if (!response.containsKey(REQUEST_KEY_ID)) { throw new IllegalArgumentException("REQUEST_KEY_ID must be specified"); } if (!response.containsKey(RESPONSE_KEY_RESULT)) { throw new IllegalArgumentException("RESPONSE_KEY_RESULT must be specified"); } try { if (mService != null) { mService.notifyPermissionResponse(packageName, response); } } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } }
Example 2
Source File: AndroidJobScheduler.java From android_job_scheduler with Apache License 2.0 | 6 votes |
@Override public boolean onStartJob(JobParameters params) { PersistableBundle extras = params.getExtras(); Context context = getApplicationContext(); if (isApplicationRunning(context)) { if (callbackMethodChannel != null) { callbackMethodChannel.invokeMethod("firedWhileApplicationRunning", null); } } else { FlutterNativeView nativeView = new FlutterNativeView(context); if (AndroidJobScheduler.pluginRegistrantCallback != null) { AndroidJobScheduler.pluginRegistrantCallback.registerWith(nativeView.getPluginRegistry()); } nativeView.runFromBundle(FlutterMain.findAppBundlePath(context), null, extras.getString(B_KEY_DART_CB), true); } if (!extras.containsKey(B_KEY_SCHEDULE_ONCE)) { AndroidJobScheduler.scheduleEvery(getApplicationContext(), AndroidJobSchedulerUtils.persistableBundleToJobInfo(extras)); } jobFinished(params, false); return true; }
Example 3
Source File: AndroidJobSchedulerUtils.java From android_job_scheduler with Apache License 2.0 | 6 votes |
public static JobInfo persistableBundleToJobInfo(PersistableBundle bundle) { JobInfo.Builder builder = new JobInfo.Builder(bundle.getInt(B_KEY_ID), new ComponentName(bundle.getString(B_KEY_COMPONENT_PKG), bundle.getString(B_KEY_COMPONENT_NAME))) .setMinimumLatency(bundle.getInt(B_KEY_INTERVAL)) .setExtras(bundle); if (bundle.containsKey(B_KEY_PERSISTENT_ACROSS_REBOOTS)) { builder.setPersisted(true); } if (bundle.containsKey(B_KEY_REQUIRES_CHARGING)) { builder.setRequiresCharging(true); } if (bundle.containsKey(B_KEY_BACKOFF_CRITERIA)) { builder.setBackoffCriteria( bundle.getPersistableBundle(B_KEY_BACKOFF_CRITERIA).getInt(B_INNER_BACKOFF_MILLIS), bundle.getPersistableBundle(B_KEY_BACKOFF_CRITERIA).getInt(B_INNER_BACKOFF_POLICY) ); } if (bundle.containsKey(B_KEY_NETWORK_TYPE)) { builder.setRequiredNetworkType( bundle.getPersistableBundle(B_KEY_NETWORK_TYPE).getInt(B_INNER_REQUIRED_NETWORK) ); } return builder.build(); }
Example 4
Source File: NotificationJobService.java From 365browser with Apache License 2.0 | 6 votes |
/** * Called when a Notification has been interacted with by the user. If we can verify that * the Intent has a notification Id, start Chrome (if needed) on the UI thread. * * We get a wakelock for our process for the duration of this method. * * @return True if there is more work to be done to handle the job, to signal we would like our * wakelock extended until we call {@link #jobFinished}. False if we have finished handling the * job. */ @Override public boolean onStartJob(final JobParameters params) { PersistableBundle extras = params.getExtras(); if (!extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_ID) || !extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN) || !extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_INFO_TAG)) { return false; } Intent intent = new Intent(extras.getString(NotificationConstants.EXTRA_NOTIFICATION_ACTION)); intent.putExtras(new Bundle(extras)); ThreadUtils.assertOnUiThread(); NotificationService.dispatchIntentOnUIThread(this, intent); // TODO(crbug.com/685197): Return true here and call jobFinished to release the wake // lock only after the event has been completely handled by the service worker. return false; }
Example 5
Source File: PostProvisioningTask.java From android-testdpc with Apache License 2.0 | 5 votes |
public boolean performPostProvisioningOperations(Intent intent) { if (isPostProvisioningDone()) { return false; } markPostProvisioningDone(); // From M onwards, permissions are not auto-granted, so we need to manually grant // permissions for TestDPC. if (Util.SDK_INT >= VERSION_CODES.M) { autoGrantRequestedPermissionsToSelf(); } // Retreive the admin extras bundle, which we can use to determine the original context for // TestDPCs launch. PersistableBundle extras = intent.getParcelableExtra( EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE); if (Util.SDK_INT >= VERSION_CODES.O) { maybeSetAffiliationIds(extras); } // If TestDPC asked GmsCore to store its state in the FRP area before factory reset, the // state will be handed over to it during the next device setup. if (Util.SDK_INT >= VERSION_CODES.O_MR1 && extras != null && extras.containsKey(KEY_DEVICE_OWNER_STATE)) { Util.setPersistentDoStateWithApplicationRestriction( mContext, mDevicePolicyManager, DeviceAdminReceiver.getComponentName(mContext), extras.getString(KEY_DEVICE_OWNER_STATE)); } // Hide the setup launcher when this app is the admin mContext.getPackageManager().setComponentEnabledSetting( new ComponentName(mContext, SETUP_MANAGEMENT_LAUNCH_ACTIVITY), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); return true; }