Java Code Examples for android.os.Bundle#setDefusable()
The following examples show how to use
android.os.Bundle#setDefusable() .
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: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public void removePeriodicSync(Account account, String authority, Bundle extras) { Bundle.setDefusable(extras, true); if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(authority)) { throw new IllegalArgumentException("Authority must not be empty"); } mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); final int callingUid = Binder.getCallingUid(); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { getSyncManager() .removePeriodicSync( new SyncStorageEngine.EndPoint(account, authority, userId), extras, "removePeriodicSync() by uid=" + callingUid); } finally { restoreCallingIdentity(identityToken); } }
Example 2
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public void putCache(String packageName, Uri key, Bundle value, int userId) { Bundle.setDefusable(value, true); enforceCrossUserPermission(userId, TAG); mContext.enforceCallingOrSelfPermission(android.Manifest.permission.CACHE_CONTENT, TAG); mContext.getSystemService(AppOpsManager.class).checkPackage(Binder.getCallingUid(), packageName); final String providerPackageName = getProviderPackageName(key); final Pair<String, Uri> fullKey = Pair.create(packageName, key); synchronized (mCache) { final ArrayMap<Pair<String, Uri>, Bundle> cache = findOrCreateCacheLocked(userId, providerPackageName); if (value != null) { cache.put(fullKey, value); } else { cache.remove(fullKey); } } }
Example 3
Source File: ContentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * Call a provider-defined method. This can be used to implement * read or write interfaces which are cheaper than using a Cursor and/or * do not fit into the traditional table model. * * @param method provider-defined method name to call. Opaque to * framework, but must be non-null. * @param arg provider-defined String argument. May be null. * @param extras provider-defined Bundle argument. May be null. * @return a result Bundle, possibly null. Will be null if the ContentProvider * does not implement call. * @throws NullPointerException if uri or method is null * @throws IllegalArgumentException if uri is not known */ public final @Nullable Bundle call(@NonNull Uri uri, @NonNull String method, @Nullable String arg, @Nullable Bundle extras) { Preconditions.checkNotNull(uri, "uri"); Preconditions.checkNotNull(method, "method"); IContentProvider provider = acquireProvider(uri); if (provider == null) { throw new IllegalArgumentException("Unknown URI " + uri); } try { final Bundle res = provider.call(mPackageName, method, arg, extras); Bundle.setDefusable(res, true); return res; } catch (RemoteException e) { // Arbitrary and not worth documenting, as Activity // Manager will kill this process shortly anyway. return null; } finally { releaseProvider(provider); } }
Example 4
Source File: ContentResolver.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Call a provider-defined method. This can be used to implement * read or write interfaces which are cheaper than using a Cursor and/or * do not fit into the traditional table model. * * @param method provider-defined method name to call. Opaque to * framework, but must be non-null. * @param arg provider-defined String argument. May be null. * @param extras provider-defined Bundle argument. May be null. * @return a result Bundle, possibly null. Will be null if the ContentProvider * does not implement call. * @throws NullPointerException if uri or method is null * @throws IllegalArgumentException if uri is not known */ public final @Nullable Bundle call(@NonNull Uri uri, @NonNull String method, @Nullable String arg, @Nullable Bundle extras) { Preconditions.checkNotNull(uri, "uri"); Preconditions.checkNotNull(method, "method"); IContentProvider provider = acquireProvider(uri); if (provider == null) { throw new IllegalArgumentException("Unknown URI " + uri); } try { final Bundle res = provider.call(mPackageName, method, arg, extras); Bundle.setDefusable(res, true); return res; } catch (RemoteException e) { // Arbitrary and not worth documenting, as Activity // Manager will kill this process shortly anyway. return null; } finally { releaseProvider(provider); } }
Example 5
Source File: SliceManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Turns a slice Uri into slice content. * * @param uri The URI to a slice provider * @param supportedSpecs List of supported specs. * @return The Slice provided by the app or null if none is given. * @see Slice */ public @Nullable Slice bindSlice(@NonNull Uri uri, @NonNull Set<SliceSpec> supportedSpecs) { Preconditions.checkNotNull(uri, "uri"); ContentResolver resolver = mContext.getContentResolver(); try (ContentProviderClient provider = resolver.acquireUnstableContentProviderClient(uri)) { if (provider == null) { Log.w(TAG, String.format("Unknown URI: %s", uri)); return null; } Bundle extras = new Bundle(); extras.putParcelable(SliceProvider.EXTRA_BIND_URI, uri); extras.putParcelableArrayList(SliceProvider.EXTRA_SUPPORTED_SPECS, new ArrayList<>(supportedSpecs)); final Bundle res = provider.call(SliceProvider.METHOD_SLICE, null, extras); Bundle.setDefusable(res, true); if (res == null) { return null; } return res.getParcelable(SliceProvider.EXTRA_SLICE); } catch (RemoteException e) { // Arbitrary and not worth documenting, as Activity // Manager will kill this process shortly anyway. return null; } }
Example 6
Source File: UserManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void setApplicationRestrictions(String packageName, Bundle restrictions, int userId) { checkSystemOrRoot("set application restrictions"); if (restrictions != null) { restrictions.setDefusable(true); } synchronized (mAppRestrictionsLock) { if (restrictions == null || restrictions.isEmpty()) { cleanAppRestrictionsForPackageLAr(packageName, userId); } else { // Write the restrictions to XML writeApplicationRestrictionsLAr(packageName, restrictions, userId); } } // Notify package of changes via an intent - only sent to explicitly registered receivers. Intent changeIntent = new Intent(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED); changeIntent.setPackage(packageName); changeIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); mContext.sendBroadcastAsUser(changeIntent, UserHandle.of(userId)); }
Example 7
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void putCache(String packageName, Uri key, Bundle value, int userId) { Bundle.setDefusable(value, true); enforceCrossUserPermission(userId, TAG); mContext.enforceCallingOrSelfPermission(android.Manifest.permission.CACHE_CONTENT, TAG); mContext.getSystemService(AppOpsManager.class).checkPackage(Binder.getCallingUid(), packageName); final String providerPackageName = getProviderPackageName(key); final Pair<String, Uri> fullKey = Pair.create(packageName, key); synchronized (mCache) { final ArrayMap<Pair<String, Uri>, Bundle> cache = findOrCreateCacheLocked(userId, providerPackageName); if (value != null) { cache.put(fullKey, value); } else { cache.remove(fullKey); } } }
Example 8
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override @RequiresPermission(android.Manifest.permission.CACHE_CONTENT) public void putCache(String packageName, Uri key, Bundle value, int userId) { Bundle.setDefusable(value, true); enforceCrossUserPermission(userId, TAG); mContext.enforceCallingOrSelfPermission(android.Manifest.permission.CACHE_CONTENT, TAG); mContext.getSystemService(AppOpsManager.class).checkPackage(Binder.getCallingUid(), packageName); final String providerPackageName = getProviderPackageName(key); final Pair<String, Uri> fullKey = Pair.create(packageName, key); synchronized (mCache) { final ArrayMap<Pair<String, Uri>, Bundle> cache = findOrCreateCacheLocked(userId, providerPackageName); if (value != null) { cache.put(fullKey, value); } else { cache.remove(fullKey); } } }
Example 9
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void requestSync(Account account, String authority, Bundle extras) { Bundle.setDefusable(extras, true); ContentResolver.validateSyncExtrasBundle(extras); int userId = UserHandle.getCallingUserId(); int uId = Binder.getCallingUid(); validateExtras(uId, extras); final int syncExemption = getSyncExemptionAndCleanUpExtrasForCaller(uId, extras); // This makes it so that future permission checks will be in the context of this // process rather than the caller's process. We will restore this before returning. long identityToken = clearCallingIdentity(); try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { syncManager.scheduleSync(account, userId, uId, authority, extras, SyncStorageEngine.AuthorityInfo.UNDEFINED, syncExemption); } } finally { restoreCallingIdentity(identityToken); } }
Example 10
Source File: SyncRequest.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private SyncRequest(Parcel in) { mExtras = Bundle.setDefusable(in.readBundle(), true); mSyncFlexTimeSecs = in.readLong(); mSyncRunTimeSecs = in.readLong(); mIsPeriodic = (in.readInt() != 0); mDisallowMetered = (in.readInt() != 0); mIsAuthority = (in.readInt() != 0); mIsExpedited = (in.readInt() != 0); mAccountToSync = in.readParcelable(null); mAuthority = in.readString(); }
Example 11
Source File: ContentProvider.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri uri, String mimeType, Bundle opts, ICancellationSignal cancellationSignal) throws FileNotFoundException { Bundle.setDefusable(opts, true); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); enforceFilePermission(callingPkg, uri, "r", null); final String original = setCallingPackage(callingPkg); try { return ContentProvider.this.openTypedAssetFile( uri, mimeType, opts, CancellationSignal.fromTransport(cancellationSignal)); } finally { setCallingPackage(original); } }
Example 12
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void removePeriodicSync(Account account, String authority, Bundle extras) { Bundle.setDefusable(extras, true); if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(authority)) { throw new IllegalArgumentException("Authority must not be empty"); } mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); validateExtras(Binder.getCallingUid(), extras); final int callingUid = Binder.getCallingUid(); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { getSyncManager() .removePeriodicSync( new SyncStorageEngine.EndPoint(account, authority, userId), extras, "removePeriodicSync() by uid=" + callingUid); } finally { restoreCallingIdentity(identityToken); } }
Example 13
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** Old API. Schedule periodic sync with default flexMillis time. */ @Override public void addPeriodicSync(Account account, String authority, Bundle extras, long pollFrequency) { Bundle.setDefusable(extras, true); if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(authority)) { throw new IllegalArgumentException("Authority must not be empty."); } mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); validateExtras(Binder.getCallingUid(), extras); int userId = UserHandle.getCallingUserId(); pollFrequency = clampPeriod(pollFrequency); long defaultFlex = SyncStorageEngine.calculateDefaultFlexTime(pollFrequency); long identityToken = clearCallingIdentity(); try { SyncStorageEngine.EndPoint info = new SyncStorageEngine.EndPoint(account, authority, userId); getSyncManager().updateOrAddPeriodicSync(info, pollFrequency, defaultFlex, extras); } finally { restoreCallingIdentity(identityToken); } }
Example 14
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public void removePeriodicSync(Account account, String authority, Bundle extras) { Bundle.setDefusable(extras, true); if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(authority)) { throw new IllegalArgumentException("Authority must not be empty"); } mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); validateExtras(Binder.getCallingUid(), extras); final int callingUid = Binder.getCallingUid(); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { getSyncManager() .removePeriodicSync( new SyncStorageEngine.EndPoint(account, authority, userId), extras, "removePeriodicSync() by uid=" + callingUid); } finally { restoreCallingIdentity(identityToken); } }
Example 15
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** Old API. Schedule periodic sync with default flexMillis time. */ @Override public void addPeriodicSync(Account account, String authority, Bundle extras, long pollFrequency) { Bundle.setDefusable(extras, true); if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(authority)) { throw new IllegalArgumentException("Authority must not be empty."); } mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); validateExtras(Binder.getCallingUid(), extras); int userId = UserHandle.getCallingUserId(); pollFrequency = clampPeriod(pollFrequency); long defaultFlex = SyncStorageEngine.calculateDefaultFlexTime(pollFrequency); long identityToken = clearCallingIdentity(); try { SyncStorageEngine.EndPoint info = new SyncStorageEngine.EndPoint(account, authority, userId); getSyncManager().updateOrAddPeriodicSync(info, pollFrequency, defaultFlex, extras); } finally { restoreCallingIdentity(identityToken); } }
Example 16
Source File: ContentProvider.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public Bundle call( String callingPkg, String method, @Nullable String arg, @Nullable Bundle extras) { Bundle.setDefusable(extras, true); final String original = setCallingPackage(callingPkg); try { return ContentProvider.this.call(method, arg, extras); } finally { setCallingPackage(original); } }
Example 17
Source File: ContentProvider.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri uri, String mimeType, Bundle opts, ICancellationSignal cancellationSignal) throws FileNotFoundException { Bundle.setDefusable(opts, true); validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); enforceFilePermission(callingPkg, uri, "r", null); final String original = setCallingPackage(callingPkg); try { return ContentProvider.this.openTypedAssetFile( uri, mimeType, opts, CancellationSignal.fromTransport(cancellationSignal)); } finally { setCallingPackage(original); } }
Example 18
Source File: ContentProvider.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public Bundle call( String callingPkg, String method, @Nullable String arg, @Nullable Bundle extras) { Bundle.setDefusable(extras, true); final String original = setCallingPackage(callingPkg); try { return ContentProvider.this.call(method, arg, extras); } finally { setCallingPackage(original); } }
Example 19
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** Old API. Schedule periodic sync with default flexMillis time. */ @Override public void addPeriodicSync(Account account, String authority, Bundle extras, long pollFrequency) { Bundle.setDefusable(extras, true); if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(authority)) { throw new IllegalArgumentException("Authority must not be empty."); } mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); int userId = UserHandle.getCallingUserId(); pollFrequency = clampPeriod(pollFrequency); long defaultFlex = SyncStorageEngine.calculateDefaultFlexTime(pollFrequency); long identityToken = clearCallingIdentity(); try { SyncStorageEngine.EndPoint info = new SyncStorageEngine.EndPoint(account, authority, userId); getSyncManager().updateOrAddPeriodicSync(info, pollFrequency, defaultFlex, extras); } finally { restoreCallingIdentity(identityToken); } }
Example 20
Source File: ActivityOptions.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** @hide */ public ActivityOptions(Bundle opts) { // If the remote side sent us bad parcelables, they won't get the // results they want, which is their loss. opts.setDefusable(true); mPackageName = opts.getString(KEY_PACKAGE_NAME); try { mUsageTimeReport = opts.getParcelable(KEY_USAGE_TIME_REPORT); } catch (RuntimeException e) { Slog.w(TAG, e); } mLaunchBounds = opts.getParcelable(KEY_LAUNCH_BOUNDS); mAnimationType = opts.getInt(KEY_ANIM_TYPE); switch (mAnimationType) { case ANIM_CUSTOM: mCustomEnterResId = opts.getInt(KEY_ANIM_ENTER_RES_ID, 0); mCustomExitResId = opts.getInt(KEY_ANIM_EXIT_RES_ID, 0); mAnimationStartedListener = IRemoteCallback.Stub.asInterface( opts.getBinder(KEY_ANIM_START_LISTENER)); break; case ANIM_CUSTOM_IN_PLACE: mCustomInPlaceResId = opts.getInt(KEY_ANIM_IN_PLACE_RES_ID, 0); break; case ANIM_SCALE_UP: case ANIM_CLIP_REVEAL: mStartX = opts.getInt(KEY_ANIM_START_X, 0); mStartY = opts.getInt(KEY_ANIM_START_Y, 0); mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0); break; case ANIM_THUMBNAIL_SCALE_UP: case ANIM_THUMBNAIL_SCALE_DOWN: case ANIM_THUMBNAIL_ASPECT_SCALE_UP: case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: // Unpackage the GraphicBuffer from the parceled thumbnail final GraphicBuffer buffer = opts.getParcelable(KEY_ANIM_THUMBNAIL); if (buffer != null) { mThumbnail = Bitmap.createHardwareBitmap(buffer); } mStartX = opts.getInt(KEY_ANIM_START_X, 0); mStartY = opts.getInt(KEY_ANIM_START_Y, 0); mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0); mAnimationStartedListener = IRemoteCallback.Stub.asInterface( opts.getBinder(KEY_ANIM_START_LISTENER)); break; case ANIM_SCENE_TRANSITION: mTransitionReceiver = opts.getParcelable(KEY_TRANSITION_COMPLETE_LISTENER); mIsReturning = opts.getBoolean(KEY_TRANSITION_IS_RETURNING, false); mSharedElementNames = opts.getStringArrayList(KEY_TRANSITION_SHARED_ELEMENTS); mResultData = opts.getParcelable(KEY_RESULT_DATA); mResultCode = opts.getInt(KEY_RESULT_CODE); mExitCoordinatorIndex = opts.getInt(KEY_EXIT_COORDINATOR_INDEX); break; } mLockTaskMode = opts.getBoolean(KEY_LOCK_TASK_MODE, false); mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY); mLaunchWindowingMode = opts.getInt(KEY_LAUNCH_WINDOWING_MODE, WINDOWING_MODE_UNDEFINED); mLaunchActivityType = opts.getInt(KEY_LAUNCH_ACTIVITY_TYPE, ACTIVITY_TYPE_UNDEFINED); mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1); mTaskOverlay = opts.getBoolean(KEY_TASK_OVERLAY, false); mTaskOverlayCanResume = opts.getBoolean(KEY_TASK_OVERLAY_CAN_RESUME, false); mAvoidMoveToFront = opts.getBoolean(KEY_AVOID_MOVE_TO_FRONT, false); mSplitScreenCreateMode = opts.getInt(KEY_SPLIT_SCREEN_CREATE_MODE, SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT); mDisallowEnterPictureInPictureWhileLaunching = opts.getBoolean( KEY_DISALLOW_ENTER_PICTURE_IN_PICTURE_WHILE_LAUNCHING, false); if (opts.containsKey(KEY_ANIM_SPECS)) { Parcelable[] specs = opts.getParcelableArray(KEY_ANIM_SPECS); mAnimSpecs = new AppTransitionAnimationSpec[specs.length]; for (int i = specs.length - 1; i >= 0; i--) { mAnimSpecs[i] = (AppTransitionAnimationSpec) specs[i]; } } if (opts.containsKey(KEY_ANIMATION_FINISHED_LISTENER)) { mAnimationFinishedListener = IRemoteCallback.Stub.asInterface( opts.getBinder(KEY_ANIMATION_FINISHED_LISTENER)); } mRotationAnimationHint = opts.getInt(KEY_ROTATION_ANIMATION_HINT); mAppVerificationBundle = opts.getBundle(KEY_INSTANT_APP_VERIFICATION_BUNDLE); if (opts.containsKey(KEY_SPECS_FUTURE)) { mSpecsFuture = IAppTransitionAnimationSpecsFuture.Stub.asInterface(opts.getBinder( KEY_SPECS_FUTURE)); } mRemoteAnimationAdapter = opts.getParcelable(KEY_REMOTE_ANIMATION_ADAPTER); }