android.os.PersistableBundle#containsKey ( )源码实例Demo

下面列出了android.os.PersistableBundle#containsKey ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: RestrictionsManager.java
/**
 * 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();
    }
}
 
@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;
}
 
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();
}
 
源代码4 项目: 365browser   文件: NotificationJobService.java
/**
 * 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;
}
 
源代码5 项目: android-testdpc   文件: PostProvisioningTask.java
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;
}